Fix: category colors and count elements

This commit is contained in:
2024-06-04 23:13:21 +03:00
parent 15105a7f33
commit 0170505376
4 changed files with 24 additions and 18 deletions

View File

@@ -46,7 +46,7 @@ android {
// You can update the following values to match your application needs. // You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion 21 minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion targetSdkVersion 34
versionCode flutterVersionCode.toInteger() versionCode flutterVersionCode.toInteger()
versionName flutterVersionName versionName flutterVersionName
} }

View File

@@ -109,13 +109,16 @@ class _BasketPageState extends State<BasketPage> {
} }
void addItem(String id) async { void addItem(String id) async {
setState(() {
final item = final item =
cartItems.firstWhere((element) => element.id == id, orElse: () { cartItems.firstWhere((element) => element.id == id, orElse: () {
final cartItem = gymCart.firstWhere((element) => element.id == id); final cartItem = gymCart.firstWhere((element) => element.id == id);
cartItem.localCount = 0; cartItem.localCount = 0;
return cartItem; return cartItem;
}); });
if (item.localCount + 1 > item.count) {
return;
}
setState(() {
item.localCount++; item.localCount++;
cartItems[cartItems.indexOf(item)].localCount = item.localCount; cartItems[cartItems.indexOf(item)].localCount = item.localCount;
totalPrice = totalPrice =

View File

@@ -269,13 +269,19 @@ class _DetailPageState extends State<DetailPage> {
item!.images[0].url, item!.images[0].url,
height: 400, height: 400,
), ),
Padding( Center(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 10), padding: const EdgeInsets.symmetric(vertical: 10),
child: Center( child: Chip(
child: Text(categoryName != null label: Text(categoryName != null
? 'Категория: ${categoryName == "" ? "Без категории" : categoryName}' ? (categoryName == ""
? "Без категории"
: categoryName!)
: ''), : ''),
)), backgroundColor: Colors.white,
),
),
),
Center( Center(
child: MarkdownBody( child: MarkdownBody(
data: '### Отстаток: _${item!.count}_', data: '### Отстаток: _${item!.count}_',

View File

@@ -8,7 +8,6 @@ import 'package:gymlink_module_web/pages/basket.dart';
import 'package:gymlink_module_web/pages/detail.dart'; import 'package:gymlink_module_web/pages/detail.dart';
import 'package:gymlink_module_web/pages/order_history.dart'; import 'package:gymlink_module_web/pages/order_history.dart';
import 'package:gymlink_module_web/providers/cart.dart'; import 'package:gymlink_module_web/providers/cart.dart';
import 'package:gymlink_module_web/providers/main.dart';
import 'package:gymlink_module_web/tools/items.dart'; import 'package:gymlink_module_web/tools/items.dart';
import 'package:gymlink_module_web/tools/prefs.dart'; import 'package:gymlink_module_web/tools/prefs.dart';
import 'package:gymlink_module_web/tools/relative.dart'; import 'package:gymlink_module_web/tools/relative.dart';
@@ -148,6 +147,8 @@ class _MainPageState extends State<MainPage> {
_onSearch(); _onSearch();
} }
}), }),
textInputAction: TextInputAction.search,
onSubmitted: (_) => _onSearch(),
decoration: InputDecoration( decoration: InputDecoration(
hintText: 'Поиск', hintText: 'Поиск',
border: OutlineInputBorder( border: OutlineInputBorder(
@@ -231,12 +232,8 @@ class _MainPageState extends State<MainPage> {
horizontal: 10, vertical: 10), horizontal: 10, vertical: 10),
child: Chip( child: Chip(
label: Text(category.name), label: Text(category.name),
//FIXME: проблема с цветом
backgroundColor: selectedCategory == category backgroundColor: selectedCategory == category
? context ? Theme.of(context).primaryColor
.read<GymLinkProvider>()
.theme
.primaryColorLight
: Colors.white, : Colors.white,
labelStyle: TextStyle( labelStyle: TextStyle(
color: selectedCategory == category color: selectedCategory == category