animation, tooltips, ui sizing fixed

This commit is contained in:
Felix 2019-08-19 12:36:12 +01:00
parent abbd0a7170
commit 68a33c53e9
2 changed files with 371 additions and 345 deletions

View File

@ -106,123 +106,126 @@ class FindOrganisations {
builder: (BuildContext context) { builder: (BuildContext context) {
return StatefulBuilder( return StatefulBuilder(
builder: (context, setState) { builder: (context, setState) {
return SimpleDialog( return AnimatedContainer(
children: <Widget>[ duration: Duration(seconds: 1),
Column( child : SimpleDialog(
children: [ children: <Widget>[
Row( Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Container( Row(
padding: EdgeInsets.fromLTRB(20, 0, 0, 0), crossAxisAlignment: CrossAxisAlignment.center,
width: 150, children: [
height: 50, Container(
child: TextField( padding: EdgeInsets.fromLTRB(20, 0, 0, 0),
controller: searchBarText, width: 150,
decoration: InputDecoration( height: 50,
hintText: "Payee Name", child: TextField(
controller: searchBarText,
decoration: InputDecoration(
hintText: "Payee Name",
),
onChanged: (value) {
if (value.length > 0) {
_searchEnabled = true;
} else {
_searchEnabled = false;
}
setState(() => {_searchEnabled});
},
onSubmitted: _searchEnabled ? (_) {
var result = _submitSearch(searchBarText.text);
result.then((_) {
setState(() {});
});
} : null,
),
), ),
onChanged: (value) {
if (value.length > 0) {
_searchEnabled = true;
} else {
_searchEnabled = false;
}
setState(() => {_searchEnabled});
},
onSubmitted: _searchEnabled ? (_) {
var result = _submitSearch(searchBarText.text);
result.then((_) {
setState(() {});
});
} : null,
),
),
Container( Container(
width: 80, width: 80,
padding: EdgeInsets.fromLTRB(20, 0, 0, 0), padding: EdgeInsets.fromLTRB(20, 0, 0, 0),
child: RaisedButton( child: RaisedButton(
onPressed: (() { onPressed: (() {
if (_searchEnabled) { if (_searchEnabled) {
SystemChannels.textInput.invokeMethod('TextInput.hide'); SystemChannels.textInput.invokeMethod('TextInput.hide');
var result = _submitSearch(searchBarText.text); var result = _submitSearch(searchBarText.text);
result.then((_) { result.then((_) {
setState(() { setState(() {
_orgsFetched = true; _orgsFetched = true;
}); });
}); });
} }
}), }),
child: Icon(Icons.search, color: Colors.white), child: Icon(Icons.search, color: Colors.white),
color: _searchEnabled ? Colors.blue : Colors.blue[200], color: _searchEnabled ? Colors.blue : Colors.blue[200],
// make inactive when search in progress as activity indicator // make inactive when search in progress as activity indicator
), ),
),
],
), ),
], ],
), ),
Column(
children: _orgsFetched ? [
Container(
padding: EdgeInsets.fromLTRB(20, 20, 20, 0),
child: Text(
listTitle,
style: new TextStyle(
fontSize: 23, fontWeight: FontWeight.bold),
),
),
Container(
padding: EdgeInsets.fromLTRB(10, 10, 10, 0),
width: MediaQuery
.of(context)
.size
.width,
height: MediaQuery
.of(context)
.size
.height * 0.67,
child: Material(
shadowColor: Colors.transparent,
color: Colors.transparent,
child: ListView.builder(
itemCount: organisationsList.length,
itemBuilder: (context, index) {
return Card(
child: ListTile(
leading: Icon(Icons.person),
title: Text(organisationsList[index].name, style: new TextStyle(fontSize: 18)),
subtitle: Text(organisationsList[index].postcode.toUpperCase()),
// trailing: Icon(Icons.arrow_forward_ios),
// onTap: _chosenOrg(organisationsList[index]),
onTap: (){
Navigator.of(context).pop(organisationsList[index]);
},
onLongPress: (){
// show more details about the organisation in a new dialog
var moreInfo = _moreInfoDialog(context, organisationsList[index]);
moreInfo.whenComplete(null);
},
),
);
},
),
),
),
] : [ Container(), ],
),
// help button for if org not listed
// cancel and ok buttons
], ],
), ),
);
Column(
children: _orgsFetched ? [
Container(
padding: EdgeInsets.fromLTRB(20, 20, 20, 0),
child: Text(
listTitle,
style: new TextStyle(
fontSize: 23, fontWeight: FontWeight.bold),
),
),
Container(
padding: EdgeInsets.fromLTRB(10, 10, 10, 0),
width: MediaQuery
.of(context)
.size
.width,
height: MediaQuery
.of(context)
.size
.height * 0.67,
child: Material(
shadowColor: Colors.transparent,
color: Colors.transparent,
child: ListView.builder(
itemCount: organisationsList.length,
itemBuilder: (context, index) {
return Card(
child: ListTile(
leading: Icon(Icons.person),
title: Text(organisationsList[index].name, style: new TextStyle(fontSize: 18)),
subtitle: Text(organisationsList[index].postcode.toUpperCase()),
// trailing: Icon(Icons.arrow_forward_ios),
// onTap: _chosenOrg(organisationsList[index]),
onTap: (){
Navigator.of(context).pop(organisationsList[index]);
},
onLongPress: (){
// show more details about the organisation in a new dialog
var moreInfo = _moreInfoDialog(context, organisationsList[index]);
moreInfo.whenComplete(null);
},
),
);
},
),
),
),
] : [ Container(), ],
),
// help button for if org not listed
// cancel and ok buttons
],
);
}, },
); );
}, },

