Skip to content

Commit

Permalink
adding orders screen and order items widget for show list of user orders
Browse files Browse the repository at this point in the history
  • Loading branch information
amirhossein-jahangiri committed Aug 17, 2021
1 parent dca0982 commit 9bcbaa4
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/screens/orders_screen.dart
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]),
),
);
}
}
26 changes: 26 additions & 0 deletions lib/widgets/order_item.dart
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)),
)
],
),
);
}
}
7 changes: 7 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
intl:
dependency: "direct main"
description:
name: intl
url: "https://pub.dartlang.org"
source: hosted
version: "0.17.0"
matcher:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dependencies:
flutter:
sdk: flutter
provider: ^5.0.0
intl: ^0.17.0


# The following adds the Cupertino Icons font to your application.
Expand Down

0 comments on commit 9bcbaa4

Please sign in to comment.