Code is B-E-A-U-TIFUL! All complies to standards.

Complies to flutter/dart 'pedantic' coding standards (their name, not mine)
This commit is contained in:
Felix 2019-08-21 14:53:52 +01:00
parent 19021a9a09
commit 55310068ea
55 changed files with 915 additions and 785 deletions

View file

@ -1,31 +0,0 @@
import 'package:flutter/material.dart';
import 'package:charts_flutter/flutter.dart' as charts;
import 'package:local_spend/common/apifunctions/get_graph_data.dart';
class PresetChart extends StatefulWidget {
PresetChart({Key key}) : super(key: key);
@override
_PresetChartState createState() {
return _PresetChartState();
}
}
class _PresetChartState extends State<PresetChart> {
@override
void initState() {
super.initState();
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
return new Container(
);
}
}

View file

@ -56,10 +56,9 @@ class _CustomerGraphsState extends State<CustomerGraphs> {
return ListView(
children: <Widget>[
Container(
padding: EdgeInsets.fromLTRB(0.0,17,0.0,0.0),
child : Text(
padding: EdgeInsets.fromLTRB(0.0, 17, 0.0, 0.0),
child: Text(
"Last Week's Total Spend",
textAlign: TextAlign.center,
style: TextStyle(
@ -69,19 +68,21 @@ class _CustomerGraphsState extends State<CustomerGraphs> {
),
),
),
Tooltip(
message: "Graph of total spend last week",
child : Container(
child: Container(
padding: EdgeInsets.symmetric(horizontal: 10),
height: 200,
child: totalLastWeekGraph.graph != null ? new charts.TimeSeriesChart(totalLastWeekGraph.graph) : Center(child: Text("Loading graph...")), //List<Series<dynamic, DateTime>>
child: totalLastWeekGraph.graph != null
? new charts.TimeSeriesChart(totalLastWeekGraph.graph)
: Center(
child: Text(
"Loading graph...")), //List<Series<dynamic, DateTime>>
),
),
Container(
padding: EdgeInsets.fromLTRB(0.0,17,0.0,0.0),
child : Text(
padding: EdgeInsets.fromLTRB(0.0, 17, 0.0, 0.0),
child: Text(
"Last Week's Average Spend",
textAlign: TextAlign.center,
style: TextStyle(
@ -91,19 +92,21 @@ class _CustomerGraphsState extends State<CustomerGraphs> {
),
),
),
Tooltip(
message: "Graph of average spend last week",
child : Container(
child: Container(
padding: EdgeInsets.symmetric(horizontal: 10),
height: 200,
child: avgSpendLastWeekGraph.graph != null ? new charts.TimeSeriesChart(avgSpendLastWeekGraph.graph) : Center(child: Text("Loading graph...")), //List<Series<dynamic, DateTime>>
child: avgSpendLastWeekGraph.graph != null
? new charts.TimeSeriesChart(avgSpendLastWeekGraph.graph)
: Center(
child: Text(
"Loading graph...")), //List<Series<dynamic, DateTime>>
),
),
Container(
padding: EdgeInsets.fromLTRB(0.0,17,0.0,0.0),
child : Text(
padding: EdgeInsets.fromLTRB(0.0, 17, 0.0, 0.0),
child: Text(
"Last Month's Total Spend",
textAlign: TextAlign.center,
style: TextStyle(
@ -113,19 +116,21 @@ class _CustomerGraphsState extends State<CustomerGraphs> {
),
),
),
Tooltip(
message: "Graph of total spend last month",
child : Container(
child: Container(
padding: EdgeInsets.symmetric(horizontal: 10),
height: 200,
child: totalLastMonthGraph.graph != null ? new charts.TimeSeriesChart(totalLastMonthGraph.graph) : Center(child: Text("Loading graph...")), //List<Series<dynamic, DateTime>>
child: totalLastMonthGraph.graph != null
? new charts.TimeSeriesChart(totalLastMonthGraph.graph)
: Center(
child: Text(
"Loading graph...")), //List<Series<dynamic, DateTime>>
),
),
Container(
padding: EdgeInsets.fromLTRB(0.0,17,0.0,0.0),
child : Text(
padding: EdgeInsets.fromLTRB(0.0, 17, 0.0, 0.0),
child: Text(
"Last Month's Average Spend",
textAlign: TextAlign.center,
style: TextStyle(
@ -135,17 +140,19 @@ class _CustomerGraphsState extends State<CustomerGraphs> {
),
),
),
Tooltip(
message: "Graph of average spend last month",
child : Container(
child: Container(
padding: EdgeInsets.symmetric(horizontal: 10),
height: 200,
child: avgSpendLastMonth.graph != null ? new charts.TimeSeriesChart(avgSpendLastMonth.graph) : Center(child: Text("Loading graph...")), //List<Series<dynamic, DateTime>>
child: avgSpendLastMonth.graph != null
? new charts.TimeSeriesChart(avgSpendLastMonth.graph)
: Center(
child: Text(
"Loading graph...")), //List<Series<dynamic, DateTime>>
),
),
],
);
}
}
}

View file

@ -5,7 +5,7 @@ import 'package:local_spend/pages/stats_page.dart';
import 'package:local_spend/pages/map_page.dart';
class HomePage extends StatelessWidget {
static String _title = 'Text here';
static String _title = 'SpendTracker';
@override
Widget build(BuildContext context) {
@ -27,11 +27,11 @@ class _HomePageState extends State<HomePageWidget> {
int _selectedIndex = 0;
static const TextStyle optionStyle =
TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
static List<Widget> _widgetOptions = <Widget>[
ReceiptPage2(),
StatsPage(),
MapPage(),
MapSample(),
MorePage()
];
@ -43,7 +43,6 @@ class _HomePageState extends State<HomePageWidget> {
@override
Widget build(BuildContext context) {
var _itemText = TextStyle(color: Colors.grey[400]);
return Scaffold(
body: Center(
@ -75,4 +74,4 @@ class _HomePageState extends State<HomePageWidget> {
),
);
}
}
}

View file

@ -9,7 +9,7 @@ import 'package:url_launcher/url_launcher.dart';
import 'package:local_spend/common/widgets/labeled_checkbox.dart';
import 'package:local_spend/common/widgets/animatedGradientButton.dart';
const URL = "https://flutter.io/";
const url = "https://flutter.io/";
class LoginPage extends StatefulWidget {
@override
@ -20,12 +20,15 @@ class LoginPage extends StatefulWidget {
class LoginPageState extends State<LoginPage> {
bool _isLoggingIn = false;
final TextEditingController _emailController = TextEditingController(/*text: 'test@example.com'*/); // remove
final TextEditingController _passwordController = TextEditingController(/*text: 'abc123'*/); // remove
bool _saveLoginDetails = true; // I am extremely sorry for the placement of this variable
// it will be fixed soon I promise
final TextEditingController _emailController =
TextEditingController(/*text: 'test@example.com'*/); // remove
final TextEditingController _passwordController =
TextEditingController(/*text: 'abc123'*/); // remove
bool _saveLoginDetails =
true; // I am extremely sorry for the placement of this variable
// it will be fixed soon I promise
FocusNode focusNode; // added so focus can move automatically
FocusNode focusNode; // added so focus can move automatically
Future launchURL(String url) async {
if (await canLaunch(url)) {
@ -34,7 +37,7 @@ class LoginPageState extends State<LoginPage> {
showDialogSingleButton(
context,
"Unable to reach your website.",
"Currently unable to reach the website $URL. Please try again at a later time.",
"Currently unable to reach the website $url. Please try again at a later time.",
"OK");
}
}
@ -55,7 +58,7 @@ class LoginPageState extends State<LoginPage> {
super.dispose();
}
_fillLoginDetails() async {
void _fillLoginDetails() async {
SharedPreferences preferences = await SharedPreferences.getInstance();
var username = await preferences.get('username');
@ -65,14 +68,14 @@ class LoginPageState extends State<LoginPage> {
_passwordController.text = await password;
}
_saveCurrentRoute(String lastRoute) async {
void _saveCurrentRoute(String lastRoute) async {
SharedPreferences preferences = await SharedPreferences.getInstance();
await preferences.setString('LastPageRoute', lastRoute);
}
login(String username, String password) async {
void login(String username, String password) async {
_isLoggingIn = true;
SystemChannels.textInput.invokeMethod('TextInput.hide');
await SystemChannels.textInput.invokeMethod('TextInput.hide');
SharedPreferences preferences = await SharedPreferences.getInstance();
if (_saveLoginDetails) {
@ -85,7 +88,7 @@ class LoginPageState extends State<LoginPage> {
print("details cleared");
}
requestLoginAPI(context, username, password).then((value) {
await requestLoginAPI(context, username, password).then((value) {
_isLoggingIn = false;
});
}
@ -100,24 +103,25 @@ class LoginPageState extends State<LoginPage> {
} else {
Navigator.of(context).pushReplacementNamed('/HomePage');
}
return null;
},
child: PlatformScaffold(
body: Stack(
children: [
AnimatedBackground([Colors.lightBlue[50], Colors.lightBlue[50]], Colors.white, Alignment.topRight, Alignment.bottomLeft, 3),
AnimatedBackground([Colors.lightBlue[50], Colors.lightBlue[50]],
Colors.white, Alignment.topRight, Alignment.bottomLeft, 3),
Container(
margin: EdgeInsets.fromLTRB(60,30,60,0),
margin: EdgeInsets.fromLTRB(60, 30, 60, 0),
child: Column(
children: <Widget>[
Expanded(
child: AnimatedContainer(
duration: Duration(seconds: 2),
margin: EdgeInsets.fromLTRB(15,0,15,0),
margin: EdgeInsets.fromLTRB(15, 0, 15, 0),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/launch_image.png')
),
image:
AssetImage('assets/images/launch_image.png')),
),
),
),
@ -159,49 +163,57 @@ class LoginPageState extends State<LoginPage> {
fontWeight: FontWeight.bold,
),
onSubmitted: (_) {
login( _emailController.text,
_passwordController.text);
login(_emailController.text, _passwordController.text);
},
),
),
Container(
margin: EdgeInsets.fromLTRB(0.0, 40.0, 0.0, 30.0),
width: 100,
height: 50,
child: Opacity(
opacity: _isLoggingIn ? 0.5 : 1,
child: ClipRRect(
borderRadius: BorderRadius.circular(2),
child : Stack(
children : [
AnimatedBackground([Colors.blue, Colors.lightBlue[300]], Colors.lightBlue, Alignment.bottomRight, Alignment.topLeft, 3),
Material(
type: MaterialType.transparency,
child : InkWell(
onTap: _isLoggingIn ? null : () => login( _emailController.text, _passwordController.text),
child: new Center(
child: new Text(
'GO', style: new TextStyle(fontSize: 18, color: Colors.white),),
Container(
margin: EdgeInsets.fromLTRB(0.0, 40.0, 0.0, 30.0),
width: 100,
height: 50,
child: Opacity(
opacity: _isLoggingIn ? 0.5 : 1,
child: ClipRRect(
borderRadius: BorderRadius.circular(2),
child: Stack(
children: [
AnimatedBackground(
[Colors.blue, Colors.lightBlue[300]],
Colors.lightBlue,
Alignment.bottomRight,
Alignment.topLeft,
3),
Material(
type: MaterialType.transparency,
child: InkWell(
onTap: _isLoggingIn
? null
: () => login(_emailController.text,
_passwordController.text),
child: new Center(
child: new Text(
'GO',
style: new TextStyle(
fontSize: 18, color: Colors.white),
),
),
),
),
),
],
],
),
),
),
),
),
Padding(
padding: EdgeInsets.fromLTRB(0, 10, 0, 50),
child: LabeledCheckbox(
label : "SAVE LOGIN",
textStyle: TextStyle(fontSize: 18, color: Colors.black54, fontWeight: FontWeight.bold),
padding: const EdgeInsets.fromLTRB(0,0,0,0),
value : _saveLoginDetails,
label: "SAVE LOGIN",
textStyle: TextStyle(
fontSize: 18,
color: Colors.black54,
fontWeight: FontWeight.bold),
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
value: _saveLoginDetails,
onChanged: (bool newValue) {
setState(() {
_saveLoginDetails = newValue;

View file

@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_maps/flutter_maps.dart';
import 'package:local_spend/common/felixApiCreds.dart';
import 'dart:async';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:local_spend/common/platform/platform_scaffold.dart';
class MapPage extends StatefulWidget {
MapPage({Key key}) : super(key: key);
@ -13,20 +14,48 @@ class MapPage extends StatefulWidget {
class _MapPageState extends State<MapPage> {
@override
void initState() {
super.initState();
Widget build(BuildContext context) {
return PlatformScaffold(
appBar: AppBar(
backgroundColor: Colors.blue[400],
title: Text(
"Submit Receipt",
style: TextStyle(
fontSize: 20,
color: Colors.white,
),
),
centerTitle: true,
iconTheme: IconThemeData(color: Colors.black),
),
body: null,
);
}
}
class MapSample extends StatefulWidget {
@override
void dispose() {
super.dispose();
}
State<MapSample> createState() => MapSampleState();
}
class MapSampleState extends State<MapSample> {
Completer<GoogleMapController> _controller = Completer();
static final CameraPosition _kGooglePlex = CameraPosition(
target: LatLng(37.42796133580664, -122.085749655962),
zoom: 14.4746,
);
@override
Widget build(BuildContext context) {
var fac = new FelixApiCreds();
// TODO: implement build
return Text(fac.mapsApiKey);
return new Scaffold(
body: GoogleMap(
mapType: MapType.hybrid,
initialCameraPosition: _kGooglePlex,
onMapCreated: (GoogleMapController controller) {
_controller.complete(controller);
},
),
);
}
}
}

View file

@ -1,4 +1,3 @@
import 'package:flutter/material.dart';
import 'package:local_spend/common/platform/platform_scaffold.dart';
import 'package:shared_preferences/shared_preferences.dart';
@ -7,7 +6,7 @@ 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 url = "https://flutter.io/";
const demonstration = false;
class MorePage extends StatefulWidget {
@ -18,7 +17,7 @@ class MorePage extends StatefulWidget {
}
class MorePageState extends State<MorePage> {
FocusNode focusNode; // added so focus can move automatically
FocusNode focusNode; // added so focus can move automatically
DateTime date;
@ -37,7 +36,7 @@ class MorePageState extends State<MorePage> {
focusNode.dispose(); //disposes focus node when form disposed
}
_saveCurrentRoute(String lastRoute) async {
void _saveCurrentRoute(String lastRoute) async {
SharedPreferences preferences = await SharedPreferences.getInstance();
await preferences.setString('LastPageRoute', lastRoute);
}
@ -52,9 +51,9 @@ class MorePageState extends State<MorePage> {
} else {
Navigator.of(context).pushReplacementNamed('/LoginPage');
}
return null;
},
child: PlatformScaffold(
appBar: AppBar(
backgroundColor: Colors.blue[400],
title: Text(
@ -68,14 +67,12 @@ class MorePageState extends State<MorePage> {
centerTitle: true,
iconTheme: IconThemeData(color: Colors.black),
),
body: Container(
child: ListView(
children: <Widget>[
Container(
padding: EdgeInsets.fromLTRB(30.0,25,30.0,0.0),
child : Text(
padding: EdgeInsets.fromLTRB(30.0, 25, 30.0, 0.0),
child: Text(
"Local Spend Tracker",
textAlign: TextAlign.center,
style: TextStyle(
@ -92,53 +89,49 @@ class MorePageState extends State<MorePage> {
height: 65.0,
child: RaisedButton(
onPressed: () {
custom.showAboutDialog(
context: context,
applicationIcon: new Icon(Icons.receipt),
applicationName: "Local Spend Tracker",
children: <Widget>
[
Text("Pear Trading is a commerce company designed to register and monitor money circulating in the local economy.\n"),
children: <Widget>[
Text(
"Pear Trading is a commerce company designed to register and monitor money circulating in the local economy.\n"),
Container(
padding: EdgeInsets.symmetric(horizontal: 10),
height: 35,
child: RaisedButton(
onPressed: () => {},
child: Text("Contact us",
style:
TextStyle(color: Colors.white, fontSize: 18.0)),
style: TextStyle(
color: Colors.white, fontSize: 18.0)),
color: Colors.green,
),
),
Container(
height: 35,
margin: EdgeInsets.fromLTRB(10, 20, 10, 0),
child: RaisedButton(
child: Text
('Pear Trading',
style: TextStyle(
color: Colors.white,
fontSize: 18.0
child: Text(
'Pear Trading',
style: TextStyle(
color: Colors.white, fontSize: 18.0),
),
),
color: Colors.lightGreen,
onPressed: () => launch('http://www.peartrade.org')
),
color: Colors.lightGreen,
onPressed: () =>
launch('http://www.peartrade.org')),
),
Container(
height: 35,
margin: EdgeInsets.fromLTRB(10, 20, 10, 0),
child: Material(
child: OutlineButton(
child: Text
('Shadowcat Systems',
child: Text(
'Shadowcat Systems',
style: TextStyle(
color: Colors.black,
fontSize: 18.0 /// I don't know what to do with this button
),
color: Colors.black, fontSize: 18.0
/// I don't know what to do with this button
),
),
onPressed: () => launch('https://shadow.cat/'),
),
@ -146,14 +139,11 @@ class MorePageState extends State<MorePage> {
shadowColor: Colors.transparent,
),
),
],
);
},
child: Text("ABOUT",
style:
TextStyle(color: Colors.white, fontSize: 22.0)),
style: TextStyle(color: Colors.white, fontSize: 22.0)),
color: Colors.blue,
),
),
@ -166,17 +156,15 @@ class MorePageState extends State<MorePage> {
child: RaisedButton(
onPressed: () {
showDialogTwoButtons(
context,
"Logout",
"Are you sure you want to log out?",
"Cancel",
"Logout",
logout
);
context,
"Logout",
"Are you sure you want to log out?",
"Cancel",
"Logout",
logout);
},
child: Text("LOGOUT",
style:
TextStyle(color: Colors.white, fontSize: 22.0)),
style: TextStyle(color: Colors.white, fontSize: 22.0)),
color: Colors.red,
),
),
@ -197,7 +185,6 @@ class MorePageState extends State<MorePage> {
// ),
// ),
// ),
],
),
),

View file

@ -1,10 +1,8 @@
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/apifunctions/get_graph_data.dart';
import 'package:charts_flutter/flutter.dart' as charts;
const URL = "https://flutter.io/";
const url = "https://flutter.io/";
const demonstration = false;
class NewStatsPage extends StatefulWidget {
@ -15,7 +13,6 @@ class NewStatsPage extends StatefulWidget {
}
class NewStatsPageState extends State<NewStatsPage> {
/// Graph types:
/// - total_last_week
/// - avg_spend_last_week
@ -33,14 +30,13 @@ class NewStatsPageState extends State<NewStatsPage> {
super.dispose();
}
_saveCurrentRoute(String lastRoute) async {
void _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],
@ -55,11 +51,7 @@ class NewStatsPageState extends State<NewStatsPage> {
centerTitle: true,
iconTheme: IconThemeData(color: Colors.black),
),
body : Container(
),
body: Container(),
);
}
}

View file

@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:local_spend/common/apifunctions/get_graph_data.dart';
import 'package:charts_flutter/flutter.dart' as charts;
//import 'package:charts_flutter/flutter.dart' as charts;
class OrgGraphs extends StatefulWidget {
OrgGraphs({Key key}) : super(key: key);
@ -27,9 +27,7 @@ class _OrgGraphsState extends State<OrgGraphs> {
@override
Widget build(BuildContext context) {
return ListView(
children: <Widget>[
],
children: <Widget>[],
);
}
}
}

View file

@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:local_spend/common/platform/platform_scaffold.dart';
import 'package:intl/intl.dart';
import 'dart:core';
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:local_spend/common/widgets/animatedGradientButton.dart';
import 'package:local_spend/common/apifunctions/find_organisations.dart';
@ -10,13 +10,6 @@ import 'package:local_spend/common/apifunctions/submit_receipt_api.dart';
import 'package:local_spend/common/apifunctions/categories.dart';
class Transaction {
DateTime date;
TextEditingController amount;
Organisation organisation;
String recurring;
bool isEssential;
String category;
Transaction(
this.date,
this.amount,
@ -25,6 +18,13 @@ class Transaction {
this.isEssential,
this.category,
);
DateTime date;
TextEditingController amount;
Organisation organisation;
String recurring;
bool isEssential;
String category;
}
class ReceiptPage2 extends StatefulWidget {
@ -44,7 +44,7 @@ class ReceiptPage2State extends State<ReceiptPage2> {
"Uncategorised",
);
_invalidDialog(context) {
AlertDialog _invalidDialog(context) {
return AlertDialog(
title: new Text("Invalid data"),
content: new Text(
@ -64,9 +64,7 @@ class ReceiptPage2State extends State<ReceiptPage2> {
return await getCategories();
}
_submitReceipt(Transaction transaction) {
DateTime dt = new DateTime.now();
void _submitReceipt(Transaction transaction) {
Receipt receipt = new Receipt();
receipt.organisationName = transaction.organisation.name;
receipt.street = transaction.organisation.streetName;
@ -86,7 +84,9 @@ class ReceiptPage2State extends State<ReceiptPage2> {
}
receipt.amount = transaction.amount.text.toString();
receipt.time = DateFormat("yyyy-MM-dd'T'hh:mm':00.000+01:00'").format(transaction.date).toString();
receipt.time = DateFormat("yyyy-MM-dd'T'hh:mm':00.000+01:00'")
.format(transaction.date)
.toString();
receipt.essential = transaction.isEssential.toString();
submitReceiptAPI(context, receipt);
@ -97,10 +97,11 @@ class ReceiptPage2State extends State<ReceiptPage2> {
@override
Widget build(BuildContext context) {
var _widgetHeight = MediaQuery.of(context).size.height * 0.06 < 40.0
? 40.0
: MediaQuery.of(context).size.height * 0.06;
var _widgetHeight = MediaQuery.of(context).size.height * 0.06 < 40.0 ? 40.0 : MediaQuery.of(context).size.height * 0.06;
if (_categories.length == 0) {
if (_categories.isNotEmpty) {
Future<List<String>> _futureCats = getCats();
_categories.add("Fetching categories...");
_futureCats.then((value) {
@ -108,15 +109,15 @@ class ReceiptPage2State extends State<ReceiptPage2> {
_categories = value;
});
}
_sampleRecurringOptions[0] = "None";
_sampleRecurringOptions[1] = "Daily";
_sampleRecurringOptions[2] = "Weekly";
_sampleRecurringOptions[3] = "Fortnightly";
_sampleRecurringOptions[4] = "Monthly";
_sampleRecurringOptions[5] = "Quarterly";
_sampleRecurringOptions[6] = "Yearly"; // these will be difficult to fetch from server as they are coded into the site's rather than fetched
_sampleRecurringOptions[6] = "Yearly";
// these will be difficult to fetch from server as they are coded into the site's HTML rather than fetched
return PlatformScaffold(
appBar: AppBar(
@ -131,15 +132,19 @@ class ReceiptPage2State extends State<ReceiptPage2> {
centerTitle: true,
iconTheme: IconThemeData(color: Colors.black),
),
body: ListView(
children: <Widget>[
// each CHILD has its own horizontal padding because if the listView has padding, Android's end-of-scroll animation
// each CHILD has its own horizontal padding because if the listView
// has padding, Android's end-of-scroll animation
// doesn't fit the screen properly and looks weird
Container(
padding: EdgeInsets.fromLTRB(MediaQuery.of(context).size.width * 0.025,MediaQuery.of(context).size.height * 0.025,0,0.0),
child : Text(
padding: EdgeInsets.fromLTRB(
MediaQuery.of(context).size.width * 0.025,
MediaQuery.of(context).size.height * 0.025,
0,
0.0),
child: Text(
"Receipt Details",
style: TextStyle(
fontSize: 26,
@ -150,13 +155,17 @@ class ReceiptPage2State extends State<ReceiptPage2> {
), // "Receipt Details" title
Container(
padding: EdgeInsets.fromLTRB(MediaQuery.of(context).size.width * 0.05,15,MediaQuery.of(context).size.width * 0.05,0.0),
padding: EdgeInsets.fromLTRB(
MediaQuery.of(context).size.width * 0.05,
15,
MediaQuery.of(context).size.width * 0.05,
0.0),
child: Tooltip(
message: "Date and time of transaction",
child: Row(
children: <Widget> [
children: <Widget>[
Container(
child : Text(
child: Text(
"Date/Time",
style: TextStyle(
fontSize: 22,
@ -166,7 +175,6 @@ class ReceiptPage2State extends State<ReceiptPage2> {
),
width: MediaQuery.of(context).size.width * 0.3,
),
Container(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
height: _widgetHeight,
@ -177,17 +185,23 @@ class ReceiptPage2State extends State<ReceiptPage2> {
context: context,
builder: (BuildContext builder) {
return Container(
height: MediaQuery.of(context).copyWith().size.height / 3,
height: MediaQuery.of(context)
.copyWith()
.size
.height /
3,
child: CupertinoDatePicker(
initialDateTime: transaction.date.isAfter(DateTime.now())
? DateTime.now()
: transaction.date,
initialDateTime:
transaction.date.isAfter(DateTime.now())
? DateTime.now()
: transaction.date,
onDateTimeChanged: (DateTime newDate) {
setState(() => {
newDate.isAfter(DateTime.now())
? transaction.date = DateTime.now()
: transaction.date = newDate,
});
newDate.isAfter(DateTime.now())
? transaction.date =
DateTime.now()
: transaction.date = newDate,
});
},
use24hFormat: true,
maximumDate: DateTime.now(),
@ -199,12 +213,20 @@ class ReceiptPage2State extends State<ReceiptPage2> {
transaction.date == null
? 'None set.'
: transaction.date.year != DateTime.now().year
? '${new DateFormat.MMMd().format(transaction.date)}' + " " + transaction.date.year.toString() + " at " + '${new DateFormat.Hm().format(transaction.date)}'
: transaction.date.day == DateTime.now().day && transaction.date.month == DateTime.now().month
? "Today at " + '${new DateFormat.Hm().format(transaction.date)}'
: '${new DateFormat.MMMd().format(transaction.date)}' + " at " + '${new DateFormat.Hm().format(transaction.date)}',
style:
TextStyle(color: Colors.white, fontSize: 22.0),
? '${new DateFormat.MMMd().format(transaction.date)}' +
" " +
transaction.date.year.toString() +
" at " +
'${new DateFormat.Hm().format(transaction.date)}'
: transaction.date.day == DateTime.now().day &&
transaction.date.month ==
DateTime.now().month
? "Today at " +
'${new DateFormat.Hm().format(transaction.date)}'
: '${new DateFormat.MMMd().format(transaction.date)}' +
" at " +
'${new DateFormat.Hm().format(transaction.date)}',
style: TextStyle(color: Colors.white, fontSize: 22.0),
),
color: Colors.blue,
),
@ -215,13 +237,17 @@ class ReceiptPage2State extends State<ReceiptPage2> {
), // Date/Time picker
Container(
padding: EdgeInsets.fromLTRB(MediaQuery.of(context).size.width * 0.05,15,MediaQuery.of(context).size.width * 0.05,0.0),
padding: EdgeInsets.fromLTRB(
MediaQuery.of(context).size.width * 0.05,
15,
MediaQuery.of(context).size.width * 0.05,
0.0),
child: Tooltip(
message: "Transaction payee",
child: Row(
children: <Widget> [
children: <Widget>[
Container(
child : Text(
child: Text(
"Payee",
style: TextStyle(
fontSize: 22,
@ -231,7 +257,6 @@ class ReceiptPage2State extends State<ReceiptPage2> {
),
width: MediaQuery.of(context).size.width * 0.3,
),
Container(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
height: _widgetHeight,
@ -244,9 +269,9 @@ class ReceiptPage2State extends State<ReceiptPage2> {
try {
organisation.name.length;
transaction.organisation = organisation;
// debugPrint(organisation.name);
// debugPrint(organisation.name);
setState(() {});
} catch(_) {
} catch (_) {
debugPrint("No organisation chosen.");
}
});
@ -255,10 +280,11 @@ class ReceiptPage2State extends State<ReceiptPage2> {
transaction.organisation.name == null
? 'Find'
: transaction.organisation.name.length > 14
? transaction.organisation.name.substring(0,12) + "..."
: transaction.organisation.name,
style:
TextStyle(color: Colors.white, fontSize: 22.0),
? transaction.organisation.name
.substring(0, 12) +
"..."
: transaction.organisation.name,
style: TextStyle(color: Colors.white, fontSize: 22.0),
),
color: Colors.blue,
),
@ -269,13 +295,17 @@ class ReceiptPage2State extends State<ReceiptPage2> {
), // Organisation picker
Container(
padding: EdgeInsets.fromLTRB(MediaQuery.of(context).size.width * 0.05,15,MediaQuery.of(context).size.width * 0.05,0.0),
padding: EdgeInsets.fromLTRB(
MediaQuery.of(context).size.width * 0.05,
15,
MediaQuery.of(context).size.width * 0.05,
0.0),
child: Tooltip(
message: "Repeating?",
child: Row(
children: <Widget> [
children: <Widget>[
Container(
child : Text(
child: Text(
"Recurring",
style: TextStyle(
fontSize: 22,
@ -285,7 +315,6 @@ class ReceiptPage2State extends State<ReceiptPage2> {
),
width: MediaQuery.of(context).size.width * 0.3,
),
Container(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
height: _widgetHeight,
@ -293,31 +322,37 @@ class ReceiptPage2State extends State<ReceiptPage2> {
child: RaisedButton(
onPressed: () {
showModalBottomSheet(
context: context,
builder: (BuildContext builder) {
return Container(
height: MediaQuery.of(context).copyWith().size.height / 3,
child: CupertinoPicker(
backgroundColor: Colors.white,
children: _sampleRecurringOptions.map((thisOption) => Text(thisOption, style: TextStyle(fontSize: 30))).toList(),
onSelectedItemChanged: ((newValue) {
transaction.recurring = _sampleRecurringOptions[newValue];
setState(() {});
}),
magnification: 1.1,
useMagnifier: true,
itemExtent: 36,
),
);
}
);
context: context,
builder: (BuildContext builder) {
return Container(
height: MediaQuery.of(context)
.copyWith()
.size
.height /
3,
child: CupertinoPicker(
backgroundColor: Colors.white,
children: _sampleRecurringOptions
.map((thisOption) => Text(thisOption,
style: TextStyle(fontSize: 30)))
.toList(),
onSelectedItemChanged: ((newValue) {
transaction.recurring =
_sampleRecurringOptions[newValue];
setState(() {});
}),
magnification: 1.1,
useMagnifier: true,
itemExtent: 36,
),
);
});
},
child: Text(
transaction.recurring == null
? 'None'
: transaction.recurring,
style:
TextStyle(color: Colors.white, fontSize: 22.0),
style: TextStyle(color: Colors.white, fontSize: 22.0),
),
color: Colors.blue,
),
@ -328,11 +363,15 @@ class ReceiptPage2State extends State<ReceiptPage2> {
), // Recurring picker
Container(
padding: EdgeInsets.fromLTRB(MediaQuery.of(context).size.width * 0.05,15,MediaQuery.of(context).size.width * 0.05,0.0),
padding: EdgeInsets.fromLTRB(
MediaQuery.of(context).size.width * 0.05,
15,
MediaQuery.of(context).size.width * 0.05,
0.0),
child: Row(
children: <Widget> [
children: <Widget>[
Container(
child : Text(
child: Text(
"Category",
style: TextStyle(
fontSize: 22,
@ -342,7 +381,6 @@ class ReceiptPage2State extends State<ReceiptPage2> {
),
width: MediaQuery.of(context).size.width * 0.3,
),
Container(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
height: _widgetHeight,
@ -355,12 +393,22 @@ class ReceiptPage2State extends State<ReceiptPage2> {
context: context,
builder: (BuildContext builder) {
return Container(
height: MediaQuery.of(context).copyWith().size.height / 3,
height: MediaQuery.of(context)
.copyWith()
.size
.height /
3,
child: CupertinoPicker(
backgroundColor: Colors.white,
children: _categories.map((thisOption) => Text(thisOption, style: TextStyle(fontSize: 30),)).toList(),
children: _categories
.map((thisOption) => Text(
thisOption,
style: TextStyle(fontSize: 30),
))
.toList(),
onSelectedItemChanged: ((newValue) {
transaction.category = _categories[newValue];
transaction.category =
_categories[newValue];
setState(() {});
}),
magnification: 1.1,
@ -374,8 +422,7 @@ class ReceiptPage2State extends State<ReceiptPage2> {
transaction.category == null
? 'None'
: transaction.category,
style:
TextStyle(color: Colors.white, fontSize: 22.0),
style: TextStyle(color: Colors.white, fontSize: 22.0),
),
color: Colors.blue,
),
@ -386,13 +433,17 @@ class ReceiptPage2State extends State<ReceiptPage2> {
), // Category picker
Container(
padding: EdgeInsets.fromLTRB(MediaQuery.of(context).size.width * 0.05,15,MediaQuery.of(context).size.width * 0.05,0.0),
padding: EdgeInsets.fromLTRB(
MediaQuery.of(context).size.width * 0.05,
15,
MediaQuery.of(context).size.width * 0.05,
0.0),
child: Tooltip(
message: "Essential or not",
child: Row(
children: <Widget> [
children: <Widget>[
Container(
child : Text(
child: Text(
"Essential",
style: TextStyle(
fontSize: 22,
@ -402,7 +453,6 @@ class ReceiptPage2State extends State<ReceiptPage2> {
),
width: MediaQuery.of(context).size.width * 0.3,
),
Container(
height: _widgetHeight,
width: MediaQuery.of(context).size.width * 0.6,
@ -419,13 +469,17 @@ class ReceiptPage2State extends State<ReceiptPage2> {
), // Essential
Container(
padding: EdgeInsets.fromLTRB(MediaQuery.of(context).size.width * 0.05,15,MediaQuery.of(context).size.width * 0.05,0.0),
padding: EdgeInsets.fromLTRB(
MediaQuery.of(context).size.width * 0.05,
15,
MediaQuery.of(context).size.width * 0.05,
0.0),
child: Tooltip(
message: "Transaction amount",
child: Row(
children: <Widget> [
children: <Widget>[
Container(
child : Text(
child: Text(
"Amount",
style: TextStyle(
fontSize: 22,
@ -435,8 +489,6 @@ class ReceiptPage2State extends State<ReceiptPage2> {
),
width: MediaQuery.of(context).size.width * 0.3,
),
Container(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
height: _widgetHeight,
@ -447,10 +499,9 @@ class ReceiptPage2State extends State<ReceiptPage2> {
),
textAlign: TextAlign.center,
controller: transaction.amount,
decoration: InputDecoration(
hintText: "0.00"
),
keyboardType: TextInputType.numberWithOptions(decimal: true, signed: true),
decoration: InputDecoration(hintText: "0.00"),
keyboardType: TextInputType.numberWithOptions(
decimal: true, signed: true),
),
),
],
@ -459,7 +510,11 @@ class ReceiptPage2State extends State<ReceiptPage2> {
), // Amount picker
Padding(
padding: EdgeInsets.fromLTRB(MediaQuery.of(context).size.width * 0.05,MediaQuery.of(context).size.height * 0.03,MediaQuery.of(context).size.width * 0.05,15.0),
padding: EdgeInsets.fromLTRB(
MediaQuery.of(context).size.width * 0.05,
MediaQuery.of(context).size.height * 0.03,
MediaQuery.of(context).size.width * 0.05,
15.0),
child: Tooltip(
message: "Submit receipt",
child: Container(
@ -470,45 +525,52 @@ class ReceiptPage2State extends State<ReceiptPage2> {
opacity: 1,
child: Stack(
children: [
AnimatedBackground([Colors.blue, Colors.lightBlue[300]], Colors.lightBlue, Alignment.topLeft, Alignment.bottomRight, 4),
AnimatedBackground(
[Colors.blue, Colors.lightBlue[300]],
Colors.lightBlue,
Alignment.topLeft,
Alignment.bottomRight,
4),
Material(
type: MaterialType.transparency,
child: InkWell(
child: Center(
child : Text("GO",
style:
TextStyle(color: Colors.white, fontSize: 30.0),
child: Text(
"GO",
style: TextStyle(
color: Colors.white, fontSize: 30.0),
),
),
onTap: () {
try {
if (transaction.amount.text == "" || transaction.organisation.name == null) {
if (transaction.amount.text == "" ||
transaction.organisation.name == null) {
showDialog(
context: context,
builder: (BuildContext context) {
return _invalidDialog(context);
}
);
});
} else {
if (double.tryParse(transaction.amount.text) != null && double.tryParse(transaction.amount.text) > 0) {
if (double.tryParse(
transaction.amount.text) !=
null &&
double.tryParse(transaction.amount.text) >
0) {
_submitReceipt(transaction);
} else {
showDialog(
context: context,
builder: (BuildContext context) {
return _invalidDialog(context);
}
);
context: context,
builder: (BuildContext context) {
return _invalidDialog(context);
});
}
}
}
catch (_) {
} catch (_) {
showDialog(
context: context,
builder: (BuildContext context) {
return _invalidDialog(context);
}
);
context: context,
builder: (BuildContext context) {
return _invalidDialog(context);
});
}
},
),
@ -524,4 +586,4 @@ class ReceiptPage2State extends State<ReceiptPage2> {
),
);
}
}
}

View file

@ -12,7 +12,7 @@ class SplashScreen extends StatefulWidget {
class _SplashScreenState extends State<SplashScreen> {
final int splashDuration = 1;
startTime() async {
Future<Timer> startTime() async {
return Timer(Duration(seconds: splashDuration), () {
SystemChannels.textInput.invokeMethod('TextInput.hide');
Navigator.of(context).pushReplacementNamed('/LoginPage');
@ -41,8 +41,7 @@ class _SplashScreenState extends State<SplashScreen> {
alignment: FractionalOffset(0.5, 0.3),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/launch_image.png')
),
image: AssetImage('assets/images/launch_image.png')),
),
),
),

View file

@ -4,7 +4,7 @@ import 'package:shared_preferences/shared_preferences.dart';
import 'package:local_spend/pages/customerGraphs.dart';
import 'package:local_spend/pages/orgGraphs.dart';
const URL = "https://flutter.io/";
const url = "https://flutter.io/";
const demonstration = false;
class StatsPage extends StatefulWidget {
@ -28,7 +28,7 @@ class StatsPageState extends State<StatsPage> {
super.dispose();
}
_saveCurrentRoute(String lastRoute) async {
void _saveCurrentRoute(String lastRoute) async {
SharedPreferences preferences = await SharedPreferences.getInstance();
await preferences.setString('LastPageRoute', lastRoute);
}
@ -43,7 +43,8 @@ class StatsPageState extends State<StatsPage> {
if (userType == "-") {
_getUserType().then((value) {
print(value);
userType = '${value[0].toUpperCase()}${value.substring(1)}'; // capitalises first letter
userType =
'${value[0].toUpperCase()}${value.substring(1)}'; // capitalises first letter
setState(() {});
});
}
@ -62,10 +63,7 @@ class StatsPageState extends State<StatsPage> {
color: Colors.white,
),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 4)
),
Padding(padding: EdgeInsets.symmetric(horizontal: 4)),
Text(
userType,
style: TextStyle(
@ -75,14 +73,16 @@ class StatsPageState extends State<StatsPage> {
),
],
),
centerTitle: true,
iconTheme: IconThemeData(color: Colors.black),
),
body : Container(
centerTitle: true,
iconTheme: IconThemeData(color: Colors.black),
),
body: Container(
padding: EdgeInsets.fromLTRB(0, 0, 0, 0),
child: (userType == "-" ? null : (userType.toLowerCase() == "customer" ? CustomerGraphs() : OrgGraphs())),
child: (userType == "-"
? null
: (userType.toLowerCase() == "customer"
? CustomerGraphs()
: OrgGraphs())),
),
);
}