Skip to content

Commit

Permalink
bug fixes, month selctor, export as file 😎🤞
Browse files Browse the repository at this point in the history
  • Loading branch information
Koushikphy committed Nov 14, 2021
1 parent b0a0db8 commit 62c3b4d
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 135 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,14 @@ Built with [Flutter](https://flutter.dev/) framework, this app can be compiled f
11. - [x] Import/Export data (JSON ?) also as an Excel sheet?
12. - [x] Add custom icon for production app.
13. - [x] App signing for distribution.
14. - [ ] Sort the data according to time at modification.
14. - [x] Sort the data according to time at modification.
13. - [x] Mocks for presentation
13. - [x] First sharable production build.
14. - [ ] Introduce search functionality to the log page.
15. - [ ] Separate data into months and a provide a option to set it.
15. - [x] Separate data into months and a provide a option to set it.
15. - [ ] Firebase authentication to sync between multiple devices.
* - [ ] Bring the share page in the main entry page.
* - [ ] Add new entry without leaving the page.
* - [ ] Share image white background with top bar
2. - [ ] Add new entry without leaving the page.
1. - [x] Share image white background with top bar
</details>


Expand Down
5 changes: 2 additions & 3 deletions lib/pages/addUser_page.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import 'package:flutter/material.dart';
import 'package:shared_expenses/theme/colors.dart';
import 'package:shared_expenses/scoped_model/expenseScope.dart';
import 'package:shared_expenses/pages/newentry_page.dart';
import 'package:animations/animations.dart';
import 'package:scoped_model/scoped_model.dart';


// add an option to remove or edit users
class AddUserCat extends StatefulWidget {
final BuildContext context;
final int type;
Expand Down
10 changes: 1 addition & 9 deletions lib/pages/daily_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,11 @@ class DailyPage extends StatelessWidget {
List<Map<String, dynamic>> _expenses = model.getExpenses;

return Scaffold(
// backgroundColor: grey.withOpacity(0.05),
body: Column(
children: [
Container(
decoration: BoxDecoration(
// color: white,
// boxShadow: [
// BoxShadow(
// color: grey.withOpacity(0.01),
// spreadRadius: 10,
// blurRadius: 3,
// ),
// ],

gradient: LinearGradient(
colors: myColors[0],
begin: Alignment.bottomCenter,
Expand Down
1 change: 1 addition & 0 deletions lib/pages/newentry_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ class _NewEntryLogState extends State<NewEntryLog> {
),
SizedBox(height: 15),
DateTimePicker(

controller: _dateEditor,
type: DateTimePickerType.date,
dateMask: 'd MMM, yyyy',
Expand Down
115 changes: 64 additions & 51 deletions lib/pages/profile_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'package:shared_expenses/pages/addUser_page.dart';
import 'package:intl/intl.dart';
import 'dart:convert';
import 'package:animations/animations.dart';
import 'package:share/share.dart';

class ProfilePage extends StatefulWidget {
final ExpenseModel model;
Expand Down Expand Up @@ -94,7 +95,7 @@ class _ProfilePageState extends State<ProfilePage> {
),
),
Text(
"v 0.1.0",
"v 0.1.1",
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.bold,
Expand Down Expand Up @@ -184,25 +185,63 @@ class _ProfilePageState extends State<ProfilePage> {
height: 15,
),
SizedBox(
height: 21,
height: 13,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
IconButton(
iconSize: 35,
tooltip: "Download the data",
icon: Icon(FlutterIcons.download_faw5s),
onPressed: showChangeDialog,
),
IconButton(
iconSize: 35,
tooltip: "Upload the data",
icon: Icon(FlutterIcons.upload_faw5s),
onPressed: saveUserData,
)
],
InkWell(
onTap: exportData,
child: Row(
children: [
Icon(FlutterIcons.file_export_faw5s),
SizedBox(width: 10),
Text(
"Export Data",
style: TextStyle(
fontSize: 21,
),
)
],
),
),
Divider(
indent: 30,
thickness: 1.0,
height: 15,
),
SizedBox(
height: 13,
),
InkWell(
onTap: importData,
child: Row(
children: [
Icon(FlutterIcons.file_import_faw5s),
SizedBox(width: 10),
Text(
"Import Data",
style: TextStyle(
fontSize: 21,
),
)
],
),
),
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
// children: [
// IconButton(
// iconSize: 35,
// tooltip: "Download the data",
// icon: Icon(FlutterIcons.download_faw5s),
// onPressed: importData,
// ),
// IconButton(
// iconSize: 35,
// tooltip: "Upload the data",
// icon: Icon(FlutterIcons.upload_faw5s),
// onPressed: exportData,
// )
// ],
// ),
],
),
),
Expand Down Expand Up @@ -370,7 +409,7 @@ class _ProfilePageState extends State<ProfilePage> {
);
}

void showChangeDialog() {
void importData() {
showDialog<void>(
context: context,
barrierDismissible: false, // user must tap button!
Expand Down Expand Up @@ -404,34 +443,6 @@ class _ProfilePageState extends State<ProfilePage> {
);
}

// void showWarningDialog(String param) {
// showDialog<void>(
// context: context,
// barrierDismissible: false, // user must tap button!
// builder: (BuildContext context) {
// return AlertDialog(
// title: Text('Alert !'),
// content: SingleChildScrollView(
// child: ListBody(
// children: <Widget>[
// Text('Can not modify existing $param'),
// ],
// ),
// ),
// actions: <Widget>[
// TextButton(
// child: Text('OK'),
// onPressed: () {
// widget.model.resetAll();
// Navigator.of(context).pop();
// },
// ),
// ],
// );
// },
// );
// }

void loadUserData() async {
FilePickerResult result = await FilePicker.platform.pickFiles();
if (result == null) {
Expand All @@ -450,7 +461,7 @@ class _ProfilePageState extends State<ProfilePage> {
widget.model.newDataLoaded(_uList, _cList, _exList);
}

void saveUserData() async {
void exportData() async {
// await Permission.storage.request();
// var status = await Permission.storage.request();

Expand All @@ -461,14 +472,16 @@ class _ProfilePageState extends State<ProfilePage> {
// it returns permission denied, so the file is saved in a given storage only for now.
final directory = await getExternalStorageDirectory();
String fileName = "${directory.path}/Expenses_$timeStamp.txt";
File file = File(fileName);

File(fileName).writeAsString(json.encode({
file.writeAsString(json.encode({
"users": widget.model.getUsers,
"categories": widget.model.getCategories,
"expenses": widget.model.getExpenses
}));

final snackBar = SnackBar(content: Text('File Saved'));
ScaffoldMessenger.of(context).showSnackBar(snackBar);
await Share.shareFiles([file.path]);
// final snackBar = SnackBar(content: Text('File Saved'));
// ScaffoldMessenger.of(context).showSnackBar(snackBar);
}
}
5 changes: 5 additions & 0 deletions lib/pages/root_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ class _RootAppState extends State<RootApp> {
setState(() {
index ??= 2;
pageIndex = index;
controller.animateToPage(
pageIndex,
duration: const Duration(milliseconds: 400),
curve: Curves.easeInOut,
);
});
}
}
98 changes: 69 additions & 29 deletions lib/pages/stats_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:screenshot/screenshot.dart';
import 'package:share/share.dart';
import 'dart:io';
import 'package:path_provider/path_provider.dart';
import 'package:select_form_field/select_form_field.dart';

class StatsPage extends StatefulWidget {
final ExpenseModel model;
Expand Down Expand Up @@ -38,6 +39,22 @@ class _StatsPageState extends State<StatsPage> {
}

Widget getBody() {
Map<String, String> months = {
"1": "January",
"2": "February",
"3": "March",
"4": "April",
"5": "May",
"6": "June",
"7": "July",
"8": "August",
"9": "September",
"10": "October",
"11": "November",
"12": "December",
"13": "All"
};

return Column(
children: [
Container(
Expand Down Expand Up @@ -90,48 +107,71 @@ class _StatsPageState extends State<StatsPage> {
),
),
),
Expanded(
child: SingleChildScrollView(
child: Screenshot(
controller: _screenShotController,
child: Container(
color: Colors.white,
child: Column(
children: <Widget>[
(widget.model.getUsers.length == 0 || widget.model.getCategories.length == 0)
? Column(
(widget.model.getUsers.length == 0 || widget.model.getCategories.length == 0)
? Column(
children: [
SizedBox(
height: 30,
),
Text(
widget.model.getUsers.length == 0 ? "No users added" : "No categories added",
style: TextStyle(fontSize: 21),
),
TextButton(
onPressed: () {
widget.callback(2);
},
child: Text("Go to settings"))
],
)
: Expanded(
child: SingleChildScrollView(
child: Screenshot(
controller: _screenShotController,
child: Container(
color: Colors.white,
child: Column(
children: <Widget>[
Column(
children: [
SizedBox(
height: 30,
),
Text(
"No users added",
style: TextStyle(fontSize: 21),
Padding(
padding: EdgeInsets.symmetric(horizontal: 15, vertical: 5),
child: SelectFormField(
initialValue: widget.model.getCurrentMonth,
labelText: 'Select Month',
style: TextStyle(
fontSize: 19,
fontWeight: FontWeight.bold,
),
items: [
for (MapEntry e in months.entries) {'value': e.key, 'label': e.value}
],
validator: (value) => value.isEmpty ? "Required filed *" : null,
onChanged: (v) => _updateMonth(v),
),
),
TextButton(
onPressed: () {
widget.callback(2);
},
child: Text("Go to settings"))
],
)
: Column(
children: [
makeStatCrad("Total Spends", Colors.pink, MaterialCommunityIcons.shopping),
makeStatCrad("Total Owe", Colors.green, MaterialIcons.account_balance),
makeStatCrad("Net Owe", Colors.purple, MaterialIcons.payment),
],
)
],
],
),
),
),
),
),
),
),
),
],
);
}

void _updateMonth(String v) {
widget.model.setCurrentMonth(v);
setState(() {
expenseShares = widget.model.calculateShares();
});
}

void _takeScreenShot() async {
final imageFile = await _screenShotController.capture();
String tempPath = (await getTemporaryDirectory()).path;
Expand Down
Loading

0 comments on commit 62c3b4d

Please sign in to comment.