Changed navigation a bit, added 'stats' section

sections are easy to add and remove
This commit is contained in:
Felix 2019-07-16 15:12:16 +01:00
parent 4ec386019d
commit c5cf66a210
No known key found for this signature in database
GPG key ID: 130EF6DC43E4DD07
6 changed files with 91 additions and 17 deletions

View file

@ -3,7 +3,7 @@ import 'package:local_spend/pages/home_page.dart';
import 'package:local_spend/pages/login_page.dart'; import 'package:local_spend/pages/login_page.dart';
import 'package:local_spend/pages/receipt_page.dart'; import 'package:local_spend/pages/receipt_page.dart';
import 'package:local_spend/pages/spash_screen.dart'; import 'package:local_spend/pages/spash_screen.dart';
import 'package:local_spend/pages/settings.dart'; import 'package:local_spend/pages/more_page.dart';
import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_localizations/flutter_localizations.dart';
void main() { void main() {
@ -32,7 +32,7 @@ class MyApp extends StatelessWidget {
"/HomePage": (BuildContext context) => HomePage(), "/HomePage": (BuildContext context) => HomePage(),
"/LoginPage": (BuildContext context) => LoginPage(), "/LoginPage": (BuildContext context) => LoginPage(),
"/ReceiptPage": (BuildContext context) => ReceiptPage(), "/ReceiptPage": (BuildContext context) => ReceiptPage(),
"/SettingsPage": (BuildContext context) => SettingsPage(), "/MorePage": (BuildContext context) => MorePage(),
}, },
home: SplashScreen(), home: SplashScreen(),
); );

View file

