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: [
|
children: [
|
||||||
imagePath,
|
imagePath,
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Text(name, style: Theme.of(context).textTheme.titleLarge),
|
Text(
|
||||||
|
name,
|
||||||
|
style: Theme.of(context).textTheme.titleLarge,
|
||||||
|
),
|
||||||
const SizedBox(height: 8),
|
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:flutter/material.dart';
|
||||||
import 'package:gymlink_module_web/components/app_bar.dart';
|
import 'package:gymlink_module_web/components/app_bar.dart';
|
||||||
import 'package:gymlink_module_web/components/heading.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 {
|
class HistoryPage extends StatelessWidget {
|
||||||
const HistoryPage({
|
const HistoryPage({
|
||||||
@@ -8,14 +42,39 @@ class HistoryPage extends StatelessWidget {
|
|||||||
});
|
});
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return const Scaffold(
|
return Scaffold(
|
||||||
appBar: GymLinkAppBar(),
|
appBar: const GymLinkAppBar(),
|
||||||
body: Column(mainAxisAlignment: MainAxisAlignment.start, children: [
|
body: Column(
|
||||||
GymLinkHeader(title: 'История заказов'),
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
Center(
|
children: [
|
||||||
child: Text('История заказов'),
|
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(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ dependencies:
|
|||||||
cupertino_icons: ^1.0.6
|
cupertino_icons: ^1.0.6
|
||||||
url_launcher: ^6.2.6
|
url_launcher: ^6.2.6
|
||||||
shared_preferences: ^2.2.3
|
shared_preferences: ^2.2.3
|
||||||
|
flutter_markdown: ^0.7.1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|||||||
Reference in New Issue
Block a user