Enhancement: back button to main menu reload
This commit is contained in:
@@ -1,8 +1,11 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:gymlink_module_web/pages/main.dart';
|
||||||
|
import 'package:gymlink_module_web/tools/routes.dart';
|
||||||
|
|
||||||
class GymLinkHeader extends StatelessWidget {
|
class GymLinkHeader extends StatelessWidget {
|
||||||
final String title;
|
final String title;
|
||||||
const GymLinkHeader({super.key, required this.title});
|
final bool toMain;
|
||||||
|
const GymLinkHeader({super.key, required this.title, this.toMain = false});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -13,7 +16,13 @@ class GymLinkHeader extends StatelessWidget {
|
|||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () => Navigator.pop(context),
|
onPressed: () => toMain
|
||||||
|
? Navigator.pushAndRemoveUntil(
|
||||||
|
context,
|
||||||
|
CustomPageRoute(
|
||||||
|
builder: (context) => const MainPage()),
|
||||||
|
(route) => route.isFirst)
|
||||||
|
: Navigator.pop(context),
|
||||||
icon: const Icon(Icons.arrow_back)),
|
icon: const Icon(Icons.arrow_back)),
|
||||||
Text(title, style: Theme.of(context).textTheme.titleLarge),
|
Text(title, style: Theme.of(context).textTheme.titleLarge),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'package:gymlink_module_web/components/app_bar.dart';
|
|||||||
import 'package:gymlink_module_web/components/basket_item_card.dart';
|
import 'package:gymlink_module_web/components/basket_item_card.dart';
|
||||||
import 'package:gymlink_module_web/components/heading.dart';
|
import 'package:gymlink_module_web/components/heading.dart';
|
||||||
import 'package:gymlink_module_web/interfaces/items.dart';
|
import 'package:gymlink_module_web/interfaces/items.dart';
|
||||||
|
import 'package:gymlink_module_web/pages/main.dart';
|
||||||
import 'package:gymlink_module_web/pages/order_confirmation.dart';
|
import 'package:gymlink_module_web/pages/order_confirmation.dart';
|
||||||
import 'package:gymlink_module_web/providers/cart.dart';
|
import 'package:gymlink_module_web/providers/cart.dart';
|
||||||
import 'package:gymlink_module_web/tools/items.dart';
|
import 'package:gymlink_module_web/tools/items.dart';
|
||||||
@@ -244,7 +245,11 @@ class _BasketPageState extends State<BasketPage> {
|
|||||||
style: Theme.of(context).textTheme.bodyLarge),
|
style: Theme.of(context).textTheme.bodyLarge),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () => Navigator.pop(context, true),
|
onPressed: () => Navigator.pushAndRemoveUntil(
|
||||||
|
context,
|
||||||
|
CustomPageRoute(
|
||||||
|
builder: (_) => const MainPage()),
|
||||||
|
(route) => route.isFirst),
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: Theme.of(context).primaryColor,
|
backgroundColor: Theme.of(context).primaryColor,
|
||||||
shape: const RoundedRectangleBorder(
|
shape: const RoundedRectangleBorder(
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'dart:math';
|
|||||||
|
|
||||||
import 'package:carousel_slider/carousel_slider.dart';
|
import 'package:carousel_slider/carousel_slider.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_markdown/flutter_markdown.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/interfaces/items.dart';
|
import 'package:gymlink_module_web/interfaces/items.dart';
|
||||||
@@ -30,7 +31,7 @@ class _DetailPageState extends State<DetailPage> {
|
|||||||
bool isInCart = false;
|
bool isInCart = false;
|
||||||
int quantity = 0;
|
int quantity = 0;
|
||||||
GymItem? item;
|
GymItem? item;
|
||||||
String categoryName = '';
|
String? categoryName;
|
||||||
final CarouselController _carouselController = CarouselController();
|
final CarouselController _carouselController = CarouselController();
|
||||||
int _currentImage = 0;
|
int _currentImage = 0;
|
||||||
|
|
||||||
@@ -68,6 +69,7 @@ class _DetailPageState extends State<DetailPage> {
|
|||||||
});
|
});
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
getCategories(context).then((value) {
|
getCategories(context).then((value) {
|
||||||
|
setState(() {
|
||||||
categoryName = value
|
categoryName = value
|
||||||
.firstWhere(
|
.firstWhere(
|
||||||
(element) => element.id == (item!.categoryId),
|
(element) => element.id == (item!.categoryId),
|
||||||
@@ -75,6 +77,7 @@ class _DetailPageState extends State<DetailPage> {
|
|||||||
)
|
)
|
||||||
.name;
|
.name;
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -147,10 +150,12 @@ class _DetailPageState extends State<DetailPage> {
|
|||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.add),
|
icon: const Icon(Icons.add),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
|
if (item!.count > quantity) {
|
||||||
await addItemToCart(widget.id);
|
await addItemToCart(widget.id);
|
||||||
setState(() {
|
setState(() {
|
||||||
quantity++;
|
quantity++;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -260,14 +265,20 @@ class _DetailPageState extends State<DetailPage> {
|
|||||||
}).toList(),
|
}).toList(),
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
: Image.network(item!.images[0].url,
|
: Image.network(
|
||||||
width: min(
|
item!.images[0].url,
|
||||||
550, MediaQuery.sizeOf(context).width)),
|
height: 400,
|
||||||
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text(
|
child: Text(categoryName != null
|
||||||
'Категория: ${categoryName == "" ? "Без категории" : categoryName}'),
|
? 'Категория: ${categoryName == "" ? "Без категории" : categoryName}'
|
||||||
|
: ''),
|
||||||
|
)),
|
||||||
|
Center(
|
||||||
|
child: MarkdownBody(
|
||||||
|
data: '### Отстаток: _${item!.count}_',
|
||||||
)),
|
)),
|
||||||
item!.description != ''
|
item!.description != ''
|
||||||
? Padding(
|
? Padding(
|
||||||
|
|||||||
@@ -91,7 +91,10 @@ class _HistoryPageState extends State<HistoryPage> {
|
|||||||
body: Column(
|
body: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
const GymLinkHeader(title: 'История заказов'),
|
const GymLinkHeader(
|
||||||
|
title: 'История заказов',
|
||||||
|
toMain: true,
|
||||||
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
Reference in New Issue
Block a user