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