View File

@ -158,164 +158,173 @@ class ReceiptPage2State extends State<ReceiptPage2> {
Container( Container(
padding: EdgeInsets.fromLTRB(25,15,15.0,0.0), padding: EdgeInsets.fromLTRB(25,15,15.0,0.0),
child: Row( child: Tooltip(
children: <Widget> [ message: "Date and time of transaction",
Container( child: Row(
child : Text( children: <Widget> [
"Date/Time", Container(
style: TextStyle( child : Text(
fontSize: 18, "Date/Time",
color: Colors.black, style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 18,
color: Colors.black,
fontWeight: FontWeight.bold,
),
), ),
width: 110,
), ),
width: 110,
),
Container( Container(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0), padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
height: 32.0, height: 32.0,
child: RaisedButton( child: RaisedButton(
onPressed: () { onPressed: () {
showModalBottomSheet( showModalBottomSheet(
context: context, context: context,
builder: (BuildContext builder) { builder: (BuildContext builder) {
return Container( return Container(
height: MediaQuery.of(context).copyWith().size.height / 3, height: MediaQuery.of(context).copyWith().size.height / 3,
child: CupertinoDatePicker( child: CupertinoDatePicker(
initialDateTime: transaction.date.isAfter(DateTime.now()) initialDateTime: transaction.date.isAfter(DateTime.now())
? DateTime.now() ? DateTime.now()
: transaction.date, : transaction.date,
onDateTimeChanged: (DateTime newDate) { onDateTimeChanged: (DateTime newDate) {
setState(() => { setState(() => {
newDate.isAfter(DateTime.now()) newDate.isAfter(DateTime.now())
? transaction.date = DateTime.now() ? transaction.date = DateTime.now()
: transaction.date = newDate, : transaction.date = newDate,
}); });
}, },
use24hFormat: true, use24hFormat: true,
maximumDate: DateTime.now(), maximumDate: DateTime.now(),
), ),
); );
}); });
}, },
child: Text( child: Text(
transaction.date == null transaction.date == null
? 'None set' ? 'None set'
: transaction.date.year == DateTime.now().year : transaction.date.year == DateTime.now().year
? '${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: 18.0),
),
color: Colors.blue,
), ),
color: Colors.blue,
), ),
), ],
], ),
), ),
), // Date/Time picker ), // Date/Time picker
Container( Container(
padding: EdgeInsets.fromLTRB(25,15,15.0,0.0), padding: EdgeInsets.fromLTRB(25,15,15.0,0.0),
child: Row( child: Tooltip(
children: <Widget> [ message: "Transaction payee",
Container( child: Row(
child : Text( children: <Widget> [
"Payee", Container(
style: TextStyle( child : Text(
fontSize: 18, "Payee",
color: Colors.black, style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 18,
color: Colors.black,
fontWeight: FontWeight.bold,
),
), ),
width: 110,
), ),
width: 110,
),
Container( Container(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0), padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
height: 32.0, height: 32.0,
child: RaisedButton( child: RaisedButton(
onPressed: () { onPressed: () {
// var popupListView = new PopupListView(); // var popupListView = new PopupListView();
// var dialog = popupListView.dialog(context, optionsList, "Choose Organization"); // var dialog = popupListView.dialog(context, optionsList, "Choose Organization");
var organisations = new FindOrganisations(); var organisations = new FindOrganisations();
var orgDialog = organisations.dialog(context); var orgDialog = organisations.dialog(context);
orgDialog.then((organisation) { orgDialog.then((organisation) {
try { try {
organisation.name.length; organisation.name.length;
transaction.organisation = organisation; transaction.organisation = organisation;
// debugPrint(organisation.name); // debugPrint(organisation.name);
setState(() {}); setState(() {});
} catch(_) { } catch(_) {
debugPrint("No organisation chosen."); debugPrint("No organisation chosen.");
} }
}); });
}, },
child: Text( child: Text(
transaction.organisation.name == null transaction.organisation.name == null
? 'Find' ? 'Find'
: transaction.organisation.name.length > 14 : transaction.organisation.name.length > 14
? 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: 18.0),
),
color: Colors.blue,
), ),
color: Colors.blue,
), ),
), ],
], ),
), ),
), // Organisation picker ), // Organisation picker
Container( Container(
padding: EdgeInsets.fromLTRB(25,15,15.0,0.0), padding: EdgeInsets.fromLTRB(25,15,15.0,0.0),
child: Row( child: Tooltip(
children: <Widget> [ message: "Transaction recrudescence",
Container( child: Row(
child : Text( children: <Widget> [
"Recurring", Container(
style: TextStyle( child : Text(
fontSize: 18, "Recurring",
color: Colors.black, style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 18,
color: Colors.black,
fontWeight: FontWeight.bold,
),
), ),
width: 110,
), ),
width: 110,
),
Container( Container(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0), padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
height: 32.0, height: 32.0,
child: RaisedButton( child: RaisedButton(
onPressed: () { onPressed: () {
showModalBottomSheet( showModalBottomSheet(
context: context, context: context,
builder: (BuildContext builder) { builder: (BuildContext builder) {
return Container( return Container(
height: MediaQuery.of(context).copyWith().size.height / 3, height: MediaQuery.of(context).copyWith().size.height / 3,
child: CupertinoPicker( child: CupertinoPicker(
backgroundColor: Colors.white, backgroundColor: Colors.white,
children: _sampleRecurringOptions.map((thisOption) => Text(thisOption)).toList(), children: _sampleRecurringOptions.map((thisOption) => Text(thisOption)).toList(),
onSelectedItemChanged: ((newValue) { onSelectedItemChanged: ((newValue) {
transaction.recurring = _sampleRecurringOptions[newValue]; transaction.recurring = _sampleRecurringOptions[newValue];
setState(() {}); setState(() {});
}), }),
itemExtent: 32, itemExtent: 32,
), ),
); );
}); });
}, },
child: Text( child: Text(
transaction.recurring == null transaction.recurring == null
? 'None' ? 'None'
: transaction.recurring, : transaction.recurring,
style: style:
TextStyle(color: Colors.white, fontSize: 18.0), TextStyle(color: Colors.white, fontSize: 18.0),
),
color: Colors.blue,
), ),
color: Colors.blue,
), ),
), ],
], ),
), ),
), // Recurring picker ), // Recurring picker
@ -338,33 +347,36 @@ class ReceiptPage2State extends State<ReceiptPage2> {
Container( Container(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0), padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
height: 32.0, height: 32.0,
child: RaisedButton( child: Tooltip(
onPressed: () { message: "Category of transaction",
showModalBottomSheet( child: RaisedButton(
context: context, onPressed: () {
builder: (BuildContext builder) { showModalBottomSheet(
return Container( context: context,
height: MediaQuery.of(context).copyWith().size.height / 3, builder: (BuildContext builder) {
child: CupertinoPicker( return Container(
backgroundColor: Colors.white, height: MediaQuery.of(context).copyWith().size.height / 3,
children: _categories.map((thisOption) => Text(thisOption)).toList(), child: CupertinoPicker(
onSelectedItemChanged: ((newValue) { backgroundColor: Colors.white,
transaction.category = _categories[newValue]; children: _categories.map((thisOption) => Text(thisOption)).toList(),
setState(() {}); onSelectedItemChanged: ((newValue) {
}), transaction.category = _categories[newValue];
itemExtent: 32, setState(() {});
), }),
); itemExtent: 32,
}); ),
}, );
child: Text( });
transaction.category == null },
? 'None' child: Text(
: transaction.category, transaction.category == null
style: ? 'None'
TextStyle(color: Colors.white, fontSize: 18.0), : transaction.category,
style:
TextStyle(color: Colors.white, fontSize: 18.0),
),
color: Colors.blue,
), ),
color: Colors.blue,
), ),
), ),
], ],
@ -373,107 +385,118 @@ class ReceiptPage2State extends State<ReceiptPage2> {
Container( Container(
padding: EdgeInsets.fromLTRB(25,15,15.0,0.0), padding: EdgeInsets.fromLTRB(25,15,15.0,0.0),
child: Row( child: Tooltip(
children: <Widget> [ message: "Essential or not",
Container( child: Row(
child : Text( children: <Widget> [
"Essential", Container(
style: TextStyle( child : Text(
fontSize: 18, "Essential",
color: Colors.black, style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 18,
color: Colors.black,
fontWeight: FontWeight.bold,
),
),
width: 95,
),
Container(
height: 32.0,
child: Checkbox(
value: transaction.isEssential,
onChanged: ((value) {
setState(() => transaction.isEssential = value);
}),
), ),
), ),
width: 95, ],
), ),
Container(
height: 32.0,
child: Checkbox(
value: transaction.isEssential,
onChanged: ((value) {
setState(() => transaction.isEssential = value);
}),
),
),
],
), ),
), // Essential ), // Essential
Container( Container(
padding: EdgeInsets.fromLTRB(25,15,15.0,0.0), padding: EdgeInsets.fromLTRB(25,15,15.0,0.0),
child: Row( child: Tooltip(
children: <Widget> [ message: "Transaction amount",
Container( child: Row(
child : Text( children: <Widget> [
"Amount", Container(
style: TextStyle( child : Text(
fontSize: 18, "Amount",
color: Colors.black, style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 18,
color: Colors.black,
fontWeight: FontWeight.bold,
),
), ),
width: 110,
), ),
width: 110,
),
Container( Container(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0), padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
height: 32.0, height: 32.0,
width: 100, width: 100,
child: TextField( child: TextField(
controller: transaction.amount, controller: transaction.amount,
decoration: InputDecoration( decoration: InputDecoration(
hintText: "0.00" hintText: "0.00"
),
keyboardType: TextInputType.numberWithOptions(decimal: true, signed: true),
), ),
keyboardType: TextInputType.numberWithOptions(decimal: true, signed: true),
), ),
), ],
], ),
), ),
), // Amount picker ), // Amount picker
Padding( Padding(
padding: EdgeInsets.fromLTRB(20.0, 20.0, 20.0, 0.0), padding: EdgeInsets.fromLTRB(20.0, 20.0, 20.0, 0.0),
child: Container( child: Tooltip(
height: 65.0, message: "Submit receipt",
child: RaisedButton( child: Container(
onPressed: () { height: 65.0,
try { child: RaisedButton(
if (transaction.amount.text == "" || transaction.organisation.name == null) { onPressed: () {
showDialog( try {
context: context, if (transaction.amount.text == "" || transaction.organisation.name == null) {
builder: (BuildContext context) {
return _invalidDialog(context);
}
);
} else {
if (double.tryParse(transaction.amount.text) != null && double.tryParse(transaction.amount.text) > 0) {
_submitReceipt(transaction);
} else {
showDialog( showDialog(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
return _invalidDialog(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);
}
);
}
} }
} }
} catch (_) {
catch (_) { showDialog(
showDialog( context: context,
context: context, builder: (BuildContext context) {
builder: (BuildContext context) { return _invalidDialog(context);
return _invalidDialog(context); }
} );
); }
} },
},
child: Text("GO",
key: Key("goButton"), child: Text("GO",
style: style:
TextStyle(color: Colors.white, fontSize: 22.0)), TextStyle(color: Colors.white, fontSize: 22.0),
color: Colors.blue, ),
color: Colors.blue,
),
), ),
), ),
), ),