diff --git a/lib/presentation/pages/home_page.dart b/lib/presentation/pages/home_page.dart index 5078e59..f14abf2 100644 --- a/lib/presentation/pages/home_page.dart +++ b/lib/presentation/pages/home_page.dart @@ -34,17 +34,17 @@ class _HomePageState extends State { case ItemCategory.food: itemName = 'Food${random.nextInt(100)}'; imageUrl = - 'static/imgDatasets/food_for_cart/Image_${random.nextInt(5)}.jpg'; + 'static/imgDatasets/food_for_cart/Image_${random.nextInt(5)}.jpg'; break; case ItemCategory.clothing: itemName = 'Clothing${random.nextInt(100)}'; imageUrl = - 'static/imgDatasets/clothing_for_cart/clothing_${random.nextInt(5)}.jpg'; + 'static/imgDatasets/clothing_for_cart/clothing_${random.nextInt(5)}.jpg'; break; case ItemCategory.electronic: itemName = 'Electronic${random.nextInt(100)}'; imageUrl = - 'static/imgDatasets/electronic_for_cart/electronic_${random.nextInt(5)}.jpg'; + 'static/imgDatasets/electronic_for_cart/electronic_${random.nextInt(5)}.jpg'; break; } @@ -83,57 +83,61 @@ class _HomePageState extends State { itemCount: cart.items.length, itemBuilder: (context, index) { return Card( - margin: - const EdgeInsets.symmetric(vertical: 8, horizontal: 10), + margin: const EdgeInsets.symmetric(vertical: 8, horizontal: 10), elevation: 4, - child: ListTile( - contentPadding: const EdgeInsets.all(16.0), - leading: ClipRRect( - borderRadius: BorderRadius.circular(10.0), - child: Image.asset( - cart.items[index].imgUrl, - width: 80, - height: 80, - fit: BoxFit.cover, + child: SizedBox( + + child: ListTile( + contentPadding: EdgeInsets.zero, + leading: ClipRRect( + borderRadius: BorderRadius.circular(10.0), + child: SizedBox( + width: 80, + height: 120, + child: Image.asset( + cart.items[index].imgUrl, + fit: BoxFit.cover, + ), + ), ), - ), - title: Text( - cart.items[index].name, - style: const TextStyle(fontSize: 18), - ), - subtitle: Text( - cart.items[index].category.toString().split('.').last, - style: const TextStyle(color: Colors.grey), - ), - trailing: IconButton( - icon: Icon( - likedItems[index] - ? Icons.thumb_up - : Icons.thumb_up_off_alt, - color: likedItems[index] ? Colors.red : Colors.grey, + title: Text( + cart.items[index].name, + style: const TextStyle(fontSize: 18), ), - onPressed: () { - setState(() { - likedItems[index] = !likedItems[index]; - }); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text(likedItems[index] - ? 'Товар лайкнут!' - : 'Лайк убран!'), + subtitle: Text( + cart.items[index].category.toString().split('.').last, + style: const TextStyle(color: Colors.grey), + ), + trailing: IconButton( + icon: Icon( + likedItems[index] + ? Icons.thumb_up + : Icons.thumb_up_off_alt, + color: likedItems[index] ? Colors.red : Colors.grey, + ), + onPressed: () { + setState(() { + likedItems[index] = !likedItems[index]; + }); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text(likedItems[index] + ? 'Товар лайкнут!' + : 'Лайк убран!'), + ), + ); + }, + ), + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + DetailsPage(item: cart.items[index]), ), ); }, ), - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - DetailsPage(item: cart.items[index]), - ), - ); - }, ), ); },