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/receipt_page.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';
void main() {
@ -32,7 +32,7 @@ class MyApp extends StatelessWidget {
"/HomePage": (BuildContext context) => HomePage(),
"/LoginPage": (BuildContext context) => LoginPage(),
"/ReceiptPage": (BuildContext context) => ReceiptPage(),
"/SettingsPage": (BuildContext context) => SettingsPage(),
"/MorePage": (BuildContext context) => MorePage(),
},
home: SplashScreen(),
);

View file

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

View file

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

View file

@ -31,7 +31,7 @@ class ReceiptPageState extends State<ReceiptPage> {
final TextEditingController _orgController = TextEditingController();
final OrganizationController _organizationController = OrganizationController();
FocusNode focusNode; // added so focus can move automatically
FocusNode focusNode;
DateTime date;
@ -55,6 +55,7 @@ class ReceiptPageState extends State<ReceiptPage> {
focusNode = FocusNode();
_recurringController.text = "None";
_categoryController.text = "";
}
@override
@ -71,7 +72,7 @@ class ReceiptPageState extends State<ReceiptPage> {
// 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');
if (organisation == null) {
@ -154,6 +155,7 @@ class ReceiptPageState extends State<ReceiptPage> {
receipt.town = organisation.town;
receipt.postcode = organisation.postcode;
receipt.recurring = recurring;
receipt.category = category;
// receipt.essential = convertBoolToString(toConvert)
@ -414,7 +416,7 @@ class ReceiptPageState extends State<ReceiptPage> {
),
onSubmitted: (_) {
submitReceipt(_amountController.text,
_timeController.text, _organizationController.organisation, _recurringController.text);
_timeController.text, _organizationController.organisation, _recurringController.text, _categoryController.text);
// 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
},
@ -515,7 +517,7 @@ class ReceiptPageState extends State<ReceiptPage> {
try {
submitReceipt(
_amountController.text, _timeController.text,
_organizationController.organisation, _recurringController.text);
_organizationController.organisation, _recurringController.text, _categoryController.text);
}
catch (_) {
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
# See https://www.dartlang.org/tools/pub/glossary#lockfile
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
analyzer:
dependency: transitive
@ -21,7 +21,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
version: "2.2.0"
boolean_selector:
dependency: transitive
description:
@ -330,7 +330,7 @@ packages:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.0"
version: "1.7.0"
pool:
dependency: transitive
description:
@ -358,7 +358,7 @@ packages:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
version: "2.0.3"
shared_preferences:
dependency: "direct main"
description:
@ -440,7 +440,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.4"
version: "0.2.5"
timing:
dependency: transitive
description: