Added order history cards
This commit is contained in:
79
lib/components/history_item_card.dart
Normal file
79
lib/components/history_item_card.dart
Normal file
@@ -0,0 +1,79 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_markdown/flutter_markdown.dart';
|
||||
|
||||
enum OrderStatus { created, inProgress, completed, canceled }
|
||||
|
||||
Map<OrderStatus, String> orderStatusMap = {
|
||||
OrderStatus.created: 'Создан',
|
||||
OrderStatus.inProgress: 'В обработке',
|
||||
OrderStatus.completed: 'Завершен',
|
||||
OrderStatus.canceled: 'Отменен',
|
||||
};
|
||||
|
||||
class HistoryItemCard extends StatelessWidget {
|
||||
final String id;
|
||||
final String cost;
|
||||
final String date;
|
||||
final Image image;
|
||||
final OrderStatus status;
|
||||
|
||||
const HistoryItemCard({
|
||||
super.key,
|
||||
required this.id,
|
||||
required this.cost,
|
||||
required this.date,
|
||||
required this.status,
|
||||
required this.image,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding:
|
||||
const EdgeInsetsDirectional.symmetric(horizontal: 10, vertical: 10),
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
minHeight: 100,
|
||||
maxHeight: 200,
|
||||
minWidth: 400,
|
||||
maxWidth: 600,
|
||||
),
|
||||
child: Card(
|
||||
elevation: 4,
|
||||
color: const Color(0xFFF2F3F9),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsetsDirectional.symmetric(horizontal: 20),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
image,
|
||||
const SizedBox(width: 20),
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
MarkdownBody(
|
||||
data: '### Заказ **№$id** от $date',
|
||||
),
|
||||
MarkdownBody(
|
||||
data: 'Статус: **${orderStatusMap[status]}**'),
|
||||
MarkdownBody(data: 'Сумма: **\$$cost**'),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -32,9 +32,15 @@ class ProductCard extends StatelessWidget {
|
||||
children: [
|
||||
imagePath,
|
||||
const SizedBox(height: 16),
|
||||
Text(name, style: Theme.of(context).textTheme.titleLarge),
|
||||
Text(
|
||||
name,
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text('\$$price', style: Theme.of(context).textTheme.titleSmall),
|
||||
Text(
|
||||
'\$$price',
|
||||
style: Theme.of(context).textTheme.titleSmall,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,6 +1,40 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gymlink_module_web/components/app_bar.dart';
|
||||
import 'package:gymlink_module_web/components/heading.dart';
|
||||
import 'package:gymlink_module_web/components/history_item_card.dart';
|
||||
|
||||
List<Map<String, String>> orders = [
|
||||
{
|
||||
"image": "product.png",
|
||||
"price": "120",
|
||||
"id": "34fa3126-bfaf-5dec-8f4a-b246c097ef73",
|
||||
"date": "11.09.2001"
|
||||
},
|
||||
{
|
||||
"image": "product.png",
|
||||
"price": "150",
|
||||
"id": "34a26e82-7656-5e98-a44a-c2d01d0b1ad1123",
|
||||
"date": "11.09.2001",
|
||||
},
|
||||
{
|
||||
"image": "product.png",
|
||||
"price": "250",
|
||||
"id": "4fb204b7-3f9e-52a2-bed1-415c00a31a37123",
|
||||
"date": "11.09.2001",
|
||||
},
|
||||
{
|
||||
"image": "product.png",
|
||||
"price": "300",
|
||||
"id": "09b2f5bb-683e-5c39-ae89-b8e152fa8bcf123",
|
||||
"date": "11.09.2001",
|
||||
},
|
||||
{
|
||||
"image": "product.png",
|
||||
"price": "100",
|
||||
"id": "cd1b6817-db94-5394-be1d-af88af79749f123",
|
||||
"date": "11.09.2001",
|
||||
}
|
||||
];
|
||||
|
||||
class HistoryPage extends StatelessWidget {
|
||||
const HistoryPage({
|
||||
@@ -8,14 +42,39 @@ class HistoryPage extends StatelessWidget {
|
||||
});
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Scaffold(
|
||||
appBar: GymLinkAppBar(),
|
||||
body: Column(mainAxisAlignment: MainAxisAlignment.start, children: [
|
||||
GymLinkHeader(title: 'История заказов'),
|
||||
Center(
|
||||
child: Text('История заказов'),
|
||||
)
|
||||
]),
|
||||
return Scaffold(
|
||||
appBar: const GymLinkAppBar(),
|
||||
body: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
const GymLinkHeader(title: 'История заказов'),
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: orders.length,
|
||||
itemBuilder: (context, index) {
|
||||
final item = orders[index];
|
||||
return HistoryItemCard(
|
||||
id: item['id']!,
|
||||
cost: item['price']!,
|
||||
date: item['date']!,
|
||||
image: Image.asset(
|
||||
item['image']!,
|
||||
width: 50,
|
||||
),
|
||||
status: OrderStatus.completed,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user