-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding orders screen and order items widget for show list of user orders
- Loading branch information
1 parent
dca0982
commit 9bcbaa4
Showing
4 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:provider/provider.dart'; | ||
|
||
import '../providers/orders.dart'; | ||
import '../widgets/order_item.dart'; | ||
|
||
class OrdersScreen extends StatelessWidget { | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final orderData = Provider.of<Orders>(context , listen: false); | ||
return Scaffold( | ||
appBar: AppBar(title: Text('Your Orders')), | ||
body: ListView.builder( | ||
itemCount: orderData.orders.length, | ||
itemBuilder: (context, index) => OrderItem(orderData.orders[index]), | ||
), | ||
); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:intl/intl.dart'; | ||
|
||
import '../models/order_item.dart' as ord; | ||
|
||
class OrderItem extends StatelessWidget { | ||
final ord.OrderItem orders; | ||
|
||
const OrderItem(this.orders); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Card( | ||
margin: const EdgeInsets.all(10.0), | ||
child: Column( | ||
children: [ | ||
ListTile( | ||
title: Text('\$ ${orders.amount}'), | ||
subtitle: Text(DateFormat('dd mm yyyy').format(orders.dateTime!)), | ||
trailing: IconButton(onPressed: (){}, icon: Icon(Icons.expand_more)), | ||
) | ||
], | ||
), | ||
); | ||
} | ||
} |
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
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