many UI improvements and subtle tweaks

This commit is contained in:
Felix 2019-08-20 13:54:45 +01:00
parent 9a5bfbaaf0
commit 231ed2c9df
15 changed files with 191 additions and 153 deletions

View File

@ -5,7 +5,7 @@ import 'package:local_spend/common/functions/get_token.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
Future<List<String>> getCategories() async { Future<List<String>> getCategories() async {
const url = "https://dev.peartrade.org/api/search/category"; const url = "https://dev.localspend.co.uk/api/search/category";
var token; var token;
await getToken().then((result) { await getToken().then((result) {

View File

@ -64,7 +64,7 @@ class Organisations {
} }
Future<List<Organisation>> findOrganisations(String search) async { Future<List<Organisation>> findOrganisations(String search) async {
final url = "https://dev.peartrade.org/api/search"; final url = "https://dev.localspend.co.uk/api/search";
var token; var token;
await getToken().then((result) { await getToken().then((result) {

View File

@ -28,7 +28,7 @@ class GraphData {
]; ];
} }
final url = "https://dev.peartrade.org/api/v1/customer/graphs"; final url = "https://dev.localspend.co.uk/api/v1/customer/graphs";
SharedPreferences preferences = await SharedPreferences.getInstance(); SharedPreferences preferences = await SharedPreferences.getInstance();
Map<String, String> body = { Map<String, String> body = {
@ -88,13 +88,13 @@ class GraphData {
// TODO: Show available graph types based on whether or not the user is an Organisation or User // TODO: Show available graph types based on whether or not the user is an Organisation or User
/// Customer graph types: https://dev.peartrade.org/api/v1/customer/graphs /// Customer graph types: https://dev.localspend.co.uk/api/v1/customer/graphs
/// - total_last_week /// - total_last_week
/// - avg_spend_last_week /// - avg_spend_last_week
/// - total_last_month /// - total_last_month
/// - avg_spend_last_month /// - avg_spend_last_month
/// ///
/// Organisations' graphs types: to fetch, POST to https://dev.peartrade.org/api/stats/[name] as {"session_key":"[boop beep]"} /// Organisations' graphs types: to fetch, POST to https://dev.localspend.co.uk/api/stats/[name] as {"session_key":"[boop beep]"}
/// - organisations_all : organisation /// - organisations_all : organisation
/// - pies : organisation/pies /// - pies : organisation/pies
/// - snippets : organisation/snippets /// - snippets : organisation/snippets
@ -110,7 +110,7 @@ class GraphData {
/// HTTP POST request sample: /// HTTP POST request sample:
/// {"graph":"total_last_week","session_key":"blahblahblah"} /// {"graph":"total_last_week","session_key":"blahblahblah"}
final url = "https://dev.peartrade.org/api/v1/customer/graphs"; final url = "https://dev.localspend.co.uk/api/v1/customer/graphs";
SharedPreferences preferences = await SharedPreferences.getInstance(); SharedPreferences preferences = await SharedPreferences.getInstance();
Map<String, String> body = { Map<String, String> body = {
@ -182,7 +182,7 @@ class OrgGraphData {
]; ];
} }
final url = "https://dev.peartrade.org/api/v1/customer/graphs"; final url = "https://dev.localspend.co.uk/api/v1/customer/graphs";
SharedPreferences preferences = await SharedPreferences.getInstance(); SharedPreferences preferences = await SharedPreferences.getInstance();
Map<String, String> body = { Map<String, String> body = {
@ -242,13 +242,13 @@ class OrgGraphData {
// TODO: Show available graph types based on whether or not the user is an Organisation or User // TODO: Show available graph types based on whether or not the user is an Organisation or User
/// Customer graph types: https://dev.peartrade.org/api/v1/customer/graphs /// Customer graph types: https://dev.localspend.co.uk/api/v1/customer/graphs
/// - total_last_week /// - total_last_week
/// - avg_spend_last_week /// - avg_spend_last_week
/// - total_last_month /// - total_last_month
/// - avg_spend_last_month /// - avg_spend_last_month
/// ///
/// Organisations' graphs types: to fetch, POST to https://dev.peartrade.org/api/stats/[name] as {"session_key":"[boop beep]"} /// Organisations' graphs types: to fetch, POST to https://dev.localspend.co.uk/api/stats/[name] as {"session_key":"[boop beep]"}
/// - organisations_all : organisation /// - organisations_all : organisation
/// - pies : organisation/pies /// - pies : organisation/pies
/// - snippets : organisation/snippets /// - snippets : organisation/snippets
@ -264,7 +264,7 @@ class OrgGraphData {
/// HTTP POST request sample: /// HTTP POST request sample:
/// {"graph":"total_last_week","session_key":"blahblahblah"} /// {"graph":"total_last_week","session_key":"blahblahblah"}
final url = "https://dev.peartrade.org/api/v1/customer/graphs"; final url = "https://dev.localspend.co.uk/api/v1/customer/graphs";
SharedPreferences preferences = await SharedPreferences.getInstance(); SharedPreferences preferences = await SharedPreferences.getInstance();
Map<String, String> body = { Map<String, String> body = {

View File

@ -11,26 +11,27 @@ Future<void> _incorrectDialog(BuildContext context, bool isLoginWrong) async {
context: context, context: context,
barrierDismissible: true, barrierDismissible: true,
builder: (BuildContext context) { builder: (BuildContext context) {
return AlertDialog( return AnimatedContainer(
title: Text("Unable to Login"), duration: Duration(seconds: 2),
content: Text(isLoginWrong ? "Incorrect login details. Please try again." : "Our servers are having issues at the moment; sorry for the inconvenience. Please try again later."), child : AlertDialog(
actions: <Widget>[ title: Text("Uh-oh!"),
FlatButton( content: Text(isLoginWrong ? "Incorrect login details. Please try again." : "Our servers are having issues at the moment; sorry for the inconvenience. Please try again later."),
child: Text('OK'), actions: <Widget>[
onPressed: () { FlatButton(
Navigator.of(context).pop(); child: Text('OK'),
}, onPressed: () {
), Navigator.of(context).pop();
], },
),
],
),
); );
}, },
); );
} }
Future<LoginModel> requestLoginAPI( Future<LoginModel> requestLoginAPI(BuildContext context, String email, String password) async {
BuildContext context, String email, String password) async { final url = "https://dev.localspend.co.uk/api/login";
//var apiUrl = ConfigWrapper.of(context).apiKey;
final url = "https://dev.peartrade.org/api/login";
Map<String, String> body = { Map<String, String> body = {
'email': email, 'email': email,
@ -43,7 +44,7 @@ Future<LoginModel> requestLoginAPI(
final response = await http.post( final response = await http.post(
url, url,
body: json.encode(body), body: json.encode(body),
); ).timeout(Duration(seconds: 5));
if (response.statusCode == 200) { if (response.statusCode == 200) {
final responseJson = json.decode(response.body); final responseJson = json.decode(response.body);
@ -61,6 +62,8 @@ Future<LoginModel> requestLoginAPI(
return null; return null;
} }
} on TimeoutException catch (_) {
_incorrectDialog(context, false);
} catch (error) { } catch (error) {
debugPrint(error.toString()); debugPrint(error.toString());
_incorrectDialog(context, false); _incorrectDialog(context, false);

View File

@ -8,7 +8,7 @@ import 'package:local_spend/common/functions/save_logout.dart';
import 'package:local_spend/model/json/login_model.dart'; import 'package:local_spend/model/json/login_model.dart';
Future<LoginModel> requestLogoutAPI(BuildContext context) async { Future<LoginModel> requestLogoutAPI(BuildContext context) async {
final url = "https://dev.peartrade.org/api/logout"; final url = "https://dev.localspend.co.uk/api/logout";
var token; var token;

View File

@ -23,7 +23,7 @@ class Receipt {
Future<LoginModel> submitReceiptAPI( Future<LoginModel> submitReceiptAPI(
BuildContext context, Receipt receipt) async { BuildContext context, Receipt receipt) async {
//var apiUrl = ConfigWrapper.of(context).apiKey; //var apiUrl = ConfigWrapper.of(context).apiKey;
final url = "https://dev.peartrade.org/api/upload"; final url = "https://dev.localspend.co.uk/api/upload";
SharedPreferences preferences = await SharedPreferences.getInstance(); SharedPreferences preferences = await SharedPreferences.getInstance();

View File

@ -0,0 +1,27 @@
import 'package:flutter/material.dart';
import 'package:simple_animations/simple_animations.dart';
class AnimatedBackground extends StatelessWidget {
@override
Widget build(BuildContext context) {
final tween = MultiTrackTween([
Track("color1").add(Duration(seconds: 4),
ColorTween(begin: Colors.lightBlue, end: Colors.lightBlue[300])),
]);
return ControlledAnimation(
playback: Playback.MIRROR,
tween: tween,
duration: tween.duration,
builder: (context, animation) {
return Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [animation["color1"], Colors.lightBlue])),
);
},
);
}
}

2
lib/env/dev.g.dart vendored
View File

@ -9,5 +9,5 @@ part of 'dev.dart';
const _$configJsonLiteral = { const _$configJsonLiteral = {
'env': 'DEV', 'env': 'DEV',
'production': false, 'production': false,
'apiUrl': 'https://dev.peartrade.org/api' 'apiUrl': 'https://dev.localspend.co.uk/api'
}; };

2
lib/env/dev.json vendored
View File

@ -1,5 +1,5 @@
{ {
"env": "DEV", "env": "DEV",
"production": false, "production": false,
"apiUrl": "https://dev.peartrade.org/api" "apiUrl": "https://dev.localspend.co.uk/api"
} }

2
lib/env/prod.g.dart vendored
View File

@ -9,5 +9,5 @@ part of 'prod.dart';
const _$configJsonLiteral = { const _$configJsonLiteral = {
'env': 'PROD', 'env': 'PROD',
'production': true, 'production': true,
'apiUrl': 'https://www.peartrade.org/api' 'apiUrl': 'https://www.localspend.co.uk/api'
}; };

2
lib/env/prod.json vendored
View File

@ -1,5 +1,5 @@
{ {
"env": "PROD", "env": "PROD",
"production": true, "production": true,
"apiUrl": "https://www.peartrade.org/api" "apiUrl": "https://www.localspend.co.uk/api"
} }

View File

@ -18,6 +18,7 @@ class LoginPage extends StatefulWidget {
} }
class LoginPageState extends State<LoginPage> { class LoginPageState extends State<LoginPage> {
bool _isLoggingIn = false;
final TextEditingController _emailController = TextEditingController(/*text: 'test@example.com'*/); // remove final TextEditingController _emailController = TextEditingController(/*text: 'test@example.com'*/); // remove
final TextEditingController _passwordController = TextEditingController(/*text: 'abc123'*/); // remove final TextEditingController _passwordController = TextEditingController(/*text: 'abc123'*/); // remove
bool _saveLoginDetails = true; // I am extremely sorry for the placement of this variable bool _saveLoginDetails = true; // I am extremely sorry for the placement of this variable
@ -69,6 +70,7 @@ class LoginPageState extends State<LoginPage> {
} }
login(String username, String password) async { login(String username, String password) async {
_isLoggingIn = true;
SystemChannels.textInput.invokeMethod('TextInput.hide'); SystemChannels.textInput.invokeMethod('TextInput.hide');
SharedPreferences preferences = await SharedPreferences.getInstance(); SharedPreferences preferences = await SharedPreferences.getInstance();
@ -82,8 +84,9 @@ class LoginPageState extends State<LoginPage> {
print("details cleared"); print("details cleared");
} }
requestLoginAPI(context, username, requestLoginAPI(context, username, password).then((value) {
password); _isLoggingIn = false;
});
} }
@override @override
@ -98,14 +101,6 @@ class LoginPageState extends State<LoginPage> {
} }
}, },
child: PlatformScaffold( child: PlatformScaffold(
// drawer: BasicDrawer(),
// body: Container(
// decoration: BoxDecoration(color: Colors.white),
// margin: const EdgeInsets.all(20),
// child: Padding(
// padding: EdgeInsets.fromLTRB(30.0, 170.0, 30.0, 0.0),
// child: ListView(
// children: <Widget>[
body: Container( body: Container(
decoration: new BoxDecoration( decoration: new BoxDecoration(
gradient: new LinearGradient( gradient: new LinearGradient(
@ -115,14 +110,15 @@ class LoginPageState extends State<LoginPage> {
end: Alignment.bottomCenter, end: Alignment.bottomCenter,
), ),
), ),
child: Container( child: AnimatedContainer(
duration: Duration(seconds: 2),
margin: EdgeInsets.fromLTRB(60,30,60,0), margin: EdgeInsets.fromLTRB(60,30,60,0),
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
child: Container( child: AnimatedContainer(
margin: EdgeInsets.fromLTRB(15,0,15,0), duration: Duration(seconds: 2),
// alignment: FractionalOffset(0.5, 0.3), // not sure what this does ngl :/ margin: EdgeInsets.fromLTRB(15,0,15,0),
decoration: BoxDecoration( decoration: BoxDecoration(
image: DecorationImage( image: DecorationImage(
image: AssetImage('assets/images/launch_image.png') image: AssetImage('assets/images/launch_image.png')
@ -177,39 +173,42 @@ class LoginPageState extends State<LoginPage> {
Padding( Padding(
padding: EdgeInsets.fromLTRB(0.0, 40.0, 0.0, 30.0), padding: EdgeInsets.fromLTRB(0.0, 40.0, 0.0, 30.0),
child : Material( child: Opacity(
child: new Container( opacity: _isLoggingIn ? 0.5 : 1,
decoration: new BoxDecoration( child : Material(
border: new Border.all(color : Colors.transparent, width: 2), child: new Container(
borderRadius: BorderRadius.all(Radius.circular(2)), decoration: new BoxDecoration(
gradient: new LinearGradient( border: new Border.all(color : Colors.transparent, width: 2),
colors: [ borderRadius: BorderRadius.all(Radius.circular(2)),
Colors.blue[300], gradient: new LinearGradient(
Colors.blue[500], colors: [
], Colors.blue[300],
stops: [0,1], Colors.blue[500],
begin: Alignment.topLeft, ],
end: Alignment.bottomRight, stops: [0,1],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
), ),
),
child : Material( child : Material(
type: MaterialType.transparency, type: MaterialType.transparency,
child : InkWell( child : InkWell(
onTap: () => login( _emailController.text, _passwordController.text), onTap: _isLoggingIn ? null : () => login( _emailController.text, _passwordController.text),
child: new Container( child: new Container(
width: 100, width: 100,
height: 50, height: 50,
child: new Center( child: new Center(
child: new Text( child: new Text(
'GO', style: new TextStyle(fontSize: 18, color: Colors.white),), 'GO', style: new TextStyle(fontSize: 18, color: Colors.white),),
),
), ),
), ),
), ),
),
),
), ),
), ),
), ),
@ -229,22 +228,6 @@ class LoginPageState extends State<LoginPage> {
}); });
}, },
), ),
/*child: LabeledCheckboxWithIcon(
label : "SAVE LOGIN",
textStyle: TextStyle(fontSize: 18, color: Colors.black54, fontWeight: FontWeight.bold),
icon: Icons.account_box, // need to remove icon padding!!
iconSize: 18,
iconColor: Colors.black54,
padding: const EdgeInsets.fromLTRB(0,0,0,0),
value : _saveLoginDetails,
onChanged: (bool newValue) {
setState(() {
_saveLoginDetails = newValue;
});
},
),*/
), ),
], ],
), ),

View File

@ -3,6 +3,7 @@ import 'package:local_spend/common/platform/platform_scaffold.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'dart:core'; import 'dart:core';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:local_spend/common/widgets/animatedGradientButton.dart';
import 'package:local_spend/common/apifunctions/find_organisations.dart'; import 'package:local_spend/common/apifunctions/find_organisations.dart';
import 'package:local_spend/common/widgets/organisations_dialog.dart'; import 'package:local_spend/common/widgets/organisations_dialog.dart';
import 'package:local_spend/common/apifunctions/submit_receipt_api.dart'; import 'package:local_spend/common/apifunctions/submit_receipt_api.dart';
@ -72,7 +73,7 @@ class ReceiptPage2State extends State<ReceiptPage2> {
// "purchase_time":"2019-08-12T11:06:00.000+01:00", // "purchase_time":"2019-08-12T11:06:00.000+01:00",
// "organisation_id":59661, // "organisation_id":59661,
// "essential":false, // "essential":false,
// "session_key":"C438432A-B775-11E9-8EE8-147589E69626" // "session_key":"C438440A-B775-11E9-8EE8-147589E69626"
// } // }
Receipt receipt = new Receipt(); Receipt receipt = new Receipt();
@ -149,7 +150,7 @@ class ReceiptPage2State extends State<ReceiptPage2> {
child : Text( child : Text(
"Receipt Details", "Receipt Details",
style: TextStyle( style: TextStyle(
fontSize: 24, fontSize: 26,
color: Colors.grey[700], color: Colors.grey[700],
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
@ -166,17 +167,18 @@ class ReceiptPage2State extends State<ReceiptPage2> {
child : Text( child : Text(
"Date/Time", "Date/Time",
style: TextStyle( style: TextStyle(
fontSize: 18, fontSize: 22,
color: Colors.black, color: Colors.black,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
width: 110, width: MediaQuery.of(context).size.width * 0.3,
), ),
Container( Container(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0), padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
height: 32.0, height: 40.0,
width: MediaQuery.of(context).size.width * 0.6,
child: RaisedButton( child: RaisedButton(
onPressed: () { onPressed: () {
showModalBottomSheet( showModalBottomSheet(
@ -208,7 +210,7 @@ class ReceiptPage2State extends State<ReceiptPage2> {
? '${new DateFormat.MMMd().format(transaction.date)}' + ", " + '${new DateFormat.Hm().format(transaction.date)}' ? '${new DateFormat.MMMd().format(transaction.date)}' + ", " + '${new DateFormat.Hm().format(transaction.date)}'
: '${new DateFormat.MMMd().format(transaction.date)}' + " " + transaction.date.year.toString() + ", " + '${new DateFormat.Hm().format(transaction.date)}', : '${new DateFormat.MMMd().format(transaction.date)}' + " " + transaction.date.year.toString() + ", " + '${new DateFormat.Hm().format(transaction.date)}',
style: style:
TextStyle(color: Colors.white, fontSize: 18.0), TextStyle(color: Colors.white, fontSize: 22.0),
), ),
color: Colors.blue, color: Colors.blue,
), ),
@ -228,17 +230,18 @@ class ReceiptPage2State extends State<ReceiptPage2> {
child : Text( child : Text(
"Payee", "Payee",
style: TextStyle( style: TextStyle(
fontSize: 18, fontSize: 22,
color: Colors.black, color: Colors.black,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
width: 110, width: MediaQuery.of(context).size.width * 0.3,
), ),
Container( Container(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0), padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
height: 32.0, height: 40.0,
width: MediaQuery.of(context).size.width * 0.6,
child: RaisedButton( child: RaisedButton(
onPressed: () { onPressed: () {
var organisations = new FindOrganisations(); var organisations = new FindOrganisations();
@ -261,7 +264,7 @@ class ReceiptPage2State extends State<ReceiptPage2> {
? transaction.organisation.name.substring(0,12) + "..." ? transaction.organisation.name.substring(0,12) + "..."
: transaction.organisation.name, : transaction.organisation.name,
style: style:
TextStyle(color: Colors.white, fontSize: 18.0), TextStyle(color: Colors.white, fontSize: 22.0),
), ),
color: Colors.blue, color: Colors.blue,
), ),
@ -281,17 +284,18 @@ class ReceiptPage2State extends State<ReceiptPage2> {
child : Text( child : Text(
"Recurring", "Recurring",
style: TextStyle( style: TextStyle(
fontSize: 18, fontSize: 22,
color: Colors.black, color: Colors.black,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
width: 110, width: MediaQuery.of(context).size.width * 0.3,
), ),
Container( Container(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0), padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
height: 32.0, height: 40.0,
width: MediaQuery.of(context).size.width * 0.6,
child: RaisedButton( child: RaisedButton(
onPressed: () { onPressed: () {
showModalBottomSheet( showModalBottomSheet(
@ -306,7 +310,7 @@ class ReceiptPage2State extends State<ReceiptPage2> {
transaction.recurring = _sampleRecurringOptions[newValue]; transaction.recurring = _sampleRecurringOptions[newValue];
setState(() {}); setState(() {});
}), }),
itemExtent: 32, itemExtent: 40,
), ),
); );
}); });
@ -316,7 +320,7 @@ class ReceiptPage2State extends State<ReceiptPage2> {
? 'None' ? 'None'
: transaction.recurring, : transaction.recurring,
style: style:
TextStyle(color: Colors.white, fontSize: 18.0), TextStyle(color: Colors.white, fontSize: 22.0),
), ),
color: Colors.blue, color: Colors.blue,
), ),
@ -334,17 +338,18 @@ class ReceiptPage2State extends State<ReceiptPage2> {
child : Text( child : Text(
"Category", "Category",
style: TextStyle( style: TextStyle(
fontSize: 18, fontSize: 22,
color: Colors.black, color: Colors.black,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
width: 110, width: MediaQuery.of(context).size.width * 0.3,
), ),
Container( Container(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0), padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
height: 32.0, height: 40.0,
width: MediaQuery.of(context).size.width * 0.6,
child: Tooltip( child: Tooltip(
message: "Category of transaction", message: "Category of transaction",
child: RaisedButton( child: RaisedButton(
@ -361,7 +366,7 @@ class ReceiptPage2State extends State<ReceiptPage2> {
transaction.category = _categories[newValue]; transaction.category = _categories[newValue];
setState(() {}); setState(() {});
}), }),
itemExtent: 32, itemExtent: 40,
), ),
); );
}); });
@ -371,7 +376,7 @@ class ReceiptPage2State extends State<ReceiptPage2> {
? 'None' ? 'None'
: transaction.category, : transaction.category,
style: style:
TextStyle(color: Colors.white, fontSize: 18.0), TextStyle(color: Colors.white, fontSize: 22.0),
), ),
color: Colors.blue, color: Colors.blue,
), ),
@ -391,16 +396,17 @@ class ReceiptPage2State extends State<ReceiptPage2> {
child : Text( child : Text(
"Essential", "Essential",
style: TextStyle( style: TextStyle(
fontSize: 18, fontSize: 22,
color: Colors.black, color: Colors.black,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
width: 95, width: MediaQuery.of(context).size.width * 0.3,
), ),
Container( Container(
height: 32.0, height: 40.0,
width: MediaQuery.of(context).size.width * 0.6,
child: Checkbox( child: Checkbox(
value: transaction.isEssential, value: transaction.isEssential,
onChanged: ((value) { onChanged: ((value) {
@ -423,19 +429,19 @@ class ReceiptPage2State extends State<ReceiptPage2> {
child : Text( child : Text(
"Amount", "Amount",
style: TextStyle( style: TextStyle(
fontSize: 18, fontSize: 22,
color: Colors.black, color: Colors.black,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
width: 110, width: MediaQuery.of(context).size.width * 0.3,
), ),
Container( Container(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0), padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
height: 32.0, height: 40.0,
width: 100, width: MediaQuery.of(context).size.width * 0.6,
child: TextField( child: TextField(
controller: transaction.amount, controller: transaction.amount,
decoration: InputDecoration( decoration: InputDecoration(
@ -454,46 +460,57 @@ class ReceiptPage2State extends State<ReceiptPage2> {
child: Tooltip( child: Tooltip(
message: "Submit receipt", message: "Submit receipt",
child: Container( child: Container(
height: 65.0, decoration: new BoxDecoration(
child: RaisedButton( border: new Border.all(color : Colors.transparent, width: 2),
onPressed: () { borderRadius: BorderRadius.all(Radius.circular(2)),
try { ),
if (transaction.amount.text == "" || transaction.organisation.name == null) { height: 75.0,
showDialog( child: Stack(
context: context, children: [
builder: (BuildContext context) { AnimatedBackground(),
return _invalidDialog(context); Material(
type: MaterialType.transparency,
child: InkWell(
child: Center(
child : Text("GO",
style:
TextStyle(color: Colors.white, fontSize: 30.0),
),
),
onTap: () {
try {
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) {
_submitReceipt(transaction);
} else {
showDialog(
context: context,
builder: (BuildContext context) {
return _invalidDialog(context);
}
);
}
} }
); }
} else { catch (_) {
if (double.tryParse(transaction.amount.text) != null && double.tryParse(transaction.amount.text) > 0) { showDialog(
_submitReceipt(transaction); context: context,
} else { builder: (BuildContext context) {
showDialog( return _invalidDialog(context);
context: context, }
builder: (BuildContext context) { );
return _invalidDialog(context); }
} },
); ),
} ),
} ],
}
catch (_) {
showDialog(
context: context,
builder: (BuildContext context) {
return _invalidDialog(context);
}
);
}
},
child: Text("GO",
style:
TextStyle(color: Colors.white, fontSize: 22.0),
),
color: Colors.blue,
), ),
), ),
), ),

View File

@ -394,6 +394,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.2.3" version: "0.2.3"
simple_animations:
dependency: "direct main"
description:
name: simple_animations
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.3"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter

View File

@ -25,6 +25,7 @@ dependencies:
flutter_linkify: ^1.0.3 flutter_linkify: ^1.0.3
flutter_fadein: ^1.1.1 flutter_fadein: ^1.1.1
charts_flutter: ^0.6.0 charts_flutter: ^0.6.0
simple_animations: ^1.3.3
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2 cupertino_icons: ^0.1.2