@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:local_spend/pages/receipt_page.dart'; import 'package:local_spend/pages/receipt_page.dart';
import 'package:local_spend/pages/settings.dart'; import 'package:local_spend/pages/more_page.dart';
import 'package:local_spend/pages/stats_page.dart';
class HomePage extends StatelessWidget { class HomePage extends StatelessWidget {
static String _title = 'Text here'; static String _title = 'Text here';
@ -27,7 +28,8 @@ class _HomePageState extends State<HomePageWidget> {
TextStyle(fontSize: 30, fontWeight: FontWeight.bold); TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
static List<Widget> _widgetOptions = <Widget>[ static List<Widget> _widgetOptions = <Widget>[
ReceiptPage(), ReceiptPage(),
SettingsPage() StatsPage(),
MorePage()
]; ];
void _onItemTapped(int index) { void _onItemTapped(int index) {
@ -48,6 +50,10 @@ class _HomePageState extends State<HomePageWidget> {
icon: Icon(Icons.receipt), icon: Icon(Icons.receipt),
title: Text('Submit Receipt'), title: Text('Submit Receipt'),
), ),
BottomNavigationBarItem(
icon: Icon(Icons.show_chart),
title: Text('Statistics'),
),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: Icon(Icons.more_horiz), icon: Icon(Icons.more_horiz),
title: Text('More'), title: Text('More'),

View file

@ -10,14 +10,14 @@ import 'package:local_spend/common/functions/showDialogTwoButtons.dart';
const URL = "https://flutter.io/"; const URL = "https://flutter.io/";
const demonstration = false; const demonstration = false;
class SettingsPage extends StatefulWidget { class MorePage extends StatefulWidget {
@override @override
State<StatefulWidget> createState() { State<StatefulWidget> createState() {
return new SettingsPageState(); return new MorePageState();
} }
} }
class SettingsPageState extends State<SettingsPage> { class MorePageState extends State<MorePage> {
FocusNode focusNode; // added so focus can move automatically FocusNode focusNode; // added so focus can move automatically
DateTime date; DateTime date;
@ -25,7 +25,7 @@ class SettingsPageState extends State<SettingsPage> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_saveCurrentRoute("/SettingsPageState"); _saveCurrentRoute("/MorePageState");
focusNode = FocusNode(); focusNode = FocusNode();
} }

View file

@ -31,7 +31,7 @@ class ReceiptPageState extends State<ReceiptPage> {
final TextEditingController _orgController = TextEditingController(); final TextEditingController _orgController = TextEditingController();
final OrganizationController _organizationController = OrganizationController(); final OrganizationController _organizationController = OrganizationController();
FocusNode focusNode; // added so focus can move automatically FocusNode focusNode;
DateTime date; DateTime date;
@ -55,6 +55,7 @@ class ReceiptPageState extends State<ReceiptPage> {
focusNode = FocusNode(); focusNode = FocusNode();
_recurringController.text = "None"; _recurringController.text = "None";
_categoryController.text = "";
} }
@override @override
@ -71,7 +72,7 @@ class ReceiptPageState extends State<ReceiptPage> {
// this file is getting really messy sorry everyone // this file is getting really messy sorry everyone
void submitReceipt(String amount, String time, Organisation organisation, String recurring) async { void submitReceipt(String amount, String time, Organisation organisation, String recurring, String category) async {
SystemChannels.textInput.invokeMethod('TextInput.hide'); SystemChannels.textInput.invokeMethod('TextInput.hide');
if (organisation == null) { if (organisation == null) {
@ -154,6 +155,7 @@ class ReceiptPageState extends State<ReceiptPage> {
receipt.town = organisation.town; receipt.town = organisation.town;
receipt.postcode = organisation.postcode; receipt.postcode = organisation.postcode;
receipt.recurring = recurring; receipt.recurring = recurring;
receipt.category = category;
// receipt.essential = convertBoolToString(toConvert) // receipt.essential = convertBoolToString(toConvert)
@ -414,7 +416,7 @@ class ReceiptPageState extends State<ReceiptPage> {
), ),
onSubmitted: (_) { onSubmitted: (_) {
submitReceipt(_amountController.text, submitReceipt(_amountController.text,
_timeController.text, _organizationController.organisation, _recurringController.text); _timeController.text, _organizationController.organisation, _recurringController.text, _categoryController.text);
// TODO: make sure organisation is valid // TODO: make sure organisation is valid
// TODO: Add 'find organisation' button which displays a dialog to, well, find the organisation's address or manual entry // TODO: Add 'find organisation' button which displays a dialog to, well, find the organisation's address or manual entry
}, },
@ -515,7 +517,7 @@ class ReceiptPageState extends State<ReceiptPage> {
try { try {
submitReceipt( submitReceipt(
_amountController.text, _timeController.text, _amountController.text, _timeController.text,
_organizationController.organisation, _recurringController.text); _organizationController.organisation, _recurringController.text, _categoryController.text);
} }
catch (_) { catch (_) {
showDialog( showDialog(

66
lib/pages/stats_page.dart Normal file
View file

@ -0,0 +1,66 @@
import 'package:flutter/material.dart';
import 'package:local_spend/common/platform/platform_scaffold.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:local_spend/common/functions/logout.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:local_spend/common/functions/customAbout.dart' as custom;
import 'package:local_spend/common/functions/showDialogTwoButtons.dart';
const URL = "https://flutter.io/";
const demonstration = false;
class StatsPage extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return new StatsPageState();
}
}
class StatsPageState extends State<StatsPage> {
@override
void initState() {
super.initState();
_saveCurrentRoute("/StatsPageState");
}
@override
void dispose() {
super.dispose();
}
_saveCurrentRoute(String lastRoute) async {
SharedPreferences preferences = await SharedPreferences.getInstance();
await preferences.setString('LastPageRoute', lastRoute);
}
@override
Widget build(BuildContext context) {
return PlatformScaffold(
appBar: AppBar(
backgroundColor: Colors.blue[400],
title: Text(
"Statistics",
style: TextStyle(
fontSize: 20,
color: Colors.white,
),
),
// leading: BackButton(),
centerTitle: true,
iconTheme: IconThemeData(color: Colors.black),
),
body: Container(
padding: EdgeInsets.fromLTRB(0, 15, 0, 0),
child: Column(
children: <Widget>[
// some graphs and charts here etc
Center(child : Text("(imagine this is a really cool graph!)"),)
],
),
),
);
}
}

View file

@ -1,5 +1,5 @@
# Generated by pub # Generated by pub
# See https://www.dartlang.org/tools/pub/glossary#lockfile # See https://dart.dev/tools/pub/glossary#lockfile
packages: packages:
analyzer: analyzer:
dependency: transitive dependency: transitive
@ -21,7 +21,7 @@ packages:
name: async name: async
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.2.0"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
@ -330,7 +330,7 @@ packages:
name: pedantic name: pedantic
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.5.0" version: "1.7.0"
pool: pool:
dependency: transitive dependency: transitive
description: description:
@ -358,7 +358,7 @@ packages:
name: quiver name: quiver
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.2" version: "2.0.3"
shared_preferences: shared_preferences:
dependency: "direct main" dependency: "direct main"
description: description:
@ -440,7 +440,7 @@ packages:
name: test_api name: test_api
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.2.4" version: "0.2.5"
timing: timing:
dependency: transitive dependency: transitive
description: description: