Fix: some changes
This commit is contained in:
@@ -6,7 +6,7 @@ class BasketItemCard extends StatelessWidget {
|
|||||||
final String name;
|
final String name;
|
||||||
final String price;
|
final String price;
|
||||||
final String id;
|
final String id;
|
||||||
final Image image;
|
final Widget image;
|
||||||
final String quantity;
|
final String quantity;
|
||||||
final VoidCallback onTapPlus;
|
final VoidCallback onTapPlus;
|
||||||
final VoidCallback onTapMinus;
|
final VoidCallback onTapMinus;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class ProductCard extends StatelessWidget {
|
class ProductCard extends StatelessWidget {
|
||||||
final Image imagePath;
|
final Widget imagePath;
|
||||||
final String name;
|
final String name;
|
||||||
final String price;
|
final String price;
|
||||||
final VoidCallback onTap;
|
final VoidCallback onTap;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ class OrderConfirmItemCard extends StatelessWidget {
|
|||||||
final String name;
|
final String name;
|
||||||
final int count;
|
final int count;
|
||||||
final double price;
|
final double price;
|
||||||
final Image image;
|
final Widget image;
|
||||||
|
|
||||||
const OrderConfirmItemCard({
|
const OrderConfirmItemCard({
|
||||||
super.key,
|
super.key,
|
||||||
|
|||||||
@@ -283,9 +283,22 @@ class _BasketPageState extends State<BasketPage> {
|
|||||||
name: shortString(item.title),
|
name: shortString(item.title),
|
||||||
price: item.price.toStringAsFixed(2),
|
price: item.price.toStringAsFixed(2),
|
||||||
id: item.id,
|
id: item.id,
|
||||||
image: Image(
|
image: FutureBuilder(
|
||||||
image: NetworkImage(item.images[0].url),
|
future: precacheImage(
|
||||||
width: 50,
|
NetworkImage(item.images[0].url),
|
||||||
|
context),
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
if (snapshot.connectionState ==
|
||||||
|
ConnectionState.done) {
|
||||||
|
return Image(
|
||||||
|
image: NetworkImage(
|
||||||
|
item.images[0].url),
|
||||||
|
width: 50,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return const CircularProgressIndicator();
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
onTapPlus: () =>
|
onTapPlus: () =>
|
||||||
addItem(item.id.toString()),
|
addItem(item.id.toString()),
|
||||||
|
|||||||
@@ -111,7 +111,6 @@ class _MainPageState extends State<MainPage> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
filteredData = data;
|
filteredData = data;
|
||||||
itemViewCount = min(filteredData.length, 5);
|
itemViewCount = min(filteredData.length, 5);
|
||||||
debugPrint(itemViewCount.toString());
|
|
||||||
});
|
});
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
for (var element in filteredData.sublist(0, itemViewCount)) {
|
for (var element in filteredData.sublist(0, itemViewCount)) {
|
||||||
@@ -281,11 +280,22 @@ class _MainPageState extends State<MainPage> {
|
|||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final product = filteredData[index];
|
final product = filteredData[index];
|
||||||
return ProductCard(
|
return ProductCard(
|
||||||
imagePath: Image(
|
imagePath: FutureBuilder(
|
||||||
image:
|
future: precacheImage(
|
||||||
Image.network(product.images[0].url)
|
NetworkImage(product.images[0].url),
|
||||||
.image,
|
context),
|
||||||
width: 120,
|
builder: (context, snapshot) {
|
||||||
|
if (snapshot.connectionState ==
|
||||||
|
ConnectionState.done) {
|
||||||
|
return Image(
|
||||||
|
image: NetworkImage(
|
||||||
|
product.images[0].url),
|
||||||
|
width: 120,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return const CircularProgressIndicator();
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
name: shortString(product.title),
|
name: shortString(product.title),
|
||||||
price: product.price.toStringAsFixed(2),
|
price: product.price.toStringAsFixed(2),
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ class _OrderConfirmationPageState extends State<OrderConfirmationPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _goToPage() async {
|
Future<void> _goToPage() async {
|
||||||
final Uri url = Uri.parse('https://google.com');
|
final Uri url = Uri.parse('https://example.org');
|
||||||
if (!await launchUrl(url, webOnlyWindowName: '_blank')) {
|
if (!await launchUrl(url, webOnlyWindowName: '_blank')) {
|
||||||
throw 'Could not launch $url';
|
throw 'Could not launch $url';
|
||||||
}
|
}
|
||||||
@@ -115,10 +115,22 @@ class _OrderConfirmationPageState extends State<OrderConfirmationPage> {
|
|||||||
final item = cartItems[index];
|
final item = cartItems[index];
|
||||||
return OrderConfirmItemCard(
|
return OrderConfirmItemCard(
|
||||||
name: shortString(item.title),
|
name: shortString(item.title),
|
||||||
image: Image(
|
image: FutureBuilder(
|
||||||
image: NetworkImage(item.images[0].url),
|
future: precacheImage(
|
||||||
width: 50,
|
NetworkImage(item.images[0].url), context),
|
||||||
height: 50),
|
builder: (context, snapshot) {
|
||||||
|
if (snapshot.connectionState ==
|
||||||
|
ConnectionState.done) {
|
||||||
|
return Image(
|
||||||
|
image: NetworkImage(item.images[0].url),
|
||||||
|
width: 50,
|
||||||
|
height: 50,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return const CircularProgressIndicator();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
price: item.price,
|
price: item.price,
|
||||||
count: item.localCount,
|
count: item.localCount,
|
||||||
);
|
);
|
||||||
@@ -165,15 +177,6 @@ class _OrderConfirmationPageState extends State<OrderConfirmationPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
CheckboxListTile(
|
|
||||||
title: const Text('Согласен с обаботкой персональных данных'),
|
|
||||||
value: isAgree,
|
|
||||||
onChanged: (value) {
|
|
||||||
setState(() {
|
|
||||||
isAgree = value!;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
_goToPage();
|
_goToPage();
|
||||||
|
|||||||
Reference in New Issue
Block a user