fix async nav + refactor
This commit is contained in:
parent
689fa13a7e
commit
bd054b0a9f
6 changed files with 52 additions and 44 deletions
|
@ -24,18 +24,19 @@ class _ConsumePageState extends State<ConsumePage> {
|
|||
super.initState();
|
||||
}
|
||||
|
||||
Future<void> _consume() async {
|
||||
void _consume() {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
_formKey.currentState!.save();
|
||||
|
||||
await API()
|
||||
.consumeItem(widget.transaction, _selectedDestination, "${_price} €");
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Item consumed successfully!')),
|
||||
);
|
||||
Navigator.of(context).pop();
|
||||
widget.refresh();
|
||||
API()
|
||||
.consumeItem(widget.transaction, _selectedDestination, "$_price €")
|
||||
.then((_) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Item consumed successfully!')),
|
||||
);
|
||||
Navigator.of(context).pop();
|
||||
widget.refresh();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ class _ItemViewState extends State<ItemView> {
|
|||
children: [
|
||||
Text("Amount: ${stat.amount}"),
|
||||
Text(
|
||||
"Total Cost: ${stat.total_price.toStringAsFixed(2)}")
|
||||
"Total Cost: ${stat.totalPrice.toStringAsFixed(2)}")
|
||||
],
|
||||
);
|
||||
},
|
||||
|
@ -125,7 +125,7 @@ class TransactionCard extends StatelessWidget {
|
|||
onTap: () {
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return ConsumePage(t.uuid, t.item, t.variant, this.refresh);
|
||||
return ConsumePage(t.uuid, t.item, t.variant, refresh);
|
||||
},
|
||||
));
|
||||
},
|
||||
|
|
|
@ -6,7 +6,7 @@ class SetupPage extends StatefulWidget {
|
|||
const SetupPage({super.key});
|
||||
|
||||
@override
|
||||
_SetupPageState createState() => _SetupPageState();
|
||||
State<SetupPage> createState() => _SetupPageState();
|
||||
}
|
||||
|
||||
class _SetupPageState extends State<SetupPage> {
|
||||
|
|
|
@ -25,18 +25,20 @@ class _SupplyPageState extends State<SupplyPage> {
|
|||
variant = widget.item.variants.keys.first;
|
||||
}
|
||||
|
||||
Future<void> _supply() async {
|
||||
void _supply() {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
_formKey.currentState!.save();
|
||||
|
||||
await API().supplyItem(widget.item.name, variant, "${_price} €",
|
||||
_selectedOrigin, _selectedLocation);
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Item added successfully!')),
|
||||
);
|
||||
Navigator.of(context).pop();
|
||||
widget.refresh();
|
||||
API()
|
||||
.supplyItem(widget.item.name, variant, "$_price €", _selectedOrigin,
|
||||
_selectedLocation)
|
||||
.then((_) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Item added successfully!')),
|
||||
);
|
||||
Navigator.of(context).pop();
|
||||
widget.refresh();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,8 +167,8 @@ class _SupplyPageState extends State<SupplyPage> {
|
|||
.map<DropdownMenuItem<String>>((id) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: id,
|
||||
child: Text(
|
||||
locations[id]!.full_name_path(locations)),
|
||||
child:
|
||||
Text(locations[id]!.fullNamePath(locations)),
|
||||
);
|
||||
}).toList(),
|
||||
onSaved: (value) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue