From 20a95e49963dc3ce03dfe0377769d5e444dd1651 Mon Sep 17 00:00:00 2001 From: sinasystem Date: Wed, 29 Jun 2022 02:46:49 +0430 Subject: [PATCH] Some improvement --- .github/workflows/main.yml | 2 +- lib/src/view/screen/cart_screen.dart | 22 ++++++++----------- lib/src/view/screen/home_screen.dart | 17 +++++--------- .../office_furniture_detail_screen.dart | 3 +-- .../screen/office_furniture_list_screen.dart | 2 +- lib/src/view/widget/cart_list_view.dart | 12 +++++----- 6 files changed, 24 insertions(+), 34 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c11c98b..3129a5c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,5 +23,5 @@ jobs: uses: ncipollo/release-action@v1 with: artifacts: "build/app/outputs/apk/release/app-release.apk" - tag: v2.0.2 + tag: v2.0.3 token: ${{ secrets.TOKEN }} \ No newline at end of file diff --git a/lib/src/view/screen/cart_screen.dart b/lib/src/view/screen/cart_screen.dart index 161860a..f8fd5bd 100644 --- a/lib/src/view/screen/cart_screen.dart +++ b/lib/src/view/screen/cart_screen.dart @@ -36,7 +36,7 @@ class CartScreen extends StatelessWidget { () { return BottomBar( priceLabel: "Total price", - priceValue: "\$${controller.totalPrice.value}", + priceValue: "\$${controller.totalPrice.value.toStringAsFixed(2)}", buttonLabel: "Checkout", onTap: controller.totalPrice > 0 ? () {} : null, ); @@ -47,18 +47,14 @@ class CartScreen extends StatelessWidget { return controller.cartFurniture.isNotEmpty ? Padding( padding: const EdgeInsets.all(15), - child: CartListView(counterButton: (furniture) { - return GetBuilder( - builder: (OfficeFurnitureController controller) { - return CounterButton( - orientation: Axis.vertical, - onIncrementSelected: () => - controller.increaseItem(furniture), - onDecrementSelected: () => - controller.decreaseItem(furniture), - label: furniture.quantity); - }, - ); + child: CartListView(furnitureItems: controller.cartFurniture,counterButton: (furniture) { + return CounterButton( + orientation: Axis.vertical, + onIncrementSelected: () => + controller.increaseItem(furniture), + onDecrementSelected: () => + controller.decreaseItem(furniture), + label: furniture.quantity); }), ) : const EmptyWidget(title: "Empty"); diff --git a/lib/src/view/screen/home_screen.dart b/lib/src/view/screen/home_screen.dart index 9bd8ee2..c145d84 100644 --- a/lib/src/view/screen/home_screen.dart +++ b/lib/src/view/screen/home_screen.dart @@ -11,17 +11,10 @@ import '../../controller/office_furniture_controller.dart'; final OfficeFurnitureController controller = Get.put(OfficeFurnitureController()); -class HomeScreen extends StatefulWidget { +class HomeScreen extends StatelessWidget { const HomeScreen({Key? key}) : super(key: key); - @override - State createState() => _HomeScreenState(); -} - -class _HomeScreenState extends State { - int selectedIndex = 0; - - List screens = const [ + final List screens = const [ OfficeFurnitureListScreen(), CartScreen(), FavoriteScreen(), @@ -32,7 +25,7 @@ class _HomeScreenState extends State { Widget build(BuildContext context) { return Scaffold( bottomNavigationBar: Obx( - () { + () { return BottomNavigationBar( unselectedItemColor: Colors.grey, currentIndex: controller.currentBottomNavItemIndex.value, @@ -42,8 +35,8 @@ class _HomeScreenState extends State { items: AppData.bottomNavigationItems .map( (element) => BottomNavigationBarItem( - icon: element.icon, label: element.label), - ) + icon: element.icon, label: element.label), + ) .toList(), ); }, diff --git a/lib/src/view/screen/office_furniture_detail_screen.dart b/lib/src/view/screen/office_furniture_detail_screen.dart index efa9ae2..a15eeb9 100644 --- a/lib/src/view/screen/office_furniture_detail_screen.dart +++ b/lib/src/view/screen/office_furniture_detail_screen.dart @@ -15,9 +15,8 @@ import 'home_screen.dart'; class OfficeFurnitureDetailScreen extends StatelessWidget { final Furniture furniture; - final int index; - const OfficeFurnitureDetailScreen({Key? key, required this.furniture,required this.index}) + const OfficeFurnitureDetailScreen({Key? key, required this.furniture}) : super(key: key); PreferredSizeWidget _appBar(BuildContext context) { diff --git a/lib/src/view/screen/office_furniture_list_screen.dart b/lib/src/view/screen/office_furniture_list_screen.dart index 053e0f2..6c0acfe 100644 --- a/lib/src/view/screen/office_furniture_list_screen.dart +++ b/lib/src/view/screen/office_furniture_list_screen.dart @@ -58,7 +58,7 @@ class OfficeFurnitureListScreen extends StatelessWidget { PageRouteBuilder( transitionDuration: const Duration(seconds: 1), pageBuilder: (_, __, ___) => - OfficeFurnitureDetailScreen(furniture: furniture, index: index), + OfficeFurnitureDetailScreen(furniture: furniture), ), ); } diff --git a/lib/src/view/widget/cart_list_view.dart b/lib/src/view/widget/cart_list_view.dart index dc5c130..74fa57d 100644 --- a/lib/src/view/widget/cart_list_view.dart +++ b/lib/src/view/widget/cart_list_view.dart @@ -2,19 +2,21 @@ import 'package:flutter/material.dart'; import 'package:office_furniture_store/core/app_extension.dart'; import 'package:office_furniture_store/core/app_style.dart'; import '../../model/furniture.dart'; -import '../screen/home_screen.dart'; class CartListView extends StatelessWidget { - const CartListView({Key? key,required this.counterButton}) : super(key: key); + const CartListView( + {Key? key, required this.counterButton, required this.furnitureItems}) + : super(key: key); final Widget Function(Furniture furniture) counterButton; + final List furnitureItems; @override Widget build(BuildContext context) { return ListView.separated( - itemCount: controller.cartFurniture.length, + itemCount: furnitureItems.length, itemBuilder: (_, index) { - Furniture furniture = controller.cartFurniture[index]; + Furniture furniture = furnitureItems[index]; return Padding( padding: const EdgeInsets.all(15), child: Row( @@ -58,7 +60,7 @@ class CartListView extends StatelessWidget { // Spacer(), counterButton(furniture) ], - ).fadeAnimation(0.4*index), + ).fadeAnimation(0.4 * index), ); }, separatorBuilder: (BuildContext context, int index) {