From adc32e730d9dcd16cfd38cc9a89dc8d31b912813 Mon Sep 17 00:00:00 2001 From: Anthony Date: Sun, 28 May 2023 22:36:39 +0100 Subject: [PATCH] v6.6.1 updates --- LabelStoreMax/CHANGELOG.md | 6 + LabelStoreMax/README.md | 2 +- ...uct_category_search_loader_controller.dart | 2 +- .../product_detail_controller.dart | 2 +- .../product_loader_controller.dart | 2 +- .../product_reviews_loader_controller.dart | 2 +- .../product_search_loader_controller.dart | 2 +- .../lib/app/models/cart_line_item.dart | 2 +- .../app/providers/payments/razorpay_pay.dart | 81 ++++++ LabelStoreMax/lib/bootstrap/extensions.dart | 127 +-------- LabelStoreMax/lib/bootstrap/helpers.dart | 2 +- .../lib/config/payment_gateways.dart | 9 + .../lib/config/validation_rules.dart | 1 - .../resources/pages/browse_category_page.dart | 2 +- .../resources/pages/browse_search_page.dart | 2 +- .../lib/resources/pages/cart_page.dart | 116 ++++---- .../pages/checkout_confirmation_page.dart | 3 +- .../resources/pages/checkout_status_page.dart | 6 +- .../resources/pages/product_detail_page.dart | 66 +++-- .../resources/pages/product_reviews_page.dart | 2 +- .../resources/pages/wishlist_page_widget.dart | 182 ++++++------- .../resources/widgets/compo_home_widget.dart | 2 +- .../resources/widgets/mello_theme_widget.dart | 42 ++- .../resources/widgets/notic_home_widget.dart | 195 +++++++------- .../widgets/product_detail_body_widget.dart | 2 +- .../product_detail_description_widget.dart | 2 +- .../product_detail_footer_actions_widget.dart | 2 +- .../widgets/product_detail_header_widget.dart | 2 +- .../product_detail_image_swiper_widget.dart | 2 +- ...roduct_detail_related_products_widget.dart | 12 +- .../product_detail_reviews_widget.dart | 2 +- .../widgets/product_detail_upsell_widget.dart | 2 +- .../lib/resources/widgets/woosignal_ui.dart | 248 +++++++++--------- LabelStoreMax/pubspec.lock | 62 +++-- LabelStoreMax/pubspec.yaml | 16 +- README.md | 2 +- 36 files changed, 574 insertions(+), 638 deletions(-) create mode 100644 LabelStoreMax/lib/app/providers/payments/razorpay_pay.dart diff --git a/LabelStoreMax/CHANGELOG.md b/LabelStoreMax/CHANGELOG.md index 30c967e..4ff7eaa 100644 --- a/LabelStoreMax/CHANGELOG.md +++ b/LabelStoreMax/CHANGELOG.md @@ -1,3 +1,9 @@ +## [6.6.1] - 2023-05-28 + +* Refactor widgets + bug fixes +* Refactor extensions.dart +* Pubspec.yaml dependency updates. + ## [6.6.0] - 2023-05-18 * Nylo v5.0.0 migration diff --git a/LabelStoreMax/README.md b/LabelStoreMax/README.md index e7aa170..1f7c2fe 100644 --- a/LabelStoreMax/README.md +++ b/LabelStoreMax/README.md @@ -4,7 +4,7 @@ # WooCommerce App: Label StoreMax -### Label StoreMax - v6.6.0 +### Label StoreMax - v6.6.1 [Official WooSignal WooCommerce App](https://woosignal.com) diff --git a/LabelStoreMax/lib/app/controllers/product_category_search_loader_controller.dart b/LabelStoreMax/lib/app/controllers/product_category_search_loader_controller.dart index 55accd6..0b4c359 100644 --- a/LabelStoreMax/lib/app/controllers/product_category_search_loader_controller.dart +++ b/LabelStoreMax/lib/app/controllers/product_category_search_loader_controller.dart @@ -10,7 +10,7 @@ import 'package:flutter_app/app/controllers/woosignal_api_loader_controller.dart'; import 'package:woosignal/models/response/product_category.dart'; -import 'package:woosignal/models/response/products.dart'; +import 'package:woosignal/models/response/product.dart'; class ProductCategorySearchLoaderController extends WooSignalApiLoaderController { diff --git a/LabelStoreMax/lib/app/controllers/product_detail_controller.dart b/LabelStoreMax/lib/app/controllers/product_detail_controller.dart index f3ca298..243e538 100644 --- a/LabelStoreMax/lib/app/controllers/product_detail_controller.dart +++ b/LabelStoreMax/lib/app/controllers/product_detail_controller.dart @@ -14,7 +14,7 @@ import 'package:flutter_app/app/models/cart_line_item.dart'; import 'package:flutter_app/bootstrap/enums/wishlist_action_enums.dart'; import 'package:flutter_app/bootstrap/helpers.dart'; import 'package:nylo_framework/nylo_framework.dart'; -import 'package:woosignal/models/response/products.dart'; +import 'package:woosignal/models/response/product.dart'; import 'package:woosignal/models/response/product_variation.dart' as ws_product_variation; diff --git a/LabelStoreMax/lib/app/controllers/product_loader_controller.dart b/LabelStoreMax/lib/app/controllers/product_loader_controller.dart index b9fa13b..4ac74ac 100644 --- a/LabelStoreMax/lib/app/controllers/product_loader_controller.dart +++ b/LabelStoreMax/lib/app/controllers/product_loader_controller.dart @@ -9,7 +9,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. import 'package:flutter_app/app/controllers/woosignal_api_loader_controller.dart'; -import 'package:woosignal/models/response/products.dart'; +import 'package:woosignal/models/response/product.dart'; class ProductLoaderController extends WooSignalApiLoaderController { ProductLoaderController(); diff --git a/LabelStoreMax/lib/app/controllers/product_reviews_loader_controller.dart b/LabelStoreMax/lib/app/controllers/product_reviews_loader_controller.dart index b35a0ae..fcbf593 100644 --- a/LabelStoreMax/lib/app/controllers/product_reviews_loader_controller.dart +++ b/LabelStoreMax/lib/app/controllers/product_reviews_loader_controller.dart @@ -10,7 +10,7 @@ import 'package:flutter_app/app/controllers/woosignal_api_loader_controller.dart'; import 'package:woosignal/models/response/product_review.dart'; -import 'package:woosignal/models/response/products.dart'; +import 'package:woosignal/models/response/product.dart'; class ProductReviewsLoaderController extends WooSignalApiLoaderController { diff --git a/LabelStoreMax/lib/app/controllers/product_search_loader_controller.dart b/LabelStoreMax/lib/app/controllers/product_search_loader_controller.dart index 558c300..52710b0 100644 --- a/LabelStoreMax/lib/app/controllers/product_search_loader_controller.dart +++ b/LabelStoreMax/lib/app/controllers/product_search_loader_controller.dart @@ -9,7 +9,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. import 'package:flutter_app/app/controllers/woosignal_api_loader_controller.dart'; -import 'package:woosignal/models/response/products.dart'; +import 'package:woosignal/models/response/product.dart'; class ProductSearchLoaderController extends WooSignalApiLoaderController { diff --git a/LabelStoreMax/lib/app/models/cart_line_item.dart b/LabelStoreMax/lib/app/models/cart_line_item.dart index 6974848..c670fd0 100644 --- a/LabelStoreMax/lib/app/models/cart_line_item.dart +++ b/LabelStoreMax/lib/app/models/cart_line_item.dart @@ -11,7 +11,7 @@ import 'package:flutter_app/bootstrap/helpers.dart'; import 'package:nylo_framework/nylo_framework.dart'; import 'package:woosignal/models/response/product_variation.dart'; -import 'package:woosignal/models/response/products.dart' as ws_product; +import 'package:woosignal/models/response/product.dart' as ws_product; class CartLineItem { String? name; diff --git a/LabelStoreMax/lib/app/providers/payments/razorpay_pay.dart b/LabelStoreMax/lib/app/providers/payments/razorpay_pay.dart new file mode 100644 index 0000000..37b922b --- /dev/null +++ b/LabelStoreMax/lib/app/providers/payments/razorpay_pay.dart @@ -0,0 +1,81 @@ +// +// LabelCore +// Label StoreMAX +// +// Created by Anthony Gordon. +// 2023, WooSignal Ltd. All rights reserved. +// + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// + +import 'package:flutter/widgets.dart'; +import 'package:flutter_app/app/models/cart.dart'; +import 'package:flutter_app/bootstrap/data/order_wc.dart'; +import 'package:flutter_app/bootstrap/helpers.dart'; +import 'package:flutter_app/resources/pages/checkout_confirmation_page.dart'; +import 'package:nylo_framework/nylo_framework.dart'; +import 'package:razorpay_flutter/razorpay_flutter.dart'; +import 'package:woosignal/models/response/tax_rate.dart'; +import 'package:woosignal/models/payload/order_wc.dart'; +import 'package:woosignal/models/response/order.dart'; + +razorPay(context, + {required CheckoutConfirmationPageState state, TaxRate? taxRate}) async { + Razorpay razorpay = Razorpay(); + + razorpay.on(Razorpay.EVENT_PAYMENT_SUCCESS, + (PaymentSuccessResponse response) async { + OrderWC orderWC = await buildOrderWC(taxRate: taxRate); + + Order? order = await appWooSignal((api) => api.createOrder(orderWC)); + + if (order != null) { + Cart.getInstance.clear(); + Navigator.pushNamed(context, "/checkout-status", arguments: order); + } else { + showToastNotification( + context, + title: "Error".tr(), + description: trans("Something went wrong, please contact our store"), + ); + state.reloadState(showLoader: false); + } + }); + + razorpay.on(Razorpay.EVENT_PAYMENT_ERROR, (PaymentFailureResponse response) { + showToastNotification(context, + title: trans("Error"), + description: response.message ?? "", + style: ToastNotificationStyleType.WARNING); + state.reloadState(showLoader: false); + }); + + razorpay.on(Razorpay.EVENT_EXTERNAL_WALLET, _handleExternalWallet); + + // CHECKOUT HELPER + await checkout(taxRate, (total, billingDetails, cart) async { + var options = { + 'key': getEnv('RAZORPAY_API_KEY'), + 'amount': (double.parse(total) * 100).toInt(), + 'name': getEnv('APP_NAME'), + 'description': await cart.cartShortDesc(), + 'prefill': { + "name": [ + billingDetails!.billingAddress?.firstName, + billingDetails.billingAddress?.lastName + ].where((t) => t != null || t != "").toList().join(" "), + "method": "card", + 'email': billingDetails.billingAddress?.emailAddress ?? "" + } + }; + + state.reloadState(showLoader: true); + + razorpay.open(options); + }); +} + +void _handleExternalWallet(ExternalWalletResponse response) {} \ No newline at end of file diff --git a/LabelStoreMax/lib/bootstrap/extensions.dart b/LabelStoreMax/lib/bootstrap/extensions.dart index 3743b72..7ac6ef5 100644 --- a/LabelStoreMax/lib/bootstrap/extensions.dart +++ b/LabelStoreMax/lib/bootstrap/extensions.dart @@ -1,81 +1,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_app/bootstrap/helpers.dart'; import 'package:flutter_app/resources/themes/styles/color_styles.dart'; +import 'package:nylo_framework/nylo_framework.dart'; extension NyText on Text { - /// Set the Style to use [displayLarge]. - Text displayLarge(BuildContext context) { - return setStyle(Theme.of(context).textTheme.displayLarge); - } - - /// Set the Style to use [displayMedium]. - Text displayMedium(BuildContext context) { - return setStyle(Theme.of(context).textTheme.displayMedium); - } - - /// Set the Style to use [displaySmall]. - Text displaySmall(BuildContext context) { - return setStyle(Theme.of(context).textTheme.displaySmall); - } - - /// Set the Style to use [headlineLarge]. - Text headingLarge(BuildContext context) { - return setStyle(Theme.of(context).textTheme.headlineLarge); - } - - /// Set the Style to use [headlineMedium]. - Text headingMedium(BuildContext context) { - return setStyle(Theme.of(context).textTheme.headlineMedium); - } - - /// Set the Style to use [headlineSmall]. - Text headingSmall(BuildContext context) { - return setStyle(Theme.of(context).textTheme.headlineSmall); - } - - /// Set the Style to use [titleLarge]. - Text titleLarge(BuildContext context) { - return setStyle(Theme.of(context).textTheme.titleLarge); - } - - /// Set the Style to use [titleMedium]. - Text titleMedium(BuildContext context) { - return setStyle(Theme.of(context).textTheme.titleMedium); - } - - /// Set the Style to use [titleSmall]. - Text titleSmall(BuildContext context) { - return setStyle(Theme.of(context).textTheme.titleSmall); - } - - /// Set the Style to use [bodyLarge]. - Text large(BuildContext context) { - return setStyle(Theme.of(context).textTheme.bodyLarge); - } - - /// Set the Style to use [bodyMedium]. - Text medium(BuildContext context) { - return setStyle(Theme.of(context).textTheme.bodyMedium); - } - - /// Set the Style to use [bodySmall]. - Text small(BuildContext context) { - return setStyle(Theme.of(context).textTheme.bodySmall); - } - - /// Make the font bold. - Text fontWeightBold() { - return copyWith(style: TextStyle(fontWeight: FontWeight.bold)); - } - - /// Make the font light. - Text fontWeightLight() { - return copyWith(style: TextStyle(fontWeight: FontWeight.w300)); - } - - /// Change the [style]. - Text setStyle(TextStyle? style) => copyWith(style: style); - /// Sets the color from your [ColorStyles] or [Color]. Text setColor( BuildContext context, Color Function(ColorStyles color) newColor, @@ -84,59 +12,6 @@ extension NyText on Text { style: TextStyle( color: newColor(ThemeColor.get(context, themeId: themeId)))); } - - /// Aligns text to the left. - Text alignLeft() { - return copyWith(textAlign: TextAlign.left); - } - - /// Aligns text to the right. - Text alignRight() { - return copyWith(textAlign: TextAlign.right); - } - - /// Aligns text to the center. - Text alignCenter() { - return copyWith(textAlign: TextAlign.center); - } - - /// Aligns text to the center. - Text setMaxLines(int maxLines) { - return copyWith(maxLines: maxLines); - } - - /// Change the [fontFamily]. - Text setFontFamily(String fontFamily) => - copyWith(style: TextStyle(fontFamily: fontFamily)); - - /// Helper to apply changes. - Text copyWith( - {Key? key, - StrutStyle? strutStyle, - TextAlign? textAlign, - TextDirection? textDirection = TextDirection.ltr, - Locale? locale, - bool? softWrap, - TextOverflow? overflow, - double? textScaleFactor, - int? maxLines, - String? semanticsLabel, - TextWidthBasis? textWidthBasis, - TextStyle? style}) { - return Text(data ?? "", - key: key ?? this.key, - strutStyle: strutStyle ?? this.strutStyle, - textAlign: textAlign ?? this.textAlign, - textDirection: textDirection ?? this.textDirection, - locale: locale ?? this.locale, - softWrap: softWrap ?? this.softWrap, - overflow: overflow ?? this.overflow, - textScaleFactor: textScaleFactor ?? this.textScaleFactor, - maxLines: maxLines ?? this.maxLines, - semanticsLabel: semanticsLabel ?? this.semanticsLabel, - textWidthBasis: textWidthBasis ?? this.textWidthBasis, - style: style != null ? this.style?.merge(style) ?? style : this.style); - } } /// Check if the [Product] is new. diff --git a/LabelStoreMax/lib/bootstrap/helpers.dart b/LabelStoreMax/lib/bootstrap/helpers.dart index 8a13c36..98f4a17 100644 --- a/LabelStoreMax/lib/bootstrap/helpers.dart +++ b/LabelStoreMax/lib/bootstrap/helpers.dart @@ -38,7 +38,7 @@ import 'package:money_formatter/money_formatter.dart'; import 'package:nylo_framework/nylo_framework.dart'; import 'package:pull_to_refresh_flutter3/pull_to_refresh_flutter3.dart'; import 'package:status_alert/status_alert.dart'; -import 'package:woosignal/models/response/products.dart'; +import 'package:woosignal/models/response/product.dart'; import 'package:woosignal/models/response/tax_rate.dart'; import 'package:woosignal/woosignal.dart'; import 'package:wp_json_api/models/responses/wp_user_info_response.dart'; diff --git a/LabelStoreMax/lib/config/payment_gateways.dart b/LabelStoreMax/lib/config/payment_gateways.dart index 92cc633..661ffde 100644 --- a/LabelStoreMax/lib/config/payment_gateways.dart +++ b/LabelStoreMax/lib/config/payment_gateways.dart @@ -1,6 +1,7 @@ import 'package:flutter_app/app/models/payment_type.dart'; import 'package:flutter_app/app/providers/payments/cash_on_delivery.dart'; import 'package:flutter_app/app/providers/payments/paypal_pay.dart'; +import 'package:flutter_app/app/providers/payments/razorpay_pay.dart'; import 'package:flutter_app/app/providers/payments/stripe_pay.dart'; import 'package:flutter_app/bootstrap/helpers.dart'; import 'package:nylo_framework/nylo_framework.dart'; @@ -43,6 +44,14 @@ List paymentTypeList = [ pay: payPalPay, ), + addPayment( + id: 5, + name: "RazorPay", + description: trans("Debit or Credit Card"), + assetImage: "razorpay.png", + pay: razorPay, + ), + // e.g. add more here // addPayment( diff --git a/LabelStoreMax/lib/config/validation_rules.dart b/LabelStoreMax/lib/config/validation_rules.dart index 88dc4fa..d06f707 100644 --- a/LabelStoreMax/lib/config/validation_rules.dart +++ b/LabelStoreMax/lib/config/validation_rules.dart @@ -1,4 +1,3 @@ -import 'package:nylo_framework/nylo_framework.dart'; /* |-------------------------------------------------------------------------- diff --git a/LabelStoreMax/lib/resources/pages/browse_category_page.dart b/LabelStoreMax/lib/resources/pages/browse_category_page.dart index 4f7789a..7edf545 100644 --- a/LabelStoreMax/lib/resources/pages/browse_category_page.dart +++ b/LabelStoreMax/lib/resources/pages/browse_category_page.dart @@ -20,7 +20,7 @@ import 'package:flutter_app/resources/widgets/woosignal_ui.dart'; import 'package:nylo_framework/nylo_framework.dart'; import 'package:pull_to_refresh_flutter3/pull_to_refresh_flutter3.dart'; import 'package:woosignal/models/response/product_category.dart'; -import 'package:woosignal/models/response/products.dart' as ws_product; +import 'package:woosignal/models/response/product.dart' as ws_product; class BrowseCategoryPage extends NyStatefulWidget { final BrowseCategoryController controller = BrowseCategoryController(); diff --git a/LabelStoreMax/lib/resources/pages/browse_search_page.dart b/LabelStoreMax/lib/resources/pages/browse_search_page.dart index 8201fcf..91488b6 100644 --- a/LabelStoreMax/lib/resources/pages/browse_search_page.dart +++ b/LabelStoreMax/lib/resources/pages/browse_search_page.dart @@ -16,7 +16,7 @@ import 'package:flutter_app/resources/widgets/app_loader_widget.dart'; import 'package:flutter_app/resources/widgets/safearea_widget.dart'; import 'package:nylo_framework/nylo_framework.dart'; import 'package:pull_to_refresh_flutter3/pull_to_refresh_flutter3.dart'; -import 'package:woosignal/models/response/products.dart' as ws_product; +import 'package:woosignal/models/response/product.dart' as ws_product; class BrowseSearchPage extends NyStatefulWidget { final BrowseSearchController controller = BrowseSearchController(); diff --git a/LabelStoreMax/lib/resources/pages/cart_page.dart b/LabelStoreMax/lib/resources/pages/cart_page.dart index 44ca588..c020566 100644 --- a/LabelStoreMax/lib/resources/pages/cart_page.dart +++ b/LabelStoreMax/lib/resources/pages/cart_page.dart @@ -16,7 +16,6 @@ import 'package:flutter_app/app/models/customer_address.dart'; import 'package:flutter_app/bootstrap/app_helper.dart'; import 'package:flutter_app/bootstrap/helpers.dart'; import 'package:flutter_app/bootstrap/shared_pref/sp_auth.dart'; -import 'package:flutter_app/resources/widgets/app_loader_widget.dart'; import 'package:flutter_app/resources/widgets/buttons.dart'; import 'package:flutter_app/resources/widgets/safearea_widget.dart'; import 'package:flutter_app/resources/widgets/text_row_widget.dart'; @@ -30,26 +29,19 @@ class CartPage extends StatefulWidget { _CartPageState createState() => _CartPageState(); } -class _CartPageState extends State { +class _CartPageState extends NyState { _CartPageState(); - bool _isLoading = true, _isCartEmpty = false; List _cartLines = []; - @override - void initState() { - super.initState(); - _cartCheck(); + boot() async { + await _cartCheck(); CheckoutSession.getInstance.coupon = null; } _cartCheck() async { List cart = await Cart.getInstance.getCart(); if (cart.isEmpty) { - setState(() { - _isLoading = false; - _isCartEmpty = true; - }); return; } @@ -59,25 +51,18 @@ class _CartPageState extends State { await (appWooSignal((api) => api.cartCheck(cartJSON))); if (cartRes.isEmpty) { Cart.getInstance.saveCartToPref(cartLineItems: []); - setState(() { - _isCartEmpty = true; - _isLoading = false; - }); return; } _cartLines = cartRes.map((json) => CartLineItem.fromJson(json)).toList(); if (_cartLines.isNotEmpty) { Cart.getInstance.saveCartToPref(cartLineItems: _cartLines); } - setState(() { - _isLoading = false; - }); } void _actionProceedToCheckout() async { List cartLineItems = await Cart.getInstance.getCart(); - if (_isLoading == true) { + if (isLoading()) { return; } @@ -163,9 +148,6 @@ class _CartPageState extends State { style: ToastNotificationStyleType.WARNING, icon: Icons.remove_shopping_cart, ); - if (_cartLines.isEmpty) { - _isCartEmpty = true; - } setState(() {}); } @@ -177,7 +159,6 @@ class _CartPageState extends State { description: trans("Cart cleared"), style: ToastNotificationStyleType.SUCCESS, icon: Icons.delete_outline); - _isCartEmpty = true; setState(() {}); } @@ -214,55 +195,46 @@ class _CartPageState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ - _isCartEmpty - ? Expanded( - child: FractionallySizedBox( - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Icon( - Icons.shopping_cart, - size: 100, - color: Colors.black45, - ), - Padding( - child: Text( - trans("Empty Basket"), - style: Theme.of(context).textTheme.bodyMedium, - ), - padding: EdgeInsets.only(top: 10), - ) - ], - ), - heightFactor: 0.5, - widthFactor: 1, + Expanded( + child: afterLoad(child: () => _cartLines.isEmpty ? FractionallySizedBox( + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Icon( + Icons.shopping_cart, + size: 100, + color: Colors.black45, ), - ) - : (_isLoading - ? Expanded( - child: AppLoaderWidget(), - ) - : Expanded( - child: ListView.builder( - padding: const EdgeInsets.all(8), - itemCount: _cartLines.length, - itemBuilder: (BuildContext context, int index) { - CartLineItem cartLineItem = _cartLines[index]; - return CartItemContainer( - cartLineItem: cartLineItem, - actionIncrementQuantity: () => - actionIncrementQuantity( - cartLineItem: cartLineItem), - actionDecrementQuantity: () => - actionDecrementQuantity( - cartLineItem: cartLineItem), - actionRemoveItem: () => - actionRemoveItem(index: index), - ); - }), - flex: 3, - )), + Padding( + child: Text( + trans("Empty Basket"), + style: Theme.of(context).textTheme.bodyMedium, + ), + padding: EdgeInsets.only(top: 10), + ) + ], + ), + heightFactor: 0.5, + widthFactor: 1, + ) : ListView.builder( + padding: const EdgeInsets.all(8), + itemCount: _cartLines.length, + itemBuilder: (BuildContext context, int index) { + CartLineItem cartLineItem = _cartLines[index]; + return CartItemContainer( + cartLineItem: cartLineItem, + actionIncrementQuantity: () => + actionIncrementQuantity( + cartLineItem: cartLineItem), + actionDecrementQuantity: () => + actionDecrementQuantity( + cartLineItem: cartLineItem), + actionRemoveItem: () => + actionRemoveItem(index: index), + ); + })), + ), Divider( color: Colors.black45, ), @@ -271,7 +243,7 @@ class _CartPageState extends State { child: (BuildContext context, data) => Padding( child: TextRowWidget( title: trans("Total"), - text: (_isLoading ? "" : data), + text: isLoading() ? '' : data, ), padding: EdgeInsets.only(bottom: 15, top: 15), ), diff --git a/LabelStoreMax/lib/resources/pages/checkout_confirmation_page.dart b/LabelStoreMax/lib/resources/pages/checkout_confirmation_page.dart index c7149d4..728fcdc 100644 --- a/LabelStoreMax/lib/resources/pages/checkout_confirmation_page.dart +++ b/LabelStoreMax/lib/resources/pages/checkout_confirmation_page.dart @@ -16,7 +16,6 @@ import 'package:flutter_app/app/models/checkout_session.dart'; import 'package:flutter_app/app/models/customer_country.dart'; import 'package:flutter_app/app/models/payment_type.dart'; import 'package:flutter_app/bootstrap/app_helper.dart'; -import 'package:flutter_app/bootstrap/extensions.dart'; import 'package:flutter_app/bootstrap/helpers.dart'; import 'package:flutter_app/resources/widgets/app_loader_widget.dart'; import 'package:flutter_app/resources/widgets/buttons.dart'; @@ -186,7 +185,7 @@ class CheckoutConfirmationPageState extends NyState { mainAxisAlignment: MainAxisAlignment.center, children: [ Text(trans("Checkout")), - Text(_wooSignalApp?.appName ?? getEnv('APP_NAME')).small(context), + Text(_wooSignalApp?.appName ?? getEnv('APP_NAME')).bodySmall(context), ], ), centerTitle: false, diff --git a/LabelStoreMax/lib/resources/pages/checkout_status_page.dart b/LabelStoreMax/lib/resources/pages/checkout_status_page.dart index 49a0df5..c740ed5 100644 --- a/LabelStoreMax/lib/resources/pages/checkout_status_page.dart +++ b/LabelStoreMax/lib/resources/pages/checkout_status_page.dart @@ -77,7 +77,7 @@ class _CheckoutStatusState extends NyState { textAlign: TextAlign.left, ), Text( - "${trans("Order Ref")}. #${_order!.id.toString()}", + "${trans("Order Ref")}. #${_order?.id.toString()}", style: Theme.of(context).textTheme.bodyLarge, textAlign: TextAlign.left, ), @@ -119,9 +119,9 @@ class _CheckoutStatusState extends NyState { ), Expanded( child: ListView.builder( - itemCount: _order!.lineItems == null + itemCount: _order?.lineItems == null ? 0 - : _order!.lineItems!.length, + : _order?.lineItems?.length, itemBuilder: (BuildContext context, int index) { ws_order.LineItems lineItem = _order!.lineItems![index]; return Container( diff --git a/LabelStoreMax/lib/resources/pages/product_detail_page.dart b/LabelStoreMax/lib/resources/pages/product_detail_page.dart index 436d204..0733fe1 100644 --- a/LabelStoreMax/lib/resources/pages/product_detail_page.dart +++ b/LabelStoreMax/lib/resources/pages/product_detail_page.dart @@ -14,7 +14,6 @@ import 'package:flutter_app/app/models/cart_line_item.dart'; import 'package:flutter_app/bootstrap/app_helper.dart'; import 'package:flutter_app/bootstrap/enums/wishlist_action_enums.dart'; import 'package:flutter_app/bootstrap/helpers.dart'; -import 'package:flutter_app/resources/widgets/app_loader_widget.dart'; import 'package:flutter_app/resources/widgets/buttons.dart'; import 'package:flutter_app/resources/widgets/cart_icon_widget.dart'; import 'package:flutter_app/resources/widgets/product_detail_body_widget.dart'; @@ -23,7 +22,7 @@ import 'package:flutter_app/resources/widgets/woosignal_ui.dart'; import 'package:nylo_framework/nylo_framework.dart'; import 'package:woosignal/models/response/product_variation.dart' as ws_product_variation; -import 'package:woosignal/models/response/products.dart' as ws_product; +import 'package:woosignal/models/response/product.dart' as ws_product; import 'package:woosignal/models/response/woosignal_app.dart'; class ProductDetailPage extends NyStatefulWidget { @@ -36,7 +35,6 @@ class ProductDetailPage extends NyStatefulWidget { } class _ProductDetailState extends NyState { - bool _isLoading = true; ws_product.Product? _product; List _productVariations = []; @@ -45,14 +43,15 @@ class _ProductDetailState extends NyState { @override init() async { + super.init(); + } + + @override + boot() async { _product = widget.controller.data(); if (_product!.type == "variable") { await _fetchProductVariations(); - return; } - setState(() { - _isLoading = false; - }); } _fetchProductVariations() async { @@ -76,9 +75,6 @@ class _ProductDetailState extends NyState { } } _productVariations = tmpVariations; - setState(() { - _isLoading = false; - }); } _modalBottomSheetOptionsForAttribute(int attributeIndex) { @@ -232,7 +228,7 @@ class _ProductDetailState extends NyState { actions: [ if (_wooSignalApp!.wishlistEnabled!) NyFutureBuilder( - future: hasAddedWishlistProduct(_product!.id), + future: hasAddedWishlistProduct(_product?.id), child: (context, dynamic isInFavourites) { return isInFavourites ? IconButton( @@ -256,32 +252,30 @@ class _ProductDetailState extends NyState { centerTitle: true, ), body: SafeArea( - child: _isLoading - ? AppLoaderWidget() - : Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - child: ProductDetailBodyWidget( - wooSignalApp: _wooSignalApp, - product: _product, - ), - ), - // - ProductDetailFooterActionsWidget( - onAddToCart: _addItemToCart, - onViewExternalProduct: - widget.controller.viewExternalProduct, - onAddQuantity: () => widget.controller - .addQuantityTapped(onSuccess: () => setState(() {})), - onRemoveQuantity: () => widget.controller - .removeQuantityTapped(onSuccess: () => setState(() {})), - product: _product, - quantity: widget.controller.quantity, - ) - ], + child: afterLoad(child: () => Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + child: ProductDetailBodyWidget( + wooSignalApp: _wooSignalApp, + product: _product, ), + ), + // + ProductDetailFooterActionsWidget( + onAddToCart: _addItemToCart, + onViewExternalProduct: + widget.controller.viewExternalProduct, + onAddQuantity: () => widget.controller + .addQuantityTapped(onSuccess: () => setState(() {})), + onRemoveQuantity: () => widget.controller + .removeQuantityTapped(onSuccess: () => setState(() {})), + product: _product, + quantity: widget.controller.quantity, + ) + ], + )) ), ); } diff --git a/LabelStoreMax/lib/resources/pages/product_reviews_page.dart b/LabelStoreMax/lib/resources/pages/product_reviews_page.dart index f622554..f80d66f 100644 --- a/LabelStoreMax/lib/resources/pages/product_reviews_page.dart +++ b/LabelStoreMax/lib/resources/pages/product_reviews_page.dart @@ -20,7 +20,7 @@ import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; import 'package:nylo_framework/nylo_framework.dart'; import 'package:pull_to_refresh_flutter3/pull_to_refresh_flutter3.dart'; import 'package:woosignal/models/response/product_review.dart'; -import 'package:woosignal/models/response/products.dart'; +import 'package:woosignal/models/response/product.dart'; import '../../app/controllers/product_reviews_controller.dart'; class ProductReviewsPage extends NyStatefulWidget { diff --git a/LabelStoreMax/lib/resources/pages/wishlist_page_widget.dart b/LabelStoreMax/lib/resources/pages/wishlist_page_widget.dart index 6490c35..296bf4e 100644 --- a/LabelStoreMax/lib/resources/pages/wishlist_page_widget.dart +++ b/LabelStoreMax/lib/resources/pages/wishlist_page_widget.dart @@ -10,25 +10,21 @@ import 'package:flutter/material.dart'; import 'package:flutter_app/bootstrap/helpers.dart'; -import 'package:flutter_app/resources/widgets/app_loader_widget.dart'; import 'package:flutter_app/resources/widgets/cached_image_widget.dart'; import 'package:nylo_framework/nylo_framework.dart'; -import 'package:woosignal/models/response/products.dart'; +import 'package:woosignal/models/response/product.dart'; class WishListPageWidget extends StatefulWidget { @override _WishListPageWidgetState createState() => _WishListPageWidgetState(); } -class _WishListPageWidgetState extends State { +class _WishListPageWidgetState extends NyState { List _products = []; - bool? isLoading; @override - void initState() { - super.initState(); - isLoading = true; - loadProducts(); + boot() async { + await loadProducts(); } loadProducts() async { @@ -36,9 +32,6 @@ class _WishListPageWidgetState extends State { List productIds = favouriteProducts.map((e) => e['id']).cast().toList(); if (productIds.isEmpty) { - setState(() { - isLoading = false; - }); return; } _products = await (appWooSignal((api) => api.getProducts( @@ -47,9 +40,6 @@ class _WishListPageWidgetState extends State { status: "publish", stockStatus: "instock", ))); - setState(() { - isLoading = false; - }); } @override @@ -60,96 +50,96 @@ class _WishListPageWidgetState extends State { title: Text(trans("Wishlist")), ), body: SafeArea( - child: isLoading! - ? AppLoaderWidget() - : _products.isEmpty && isLoading == false - ? Center( - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon( - Icons.favorite, - size: 40, + child: afterLoad( + child: () => _products.isEmpty + ? Center( + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.favorite, + size: 40, + ), + Padding( + padding: EdgeInsets.symmetric(vertical: 12), + ), + Text(trans("No items found"), + style: Theme.of(context) + .textTheme + .titleLarge! + .setColor(context, + (color) => color!.primaryContent)) + ], + ), + ) + : ListView.separated( + padding: EdgeInsets.only(top: 10), + itemBuilder: (BuildContext context, int index) { + Product product = _products[index]; + return InkWell( + onTap: () => Navigator.pushNamed( + context, "/product-detail", + arguments: product), + child: Container( + child: Row( + children: [ + Container( + margin: EdgeInsets.only(left: 8), + child: CachedImageWidget( + image: (product.images.isNotEmpty + ? product.images.first.src + : getEnv("PRODUCT_PLACEHOLDER_IMAGE")), + fit: BoxFit.contain, + width: double.infinity, ), - Padding( - padding: EdgeInsets.symmetric(vertical: 12), - ), - Text(trans("No items found"), - style: Theme.of(context) - .textTheme - .titleLarge! - .setColor(context, - (color) => color!.primaryContent)) - ], - ), - ) - : ListView.separated( - padding: EdgeInsets.only(top: 10), - itemBuilder: (BuildContext context, int index) { - Product product = _products[index]; - return InkWell( - onTap: () => Navigator.pushNamed( - context, "/product-detail", - arguments: product), + width: MediaQuery.of(context).size.width / 4, + ), + Expanded( child: Container( - child: Row( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.center, children: [ - Container( - margin: EdgeInsets.only(left: 8), - child: CachedImageWidget( - image: (product.images.isNotEmpty - ? product.images.first.src - : getEnv("PRODUCT_PLACEHOLDER_IMAGE")), - fit: BoxFit.contain, - width: double.infinity, - ), - width: MediaQuery.of(context).size.width / 4, + Text( + product.name!, + style: TextStyle( + fontWeight: FontWeight.bold), + maxLines: 2, + overflow: TextOverflow.ellipsis, ), - Expanded( - child: Container( - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - Text( - product.name!, - style: TextStyle( - fontWeight: FontWeight.bold), - maxLines: 2, - overflow: TextOverflow.ellipsis, - ), - Text( - formatStringCurrency( - total: product.price), - ), - ], - ), - ), + Text( + formatStringCurrency( + total: product.price), ), - Container( - width: MediaQuery.of(context).size.width / 5, - alignment: Alignment.center, - child: IconButton( - icon: Icon( - Icons.favorite, - color: Colors.red, - ), - onPressed: () => - _removeFromWishlist(product), - ), - ) ], ), ), - ); - }, - separatorBuilder: (BuildContext context, int index) { - return Divider(); - }, - itemCount: _products.length)), + ), + Container( + width: MediaQuery.of(context).size.width / 5, + alignment: Alignment.center, + child: IconButton( + icon: Icon( + Icons.favorite, + color: Colors.red, + ), + onPressed: () => + _removeFromWishlist(product), + ), + ) + ], + ), + ), + ); + }, + separatorBuilder: (BuildContext context, int index) { + return Divider(); + }, + itemCount: _products.length)), + ), ); } diff --git a/LabelStoreMax/lib/resources/widgets/compo_home_widget.dart b/LabelStoreMax/lib/resources/widgets/compo_home_widget.dart index 222a99f..999e391 100644 --- a/LabelStoreMax/lib/resources/widgets/compo_home_widget.dart +++ b/LabelStoreMax/lib/resources/widgets/compo_home_widget.dart @@ -20,7 +20,7 @@ import 'package:flutter_swiper_view/flutter_swiper_view.dart'; import 'package:nylo_framework/nylo_framework.dart'; import 'package:woosignal/models/response/product_category.dart'; import 'package:woosignal/models/response/woosignal_app.dart'; -import 'package:woosignal/models/response/products.dart'; +import 'package:woosignal/models/response/product.dart'; class CompoHomeWidget extends StatefulWidget { CompoHomeWidget({Key? key, required this.wooSignalApp}) : super(key: key); diff --git a/LabelStoreMax/lib/resources/widgets/mello_theme_widget.dart b/LabelStoreMax/lib/resources/widgets/mello_theme_widget.dart index 73f8624..6ffaa18 100644 --- a/LabelStoreMax/lib/resources/widgets/mello_theme_widget.dart +++ b/LabelStoreMax/lib/resources/widgets/mello_theme_widget.dart @@ -11,7 +11,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_app/app/controllers/product_loader_controller.dart'; import 'package:flutter_app/bootstrap/helpers.dart'; -import 'package:flutter_app/resources/widgets/app_loader_widget.dart'; import 'package:flutter_app/resources/widgets/cart_icon_widget.dart'; import 'package:flutter_app/resources/widgets/home_drawer_widget.dart'; import 'package:flutter_app/resources/widgets/safearea_widget.dart'; @@ -20,7 +19,7 @@ import 'package:nylo_framework/nylo_framework.dart'; import 'package:pull_to_refresh_flutter3/pull_to_refresh_flutter3.dart'; import 'package:woosignal/models/response/woosignal_app.dart'; import 'package:woosignal/models/response/product_category.dart' as ws_category; -import 'package:woosignal/models/response/products.dart' as ws_product; +import 'package:woosignal/models/response/product.dart' as ws_product; class MelloThemeWidget extends StatefulWidget { MelloThemeWidget( @@ -33,7 +32,7 @@ class MelloThemeWidget extends StatefulWidget { _MelloThemeWidgetState createState() => _MelloThemeWidgetState(); } -class _MelloThemeWidgetState extends State { +class _MelloThemeWidgetState extends NyState { final RefreshController _refreshController = RefreshController(initialRefresh: false); final ProductLoaderController _productLoaderController = @@ -41,20 +40,21 @@ class _MelloThemeWidgetState extends State { List _categories = []; - bool _shouldStopRequests = false, _isLoading = true; + bool _shouldStopRequests = false; @override - void initState() { - super.initState(); - _home(); + void init() async { + super.init(); + } + + @override + boot() async { + await _home(); } _home() async { await fetchProducts(); await _fetchCategories(); - setState(() { - _isLoading = false; - }); } _fetchCategories() async { @@ -110,18 +110,16 @@ class _MelloThemeWidgetState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( - child: _isLoading - ? AppLoaderWidget() - : RefreshableScrollContainer( - controller: _refreshController, - onRefresh: _onRefresh, - onLoading: _onLoading, - products: _productLoaderController.getResults(), - onTap: _showProduct, - bannerHeight: MediaQuery.of(context).size.height / 3.5, - bannerImages: bannerImages, - modalBottomSheetMenu: _modalBottomSheetMenu, - ), + child: afterLoad(child: () => RefreshableScrollContainer( + controller: _refreshController, + onRefresh: _onRefresh, + onLoading: _onLoading, + products: _productLoaderController.getResults(), + onTap: _showProduct, + bannerHeight: MediaQuery.of(context).size.height / 3.5, + bannerImages: bannerImages, + modalBottomSheetMenu: _modalBottomSheetMenu, + )), flex: 1, ), ], diff --git a/LabelStoreMax/lib/resources/widgets/notic_home_widget.dart b/LabelStoreMax/lib/resources/widgets/notic_home_widget.dart index 059bb86..e0ed329 100644 --- a/LabelStoreMax/lib/resources/widgets/notic_home_widget.dart +++ b/LabelStoreMax/lib/resources/widgets/notic_home_widget.dart @@ -12,7 +12,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_app/app/controllers/product_loader_controller.dart'; import 'package:flutter_app/bootstrap/helpers.dart'; -import 'package:flutter_app/resources/widgets/app_loader_widget.dart'; import 'package:flutter_app/resources/widgets/cached_image_widget.dart'; import 'package:flutter_app/resources/widgets/home_drawer_widget.dart'; import 'package:flutter_app/resources/widgets/no_results_for_products_widget.dart'; @@ -23,7 +22,7 @@ import 'package:nylo_framework/nylo_framework.dart'; import 'package:pull_to_refresh_flutter3/pull_to_refresh_flutter3.dart'; import 'package:woosignal/models/response/woosignal_app.dart'; import 'package:woosignal/models/response/product_category.dart' as ws_category; -import 'package:woosignal/models/response/products.dart' as ws_product; +import 'package:woosignal/models/response/product.dart' as ws_product; class NoticHomeWidget extends StatefulWidget { NoticHomeWidget({Key? key, required this.wooSignalApp}) : super(key: key); @@ -34,7 +33,7 @@ class NoticHomeWidget extends StatefulWidget { _NoticHomeWidgetState createState() => _NoticHomeWidgetState(); } -class _NoticHomeWidgetState extends State { +class _NoticHomeWidgetState extends NyState { Widget? activeWidget; final RefreshController _refreshController = RefreshController(initialRefresh: false); @@ -43,20 +42,16 @@ class _NoticHomeWidgetState extends State { ProductLoaderController(); List _categories = []; - bool _shouldStopRequests = false, _isLoading = true; - + bool _shouldStopRequests = false; + @override - void initState() { - super.initState(); - _home(); + boot() async { + await _home(); } _home() async { await fetchProducts(); await _fetchCategories(); - setState(() { - _isLoading = false; - }); } _fetchCategories() async { @@ -114,102 +109,98 @@ class _NoticHomeWidgetState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ - (_isLoading - ? Expanded(child: AppLoaderWidget()) - : Expanded( - child: ListView( - shrinkWrap: true, + Expanded( + child: afterLoad(child: () => ListView( + shrinkWrap: true, + children: [ + Container( + margin: EdgeInsets.only(bottom: 15), + child: Swiper( + itemBuilder: (BuildContext context, int index) { + return CachedImageWidget( + image: + widget.wooSignalApp!.bannerImages![index], + fit: BoxFit.cover, + ); + }, + itemCount: + widget.wooSignalApp!.bannerImages!.length, + viewportFraction: 0.8, + scale: 0.9, + ), + height: MediaQuery.of(context).size.height / 2.5, + ), + Container( + height: 75, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Container( - margin: EdgeInsets.only(bottom: 15), - child: Swiper( - itemBuilder: (BuildContext context, int index) { - return CachedImageWidget( - image: - widget.wooSignalApp!.bannerImages![index], - fit: BoxFit.cover, - ); - }, - itemCount: - widget.wooSignalApp!.bannerImages!.length, - viewportFraction: 0.8, - scale: 0.9, - ), - height: MediaQuery.of(context).size.height / 2.5, - ), - Container( - height: 100, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text(trans("Must have")), - Flexible( - child: Text( - trans("Our selection of new items"), - style: Theme.of(context) - .textTheme - .headlineMedium, - maxLines: 2, - overflow: TextOverflow.ellipsis, - ), - ) - ], - ), - ), - Container( - height: 250, - child: SmartRefresher( - enablePullDown: true, - enablePullUp: true, - footer: CustomFooter( - builder: - (BuildContext context, LoadStatus? mode) { - Widget body; - if (mode == LoadStatus.idle) { - body = Text(trans("pull up load")); - } else if (mode == LoadStatus.loading) { - body = CupertinoActivityIndicator(); - } else if (mode == LoadStatus.failed) { - body = - Text(trans("Load Failed! Click retry!")); - } else if (mode == LoadStatus.canLoading) { - body = Text(trans("release to load more")); - } else { - return SizedBox.shrink(); - } - return Container( - height: 55.0, - child: Center(child: body), - ); - }, - ), - controller: _refreshController, - onRefresh: _onRefresh, - onLoading: _onLoading, - child: (products.isNotEmpty - ? ListView.builder( - scrollDirection: Axis.horizontal, - shrinkWrap: false, - itemBuilder: (cxt, i) { - return Container( - // height: 200, - width: - MediaQuery.of(context).size.width / - 2.5, - child: ProductItemContainer( - product: products[i], - onTap: _showProduct), - ); - }, - itemCount: products.length, - ) - : NoResultsForProductsWidget()), + Text(trans("Must have")), + Flexible( + child: Text( + trans("Our selection of new items"), + style: Theme.of(context) + .textTheme + .headlineMedium, + maxLines: 1, + overflow: TextOverflow.ellipsis, ), ) ], ), - flex: 1, - )), + ), + Container( + height: 380, + child: SmartRefresher( + enablePullDown: true, + enablePullUp: true, + footer: CustomFooter( + builder: + (BuildContext context, LoadStatus? mode) { + Widget body; + if (mode == LoadStatus.idle) { + body = Text(trans("pull up load")); + } else if (mode == LoadStatus.loading) { + body = CupertinoActivityIndicator(); + } else if (mode == LoadStatus.failed) { + body = + Text(trans("Load Failed! Click retry!")); + } else if (mode == LoadStatus.canLoading) { + body = Text(trans("release to load more")); + } else { + return SizedBox.shrink(); + } + return Container( + height: 55.0, + child: Center(child: body), + ); + }, + ), + controller: _refreshController, + onRefresh: _onRefresh, + onLoading: _onLoading, + child: (products.isNotEmpty + ? ListView.builder( + scrollDirection: Axis.horizontal, + shrinkWrap: false, + itemBuilder: (cxt, i) { + return Container( + width: + MediaQuery.of(context).size.width / + 2.5, + child: ProductItemContainer( + product: products[i], + onTap: _showProduct), + ); + }, + itemCount: products.length, + ) + : NoResultsForProductsWidget()), + ), + ) + ], + ), + ),flex: 1,), ], ), ), diff --git a/LabelStoreMax/lib/resources/widgets/product_detail_body_widget.dart b/LabelStoreMax/lib/resources/widgets/product_detail_body_widget.dart index 74c5a94..d9a7be4 100644 --- a/LabelStoreMax/lib/resources/widgets/product_detail_body_widget.dart +++ b/LabelStoreMax/lib/resources/widgets/product_detail_body_widget.dart @@ -15,7 +15,7 @@ import 'package:flutter_app/resources/widgets/product_detail_image_swiper_widget import 'package:flutter_app/resources/widgets/product_detail_related_products_widget.dart'; import 'package:flutter_app/resources/widgets/product_detail_reviews_widget.dart'; import 'package:flutter_app/resources/widgets/product_detail_upsell_widget.dart'; -import 'package:woosignal/models/response/products.dart'; +import 'package:woosignal/models/response/product.dart'; import 'package:woosignal/models/response/woosignal_app.dart'; class ProductDetailBodyWidget extends StatelessWidget { diff --git a/LabelStoreMax/lib/resources/widgets/product_detail_description_widget.dart b/LabelStoreMax/lib/resources/widgets/product_detail_description_widget.dart index bd99648..298f45a 100644 --- a/LabelStoreMax/lib/resources/widgets/product_detail_description_widget.dart +++ b/LabelStoreMax/lib/resources/widgets/product_detail_description_widget.dart @@ -13,7 +13,7 @@ import 'package:flutter_app/resources/widgets/woosignal_ui.dart'; import 'package:flutter_widget_from_html_core/flutter_widget_from_html_core.dart'; import 'package:nylo_framework/nylo_framework.dart'; import 'package:url_launcher/url_launcher.dart'; -import 'package:woosignal/models/response/products.dart'; +import 'package:woosignal/models/response/product.dart'; class ProductDetailDescriptionWidget extends StatelessWidget { const ProductDetailDescriptionWidget({Key? key, required this.product}) diff --git a/LabelStoreMax/lib/resources/widgets/product_detail_footer_actions_widget.dart b/LabelStoreMax/lib/resources/widgets/product_detail_footer_actions_widget.dart index b36acef..30da932 100644 --- a/LabelStoreMax/lib/resources/widgets/product_detail_footer_actions_widget.dart +++ b/LabelStoreMax/lib/resources/widgets/product_detail_footer_actions_widget.dart @@ -13,7 +13,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_app/bootstrap/helpers.dart'; import 'package:flutter_app/resources/widgets/buttons.dart'; import 'package:nylo_framework/nylo_framework.dart'; -import 'package:woosignal/models/response/products.dart'; +import 'package:woosignal/models/response/product.dart'; class ProductDetailFooterActionsWidget extends StatelessWidget { const ProductDetailFooterActionsWidget( diff --git a/LabelStoreMax/lib/resources/widgets/product_detail_header_widget.dart b/LabelStoreMax/lib/resources/widgets/product_detail_header_widget.dart index 747d136..8b931a5 100644 --- a/LabelStoreMax/lib/resources/widgets/product_detail_header_widget.dart +++ b/LabelStoreMax/lib/resources/widgets/product_detail_header_widget.dart @@ -10,7 +10,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_app/bootstrap/helpers.dart'; -import 'package:woosignal/models/response/products.dart'; +import 'package:woosignal/models/response/product.dart'; class ProductDetailHeaderWidget extends StatelessWidget { const ProductDetailHeaderWidget({Key? key, required this.product}) diff --git a/LabelStoreMax/lib/resources/widgets/product_detail_image_swiper_widget.dart b/LabelStoreMax/lib/resources/widgets/product_detail_image_swiper_widget.dart index 828f4cc..0e6238b 100644 --- a/LabelStoreMax/lib/resources/widgets/product_detail_image_swiper_widget.dart +++ b/LabelStoreMax/lib/resources/widgets/product_detail_image_swiper_widget.dart @@ -12,7 +12,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_app/resources/widgets/cached_image_widget.dart'; import 'package:flutter_swiper_view/flutter_swiper_view.dart'; import 'package:nylo_framework/nylo_framework.dart'; -import 'package:woosignal/models/response/products.dart'; +import 'package:woosignal/models/response/product.dart'; class ProductDetailImageSwiperWidget extends StatelessWidget { const ProductDetailImageSwiperWidget( diff --git a/LabelStoreMax/lib/resources/widgets/product_detail_related_products_widget.dart b/LabelStoreMax/lib/resources/widgets/product_detail_related_products_widget.dart index bacf6af..3fecc6c 100644 --- a/LabelStoreMax/lib/resources/widgets/product_detail_related_products_widget.dart +++ b/LabelStoreMax/lib/resources/widgets/product_detail_related_products_widget.dart @@ -12,7 +12,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_app/bootstrap/helpers.dart'; import 'package:flutter_app/resources/widgets/woosignal_ui.dart'; import 'package:nylo_framework/nylo_framework.dart'; -import 'package:woosignal/models/response/products.dart'; +import 'package:woosignal/models/response/product.dart'; import 'package:woosignal/models/response/woosignal_app.dart'; class ProductDetailRelatedProductsWidget extends StatelessWidget { @@ -55,7 +55,7 @@ class ProductDetailRelatedProductsWidget extends StatelessWidget { child: NyFutureBuilder>( future: fetchRelated(), child: (context, relatedProducts) { - if (relatedProducts == null) { + if (relatedProducts.isEmpty) { return SizedBox.shrink(); } return ListView( @@ -74,9 +74,7 @@ class ProductDetailRelatedProductsWidget extends StatelessWidget { ); } - Future> fetchRelated() async { - return await (appWooSignal( - (api) => api.getProducts(perPage: 100, include: product!.relatedIds), - )); - } + Future> fetchRelated() async => await (appWooSignal( + (api) => api.getProducts(perPage: 100, include: product!.relatedIds), + )); } diff --git a/LabelStoreMax/lib/resources/widgets/product_detail_reviews_widget.dart b/LabelStoreMax/lib/resources/widgets/product_detail_reviews_widget.dart index 444fc55..14890e2 100644 --- a/LabelStoreMax/lib/resources/widgets/product_detail_reviews_widget.dart +++ b/LabelStoreMax/lib/resources/widgets/product_detail_reviews_widget.dart @@ -16,7 +16,7 @@ import 'package:flutter_app/resources/widgets/product_detail_review_tile_widget. import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:nylo_framework/nylo_framework.dart'; import 'package:woosignal/models/response/product_review.dart'; -import 'package:woosignal/models/response/products.dart'; +import 'package:woosignal/models/response/product.dart'; import 'package:woosignal/models/response/woosignal_app.dart'; class ProductDetailReviewsWidget extends StatefulWidget { diff --git a/LabelStoreMax/lib/resources/widgets/product_detail_upsell_widget.dart b/LabelStoreMax/lib/resources/widgets/product_detail_upsell_widget.dart index 2a6fd60..3060c8a 100644 --- a/LabelStoreMax/lib/resources/widgets/product_detail_upsell_widget.dart +++ b/LabelStoreMax/lib/resources/widgets/product_detail_upsell_widget.dart @@ -13,7 +13,7 @@ import 'package:flutter_app/app/controllers/product_loader_controller.dart'; import 'package:flutter_app/resources/widgets/app_loader_widget.dart'; import 'package:flutter_app/resources/widgets/woosignal_ui.dart'; import 'package:nylo_framework/nylo_framework.dart'; -import 'package:woosignal/models/response/products.dart'; +import 'package:woosignal/models/response/product.dart'; import 'package:woosignal/models/response/woosignal_app.dart'; class ProductDetailUpsellWidget extends StatefulWidget { diff --git a/LabelStoreMax/lib/resources/widgets/woosignal_ui.dart b/LabelStoreMax/lib/resources/widgets/woosignal_ui.dart index c23f229..47a1ae5 100644 --- a/LabelStoreMax/lib/resources/widgets/woosignal_ui.dart +++ b/LabelStoreMax/lib/resources/widgets/woosignal_ui.dart @@ -23,7 +23,7 @@ import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; import 'package:flutter_swiper_view/flutter_swiper_view.dart'; import 'package:nylo_framework/nylo_framework.dart'; import 'package:pull_to_refresh_flutter3/pull_to_refresh_flutter3.dart'; -import 'package:woosignal/models/response/products.dart'; +import 'package:woosignal/models/response/product.dart'; import 'package:woosignal/models/response/tax_rate.dart'; class RefreshableScrollContainer extends StatelessWidget { @@ -108,7 +108,7 @@ class RefreshableScrollContainer extends StatelessWidget { .map((product) => StaggeredGridTile.fit( crossAxisCellCount: 1, child: Container( - height: 200, + height: 300, child: ProductItemContainer( product: product, onTap: onTap, @@ -316,138 +316,134 @@ class ProductItemContainer extends StatelessWidget { return SizedBox.shrink(); } - return LayoutBuilder( - builder: (cxt, constraints) => InkWell( - child: Container( - margin: EdgeInsets.all(4), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Container( - height: constraints.maxHeight / 1.6, - child: ClipRRect( - borderRadius: BorderRadius.circular(3.0), - child: Stack( - children: [ - Container( - color: Colors.grey[100], - height: double.infinity, - width: double.infinity, - ), - CachedImageWidget( - image: (product!.images.isNotEmpty - ? product!.images.first.src - : getEnv("PRODUCT_PLACEHOLDER_IMAGE")), - fit: BoxFit.contain, - height: constraints.maxHeight / 1.6, - width: double.infinity, - ), - if (isProductNew(product)) - Container(padding: EdgeInsets.all(4), child: Text("New", style: TextStyle(color: Colors.white),), decoration: BoxDecoration(color: Colors.black),), - if (product!.onSale! && product!.type != "variable") - Positioned( - bottom: 0, - left: 0, - right: 0, - child: Container( - padding: EdgeInsets.all(3), - decoration: BoxDecoration( - color: Colors.white70, - // borderRadius: BorderRadius.circular(4), - ), - child: RichText( - textAlign: TextAlign.center, - text: TextSpan( - text: '', - style: Theme.of(context).textTheme.bodyLarge, - children: [ - TextSpan( - text: - "${workoutSaleDiscount(salePrice: product!.salePrice, priceBefore: product!.regularPrice)}% ${trans("off")}", - style: Theme.of(context) - .textTheme - .bodyLarge! - .copyWith( - color: Colors.black, - fontSize: 13, - ), - ), - ], - ), + double height = 280; + return InkWell( + child: Container( + margin: EdgeInsets.all(4), + child: ListView( + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + children: [ + Container( + height: 180, + child: ClipRRect( + borderRadius: BorderRadius.circular(3.0), + child: Stack( + children: [ + Container( + color: Colors.grey[100], + height: double.infinity, + width: double.infinity, + ), + CachedImageWidget( + image: (product!.images.isNotEmpty + ? product!.images.first.src + : getEnv("PRODUCT_PLACEHOLDER_IMAGE")), + fit: BoxFit.contain, + height: height, + width: double.infinity, + ), + if (isProductNew(product)) + Container(padding: EdgeInsets.all(4), child: Text("New", style: TextStyle(color: Colors.white),), decoration: BoxDecoration(color: Colors.black),), + if (product!.onSale! && product!.type != "variable") + Positioned( + bottom: 0, + left: 0, + right: 0, + child: Container( + padding: EdgeInsets.all(3), + decoration: BoxDecoration( + color: Colors.white70, + ), + child: RichText( + textAlign: TextAlign.center, + text: TextSpan( + text: '', + style: Theme.of(context).textTheme.bodyLarge, + children: [ + TextSpan( + text: + "${workoutSaleDiscount(salePrice: product!.salePrice, priceBefore: product!.regularPrice)}% ${trans("off")}", + style: Theme.of(context) + .textTheme + .bodyLarge! + .copyWith( + color: Colors.black, + fontSize: 13, + ), + ), + ], ), ), ), - ], - ), - ), - ), - Container( - margin: const EdgeInsets.only(top: 2, bottom: 2), - child: Text( - product!.name!, - style: Theme.of(context) - .textTheme - .bodyMedium! - .copyWith(fontSize: 15), - maxLines: 2, - overflow: TextOverflow.ellipsis, - ), - ), - Flexible( - child: Container( - padding: EdgeInsets.only(top: 4), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - AutoSizeText( - "${formatStringCurrency(total: product!.price)} ", - style: Theme.of(context) - .textTheme - .bodyLarge! - .copyWith(fontWeight: FontWeight.w800), - textAlign: TextAlign.left, ), - if (product!.onSale! && product!.type != "variable") - RichText( - text: TextSpan(children: [ - TextSpan( - text: '${trans("Was")}: ', - style: Theme.of(context) - .textTheme - .bodyLarge! - .copyWith( - fontSize: 11, - ), - ), - TextSpan( - text: formatStringCurrency( - total: product!.regularPrice, - ), - style: Theme.of(context) - .textTheme - .bodyLarge! - .copyWith( - decoration: TextDecoration.lineThrough, - color: Colors.grey, - fontSize: 11, - ), - ), - ]), - ), - ].toList(), - ), + ], ), ), - ], - ), + ), + Container( + margin: const EdgeInsets.only(top: 2, bottom: 2), + child: Text( + product!.name!, + style: Theme.of(context) + .textTheme + .bodyMedium! + .copyWith(fontSize: 15), + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), + ), + Container( + padding: EdgeInsets.only(top: 4), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + AutoSizeText( + "${formatStringCurrency(total: product!.price)} ", + style: Theme.of(context) + .textTheme + .bodyLarge! + .copyWith(fontWeight: FontWeight.w800), + textAlign: TextAlign.left, + ), + if (product!.onSale! && product!.type != "variable") + RichText( + text: TextSpan(children: [ + TextSpan( + text: '${trans("Was")}: ', + style: Theme.of(context) + .textTheme + .bodyLarge! + .copyWith( + fontSize: 11, + ), + ), + TextSpan( + text: formatStringCurrency( + total: product!.regularPrice, + ), + style: Theme.of(context) + .textTheme + .bodyLarge! + .copyWith( + decoration: TextDecoration.lineThrough, + color: Colors.grey, + fontSize: 11, + ), + ), + ]), + ), + ].toList(), + ), + ), + ], ), - onTap: () => onTap != null - ? onTap!(product) - : Navigator.pushNamed(context, "/product-detail", - arguments: product), ), + onTap: () => onTap != null + ? onTap!(product) + : Navigator.pushNamed(context, "/product-detail", + arguments: product), ); } } diff --git a/LabelStoreMax/pubspec.lock b/LabelStoreMax/pubspec.lock index d77a9f0..206f7a3 100644 --- a/LabelStoreMax/pubspec.lock +++ b/LabelStoreMax/pubspec.lock @@ -189,10 +189,10 @@ packages: dependency: transitive description: name: device_info_plus - sha256: "9b1a0c32b2a503f8fe9f8764fac7b5fcd4f6bd35d8f49de5350bccf9e2a33b8a" + sha256: "499c61743e13909c13374a8c209075385858c614b9c0f2487b5f9995eeaf7369" url: "https://pub.dev" source: hosted - version: "9.0.0" + version: "9.0.1" device_info_plus_platform_interface: dependency: transitive description: @@ -209,6 +209,14 @@ packages: url: "https://pub.dev" source: hosted version: "5.1.2" + eventify: + dependency: transitive + description: + name: eventify + sha256: b829429f08586cc2001c628e7499e3e3c2493a1d895fd73b00ecb23351aa5a66 + url: "https://pub.dev" + source: hosted + version: "1.0.1" fake_async: dependency: transitive description: @@ -407,10 +415,10 @@ packages: dependency: "direct main" description: name: flutter_stripe - sha256: "95f3c4b907493ff5cdd6b3cdeda03bb59c2bc409d0c0bfb44db948374f9c3595" + sha256: "51c3ab5f7a705d864d719eb13882abbb3964c4f61983a13af6dc56607537b1e4" url: "https://pub.dev" source: hosted - version: "9.1.1" + version: "9.2.0" flutter_styled_toast: dependency: transitive description: @@ -453,6 +461,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.10.1" + fluttertoast: + dependency: transitive + description: + name: fluttertoast + sha256: "474f7d506230897a3cd28c965ec21c5328ae5605fc9c400cd330e9e9d6ac175c" + url: "https://pub.dev" + source: hosted + version: "8.2.2" freezed_annotation: dependency: transitive description: @@ -481,10 +497,10 @@ packages: dependency: "direct main" description: name: google_fonts - sha256: "6b6f10f0ce3c42f6552d1c70d2c28d764cf22bb487f50f66cca31dcd5194f4d6" + sha256: "2776c66b3e97c6cdd58d1bd3281548b074b64f1fd5c8f82391f7456e38849567" url: "https://pub.dev" source: hosted - version: "4.0.4" + version: "4.0.5" html: dependency: "direct main" description: @@ -494,13 +510,13 @@ packages: source: hosted version: "0.15.3" http: - dependency: transitive + dependency: "direct overridden" description: name: http - sha256: "5895291c13fa8a3bd82e76d5627f69e0d85ca6a30dcac95c4ea19a5d555879c2" + sha256: "4c3f04bfb64d3efd508d06b41b825542f08122d30bda4933fb95c069d22a4fa3" url: "https://pub.dev" source: hosted - version: "0.13.6" + version: "1.0.0" http_parser: dependency: transitive description: @@ -601,18 +617,18 @@ packages: dependency: "direct main" description: name: nylo_framework - sha256: "89cd06e70cd5e402e16174385bcbe24cb4954fc4ce2e6de30e774e5a19fd6b56" + sha256: f9960dce938d1046166cc97f7ab613638d7e4f45e6e2a9b30e7d2b004d1d833d url: "https://pub.dev" source: hosted - version: "5.0.0" + version: "5.0.2" nylo_support: dependency: transitive description: name: nylo_support - sha256: "72228f50a1e37bc2e3c27dfe28ce72b7f72aa120829fb83b8c0d15f6f15c074b" + sha256: "011a1614b2440ffcbac821e6624ca25355e304af6c8b5c298203bbbe547da00e" url: "https://pub.dev" source: hosted - version: "5.0.0" + version: "5.1.2" octo_image: dependency: transitive description: @@ -633,10 +649,10 @@ packages: dependency: "direct main" description: name: package_info_plus - sha256: d39e8fbff4c5aef4592737e25ad6ac500df006ce7a7a8e1f838ce1256e167542 + sha256: "28386bbe89ab5a7919a47cea99cdd1128e5a6e0bbd7eaafe20440ead84a15de3" url: "https://pub.dev" source: hosted - version: "4.0.0" + version: "4.0.1" package_info_plus_platform_interface: dependency: transitive description: @@ -773,6 +789,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.1" + razorpay_flutter: + dependency: "direct main" + description: + name: razorpay_flutter + sha256: d73a536032f6939f0a6706cff958904d471eb1acb3dc957c8cc4e1628f0fbc28 + url: "https://pub.dev" + source: hosted + version: "1.3.5" recase: dependency: transitive description: @@ -918,10 +942,10 @@ packages: dependency: transitive description: name: stripe_ios - sha256: "1ce3922c9e9fd2e3ced6b9d349966fa19074794eec1c9bac3cec1bca53e98c85" + sha256: e397609a5083b79706814342b40a2a58f1b97ecab2b9d6cae8d8e9f59646fc8c url: "https://pub.dev" source: hosted - version: "9.1.0" + version: "9.2.1" stripe_platform_interface: dependency: transitive description: @@ -1118,10 +1142,10 @@ packages: dependency: "direct main" description: name: woosignal - sha256: "67d6962b9b38e0da217bc136ddfd76dea7f9e876905f8b196be49f0f6b83e922" + sha256: "985313603ad26dbb48420ce1b9029ebec7b6681861bab094c5f89d1710281ac3" url: "https://pub.dev" source: hosted - version: "3.4.0" + version: "3.5.0" wp_json_api: dependency: "direct main" description: diff --git a/LabelStoreMax/pubspec.yaml b/LabelStoreMax/pubspec.yaml index d0dbd9a..4a35de8 100644 --- a/LabelStoreMax/pubspec.yaml +++ b/LabelStoreMax/pubspec.yaml @@ -1,7 +1,7 @@ # Official WooSignal App Template for WooCommerce # Label StoreMax -# Version: 6.6.0 +# Version: 6.6.1 # Author: Anthony Gordon # Homepage: https://woosignal.com # Documentation: https://woosignal.com/docs/app/label-storemax @@ -26,14 +26,14 @@ environment: flutter: ">=3.0.0" dependencies: - google_fonts: ^4.0.3 + google_fonts: ^4.0.5 analyzer: ^5.12.0 intl: ^0.18.0 - nylo_framework: ^5.0.0 - woosignal: ^3.4.0 + nylo_framework: ^5.0.2 + woosignal: ^3.5.0 wp_json_api: ^3.3.2 cached_network_image: ^3.2.3 - package_info_plus: ^4.0.0 + package_info_plus: ^4.0.1 money_formatter: ^0.0.3 flutter_web_browser: ^0.17.1 webview_flutter: ^3.0.4 @@ -61,7 +61,11 @@ dependencies: # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.5 collection: ^1.15.0 - flutter_stripe: ^9.1.1 + flutter_stripe: ^9.2.0 + razorpay_flutter: ^1.3.5 + +dependency_overrides: + http: ^1.0.0 dev_dependencies: flutter_launcher_icons: ^0.13.1 diff --git a/README.md b/README.md index 3bfd23c..459b1b2 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ # WooCommerce App: Label StoreMax -### Label StoreMax - v6.6.0 +### Label StoreMax - v6.6.1 [Official WooSignal WooCommerce App](https://woosignal.com)