Skip to content

Commit

Permalink
finalize changes 🥳🎉
Browse files Browse the repository at this point in the history
  • Loading branch information
Koushikphy committed May 3, 2021
1 parent 33c7cb3 commit a3229ac
Show file tree
Hide file tree
Showing 11 changed files with 212 additions and 527 deletions.
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"pubspec.lock": true,
".metadata": true,
"**/generated_plugin_registrant.dart":true,
"**/chart":true
"**/chart":true,
"**/.idea":true,
"**/.flutter*":true
}
}
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ A Simeple app for managing group shared expenses. Just add users group and categ
Built with [Flutter](https://flutter.dev/) framework, this app can be compiled for both Andoroid and iOS.

### Usage
* Download the app from the [release section](https://github.com/Koushikphy/Shared-Expense-Manager/releases)
* Add list of users seperated by comma (,) in the setting page.
* Add list of categories.
* **Download** the app from the [release section](https://github.com/Koushikphy/Shared-Expense-Manager/releases).
* Add list of users and categories seperated by comma (,) in the setting page.
* Tap on the `+` button to add new expense record.
* Check the Stats page for current expenses status.
* Tap on individual record in the log page to edit/delete them.
Expand Down
299 changes: 149 additions & 150 deletions lib/pages/daily_page.dart

Large diffs are not rendered by default.

81 changes: 4 additions & 77 deletions lib/pages/newentry_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@ import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:date_time_picker/date_time_picker.dart';
import 'package:select_form_field/select_form_field.dart';
// import 'package:multiselect_formfield/multiselect_formfield.dart';
import 'package:shared_expenses/scoped_model/expenseScope.dart';
import 'package:shared_expenses/pages/share_page.dart';
import 'package:shared_expenses/theme/colors.dart';
import 'package:scoped_model/scoped_model.dart';

class NewEntryLog extends StatefulWidget {
// final ExpenseModel model;
final Function callback;
final BuildContext context;
final int index;
// NewEntryLog({Key key, @required this.model, this.callback, this.context}) : super(key: key);
NewEntryLog({Key key, this.callback, this.context, this.index = -999}) : super(key: key);
// ExpenseModel model
@override
_NewEntryLogState createState() => _NewEntryLogState();
}
Expand All @@ -28,8 +24,7 @@ class _NewEntryLogState extends State<NewEntryLog> {
TextEditingController _amountEditor = TextEditingController();
TextEditingController _dateEditor = TextEditingController(text: DateTime.now().toString());
TextEditingController _categoryEditor = TextEditingController();
// double _oldVal = 0.0;
ExpenseModel model; //= ScopedModel.of(context);
ExpenseModel model;
bool showError = false;
int count1 = 1;
int count2 = 0;
Expand All @@ -38,8 +33,7 @@ class _NewEntryLogState extends State<NewEntryLog> {
void initState() {
model = ScopedModel.of(widget.context);
super.initState();
print('index ${widget.index}');
aList = List.filled(model.users.length, 0.0);
aList = List.filled(model.getUsers.length, 0.0);
editRecord = widget.index != -999;
if (editRecord) {
Map<String, String> data = {...model.getExpenses[widget.index]};
Expand All @@ -55,14 +49,12 @@ class _NewEntryLogState extends State<NewEntryLog> {
@override
Widget build(BuildContext context) {
// var size = MediaQuery.of(context).size;
// print(aList.length);
return Scaffold(
appBar: AppBar(
backgroundColor: secondary,
actions: <Widget>[
IconButton(
onPressed: () {
// formKey.currentState.validate();
if (formKey.currentState.validate() && sharedProperly()) {
Map<String, String> data = {
"date": DateFormat('dd-MM-yyyy').format(DateFormat('yyyy-MM-dd').parse(_dateEditor.text)),
Expand All @@ -73,14 +65,6 @@ class _NewEntryLogState extends State<NewEntryLog> {
"shareBy": aList.map((e) => e.toString()).join(',')
};
editRecord ? model.editExpense(widget.index, data) : model.addExpense(data);
// model.addExpense({
// "date": DateFormat('dd-MM-yyyy').format(DateFormat('yyyy-MM-dd').parse(_dateEditor.text)),
// "person": _personEditor.text,
// "item": _itemEditor.text,
// "category": _categoryEditor.text,
// "amount": _amountEditor.text,
// "shareBy": aList.map((e) => e.toString()).join(',')
// });
widget.callback(0); //move to log page
Navigator.pop(context);
}
Expand Down Expand Up @@ -138,23 +122,16 @@ class _NewEntryLogState extends State<NewEntryLog> {
children: <Widget>[
TextFormField(
autovalidateMode: AutovalidateMode.onUserInteraction,
// initialValue: data["item"],
decoration: const InputDecoration(
icon: Icon(Icons.shopping_cart_outlined),
hintText: 'Where did you spent the money?',
labelText: 'Item',
),
// onSaved: (String value) {},
// onChanged: (val) {
// data["item"] = val;
// },
controller: _itemEditor,
validator: (value) => value.isEmpty ? "Required filed *" : null,
),
SizedBox(height: 15),
SelectFormField(
type: SelectFormFieldType.dropdown, // or can be dialog
// initialValue: data['person'],
icon: Icon(Icons.person_outline),
labelText: 'Spent By',
controller: _personEditor,
Expand All @@ -164,36 +141,17 @@ class _NewEntryLogState extends State<NewEntryLog> {
"label": e,
})
.toList(),
// onChanged: (val) {
// data["person"] = val;
// // print(data);
// },
validator: (value) => value.isEmpty ? "Required filed *" : null,
// onSaved: (val) => print(val),
),
TextFormField(
autovalidateMode: AutovalidateMode.onUserInteraction,
// initialValue: data['amount'],
keyboardType: TextInputType.number,
controller: _amountEditor,
decoration: const InputDecoration(
icon: Icon(Icons.account_balance_wallet_outlined),
hintText: 'How much money is spent?',
labelText: "Amount",
),

onChanged: (val) {
// print(_oldVal);
// print(double.parse(val));
// print(_oldVal != double.parse(val));
// if (_oldVal != double.parse(val))
// setState(() {
// _oldVal = double.parse(val); // jsut don't reset the values;
// aList = List.filled(model.users.length, 0.0);
// });
// print(data);
},
// onSaved: (String value) {},
validator: (val) {
if (val.isEmpty) return "Required filed *";
if (double.tryParse(val) == null) {
Expand All @@ -207,31 +165,15 @@ class _NewEntryLogState extends State<NewEntryLog> {
controller: _dateEditor,
type: DateTimePickerType.date,
dateMask: 'd MMM, yyyy',
// initialValue: data['date'],
firstDate: DateTime(2000),
lastDate: DateTime(2100),
icon: Icon(Icons.event),
dateLabelText: 'Date',
// onChanged: (val) {
// data["date"] = DateFormat('dd-MM-yyyy').format(
// DateFormat('yyyy-MM-dd').parse(val),
// );
// print(data["date"]);
// print("from chnage");
// },
// onFieldSubmitted: (value) {
// data["date"] = DateFormat('dd-MM-yyyy').format(
// DateFormat('yyyy-MM-dd').parse(value),
// );
// print(data["date"]);
// print("from submit");
// },
validator: (value) => value.isEmpty ? "Required field *" : null),
SizedBox(height: 15),
SelectFormField(
key: ValueKey<int>(count2),
type: SelectFormFieldType.dropdown, // or can be dialog
// initialValue: data['category'],
controller: _categoryEditor,
icon: Icon(Icons.category),
hintText: 'Category of the spend',
Expand All @@ -242,13 +184,7 @@ class _NewEntryLogState extends State<NewEntryLog> {
"label": e,
})
.toList(),
// onChanged: (val) {
// data["category"] = val;
// // print(data);
// },
// onSaved: (newValue) {
// _shareEditor = newValue;
// },

validator: (value) => value.isEmpty ? "Required field *" : null,
),
SizedBox(height: 15),
Expand All @@ -257,7 +193,7 @@ class _NewEntryLogState extends State<NewEntryLog> {
onTap: () {
var val = double.parse(_amountEditor.text);
if (val != null) {
if (aList.fold(0, (a, b) => a + b) != val) aList = List.filled(model.users.length, 0.0);
if (aList.fold(0, (a, b) => a + b) != val) aList = List.filled(model.getUsers.length, 0.0);

Navigator.push(
context,
Expand Down Expand Up @@ -358,15 +294,6 @@ class _NewEntryLogState extends State<NewEntryLog> {
});
}

resetPage() {
formKey.currentState.reset();
setState(() {
++count1;
--count2;
// aList = List.filled(model.users.length, 0.0);
});
}

sharedProperly() {
double summed = aList.fold(0, (a, b) => a + b);
var val = double.parse(_amountEditor.text);
Expand Down
15 changes: 1 addition & 14 deletions lib/pages/profile_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ import 'package:flutter/material.dart';
import 'package:flutter/gestures.dart';
import 'package:shared_expenses/scoped_model/expenseScope.dart';
import 'package:url_launcher/url_launcher.dart';
// import 'package:flutter_file_dialog/flutter_file_dialog.dart';
import 'package:file_picker/file_picker.dart';
import 'dart:io';
// import 'package:permission_handler/permission_handler.dart';
import 'package:path_provider/path_provider.dart';

import 'package:intl/intl.dart';
import 'dart:convert';
// import 'package:shared_preferences/shared_preferences.dart';

class ProfilePage extends StatefulWidget {
final ExpenseModel model;
Expand Down Expand Up @@ -44,8 +42,6 @@ class _ProfilePageState extends State<ProfilePage> {
Widget getBody() {
// var size = MediaQuery.of(context).size;
return Column(
// mainAxisSize: MainAxisSize.max,
// mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Container(
decoration: BoxDecoration(
Expand Down Expand Up @@ -98,9 +94,6 @@ class _ProfilePageState extends State<ProfilePage> {
"Shared Expense Manager",
style: TextStyle(
fontSize: 25, color: myColors[2][0],
// fontWeight: FontWeight.bold,

//
),
),
Text(
Expand Down Expand Up @@ -130,7 +123,6 @@ class _ProfilePageState extends State<ProfilePage> {
"Users",
style: TextStyle(
fontSize: 21,
// fontWeight: FontWeight.bold,
),
)
],
Expand Down Expand Up @@ -242,7 +234,7 @@ class _ProfilePageState extends State<ProfilePage> {
);
}

var _url = 'https://github.com/Koushikphy';
var _url = 'https://github.com/Koushikphy/Shared-Expense-Manager';
void _launchURL() async {
await canLaunch(_url) ? await launch(_url) : throw 'Could not launch $_url';
}
Expand Down Expand Up @@ -287,7 +279,6 @@ class _ProfilePageState extends State<ProfilePage> {
widget.model.setUsers(uList);
}

// print(widget.model.getUsers);
},
),
TextButton(
Expand Down Expand Up @@ -447,10 +438,6 @@ class _ProfilePageState extends State<ProfilePage> {
return;
}

// String timeStamp = DateFormat('dd_MM_yyyy').format(DateTime.now());
// final directory = await getExternalStorageDirectory();
// String fileName = "${directory.path}/Expenses_$timeStamp.txt";

String fileName = result.files.single.path;
var data = json.decode(File(fileName).readAsStringSync());
// print(data);
Expand Down
7 changes: 1 addition & 6 deletions lib/pages/root_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import 'package:shared_expenses/pages/profile_page.dart';
import 'package:shared_expenses/pages/newentry_page.dart';
import 'package:shared_expenses/scoped_model/expenseScope.dart';
import 'package:swipedetector/swipedetector.dart';
// import 'package:shared_expenses/pages/chart/wip.dart';

class RootApp extends StatefulWidget {
@override
Expand Down Expand Up @@ -37,10 +36,9 @@ class _RootAppState extends State<RootApp> {
child: IndexedStack(
index: pageIndex,
children: <Widget>[
DailyPage(model1: model, callback: callback),
DailyPage(model: model, callback: callback),
StatsPage(model: model, callback: callback),
ProfilePage(model: model),
// NewEntryLog(model: model, callback: callback)
],
),
onSwipeRight: () {
Expand All @@ -62,7 +60,6 @@ class _RootAppState extends State<RootApp> {
icons: <IconData>[
Ionicons.md_calendar,
Ionicons.md_stats,
// Ionicons.md_pie,
Ionicons.md_settings,
],
activeIndex: pageIndex,
Expand All @@ -78,8 +75,6 @@ class _RootAppState extends State<RootApp> {
),
floatingActionButton: FloatingActionButton(
onPressed: () {
// selectedTab(3);

Navigator.push(
context,
MaterialPageRoute(
Expand Down
Loading

0 comments on commit a3229ac

Please sign in to comment.