2019-08-05 09:33:39 +01:00
import ' package:flutter/material.dart ' ;
import ' package:local_spend/common/platform/platform_scaffold.dart ' ;
2019-08-05 11:44:03 +01:00
import ' package:intl/intl.dart ' ;
2019-08-21 14:53:52 +01:00
import ' dart:async ' ;
2019-08-05 11:44:03 +01:00
import ' package:flutter/cupertino.dart ' ;
2019-08-20 13:54:45 +01:00
import ' package:local_spend/common/widgets/animatedGradientButton.dart ' ;
2019-08-07 13:15:15 +01:00
import ' package:local_spend/common/apifunctions/find_organisations.dart ' ;
import ' package:local_spend/common/widgets/organisations_dialog.dart ' ;
2019-08-12 11:37:59 +01:00
import ' package:local_spend/common/apifunctions/submit_receipt_api.dart ' ;
2019-08-12 12:09:04 +01:00
import ' package:local_spend/common/apifunctions/categories.dart ' ;
2019-08-05 09:33:39 +01:00
2019-08-05 12:24:40 +01:00
class Transaction {
Transaction (
this . date ,
this . amount ,
2019-08-07 13:15:15 +01:00
this . organisation ,
2019-08-12 11:19:37 +01:00
this . recurring ,
this . isEssential ,
this . category ,
2019-08-05 12:24:40 +01:00
) ;
2019-08-21 14:53:52 +01:00
DateTime date ;
TextEditingController amount ;
Organisation organisation ;
String recurring ;
bool isEssential ;
String category ;
2019-08-05 12:24:40 +01:00
}
2019-08-05 09:33:39 +01:00
class ReceiptPage2 extends StatefulWidget {
@ override
State < StatefulWidget > createState ( ) {
return new ReceiptPage2State ( ) ;
}
}
class ReceiptPage2State extends State < ReceiptPage2 > {
2019-08-07 13:15:15 +01:00
Transaction transaction = new Transaction (
DateTime . now ( ) ,
new TextEditingController ( ) ,
new Organisation ( null , null , null , null , null ) ,
2019-08-12 11:19:37 +01:00
" None " ,
false ,
" Uncategorised " ,
2019-08-07 13:15:15 +01:00
) ;
2019-08-12 12:29:49 +01:00
2019-08-21 14:53:52 +01:00
AlertDialog _invalidDialog ( context ) {
2019-08-12 12:29:49 +01:00
return AlertDialog (
title: new Text ( " Invalid data " ) ,
content: new Text (
" We couldn't process your request because some of the data entered is invalid. " ) ,
actions: < Widget > [
new FlatButton (
child: new Text ( " OK " ) ,
onPressed: ( ) {
Navigator . of ( context ) . pop ( ) ;
} ,
) ,
] ,
) ;
}
2019-08-12 12:09:04 +01:00
Future < List < String > > getCats ( ) async {
return await getCategories ( ) ;
}
2019-08-12 11:19:37 +01:00
2019-08-21 14:53:52 +01:00
void _submitReceipt ( Transaction transaction ) {
2019-08-12 11:37:59 +01:00
Receipt receipt = new Receipt ( ) ;
receipt . organisationName = transaction . organisation . name ;
receipt . street = transaction . organisation . streetName ;
receipt . postcode = transaction . organisation . postcode ;
receipt . town = transaction . organisation . town ;
2019-08-12 12:29:49 +01:00
2019-08-12 11:37:59 +01:00
receipt . recurring = transaction . recurring ;
2019-08-12 11:54:13 +01:00
if ( transaction . recurring = = " None " ) {
receipt . recurring = " " ;
}
2019-08-12 11:37:59 +01:00
receipt . category = transaction . category ;
2019-08-12 12:29:49 +01:00
if ( transaction . category = = " Uncategorised " ) {
receipt . category = " " ;
}
2019-08-12 11:37:59 +01:00
receipt . amount = transaction . amount . text . toString ( ) ;
2019-08-21 14:53:52 +01:00
receipt . time = DateFormat ( " yyyy-MM-dd'T'hh:mm':00.000+01:00' " )
. format ( transaction . date )
. toString ( ) ;
2019-08-12 11:37:59 +01:00
receipt . essential = transaction . isEssential . toString ( ) ;
submitReceiptAPI ( context , receipt ) ;
}
2019-08-12 11:19:37 +01:00
List < String > _sampleRecurringOptions = new List < String > ( 7 ) ;
2019-08-12 16:28:46 +01:00
List < String > _categories = new List < String > ( ) ;
2019-08-12 11:19:37 +01:00
2019-08-05 09:33:39 +01:00
@ override
Widget build ( BuildContext context ) {
2019-08-21 14:53:52 +01:00
var _widgetHeight = MediaQuery . of ( context ) . size . height * 0.06 < 40.0
? 40.0
: MediaQuery . of ( context ) . size . height * 0.06 ;
2019-08-12 12:09:04 +01:00
2019-08-21 14:53:52 +01:00
if ( _categories . isNotEmpty ) {
2019-08-12 16:28:46 +01:00
Future < List < String > > _futureCats = getCats ( ) ;
_categories . add ( " Fetching categories... " ) ;
_futureCats . then ( ( value ) {
_categories = null ;
_categories = value ;
} ) ;
}
2019-08-21 14:53:52 +01:00
2019-08-12 11:19:37 +01:00
_sampleRecurringOptions [ 0 ] = " None " ;
_sampleRecurringOptions [ 1 ] = " Daily " ;
_sampleRecurringOptions [ 2 ] = " Weekly " ;
_sampleRecurringOptions [ 3 ] = " Fortnightly " ;
_sampleRecurringOptions [ 4 ] = " Monthly " ;
_sampleRecurringOptions [ 5 ] = " Quarterly " ;
2019-08-21 14:53:52 +01:00
_sampleRecurringOptions [ 6 ] = " Yearly " ;
// these will be difficult to fetch from server as they are coded into the site's HTML rather than fetched
2019-08-05 11:44:03 +01:00
2019-08-05 09:33:39 +01:00
return PlatformScaffold (
appBar: AppBar (
2019-08-08 15:25:43 +01:00
backgroundColor: Colors . blue [ 400 ] ,
title: Text (
" Submit Receipt " ,
style: TextStyle (
fontSize: 20 ,
color: Colors . white ,
) ,
2019-08-05 09:33:39 +01:00
) ,
2019-08-08 15:25:43 +01:00
centerTitle: true ,
iconTheme: IconThemeData ( color: Colors . black ) ,
2019-08-05 09:33:39 +01:00
) ,
2019-08-05 11:44:03 +01:00
body: ListView (
children: < Widget > [
2019-08-21 14:53:52 +01:00
// each CHILD has its own horizontal padding because if the listView
// has padding, Android's end-of-scroll animation
2019-08-05 11:44:03 +01:00
// doesn't fit the screen properly and looks weird
2019-08-05 12:11:40 +01:00
2019-08-05 11:44:03 +01:00
Container (
2019-08-21 14:53:52 +01:00
padding: EdgeInsets . fromLTRB (
MediaQuery . of ( context ) . size . width * 0.025 ,
MediaQuery . of ( context ) . size . height * 0.025 ,
0 ,
0.0 ) ,
child: Text (
2019-08-05 11:44:03 +01:00
" Receipt Details " ,
style: TextStyle (
2019-08-20 13:54:45 +01:00
fontSize: 26 ,
2019-08-05 11:44:03 +01:00
color: Colors . grey [ 700 ] ,
fontWeight: FontWeight . bold ,
) ,
) ,
2019-08-05 12:11:40 +01:00
) , // "Receipt Details" title
2019-08-05 11:44:03 +01:00
Container (
2019-08-21 14:53:52 +01:00
padding: EdgeInsets . fromLTRB (
MediaQuery . of ( context ) . size . width * 0.05 ,
15 ,
MediaQuery . of ( context ) . size . width * 0.05 ,
0.0 ) ,
2019-08-19 12:36:12 +01:00
child: Tooltip (
message: " Date and time of transaction " ,
child: Row (
2019-08-21 14:53:52 +01:00
children: < Widget > [
2019-08-19 12:36:12 +01:00
Container (
2019-08-21 14:53:52 +01:00
child: Text (
2019-08-19 12:36:12 +01:00
" Date/Time " ,
style: TextStyle (
2019-08-20 13:54:45 +01:00
fontSize: 22 ,
2019-08-19 12:36:12 +01:00
color: Colors . black ,
fontWeight: FontWeight . bold ,
) ,
2019-08-05 12:24:40 +01:00
) ,
2019-08-20 13:54:45 +01:00
width: MediaQuery . of ( context ) . size . width * 0.3 ,
2019-08-05 11:44:03 +01:00
) ,
2019-08-19 12:36:12 +01:00
Container (
padding: const EdgeInsets . fromLTRB ( 0 , 0 , 0 , 0 ) ,
2019-08-21 10:16:46 +01:00
height: _widgetHeight ,
2019-08-20 13:54:45 +01:00
width: MediaQuery . of ( context ) . size . width * 0.6 ,
2019-08-19 12:36:12 +01:00
child: RaisedButton (
onPressed: ( ) {
showModalBottomSheet (
context: context ,
builder: ( BuildContext builder ) {
return Container (
2019-08-21 14:53:52 +01:00
height: MediaQuery . of ( context )
. copyWith ( )
. size
. height /
3 ,
2019-08-19 12:36:12 +01:00
child: CupertinoDatePicker (
2019-08-21 14:53:52 +01:00
initialDateTime:
transaction . date . isAfter ( DateTime . now ( ) )
? DateTime . now ( )
: transaction . date ,
2019-08-19 12:36:12 +01:00
onDateTimeChanged: ( DateTime newDate ) {
setState ( ( ) = > {
2019-08-21 14:53:52 +01:00
newDate . isAfter ( DateTime . now ( ) )
? transaction . date =
DateTime . now ( )
: transaction . date = newDate ,
} ) ;
2019-08-19 12:36:12 +01:00
} ,
use24hFormat: true ,
maximumDate: DateTime . now ( ) ,
) ,
) ;
} ) ;
} ,
child: Text (
transaction . date = = null
2019-08-20 16:01:56 +01:00
? ' None set. '
: transaction . date . year ! = DateTime . now ( ) . year
2019-08-21 14:53:52 +01:00
? ' ${ 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 ) ,
2019-08-19 12:36:12 +01:00
) ,
color: Colors . blue ,
2019-08-05 11:44:03 +01:00
) ,
) ,
2019-08-19 12:36:12 +01:00
] ,
) ,
2019-08-05 11:44:03 +01:00
) ,
2019-08-05 12:11:40 +01:00
) , // Date/Time picker
Container (
2019-08-21 14:53:52 +01:00
padding: EdgeInsets . fromLTRB (
MediaQuery . of ( context ) . size . width * 0.05 ,
15 ,
MediaQuery . of ( context ) . size . width * 0.05 ,
0.0 ) ,
2019-08-19 12:36:12 +01:00
child: Tooltip (
message: " Transaction payee " ,
child: Row (
2019-08-21 14:53:52 +01:00
children: < Widget > [
2019-08-19 12:36:12 +01:00
Container (
2019-08-21 14:53:52 +01:00
child: Text (
2019-08-19 12:36:12 +01:00
" Payee " ,
style: TextStyle (
2019-08-20 13:54:45 +01:00
fontSize: 22 ,
2019-08-19 12:36:12 +01:00
color: Colors . black ,
fontWeight: FontWeight . bold ,
) ,
2019-08-05 12:24:40 +01:00
) ,
2019-08-20 13:54:45 +01:00
width: MediaQuery . of ( context ) . size . width * 0.3 ,
2019-08-05 12:11:40 +01:00
) ,
2019-08-19 12:36:12 +01:00
Container (
padding: const EdgeInsets . fromLTRB ( 0 , 0 , 0 , 0 ) ,
2019-08-21 10:16:46 +01:00
height: _widgetHeight ,
2019-08-20 13:54:45 +01:00
width: MediaQuery . of ( context ) . size . width * 0.6 ,
2019-08-19 12:36:12 +01:00
child: RaisedButton (
onPressed: ( ) {
var organisations = new FindOrganisations ( ) ;
var orgDialog = organisations . dialog ( context ) ;
orgDialog . then ( ( organisation ) {
try {
organisation . name . length ;
transaction . organisation = organisation ;
2019-08-21 14:53:52 +01:00
// debugPrint(organisation.name);
2019-08-19 12:36:12 +01:00
setState ( ( ) { } ) ;
2019-08-21 14:53:52 +01:00
} catch ( _ ) {
2019-08-19 12:36:12 +01:00
debugPrint ( " No organisation chosen. " ) ;
}
} ) ;
} ,
child: Text (
transaction . organisation . name = = null
? ' Find '
: transaction . organisation . name . length > 14
2019-08-21 14:53:52 +01:00
? transaction . organisation . name
. substring ( 0 , 12 ) +
" ... "
: transaction . organisation . name ,
style: TextStyle ( color: Colors . white , fontSize: 22.0 ) ,
2019-08-19 12:36:12 +01:00
) ,
color: Colors . blue ,
2019-08-05 12:11:40 +01:00
) ,
) ,
2019-08-19 12:36:12 +01:00
] ,
) ,
2019-08-05 12:11:40 +01:00
) ,
2019-08-07 13:15:15 +01:00
) , // Organisation picker
2019-08-12 11:19:37 +01:00
Container (
2019-08-21 14:53:52 +01:00
padding: EdgeInsets . fromLTRB (
MediaQuery . of ( context ) . size . width * 0.05 ,
15 ,
MediaQuery . of ( context ) . size . width * 0.05 ,
0.0 ) ,
2019-08-19 12:36:12 +01:00
child: Tooltip (
2019-08-21 10:16:46 +01:00
message: " Repeating? " ,
2019-08-19 12:36:12 +01:00
child: Row (
2019-08-21 14:53:52 +01:00
children: < Widget > [
2019-08-19 12:36:12 +01:00
Container (
2019-08-21 14:53:52 +01:00
child: Text (
2019-08-19 12:36:12 +01:00
" Recurring " ,
style: TextStyle (
2019-08-20 13:54:45 +01:00
fontSize: 22 ,
2019-08-19 12:36:12 +01:00
color: Colors . black ,
fontWeight: FontWeight . bold ,
) ,
2019-08-12 11:19:37 +01:00
) ,
2019-08-20 13:54:45 +01:00
width: MediaQuery . of ( context ) . size . width * 0.3 ,
2019-08-12 11:19:37 +01:00
) ,
2019-08-19 12:36:12 +01:00
Container (
padding: const EdgeInsets . fromLTRB ( 0 , 0 , 0 , 0 ) ,
2019-08-21 10:16:46 +01:00
height: _widgetHeight ,
2019-08-20 13:54:45 +01:00
width: MediaQuery . of ( context ) . size . width * 0.6 ,
2019-08-19 12:36:12 +01:00
child: RaisedButton (
onPressed: ( ) {
showModalBottomSheet (
2019-08-21 14:53:52 +01:00
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 ,
) ,
) ;
} ) ;
2019-08-19 12:36:12 +01:00
} ,
child: Text (
transaction . recurring = = null
? ' None '
: transaction . recurring ,
2019-08-21 14:53:52 +01:00
style: TextStyle ( color: Colors . white , fontSize: 22.0 ) ,
2019-08-19 12:36:12 +01:00
) ,
color: Colors . blue ,
2019-08-12 11:19:37 +01:00
) ,
) ,
2019-08-19 12:36:12 +01:00
] ,
) ,
2019-08-12 11:19:37 +01:00
) ,
) , // Recurring picker
Container (
2019-08-21 14:53:52 +01:00
padding: EdgeInsets . fromLTRB (
MediaQuery . of ( context ) . size . width * 0.05 ,
15 ,
MediaQuery . of ( context ) . size . width * 0.05 ,
0.0 ) ,
2019-08-12 11:19:37 +01:00
child: Row (
2019-08-21 14:53:52 +01:00
children: < Widget > [
2019-08-12 11:19:37 +01:00
Container (
2019-08-21 14:53:52 +01:00
child: Text (
2019-08-12 11:19:37 +01:00
" Category " ,
style: TextStyle (
2019-08-20 13:54:45 +01:00
fontSize: 22 ,
2019-08-12 11:19:37 +01:00
color: Colors . black ,
fontWeight: FontWeight . bold ,
) ,
) ,
2019-08-20 13:54:45 +01:00
width: MediaQuery . of ( context ) . size . width * 0.3 ,
2019-08-12 11:19:37 +01:00
) ,
Container (
padding: const EdgeInsets . fromLTRB ( 0 , 0 , 0 , 0 ) ,
2019-08-21 10:16:46 +01:00
height: _widgetHeight ,
2019-08-20 13:54:45 +01:00
width: MediaQuery . of ( context ) . size . width * 0.6 ,
2019-08-19 12:36:12 +01:00
child: Tooltip (
message: " Category of transaction " ,
child: RaisedButton (
onPressed: ( ) {
showModalBottomSheet (
context: context ,
builder: ( BuildContext builder ) {
return Container (
2019-08-21 14:53:52 +01:00
height: MediaQuery . of ( context )
. copyWith ( )
. size
. height /
3 ,
2019-08-19 12:36:12 +01:00
child: CupertinoPicker (
backgroundColor: Colors . white ,
2019-08-21 14:53:52 +01:00
children: _categories
. map ( ( thisOption ) = > Text (
thisOption ,
style: TextStyle ( fontSize: 30 ) ,
) )
. toList ( ) ,
2019-08-19 12:36:12 +01:00
onSelectedItemChanged: ( ( newValue ) {
2019-08-21 14:53:52 +01:00
transaction . category =
_categories [ newValue ] ;
2019-08-19 12:36:12 +01:00
setState ( ( ) { } ) ;
} ) ,
2019-08-20 14:13:01 +01:00
magnification: 1.1 ,
useMagnifier: true ,
itemExtent: 36 ,
2019-08-19 12:36:12 +01:00
) ,
) ;
} ) ;
} ,
child: Text (
transaction . category = = null
? ' None '
: transaction . category ,
2019-08-21 14:53:52 +01:00
style: TextStyle ( color: Colors . white , fontSize: 22.0 ) ,
2019-08-19 12:36:12 +01:00
) ,
color: Colors . blue ,
2019-08-12 11:19:37 +01:00
) ,
) ,
) ,
] ,
) ,
) , // Category picker
Container (
2019-08-21 14:53:52 +01:00
padding: EdgeInsets . fromLTRB (
MediaQuery . of ( context ) . size . width * 0.05 ,
15 ,
MediaQuery . of ( context ) . size . width * 0.05 ,
0.0 ) ,
2019-08-19 12:36:12 +01:00
child: Tooltip (
message: " Essential or not " ,
child: Row (
2019-08-21 14:53:52 +01:00
children: < Widget > [
2019-08-19 12:36:12 +01:00
Container (
2019-08-21 14:53:52 +01:00
child: Text (
2019-08-19 12:36:12 +01:00
" Essential " ,
style: TextStyle (
2019-08-20 13:54:45 +01:00
fontSize: 22 ,
2019-08-19 12:36:12 +01:00
color: Colors . black ,
fontWeight: FontWeight . bold ,
) ,
2019-08-12 11:19:37 +01:00
) ,
2019-08-20 13:54:45 +01:00
width: MediaQuery . of ( context ) . size . width * 0.3 ,
2019-08-12 11:19:37 +01:00
) ,
2019-08-19 12:36:12 +01:00
Container (
2019-08-21 10:16:46 +01:00
height: _widgetHeight ,
2019-08-20 13:54:45 +01:00
width: MediaQuery . of ( context ) . size . width * 0.6 ,
2019-08-19 12:36:12 +01:00
child: Checkbox (
value: transaction . isEssential ,
onChanged: ( ( value ) {
setState ( ( ) = > transaction . isEssential = value ) ;
} ) ,
) ,
2019-08-12 11:19:37 +01:00
) ,
2019-08-19 12:36:12 +01:00
] ,
) ,
2019-08-12 11:19:37 +01:00
) ,
) , // Essential
2019-08-07 13:15:15 +01:00
Container (
2019-08-21 14:53:52 +01:00
padding: EdgeInsets . fromLTRB (
MediaQuery . of ( context ) . size . width * 0.05 ,
15 ,
MediaQuery . of ( context ) . size . width * 0.05 ,
0.0 ) ,
2019-08-19 12:36:12 +01:00
child: Tooltip (
message: " Transaction amount " ,
child: Row (
2019-08-21 14:53:52 +01:00
children: < Widget > [
2019-08-19 12:36:12 +01:00
Container (
2019-08-21 14:53:52 +01:00
child: Text (
2019-08-19 12:36:12 +01:00
" Amount " ,
style: TextStyle (
2019-08-20 13:54:45 +01:00
fontSize: 22 ,
2019-08-19 12:36:12 +01:00
color: Colors . black ,
fontWeight: FontWeight . bold ,
) ,
2019-08-07 13:15:15 +01:00
) ,
2019-08-20 13:54:45 +01:00
width: MediaQuery . of ( context ) . size . width * 0.3 ,
2019-08-07 13:15:15 +01:00
) ,
2019-08-19 12:36:12 +01:00
Container (
padding: const EdgeInsets . fromLTRB ( 0 , 0 , 0 , 0 ) ,
2019-08-21 10:16:46 +01:00
height: _widgetHeight ,
2019-08-20 13:54:45 +01:00
width: MediaQuery . of ( context ) . size . width * 0.6 ,
2019-08-19 12:36:12 +01:00
child: TextField (
2019-08-20 14:06:39 +01:00
style: TextStyle (
fontSize: 20 ,
) ,
textAlign: TextAlign . center ,
2019-08-19 12:36:12 +01:00
controller: transaction . amount ,
2019-08-21 14:53:52 +01:00
decoration: InputDecoration ( hintText: " 0.00 " ) ,
keyboardType: TextInputType . numberWithOptions (
decimal: true , signed: true ) ,
2019-08-07 13:15:15 +01:00
) ,
) ,
2019-08-19 12:36:12 +01:00
] ,
) ,
2019-08-07 13:15:15 +01:00
) ,
2019-08-05 12:24:40 +01:00
) , // Amount picker
2019-08-05 11:44:03 +01:00
2019-08-12 11:37:59 +01:00
Padding (
2019-08-21 14:53:52 +01:00
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 ) ,
2019-08-19 12:36:12 +01:00
child: Tooltip (
message: " Submit receipt " ,
child: Container (
2019-08-21 10:16:46 +01:00
height: _widgetHeight * 1.7 ,
2019-08-20 13:58:53 +01:00
child: ClipRRect (
borderRadius: BorderRadius . circular ( 2 ) ,
2019-08-20 16:01:56 +01:00
child: Opacity (
opacity: 1 ,
child: Stack (
children: [
2019-08-21 14:53:52 +01:00
AnimatedBackground (
[ Colors . blue , Colors . lightBlue [ 300 ] ] ,
Colors . lightBlue ,
Alignment . topLeft ,
Alignment . bottomRight ,
4 ) ,
2019-08-20 16:01:56 +01:00
Material (
type: MaterialType . transparency ,
child: InkWell (
child: Center (
2019-08-21 14:53:52 +01:00
child: Text (
" GO " ,
style: TextStyle (
color: Colors . white , fontSize: 30.0 ) ,
2019-08-20 16:01:56 +01:00
) ,
2019-08-20 13:58:53 +01:00
) ,
2019-08-20 16:01:56 +01:00
onTap: ( ) {
try {
2019-08-21 14:53:52 +01:00
if ( transaction . amount . text = = " " | |
transaction . organisation . name = = null ) {
2019-08-20 13:58:53 +01:00
showDialog (
2019-08-20 16:01:56 +01:00
context: context ,
builder: ( BuildContext context ) {
return _invalidDialog ( context ) ;
2019-08-21 14:53:52 +01:00
} ) ;
2019-08-20 16:01:56 +01:00
} else {
2019-08-21 14:53:52 +01:00
if ( double . tryParse (
transaction . amount . text ) ! =
null & &
double . tryParse ( transaction . amount . text ) >
0 ) {
2019-08-20 16:01:56 +01:00
_submitReceipt ( transaction ) ;
} else {
showDialog (
2019-08-21 14:53:52 +01:00
context: context ,
builder: ( BuildContext context ) {
return _invalidDialog ( context ) ;
} ) ;
2019-08-20 16:01:56 +01:00
}
2019-08-20 13:58:53 +01:00
}
2019-08-21 14:53:52 +01:00
} catch ( _ ) {
2019-08-20 16:01:56 +01:00
showDialog (
2019-08-21 14:53:52 +01:00
context: context ,
builder: ( BuildContext context ) {
return _invalidDialog ( context ) ;
} ) ;
2019-08-20 16:01:56 +01:00
}
} ,
) ,
2019-08-20 13:58:53 +01:00
) ,
2019-08-20 16:01:56 +01:00
] ,
) ,
2019-08-20 13:58:53 +01:00
) ,
2019-08-19 12:36:12 +01:00
) ,
2019-08-12 11:37:59 +01:00
) ,
) ,
) ,
2019-08-05 11:44:03 +01:00
] ,
) ,
2019-08-05 09:33:39 +01:00
) ;
}
2019-08-21 14:53:52 +01:00
}