/view_three.dart Secret
Created
May 2, 2023 20:33
modal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class _ShowOrderState extends State<ShowOrder> { | |
@override | |
Widget build(BuildContext context) { | |
return Consumer<AppProvider>( | |
builder: (context, state, child) { | |
return AlertDialog( | |
title: | |
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ | |
const Text( | |
"Order Details", | |
style: TextStyle(fontSize: 25), | |
), | |
if (state.orderItems![widget.index].orderStatus == "delivered" || | |
state.orderItems![widget.index].orderStatus == "canceled" || | |
state.orderItems![widget.index].delivery!.deliveryStatus == | |
"completed" || | |
state.orderItems![widget.index].delivery!.deliveryStatus == | |
"failed") | |
Container() | |
else | |
ElevatedButton( | |
onPressed: () { | |
state.cancelorder( | |
state.orderItems![widget.index].id!, | |
"failed", | |
"canceled", | |
state.orderItems![widget.index].delivery!.$id!); | |
print(state | |
.orderItems![widget.index].delivery!.deliveryStatus!); | |
}, | |
child: const Text("Cancel Order")) | |
]), | |
content: SizedBox( | |
width: MediaQuery.of(context).size.width, | |
height: MediaQuery.of(context).size.height, | |
child: Column(mainAxisSize: MainAxisSize.min, children: [ | |
Expanded( | |
child: ListView.builder( | |
itemCount: state.orderItems![widget.index].foodItems!.length, | |
itemBuilder: (context, index) { | |
if (state.orderItems![widget.index].foodItems!.isNotEmpty) { | |
return ListTile( | |
title: Text( | |
state.orderItems![widget.index].foodItems![index]), | |
); | |
} | |
return null; | |
}, | |
), | |
), | |
if (state.orderItems![widget.index].orderStatus == "delivered" && | |
state.orderItems![widget.index].delivery!.deliveryStatus == | |
"in-progress") | |
ListTile( | |
title: const Padding( | |
padding: EdgeInsets.all(8), | |
child: Text( | |
"Have you recieved your package", | |
style: TextStyle(fontSize: 16), | |
), | |
), | |
trailing: Row( | |
mainAxisSize: MainAxisSize.min, | |
children: [ | |
ElevatedButton( | |
child: const Text('Yes'), | |
onPressed: () { | |
if (state.orderItems![widget.index].orderStatus == | |
"delivered") { | |
state.updateOrderDocument( | |
state.orderItems![widget.index].id!, | |
"completed", | |
state.orderItems![widget.index].delivery!.$id); | |
} | |
}, | |
), | |
const SizedBox( | |
width: 10, | |
), | |
ElevatedButton( | |
child: const Text('No'), | |
onPressed: () { | |
if (state.orderItems![widget.index].orderStatus == | |
"delivered") { | |
state.updateOrderDocument( | |
state.orderItems![widget.index].id!, | |
"failed", | |
state.orderItems![widget.index].delivery!.$id); | |
} | |
}, | |
), | |
], | |
), | |
) | |
else | |
Container( | |
width: MediaQuery.of(context).size.width, | |
padding: const EdgeInsets.all(10.0), | |
child: Center( | |
child: Text( | |
state.orderItems![widget.index].delivery!.deliveryStatus!, | |
style: TextStyle( | |
color: Color(state.getDeliveryStatusColor(state | |
.orderItems![widget.index] | |
.delivery! | |
.deliveryStatus!)), | |
fontSize: 20.0), | |
), | |
), | |
) | |
]), | |
), | |
); | |
}, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment