From ed6460836fae778c6e66cdd017910f719ab4014f Mon Sep 17 00:00:00 2001 From: Anthony Date: Mon, 8 Mar 2021 01:38:45 +0000 Subject: [PATCH] v3.0.0 - Major release, Flutter 2.0.0+ support + more --- LabelStoreMax/CHANGELOG.md | 8 + LabelStoreMax/ios/Flutter/.last_build_id | 2 +- LabelStoreMax/ios/Flutter/Flutter.podspec | 8 +- .../ios/Runner.xcodeproj/project.pbxproj | 2 - .../contents.xcworkspacedata | 2 +- LabelStoreMax/lang/de.json | 4 +- LabelStoreMax/lang/en.json | 4 +- LabelStoreMax/lang/es.json | 4 +- LabelStoreMax/lang/fr.json | 4 +- LabelStoreMax/lang/hi.json | 4 +- LabelStoreMax/lang/it.json | 4 +- LabelStoreMax/lang/pt.json | 4 +- .../lib/generated_plugin_registrant.dart | 17 + LabelStoreMax/lib/helpers/app_helper.dart | 9 + .../lib/helpers/app_localizations.dart | 4 +- LabelStoreMax/lib/helpers/data/order_wc.dart | 10 +- .../lib/helpers/shared_pref/sp_user_id.dart | 3 +- LabelStoreMax/lib/helpers/tools.dart | 22 +- LabelStoreMax/lib/labelconfig.dart | 32 +- LabelStoreMax/lib/main.dart | 28 +- LabelStoreMax/lib/models/cart.dart | 37 +- .../lib/models/checkout_session.dart | 4 +- .../lib/models/customer_address.dart | 4 +- .../lib/models/customer_country.dart | 9 +- .../lib/models/default_shipping.dart | 10 +- LabelStoreMax/lib/models/payment_type.dart | 9 +- LabelStoreMax/lib/models/shipping_type.dart | 18 +- LabelStoreMax/lib/pages/about.dart | 26 +- .../lib/pages/account_billing_details.dart | 53 +- LabelStoreMax/lib/pages/account_detail.dart | 32 +- LabelStoreMax/lib/pages/account_landing.dart | 39 +- .../lib/pages/account_order_detail.dart | 21 +- .../lib/pages/account_profile_update.dart | 18 +- LabelStoreMax/lib/pages/account_register.dart | 74 +- .../lib/pages/account_shipping_details.dart | 55 +- LabelStoreMax/lib/pages/browse_category.dart | 45 +- LabelStoreMax/lib/pages/browse_search.dart | 23 +- LabelStoreMax/lib/pages/cart.dart | 20 +- .../lib/pages/checkout_confirmation.dart | 77 +- LabelStoreMax/lib/pages/checkout_details.dart | 68 +- .../lib/pages/checkout_payment_type.dart | 5 +- .../lib/pages/checkout_shipping_type.dart | 19 +- LabelStoreMax/lib/pages/checkout_status.dart | 2 +- .../lib/pages/customer_countries.dart | 2 +- LabelStoreMax/lib/pages/error_page.dart | 2 +- LabelStoreMax/lib/pages/home.dart | 85 +- LabelStoreMax/lib/pages/home_menu.dart | 18 +- LabelStoreMax/lib/pages/home_search.dart | 5 +- .../lib/pages/no_connection_page.dart | 73 ++ LabelStoreMax/lib/pages/product_detail.dart | 115 +-- LabelStoreMax/lib/providers/razor_pay.dart | 23 +- LabelStoreMax/lib/widgets/buttons.dart | 152 ++- .../lib/widgets/customer_address_input.dart | 93 +- LabelStoreMax/lib/widgets/menu_item.dart | 57 +- LabelStoreMax/lib/widgets/woosignal_ui.dart | 936 +++++++++++------- LabelStoreMax/pubspec.lock | 53 +- LabelStoreMax/pubspec.yaml | 16 +- README.md | 4 +- 58 files changed, 1390 insertions(+), 1087 deletions(-) create mode 100644 LabelStoreMax/lib/generated_plugin_registrant.dart create mode 100644 LabelStoreMax/lib/helpers/app_helper.dart create mode 100644 LabelStoreMax/lib/pages/no_connection_page.dart diff --git a/LabelStoreMax/CHANGELOG.md b/LabelStoreMax/CHANGELOG.md index 72eede2..04f45b1 100644 --- a/LabelStoreMax/CHANGELOG.md +++ b/LabelStoreMax/CHANGELOG.md @@ -1,3 +1,11 @@ +## [3.0.0] - 2020-03-08 + +* Major release +* Flutter 2.0.0+ support +* Manage app from WooSignal +* Code tidy up +* Bug fixes + ## [2.6.0] - 2020-02-24 * Ability to manage affiliate products diff --git a/LabelStoreMax/ios/Flutter/.last_build_id b/LabelStoreMax/ios/Flutter/.last_build_id index 8d22dc2..6c5bcf2 100644 --- a/LabelStoreMax/ios/Flutter/.last_build_id +++ b/LabelStoreMax/ios/Flutter/.last_build_id @@ -1 +1 @@ -bc983e13b3efb48b50e7a3cb8fc4ede2 \ No newline at end of file +5b271ab1c6a17b054237577340baf791 \ No newline at end of file diff --git a/LabelStoreMax/ios/Flutter/Flutter.podspec b/LabelStoreMax/ios/Flutter/Flutter.podspec index 5ca3041..2c4421c 100644 --- a/LabelStoreMax/ios/Flutter/Flutter.podspec +++ b/LabelStoreMax/ios/Flutter/Flutter.podspec @@ -1,18 +1,18 @@ # # NOTE: This podspec is NOT to be published. It is only used as a local source! +# This is a generated file; do not edit or check into version control. # Pod::Spec.new do |s| s.name = 'Flutter' s.version = '1.0.0' s.summary = 'High-performance, high-fidelity mobile apps.' - s.description = <<-DESC -Flutter provides an easy and productive way to build and deploy high-performance mobile apps for Android and iOS. - DESC s.homepage = 'https://flutter.io' s.license = { :type => 'MIT' } s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' } s.source = { :git => 'https://github.com/flutter/engine', :tag => s.version.to_s } s.ios.deployment_target = '8.0' - s.vendored_frameworks = 'Flutter.framework' + # Framework linking is handled by Flutter tooling, not CocoaPods. + # Add a placeholder to satisfy `s.dependency 'Flutter'` plugin podspecs. + s.vendored_frameworks = 'path/to/nothing' end diff --git a/LabelStoreMax/ios/Runner.xcodeproj/project.pbxproj b/LabelStoreMax/ios/Runner.xcodeproj/project.pbxproj index 9888538..5ec8a81 100644 --- a/LabelStoreMax/ios/Runner.xcodeproj/project.pbxproj +++ b/LabelStoreMax/ios/Runner.xcodeproj/project.pbxproj @@ -265,7 +265,6 @@ inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", "${BUILT_PRODUCTS_DIR}/FMDB/FMDB.framework", - "${PODS_ROOT}/../Flutter/Flutter.framework", "${BUILT_PRODUCTS_DIR}/Stripe/Stripe.framework", "${BUILT_PRODUCTS_DIR}/device_info/device_info.framework", "${BUILT_PRODUCTS_DIR}/flutter_money_formatter/flutter_money_formatter.framework", @@ -283,7 +282,6 @@ name = "[CP] Embed Pods Frameworks"; outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FMDB.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Stripe.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/device_info.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_money_formatter.framework", diff --git a/LabelStoreMax/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/LabelStoreMax/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 1d526a1..919434a 100644 --- a/LabelStoreMax/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/LabelStoreMax/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/LabelStoreMax/lang/de.json b/LabelStoreMax/lang/de.json index cf2dbab..48e97ed 100644 --- a/LabelStoreMax/lang/de.json +++ b/LabelStoreMax/lang/de.json @@ -172,5 +172,7 @@ "Account updated": "Konto aktualisiert", "Spend a minimum of": "Geben Sie mindestens ein", "for": "zum", - "Buy Product": "Produkt kaufen" + "Buy Product": "Produkt kaufen", + "Retry": "Wiederholen", + "Retry later": "Versuchen Sie es später erneut" } \ No newline at end of file diff --git a/LabelStoreMax/lang/en.json b/LabelStoreMax/lang/en.json index 76c2249..cb8177a 100644 --- a/LabelStoreMax/lang/en.json +++ b/LabelStoreMax/lang/en.json @@ -172,5 +172,7 @@ "Account updated": "Account updated", "Spend a minimum of": "Spend a minimum of", "for": "for", - "Buy Product": "Buy Product" + "Buy Product": "Buy Product", + "Retry": "Retry", + "Retry later": "Retry later" } \ No newline at end of file diff --git a/LabelStoreMax/lang/es.json b/LabelStoreMax/lang/es.json index fd06f5b..a98ce7d 100644 --- a/LabelStoreMax/lang/es.json +++ b/LabelStoreMax/lang/es.json @@ -172,5 +172,7 @@ "Account updated": "Cuenta actualizada", "Spend a minimum of": "Gasta un mínimo de", "for": "para", - "Buy Product": "Comprar producto" + "Buy Product": "Comprar producto", + "Retry": "Rever", + "Retry later": "Reintentar más tarde" } \ No newline at end of file diff --git a/LabelStoreMax/lang/fr.json b/LabelStoreMax/lang/fr.json index 351a445..9128c1d 100644 --- a/LabelStoreMax/lang/fr.json +++ b/LabelStoreMax/lang/fr.json @@ -172,5 +172,7 @@ "Account updated": "Compte mis à jour", "Spend a minimum of": "Dépensez un minimum de", "for": "pour", - "Buy Product": "Acheter un produit" + "Buy Product": "Acheter un produit", + "Retry": "Recommencez", + "Retry later": "Réessayer plus tard" } \ No newline at end of file diff --git a/LabelStoreMax/lang/hi.json b/LabelStoreMax/lang/hi.json index f981092..60744d5 100644 --- a/LabelStoreMax/lang/hi.json +++ b/LabelStoreMax/lang/hi.json @@ -172,5 +172,7 @@ "Account updated": "khaata apadet kiya gaya", "Spend a minimum of": "kam se kam kharch karen", "for": "ke liye", - "Buy Product": "utpaad khareeden" + "Buy Product": "utpaad khareeden", + "Retry": "pun: prayaas karen", + "Retry later": "baad mein pun: prayaas karen" } \ No newline at end of file diff --git a/LabelStoreMax/lang/it.json b/LabelStoreMax/lang/it.json index 768bfeb..2c228cd 100644 --- a/LabelStoreMax/lang/it.json +++ b/LabelStoreMax/lang/it.json @@ -172,5 +172,7 @@ "Account updated": "Account aggiornato", "Spend a minimum of": "Spendi un minimo di", "for": "per", - "Buy Product": "Acquista prodotto" + "Buy Product": "Acquista prodotto", + "Retry": "Riprova", + "Retry later": "Riprova più tardi" } \ No newline at end of file diff --git a/LabelStoreMax/lang/pt.json b/LabelStoreMax/lang/pt.json index 6cc09fa..3b89b13 100644 --- a/LabelStoreMax/lang/pt.json +++ b/LabelStoreMax/lang/pt.json @@ -172,5 +172,7 @@ "Account updated": "Conta atualizada", "Spend a minimum of": "Gaste um mínimo de", "for": "para", - "Buy Product": "Comprar Produto" + "Buy Product": "Comprar Produto", + "Retry": "Tentar novamente", + "Retry later": "Tentar mais tarde" } \ No newline at end of file diff --git a/LabelStoreMax/lib/generated_plugin_registrant.dart b/LabelStoreMax/lib/generated_plugin_registrant.dart new file mode 100644 index 0000000..fb854d7 --- /dev/null +++ b/LabelStoreMax/lib/generated_plugin_registrant.dart @@ -0,0 +1,17 @@ +// +// Generated file. Do not edit. +// + +// ignore_for_file: lines_longer_than_80_chars + +import 'package:shared_preferences_web/shared_preferences_web.dart'; +import 'package:url_launcher_web/url_launcher_web.dart'; + +import 'package:flutter_web_plugins/flutter_web_plugins.dart'; + +// ignore: public_member_api_docs +void registerPlugins(Registrar registrar) { + SharedPreferencesPlugin.registerWith(registrar); + UrlLauncherPlugin.registerWith(registrar); + registrar.registerMessageHandler(); +} diff --git a/LabelStoreMax/lib/helpers/app_helper.dart b/LabelStoreMax/lib/helpers/app_helper.dart new file mode 100644 index 0000000..9547844 --- /dev/null +++ b/LabelStoreMax/lib/helpers/app_helper.dart @@ -0,0 +1,9 @@ +import 'package:woosignal/models/response/woosignal_app.dart'; + +class AppHelper { + AppHelper._privateConstructor(); + + static final AppHelper instance = AppHelper._privateConstructor(); + + WooSignalApp appConfig; +} diff --git a/LabelStoreMax/lib/helpers/app_localizations.dart b/LabelStoreMax/lib/helpers/app_localizations.dart index fc3bb6b..05a865c 100644 --- a/LabelStoreMax/lib/helpers/app_localizations.dart +++ b/LabelStoreMax/lib/helpers/app_localizations.dart @@ -40,9 +40,7 @@ class AppLocalizations { }); } - String trans(String key) { - return _localizedStrings[key]; - } + String trans(String key) => _localizedStrings[key]; } class _AppLocalizationsDelegate diff --git a/LabelStoreMax/lib/helpers/data/order_wc.dart b/LabelStoreMax/lib/helpers/data/order_wc.dart index b531f0f..c4e328d 100644 --- a/LabelStoreMax/lib/helpers/data/order_wc.dart +++ b/LabelStoreMax/lib/helpers/data/order_wc.dart @@ -10,18 +10,20 @@ import 'dart:io'; +import 'package:label_storemax/helpers/app_helper.dart'; import 'package:label_storemax/helpers/shared_pref/sp_user_id.dart'; import 'package:label_storemax/helpers/tools.dart'; -import 'package:label_storemax/labelconfig.dart'; import 'package:label_storemax/models/billing_details.dart'; import 'package:label_storemax/models/cart.dart'; import 'package:label_storemax/models/cart_line_item.dart'; import 'package:label_storemax/models/checkout_session.dart'; import 'package:woosignal/models/payload/order_wc.dart'; import 'package:woosignal/models/response/tax_rate.dart'; +import 'package:woosignal/models/response/woosignal_app.dart'; Future buildOrderWC({TaxRate taxRate, bool markPaid = true}) async { OrderWC orderWC = OrderWC(); + WooSignalApp wooSignalApp = AppHelper.instance.appConfig; String paymentMethodName = CheckoutSession.getInstance.paymentType.name ?? ""; @@ -33,9 +35,9 @@ Future buildOrderWC({TaxRate taxRate, bool markPaid = true}) async { orderWC.setPaid = markPaid; orderWC.status = "pending"; - orderWC.currency = app_currency_iso.toUpperCase(); + orderWC.currency = wooSignalApp.currencyMeta.code.toUpperCase(); orderWC.customerId = - (use_wp_login == true) ? int.parse(await readUserId()) : 0; + (wooSignalApp.wpLoginEnabled == 1) ? int.parse(await readUserId()) : 0; List lineItems = []; List cartItems = await Cart.getInstance.getCart(); @@ -89,7 +91,7 @@ Future buildOrderWC({TaxRate taxRate, bool markPaid = true}) async { orderWC.shipping = shipping; orderWC.shippingLines = []; - if (app_disable_shipping == false) { + if (wooSignalApp.disableShipping != 1) { Map shippingLineFeeObj = CheckoutSession.getInstance.shippingType.toShippingLineFee(); if (shippingLineFeeObj != null) { diff --git a/LabelStoreMax/lib/helpers/shared_pref/sp_user_id.dart b/LabelStoreMax/lib/helpers/shared_pref/sp_user_id.dart index 130a301..17ad4f3 100644 --- a/LabelStoreMax/lib/helpers/shared_pref/sp_user_id.dart +++ b/LabelStoreMax/lib/helpers/shared_pref/sp_user_id.dart @@ -20,8 +20,7 @@ storeUserId(String v) async { Future readUserId() async { SharedPref sharedPref = SharedPref(); - String val = await sharedPref.read(keyUserId); - return val; + return await sharedPref.read(keyUserId); } destroyUserId(BuildContext context) async { diff --git a/LabelStoreMax/lib/helpers/tools.dart b/LabelStoreMax/lib/helpers/tools.dart index 388efd1..152a624 100644 --- a/LabelStoreMax/lib/helpers/tools.dart +++ b/LabelStoreMax/lib/helpers/tools.dart @@ -15,6 +15,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; import 'package:intl/intl.dart'; import 'package:label_storemax/app_payment_methods.dart'; +import 'package:label_storemax/helpers/app_helper.dart'; import 'package:label_storemax/helpers/app_localizations.dart'; import 'package:flutter/material.dart'; import 'package:label_storemax/labelconfig.dart'; @@ -127,7 +128,7 @@ String formatDoubleCurrency({double total}) { FlutterMoneyFormatter fmf = FlutterMoneyFormatter( amount: total, settings: MoneyFormatterSettings( - symbol: app_currency_symbol, + symbol: AppHelper.instance.appConfig.currencyMeta.symbolNative, ), ); return fmf.output.symbolOnLeft; @@ -143,7 +144,7 @@ String formatStringCurrency({@required String total}) { FlutterMoneyFormatter fmf = FlutterMoneyFormatter( amount: tmpVal, settings: MoneyFormatterSettings( - symbol: app_currency_symbol, + symbol: AppHelper.instance.appConfig.currencyMeta.symbolNative, ), ); return fmf.output.symbolOnLeft; @@ -159,7 +160,8 @@ String workoutSaleDiscount( openBrowserTab({@required String url}) async { await FlutterWebBrowser.openWebPage( - url: url, customTabsOptions: CustomTabsOptions(toolbarColor: Colors.white70)); + url: url, + customTabsOptions: CustomTabsOptions(toolbarColor: Colors.white70)); } EdgeInsets safeAreaDefault() { @@ -438,9 +440,7 @@ String dateFormatted({@required String date, @required String formatType}) => enum FormatType { DateTime, - Date, - Time, } @@ -511,8 +511,7 @@ Widget refreshableScroll(context, itemBuilder: (BuildContext context, int index) { return Container( height: 200, - child: wsCardProductItem( - context, + child: ProductItemContainer( index: (index), product: products[index], onTap: onTap, @@ -523,7 +522,7 @@ Widget refreshableScroll(context, mainAxisSpacing: 4.0, crossAxisSpacing: 4.0, ) - : wsNoResults(context)), + : NoProductResults()), ); } @@ -554,11 +553,8 @@ Future> getDefaultShipping(BuildContext context) async { List shipping = []; dataJson.forEach((key, value) { - DefaultShipping defaultShipping = DefaultShipping(); - defaultShipping.code = key; - defaultShipping.country = value['country']; - - defaultShipping.states = []; + DefaultShipping defaultShipping = + DefaultShipping(code: key, country: value['country'], states: []); if (value['states'] != null) { value['states'].forEach((key1, value2) { defaultShipping.states diff --git a/LabelStoreMax/lib/labelconfig.dart b/LabelStoreMax/lib/labelconfig.dart index 01dc0da..ffabb23 100644 --- a/LabelStoreMax/lib/labelconfig.dart +++ b/LabelStoreMax/lib/labelconfig.dart @@ -16,7 +16,7 @@ import 'dart:ui'; Developer Notes SUPPORT EMAIL - support@woosignal.com - VERSION - 2.6.0 + VERSION - 3.0.0 https://woosignal.com */ @@ -29,20 +29,8 @@ const app_key = "Your app key from WooSignal"; // Your App key from WooSignal // link: https://woosignal.com/dashboard/apps -const app_logo_url = "https://woosignal.com/images/120x120_woosignal.png"; - -const app_terms_url = "https://yourdomain.com/terms"; -const app_privacy_url = "https://yourdomain.com/privacy"; - /**/ -const app_currency_symbol = "\£"; -const app_currency_iso = "gbp"; - -const app_products_prices_include_tax = true; - -const app_disable_shipping = false; - const Locale app_locale = Locale('en'); const List app_locales_supported = [ @@ -57,7 +45,8 @@ const List app_locales_supported = [ // then create a new lang json file using keys from en.json // e.g. lang/es.json -const app_product_placeholder_image = "https://woosignal.com/images/woocommerce-placeholder.png"; +const app_product_placeholder_image = + "https://woosignal.com/images/woocommerce-placeholder.png"; /**/ @@ -73,25 +62,12 @@ const app_payment_methods = ["Stripe"]; const app_stripe_account = "Your Stripe Key from WooSignal"; -const app_stripe_live_mode = false; +const app_stripe_live_mode = false; // set to true for live Stripe payments // For Live Payments follow the below steps // #1 SET the above to true for live payments // #2 Next visit https://woosignal.com/dashboard // #3 Then change "Environment for Stripe" to Live mode -/**/ - -// Allows customers to login/register, view account, purchase items as a user. -// #1 Install the "WP JSON API" plugin on WordPress via https://woosignal.com/plugins/wordpress/wp-json-api -// #2 Next activate the plugin on your WordPress and enable "use_wp_login = true" -// link: https://woosignal.com/dashboard/plugins - -const use_wp_login = false; -const app_base_url = "https://mysite.com"; // change to your url -const app_forgot_password_url = - "https://mysite.com/my-account/lost-password"; // change to your forgot password url -const app_wp_api_path = "/wp-json"; // By default "/wp-json" should work - /**/ // https://razorpay.com/ diff --git a/LabelStoreMax/lib/main.dart b/LabelStoreMax/lib/main.dart index 7c8cc62..92afa47 100644 --- a/LabelStoreMax/lib/main.dart +++ b/LabelStoreMax/lib/main.dart @@ -11,7 +11,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:hexcolor/hexcolor.dart'; -import 'package:label_storemax/helpers/shared_pref.dart'; +import 'package:label_storemax/helpers/app_helper.dart'; +import 'package:label_storemax/helpers/tools.dart'; import 'package:label_storemax/pages/account_billing_details.dart'; import 'package:label_storemax/pages/account_detail.dart'; import 'package:label_storemax/pages/account_landing.dart'; @@ -21,11 +22,12 @@ import 'package:label_storemax/pages/account_register.dart'; import 'package:label_storemax/pages/account_shipping_details.dart'; import 'package:label_storemax/pages/customer_countries.dart'; import 'package:label_storemax/pages/error_page.dart'; +import 'package:label_storemax/pages/no_connection_page.dart'; import 'package:label_storemax/pages/product_image_viewer_page.dart'; -import 'package:shared_preferences/shared_preferences.dart'; import 'package:woosignal/models/response/order.dart'; import 'package:woosignal/models/response/product_category.dart'; import 'package:woosignal/models/response/products.dart'; +import 'package:woosignal/models/response/woosignal_app.dart'; import 'package:wp_json_api/wp_json_api.dart'; import 'labelconfig.dart'; import 'package:label_storemax/pages/checkout_details.dart'; @@ -52,18 +54,25 @@ void main() async { await SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, ]); + String initialRoute = '/no-connection'; + WooSignalApp wooSignalApp = await appWooSignal((api) => api.getApp()); - String initialRoute = "/home"; - if (use_wp_login == true) { - WPJsonAPI.instance.initWith( - baseUrl: app_base_url, - shouldDebug: app_debug, - wpJsonPath: app_wp_api_path); + if (wooSignalApp != null) { + initialRoute = "/home"; + AppHelper.instance.appConfig = wooSignalApp; + + if (wooSignalApp.wpLoginEnabled == 1) { + WPJsonAPI.instance.initWith( + baseUrl: wooSignalApp.wpLoginBaseUrl, + shouldDebug: wooSignalApp.appDebug == 1 ? true : false, + wpJsonPath: wooSignalApp.wpLoginWpApiPath, + ); + } } runApp( new MaterialApp( - title: app_name, + title: wooSignalApp?.appName ?? "Label StoreMax", color: Colors.white, debugShowCheckedModeBanner: false, initialRoute: initialRoute, @@ -81,6 +90,7 @@ void main() async { new AccountBillingDetailsPage(), '/account-shipping-details': (BuildContext context) => new AccountShippingDetailsPage(), + '/no-connection': (BuildContext context) => new NoConnectionPage(), }, onGenerateRoute: (settings) { switch (settings.name) { diff --git a/LabelStoreMax/lib/models/cart.dart b/LabelStoreMax/lib/models/cart.dart index 3cd69f1..64094b9 100644 --- a/LabelStoreMax/lib/models/cart.dart +++ b/LabelStoreMax/lib/models/cart.dart @@ -10,8 +10,9 @@ import 'dart:convert'; +import 'package:flutter/cupertino.dart'; +import 'package:label_storemax/helpers/app_helper.dart'; import 'package:label_storemax/helpers/shared_pref.dart'; -import 'package:label_storemax/labelconfig.dart'; import 'package:label_storemax/models/cart_line_item.dart'; import 'package:label_storemax/models/checkout_session.dart'; import 'package:label_storemax/models/shipping_type.dart'; @@ -31,7 +32,7 @@ class Cart { SharedPref sharedPref = SharedPref(); String currentCartArrJSON = (await sharedPref.read(_keyCart) as String); if (currentCartArrJSON == null) { - cartLineItems = List(); + cartLineItems = []; } else { cartLineItems = (jsonDecode(currentCartArrJSON) as List) .map((i) => CartLineItem.fromJson(i)) @@ -40,7 +41,7 @@ class Cart { return cartLineItems; } - void addToCart({CartLineItem cartLineItem}) async { + void addToCart({@required CartLineItem cartLineItem}) async { List cartLineItems = await getCart(); if (cartLineItem.variationId != null) { @@ -52,7 +53,7 @@ class Cart { return; } } else { - var firstCartItem = cartLineItems.firstWhere( + CartLineItem firstCartItem = cartLineItems.firstWhere( (i) => i.productId == cartLineItem.productId, orElse: () => null); if (firstCartItem != null) { @@ -64,7 +65,7 @@ class Cart { saveCartToPref(cartLineItems: cartLineItems); } - Future getTotal({bool withFormat}) async { + Future getTotal({bool withFormat = false}) async { List cartLineItems = await getCart(); double total = 0; cartLineItems.forEach((cartItem) { @@ -77,7 +78,7 @@ class Cart { return total.toStringAsFixed(2); } - Future getSubtotal({bool withFormat}) async { + Future getSubtotal({bool withFormat = false}) async { List cartLineItems = await getCart(); double subtotal = 0; cartLineItems.forEach((cartItem) { @@ -90,9 +91,10 @@ class Cart { } void updateQuantity( - {CartLineItem cartLineItem, int incrementQuantity}) async { + {@required CartLineItem cartLineItem, + @required int incrementQuantity}) async { List cartLineItems = await getCart(); - List tmpCartItem = new List(); + List tmpCartItem = []; cartLineItems.forEach((cartItem) { if (cartItem.variationId == cartLineItem.variationId && cartItem.productId == cartLineItem.productId) { @@ -107,15 +109,14 @@ class Cart { Future cartShortDesc() async { List cartLineItems = await getCart(); - var tmpShortItemDesc = []; - cartLineItems.forEach((cartItem) { - tmpShortItemDesc - .add(cartItem.quantity.toString() + " x | " + cartItem.name); - }); - return tmpShortItemDesc.join(","); + return cartLineItems + .map((cartItem) => + "${cartItem.quantity.toString()} x | ${cartItem.name}") + .toList() + .join(","); } - void removeCartItemForIndex({int index}) async { + void removeCartItemForIndex({@required int index}) async { List cartLineItems = await getCart(); cartLineItems.removeAt(index); saveCartToPref(cartLineItems: cartLineItems); @@ -123,13 +124,13 @@ class Cart { void clear() { SharedPref sharedPref = SharedPref(); - List cartLineItems = new List(); + List cartLineItems = []; String jsonArrCartItems = jsonEncode(cartLineItems.map((i) => i.toJson()).toList()); sharedPref.save(_keyCart, jsonArrCartItems); } - void saveCartToPref({List cartLineItems}) { + void saveCartToPref({@required List cartLineItems}) { SharedPref sharedPref = SharedPref(); String jsonArrCartItems = jsonEncode(cartLineItems.map((i) => i.toJson()).toList()); @@ -149,7 +150,7 @@ class Cart { cartItems.where((c) => c.taxStatus == 'taxable').toList(); double cartSubtotal = 0; - if (app_products_prices_include_tax == false && + if (AppHelper.instance.appConfig.productPricesIncludeTax == 1 && taxableCartLines.length > 0) { cartSubtotal = taxableCartLines .map((m) => parseWcPrice(m.subtotal) * m.quantity) diff --git a/LabelStoreMax/lib/models/checkout_session.dart b/LabelStoreMax/lib/models/checkout_session.dart index 22a818a..5c7ef2f 100644 --- a/LabelStoreMax/lib/models/checkout_session.dart +++ b/LabelStoreMax/lib/models/checkout_session.dart @@ -100,7 +100,7 @@ class CheckoutSession { sharedPref.remove(sfKeyShippingCheckout); } - Future total({bool withFormat, TaxRate taxRate}) async { + Future total({bool withFormat = false, TaxRate taxRate}) async { double totalCart = parseWcPrice(await Cart.getInstance.getTotal()); double totalShipping = 0; if (shippingType != null && shippingType.object != null) { @@ -126,7 +126,7 @@ class CheckoutSession { total += parseWcPrice(taxAmount); } - if (withFormat != null && withFormat == true) { + if (withFormat == true) { return formatDoubleCurrency(total: total); } return total.toStringAsFixed(2); diff --git a/LabelStoreMax/lib/models/customer_address.dart b/LabelStoreMax/lib/models/customer_address.dart index d8c12b0..b5b11d0 100644 --- a/LabelStoreMax/lib/models/customer_address.dart +++ b/LabelStoreMax/lib/models/customer_address.dart @@ -49,7 +49,7 @@ class CustomerAddress { : false); String addressFull() { - List tmpArrAddress = new List(); + List tmpArrAddress = []; if (addressLine != null && addressLine != "") { tmpArrAddress.add(addressLine); } @@ -70,7 +70,7 @@ class CustomerAddress { } String nameFull() { - List tmpArrName = new List(); + List tmpArrName = []; if (firstName != "") { tmpArrName.add(firstName); } diff --git a/LabelStoreMax/lib/models/customer_country.dart b/LabelStoreMax/lib/models/customer_country.dart index ea8d8a8..8e8a786 100644 --- a/LabelStoreMax/lib/models/customer_country.dart +++ b/LabelStoreMax/lib/models/customer_country.dart @@ -29,10 +29,10 @@ class CustomerCountry { if (json == null) { return; } - if (json['country_code'] != null) { + if (json['country_code'] != null) { countryCode = json['country_code']; } - if (json['name'] != null) { + if (json['name'] != null) { name = json['name']; } if (json['state'] != null) { @@ -40,9 +40,8 @@ class CustomerCountry { } } - bool hasState() { - return this.state != null && this.state.name != null ? true : false; - } + bool hasState() => + (this.state != null && this.state.name != null ? true : false); Map toJson() { final Map data = new Map(); diff --git a/LabelStoreMax/lib/models/default_shipping.dart b/LabelStoreMax/lib/models/default_shipping.dart index 057fc38..2bb965e 100644 --- a/LabelStoreMax/lib/models/default_shipping.dart +++ b/LabelStoreMax/lib/models/default_shipping.dart @@ -8,18 +8,21 @@ // 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/cupertino.dart'; + class DefaultShipping { String code; String country; List states; - DefaultShipping({this.code, this.country, this.states}); + DefaultShipping( + {@required this.code, @required this.country, @required this.states}); } class DefaultShippingState { String code; String name; - DefaultShippingState({this.code, this.name}); + DefaultShippingState({@required this.code, @required this.name}); Map toJson() { final Map data = new Map(); @@ -29,9 +32,6 @@ class DefaultShippingState { } DefaultShippingState.fromJson(Map json) { - if (json == null) { - return; - } this.code = json['code']; this.name = json['name']; } diff --git a/LabelStoreMax/lib/models/payment_type.dart b/LabelStoreMax/lib/models/payment_type.dart index 90fec49..2ad9113 100644 --- a/LabelStoreMax/lib/models/payment_type.dart +++ b/LabelStoreMax/lib/models/payment_type.dart @@ -8,6 +8,8 @@ // 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/cupertino.dart'; + class PaymentType { int id; String name; @@ -15,5 +17,10 @@ class PaymentType { String assetImage; Function pay; - PaymentType({this.id, this.name, this.desc, this.assetImage, this.pay}); + PaymentType( + {@required this.id, + @required this.name, + @required this.desc, + @required this.assetImage, + @required this.pay}); } diff --git a/LabelStoreMax/lib/models/shipping_type.dart b/LabelStoreMax/lib/models/shipping_type.dart index a3e3d45..b23b7dd 100644 --- a/LabelStoreMax/lib/models/shipping_type.dart +++ b/LabelStoreMax/lib/models/shipping_type.dart @@ -8,6 +8,7 @@ // 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/cupertino.dart'; import 'package:woosignal/models/response/shipping_method.dart'; import '../helpers/tools.dart'; @@ -18,7 +19,11 @@ class ShippingType { String minimumValue; dynamic object; - ShippingType({this.methodId, this.object, this.cost, this.minimumValue}); + ShippingType( + {@required this.methodId, + this.object, + @required this.cost, + @required this.minimumValue}); Map toJson() => { 'methodId': methodId, @@ -27,8 +32,8 @@ class ShippingType { 'minimumValue': minimumValue }; - String getTotal({bool withFormatting}) { - if (this.methodId != null && this.object != null) { + String getTotal({bool withFormatting = false}) { + if (this.object != null) { switch (this.methodId) { case "flat_rate": FlatRate flatRate = (this.object as FlatRate); @@ -47,14 +52,13 @@ class ShippingType { : localPickup.cost); default: return "0"; - break; } } return "0"; } String getTitle() { - if (this.methodId != null && this.object != null) { + if (this.object != null) { switch (this.methodId) { case "flat_rate": FlatRate flatRate = (this.object as FlatRate); @@ -67,14 +71,13 @@ class ShippingType { return localPickup.title; default: return ""; - break; } } return ""; } Map toShippingLineFee() { - if (this.methodId != null && this.object != null) { + if (this.object != null) { Map tmpShippingLinesObj = {}; switch (this.methodId) { @@ -98,7 +101,6 @@ class ShippingType { break; default: return null; - break; } return tmpShippingLinesObj; } diff --git a/LabelStoreMax/lib/pages/about.dart b/LabelStoreMax/lib/pages/about.dart index 69a7b02..ab0a07c 100644 --- a/LabelStoreMax/lib/pages/about.dart +++ b/LabelStoreMax/lib/pages/about.dart @@ -9,11 +9,12 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. import 'package:flutter/material.dart'; +import 'package:label_storemax/helpers/app_helper.dart'; import 'package:label_storemax/helpers/tools.dart'; -import 'package:label_storemax/labelconfig.dart'; import 'package:label_storemax/widgets/menu_item.dart'; import 'package:label_storemax/widgets/woosignal_ui.dart'; import 'package:package_info/package_info.dart'; +import 'package:woosignal/models/response/woosignal_app.dart'; class AboutPage extends StatefulWidget { AboutPage(); @@ -25,9 +26,12 @@ class AboutPage extends StatefulWidget { class _AboutPageState extends State { _AboutPageState(); + WooSignalApp _wooSignalApp; + @override void initState() { super.initState(); + _wooSignalApp = AppHelper.instance.appConfig; } @override @@ -48,11 +52,11 @@ class _AboutPageState extends State { body: SafeArea( minimum: safeAreaDefault(), child: Column( - mainAxisAlignment: MainAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Flexible( - child: storeLogo(), + Expanded( + child: Center(child: StoreLogo()), flex: 2, ), Flexible( @@ -60,14 +64,12 @@ class _AboutPageState extends State { crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - wsMenuItem( - context, + MenuItem( title: trans(context, "Privacy policy"), leading: Icon(Icons.people), action: _actionPrivacy, ), - wsMenuItem( - context, + MenuItem( title: trans(context, "Terms and conditions"), leading: Icon(Icons.description), action: _actionTerms, @@ -106,11 +108,7 @@ class _AboutPageState extends State { ); } - void _actionTerms() { - openBrowserTab(url: app_terms_url); - } + void _actionTerms() => openBrowserTab(url: _wooSignalApp.appTermslink); - void _actionPrivacy() { - openBrowserTab(url: app_privacy_url); - } + void _actionPrivacy() => openBrowserTab(url: _wooSignalApp.appPrivacylink); } diff --git a/LabelStoreMax/lib/pages/account_billing_details.dart b/LabelStoreMax/lib/pages/account_billing_details.dart index bbeaba6..70c65d2 100644 --- a/LabelStoreMax/lib/pages/account_billing_details.dart +++ b/LabelStoreMax/lib/pages/account_billing_details.dart @@ -32,31 +32,19 @@ class _AccountBillingDetailsPageState extends State { _AccountBillingDetailsPageState(); // BILLING TEXT CONTROLLERS - TextEditingController _txtShippingFirstName; - TextEditingController _txtShippingLastName; - TextEditingController _txtShippingAddressLine; - TextEditingController _txtShippingCity; - TextEditingController _txtShippingState; - TextEditingController _txtShippingPostalCode; - TextEditingController _txtShippingCountry; + TextEditingController _txtShippingFirstName = TextEditingController(); + TextEditingController _txtShippingLastName = TextEditingController(); + TextEditingController _txtShippingAddressLine = TextEditingController(); + TextEditingController _txtShippingCity = TextEditingController(); + TextEditingController _txtShippingState = TextEditingController(); + TextEditingController _txtShippingPostalCode = TextEditingController(); + TextEditingController _txtShippingCountry = TextEditingController(); - bool _isLoading, _isUpdating; + bool _isLoading = true, _isUpdating = false; @override void initState() { super.initState(); - - _txtShippingFirstName = TextEditingController(); - _txtShippingLastName = TextEditingController(); - _txtShippingAddressLine = TextEditingController(); - _txtShippingCity = TextEditingController(); - _txtShippingState = TextEditingController(); - _txtShippingPostalCode = TextEditingController(); - _txtShippingCountry = TextEditingController(); - - _isLoading = true; - _isUpdating = false; - _fetchUserDetails(); } @@ -84,7 +72,7 @@ class _AccountBillingDetailsPageState extends State { @override Widget build(BuildContext context) { return Scaffold( - resizeToAvoidBottomPadding: false, + resizeToAvoidBottomInset: false, appBar: AppBar( backgroundColor: Colors.transparent, title: Text( @@ -113,16 +101,14 @@ class _AccountBillingDetailsPageState extends State { Row( children: [ Flexible( - child: wsTextEditingRow( - context, + child: TextEditingRow( heading: trans(context, "First Name"), controller: _txtShippingFirstName, shouldAutoFocus: true, ), ), Flexible( - child: wsTextEditingRow( - context, + child: TextEditingRow( heading: trans(context, "Last Name"), controller: _txtShippingLastName, ), @@ -132,21 +118,19 @@ class _AccountBillingDetailsPageState extends State { mainAxisAlignment: MainAxisAlignment.spaceEvenly, ), - wsTextEditingRow( - context, + TextEditingRow( heading: trans(context, "Address Line"), controller: _txtShippingAddressLine, ), Row(children: [ Flexible( - child: wsTextEditingRow( - context, + child: TextEditingRow( heading: trans(context, "City"), controller: _txtShippingCity, ), ), Flexible( - child: wsTextEditingRow(context, + child: TextEditingRow( heading: trans(context, "State"), keyboardType: TextInputType.emailAddress, controller: _txtShippingState), @@ -155,14 +139,13 @@ class _AccountBillingDetailsPageState extends State { Row( children: [ Flexible( - child: wsTextEditingRow( - context, + child: TextEditingRow( heading: trans(context, "Postal code"), controller: _txtShippingPostalCode, ), ), Flexible( - child: wsTextEditingRow(context, + child: TextEditingRow( heading: trans(context, "Country"), keyboardType: TextInputType.emailAddress, @@ -198,10 +181,10 @@ class _AccountBillingDetailsPageState extends State { ), Column( children: [ - wsPrimaryButton(context, + PrimaryButton( title: trans(context, "UPDATE DETAILS"), action: - _isUpdating ? null : _updateBillingDetails), + _isUpdating ? () {} : _updateBillingDetails), ], ), ], diff --git a/LabelStoreMax/lib/pages/account_detail.dart b/LabelStoreMax/lib/pages/account_detail.dart index dcb8f92..e0f8818 100644 --- a/LabelStoreMax/lib/pages/account_detail.dart +++ b/LabelStoreMax/lib/pages/account_detail.dart @@ -32,12 +32,14 @@ class _AccountDetailPageState extends State RefreshController _refreshController = RefreshController(initialRefresh: false); - bool _shouldStopRequests, waitForNextRequest, _isLoading, _isLoadingOrders; + bool _shouldStopRequests = false, + waitForNextRequest = false, + _isLoading = true, + _isLoadingOrders = true; - int _page; - List _orders; + int _page = 1, _currentTabIndex = 0; + List _orders = []; WCCustomerInfoResponse _wcCustomerInfoResponse; - int _currentTabIndex = 0; Widget _activeBody; TabController _tabController; @@ -46,11 +48,6 @@ class _AccountDetailPageState extends State @override void initState() { super.initState(); - _shouldStopRequests = false; - waitForNextRequest = false; - - _isLoading = true; - _isLoadingOrders = true; _page = 1; _orders = []; _tabs = [ @@ -117,7 +114,7 @@ class _AccountDetailPageState extends State ), centerTitle: true, ), - resizeToAvoidBottomPadding: false, + resizeToAvoidBottomInset: false, body: SafeArea( minimum: safeAreaDefault(), child: _isLoading @@ -337,7 +334,7 @@ class _AccountDetailPageState extends State controller: _refreshController, onRefresh: _onRefresh, onLoading: _onLoading, - child: (_orders.length != null && _orders.length > 0 + child: (_orders.length > 0 ? ListView.builder( itemBuilder: (cxt, i) { return Card( @@ -482,12 +479,9 @@ class _AccountDetailPageState extends State } } - _viewProfileDetail(int i) { - int orderId = _orders[i].id; - Navigator.pushNamed( - context, - "/account-order-detail", - arguments: orderId, - ); - } + _viewProfileDetail(int i) => Navigator.pushNamed( + context, + "/account-order-detail", + arguments: _orders[i].id, + ); } diff --git a/LabelStoreMax/lib/pages/account_landing.dart b/LabelStoreMax/lib/pages/account_landing.dart index eab4e92..47b3205 100644 --- a/LabelStoreMax/lib/pages/account_landing.dart +++ b/LabelStoreMax/lib/pages/account_landing.dart @@ -10,10 +10,10 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:label_storemax/helpers/app_helper.dart'; import 'package:label_storemax/helpers/shared_pref/sp_auth.dart'; import 'package:label_storemax/helpers/shared_pref/sp_user_id.dart'; import 'package:label_storemax/helpers/tools.dart'; -import 'package:label_storemax/labelconfig.dart'; import 'package:label_storemax/widgets/buttons.dart'; import 'package:label_storemax/widgets/woosignal_ui.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -32,23 +32,20 @@ class AccountLandingPage extends StatefulWidget { } class _AccountLandingPageState extends State { - bool _hasTappedLogin; - TextEditingController _tfEmailController, _tfPasswordController; + bool _hasTappedLogin = false; + TextEditingController _tfEmailController = TextEditingController(), + _tfPasswordController = TextEditingController(); @override void initState() { super.initState(); - - _hasTappedLogin = false; - _tfEmailController = TextEditingController(); - _tfPasswordController = TextEditingController(); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, - resizeToAvoidBottomPadding: false, + resizeToAvoidBottomInset: false, body: SafeArea( child: Column( crossAxisAlignment: CrossAxisAlignment.center, @@ -59,7 +56,7 @@ class _AccountLandingPageState extends State { crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.start, children: [ - storeLogo(height: 100), + StoreLogo(height: 100), Flexible( child: Container( height: 70, @@ -91,19 +88,18 @@ class _AccountLandingPageState extends State { crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - wsTextEditingRow(context, + TextEditingRow( heading: trans(context, "Email"), controller: _tfEmailController, keyboardType: TextInputType.emailAddress), - wsTextEditingRow(context, + TextEditingRow( heading: trans(context, "Password"), controller: _tfPasswordController, keyboardType: TextInputType.visiblePassword, obscureText: true), - wsPrimaryButton( - context, + PrimaryButton( title: trans(context, "Login"), - action: _hasTappedLogin == true ? null : _loginUser, + action: _hasTappedLogin == true ? () {} : _loginUser, ), ], ), @@ -111,7 +107,7 @@ class _AccountLandingPageState extends State { ], ), ), - FlatButton( + TextButton( child: Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, @@ -133,12 +129,15 @@ class _AccountLandingPageState extends State { Navigator.pushNamed(context, "/account-register"); }, ), - wsLinkButton(context, title: trans(context, "Forgot Password"), + LinkButton( + title: trans(context, "Forgot Password"), action: () { - launch(app_forgot_password_url); - }), + String forgotPasswordUrl = + AppHelper.instance.appConfig.wpLoginForgotPasswordUrl; + launch(forgotPasswordUrl); + }), Divider(), - wsLinkButton(context, + LinkButton( title: trans(context, "Back"), action: () => Navigator.pop(context)), ], @@ -151,7 +150,7 @@ class _AccountLandingPageState extends State { String email = _tfEmailController.text; String password = _tfPasswordController.text; - if (email != null) { + if (email.isNotEmpty) { email = email.trim(); } diff --git a/LabelStoreMax/lib/pages/account_order_detail.dart b/LabelStoreMax/lib/pages/account_order_detail.dart index e827284..5c29ff7 100644 --- a/LabelStoreMax/lib/pages/account_order_detail.dart +++ b/LabelStoreMax/lib/pages/account_order_detail.dart @@ -19,24 +19,21 @@ import 'package:woosignal/models/response/order.dart'; class AccountOrderDetailPage extends StatefulWidget { final int orderId; - AccountOrderDetailPage({Key key, this.orderId}) : super(key: key); + AccountOrderDetailPage({Key key, @required this.orderId}) : super(key: key); @override - _AccountOrderDetailPageState createState() => - _AccountOrderDetailPageState(this.orderId); + _AccountOrderDetailPageState createState() => _AccountOrderDetailPageState(); } class _AccountOrderDetailPageState extends State { - _AccountOrderDetailPageState(this._orderId); + _AccountOrderDetailPageState(); - int _orderId; Order _order; - bool _isLoading; + bool _isLoading = true; @override void initState() { super.initState(); - _isLoading = true; _fetchOrder(); } @@ -53,12 +50,12 @@ class _AccountOrderDetailPageState extends State { margin: EdgeInsets.only(left: 0), ), title: Text( - "${capitalize(trans(context, "Order"))} #${_orderId.toString()}", + "${capitalize(trans(context, "Order"))} #${widget.orderId.toString()}", style: Theme.of(context).primaryTextTheme.headline6, ), centerTitle: true, ), - resizeToAvoidBottomPadding: false, + resizeToAvoidBottomInset: false, body: SafeArea( minimum: safeAreaDefault(), child: _isLoading @@ -173,9 +170,7 @@ class _AccountOrderDetailPageState extends State { textAlign: TextAlign.left, ), Text( - "x" + - _order.lineItems[i].quantity - .toString(), + "x${_order.lineItems[i].quantity.toString()}", style: Theme.of(context) .primaryTextTheme .bodyText1 @@ -209,7 +204,7 @@ class _AccountOrderDetailPageState extends State { _fetchOrder() async { _order = await appWooSignal((api) { - return api.retrieveOrder(_orderId); + return api.retrieveOrder(widget.orderId); }); if (_order != null) { setState(() { diff --git a/LabelStoreMax/lib/pages/account_profile_update.dart b/LabelStoreMax/lib/pages/account_profile_update.dart index 533aa9c..f921ec3 100644 --- a/LabelStoreMax/lib/pages/account_profile_update.dart +++ b/LabelStoreMax/lib/pages/account_profile_update.dart @@ -30,8 +30,9 @@ class AccountProfileUpdatePage extends StatefulWidget { class _AccountProfileUpdatePageState extends State { _AccountProfileUpdatePageState(); - bool isLoading; - TextEditingController _tfFirstName, _tfLastName; + bool isLoading = true; + TextEditingController _tfFirstName = TextEditingController(), + _tfLastName = TextEditingController(); @override void dispose() { @@ -41,11 +42,6 @@ class _AccountProfileUpdatePageState extends State { @override void initState() { super.initState(); - - isLoading = true; - _tfFirstName = TextEditingController(); - _tfLastName = TextEditingController(); - _fetchUserDetails(); } @@ -91,16 +87,14 @@ class _AccountProfileUpdatePageState extends State { child: Row( children: [ Flexible( - child: wsTextEditingRow( - context, + child: TextEditingRow( heading: trans(context, "First Name"), controller: _tfFirstName, keyboardType: TextInputType.text, ), ), Flexible( - child: wsTextEditingRow( - context, + child: TextEditingRow( heading: trans(context, "Last Name"), controller: _tfLastName, keyboardType: TextInputType.text, @@ -115,7 +109,7 @@ class _AccountProfileUpdatePageState extends State { Padding( padding: EdgeInsets.only(top: 10), ), - wsPrimaryButton(context, + PrimaryButton( title: trans(context, "Update details"), action: _updateDetails) ], diff --git a/LabelStoreMax/lib/pages/account_register.dart b/LabelStoreMax/lib/pages/account_register.dart index 8fca8cc..27cc99a 100644 --- a/LabelStoreMax/lib/pages/account_register.dart +++ b/LabelStoreMax/lib/pages/account_register.dart @@ -9,13 +9,14 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. import 'package:flutter/material.dart'; +import 'package:label_storemax/helpers/app_helper.dart'; import 'package:label_storemax/helpers/shared_pref/sp_auth.dart'; import 'package:label_storemax/helpers/shared_pref/sp_user_id.dart'; import 'package:label_storemax/helpers/tools.dart'; -import 'package:label_storemax/labelconfig.dart'; import 'package:label_storemax/widgets/buttons.dart'; import 'package:label_storemax/widgets/woosignal_ui.dart'; import 'package:woosignal/helpers/shared_pref.dart'; +import 'package:woosignal/models/response/woosignal_app.dart'; import 'package:wp_json_api/exceptions/empty_username_exception.dart'; import 'package:wp_json_api/exceptions/existing_user_email_exception.dart'; import 'package:wp_json_api/exceptions/existing_user_login_exception.dart'; @@ -36,21 +37,16 @@ class AccountRegistrationPage extends StatefulWidget { class _AccountRegistrationPageState extends State { _AccountRegistrationPageState(); - bool _hasTappedRegister; - TextEditingController _tfEmailAddressController; - TextEditingController _tfPasswordController; - TextEditingController _tfFirstNameController; - TextEditingController _tfLastNameController; + bool _hasTappedRegister = false; + TextEditingController _tfEmailAddressController = TextEditingController(); + TextEditingController _tfPasswordController = TextEditingController(); + TextEditingController _tfFirstNameController = TextEditingController(); + TextEditingController _tfLastNameController = TextEditingController(); + WooSignalApp _wooSignalApp = AppHelper.instance.appConfig; @override void initState() { super.initState(); - - _hasTappedRegister = false; - _tfEmailAddressController = TextEditingController(); - _tfPasswordController = TextEditingController(); - _tfFirstNameController = TextEditingController(); - _tfLastNameController = TextEditingController(); } @override @@ -68,7 +64,7 @@ class _AccountRegistrationPageState extends State { ), centerTitle: true, ), - resizeToAvoidBottomPadding: false, + resizeToAvoidBottomInset: false, body: SafeArea( minimum: safeAreaDefault(), child: Column( @@ -78,8 +74,7 @@ class _AccountRegistrationPageState extends State { child: Row( children: [ Flexible( - child: wsTextEditingRow( - context, + child: TextEditingRow( heading: trans(context, "First Name"), controller: _tfFirstNameController, shouldAutoFocus: true, @@ -87,8 +82,7 @@ class _AccountRegistrationPageState extends State { ), ), Flexible( - child: wsTextEditingRow( - context, + child: TextEditingRow( heading: trans(context, "Last Name"), controller: _tfLastNameController, shouldAutoFocus: false, @@ -97,24 +91,22 @@ class _AccountRegistrationPageState extends State { ), ], )), - wsTextEditingRow( - context, + TextEditingRow( heading: trans(context, "Email address"), controller: _tfEmailAddressController, shouldAutoFocus: false, keyboardType: TextInputType.emailAddress, ), - wsTextEditingRow( - context, + TextEditingRow( heading: trans(context, "Password"), controller: _tfPasswordController, shouldAutoFocus: true, obscureText: true, ), Padding( - child: wsPrimaryButton(context, + child: PrimaryButton( title: trans(context, "Sign up"), - action: _hasTappedRegister ? null : _signUpTapped), + action: _hasTappedRegister ? () {} : _signUpTapped), padding: EdgeInsets.only(top: 10), ), Padding( @@ -123,7 +115,7 @@ class _AccountRegistrationPageState extends State { text: TextSpan( text: trans( context, "By tapping \"Register\" you agree to ") + - app_name + + AppHelper.instance.appConfig.appName + '\'s ', children: [ TextSpan( @@ -154,7 +146,7 @@ class _AccountRegistrationPageState extends State { String firstName = _tfFirstNameController.text; String lastName = _tfLastNameController.text; - if (email != null) { + if (email.isNotEmpty) { email = email.trim(); } @@ -180,7 +172,7 @@ class _AccountRegistrationPageState extends State { }); String username = - (email.replaceAll(new RegExp(r'(@|\.)'), "")) + randomStr(4); + (email.replaceAll(new RegExp(r'([@.])'), "")) + randomStr(4); WPUserRegisterResponse wpUserRegisterResponse; try { @@ -243,7 +235,7 @@ class _AccountRegistrationPageState extends State { .wpUpdateUserInfo(token, firstName: firstName, lastName: lastName)); showEdgeAlertWith(context, - title: trans(context, "Hello") + " $firstName", + title: "${trans(context, "Hello")} $firstName", desc: trans(context, "you're now logged in"), style: EdgeAlertStyle.SUCCESS, icon: Icons.account_circle); @@ -254,26 +246,28 @@ class _AccountRegistrationPageState extends State { } _viewTOSModal() { - showPlatformAlertDialog(context, - title: trans(context, "Actions"), - subtitle: trans(context, "View Terms and Conditions or Privacy policy"), - actions: [ - dialogAction(context, - title: trans(context, "Terms and Conditions"), - action: _viewTermsConditions), - dialogAction(context, - title: trans(context, "Privacy Policy"), - action: _viewPrivacyPolicy), - ]); + showPlatformAlertDialog( + context, + title: trans(context, "Actions"), + subtitle: trans(context, "View Terms and Conditions or Privacy policy"), + actions: [ + dialogAction(context, + title: trans(context, "Terms and Conditions"), + action: _viewTermsConditions), + dialogAction(context, + title: trans(context, "Privacy Policy"), + action: _viewPrivacyPolicy), + ], + ); } void _viewTermsConditions() { Navigator.pop(context); - openBrowserTab(url: app_terms_url); + openBrowserTab(url: _wooSignalApp.appTermslink); } void _viewPrivacyPolicy() { Navigator.pop(context); - openBrowserTab(url: app_privacy_url); + openBrowserTab(url: _wooSignalApp.appPrivacylink); } } diff --git a/LabelStoreMax/lib/pages/account_shipping_details.dart b/LabelStoreMax/lib/pages/account_shipping_details.dart index 0c72499..1faade8 100644 --- a/LabelStoreMax/lib/pages/account_shipping_details.dart +++ b/LabelStoreMax/lib/pages/account_shipping_details.dart @@ -33,31 +33,19 @@ class _AccountShippingDetailsPageState _AccountShippingDetailsPageState(); // BILLING TEXT CONTROLLERS - TextEditingController _txtShippingFirstName; - TextEditingController _txtShippingLastName; - TextEditingController _txtShippingAddressLine; - TextEditingController _txtShippingCity; - TextEditingController _txtShippingPostalCode; - TextEditingController _txtShippingState; - TextEditingController _txtShippingCountry; + TextEditingController _txtShippingFirstName = TextEditingController(); + TextEditingController _txtShippingLastName = TextEditingController(); + TextEditingController _txtShippingAddressLine = TextEditingController(); + TextEditingController _txtShippingCity = TextEditingController(); + TextEditingController _txtShippingPostalCode = TextEditingController(); + TextEditingController _txtShippingState = TextEditingController(); + TextEditingController _txtShippingCountry = TextEditingController(); - bool _isLoading, _isUpdating; + bool _isLoading = true, _isUpdating = false; @override void initState() { super.initState(); - - _txtShippingFirstName = TextEditingController(); - _txtShippingLastName = TextEditingController(); - _txtShippingAddressLine = TextEditingController(); - _txtShippingCity = TextEditingController(); - _txtShippingPostalCode = TextEditingController(); - _txtShippingState = TextEditingController(); - _txtShippingCountry = TextEditingController(); - - _isLoading = true; - _isUpdating = false; - _fetchUserDetails(); } @@ -100,7 +88,7 @@ class _AccountShippingDetailsPageState @override Widget build(BuildContext context) { return Scaffold( - resizeToAvoidBottomPadding: false, + resizeToAvoidBottomInset: false, appBar: AppBar( backgroundColor: Colors.transparent, title: Text( @@ -131,16 +119,14 @@ class _AccountShippingDetailsPageState Row( children: [ Flexible( - child: wsTextEditingRow( - context, + child: TextEditingRow( heading: trans(context, "First Name"), controller: _txtShippingFirstName, shouldAutoFocus: true, ), ), Flexible( - child: wsTextEditingRow( - context, + child: TextEditingRow( heading: trans(context, "Last Name"), controller: _txtShippingLastName, ), @@ -150,22 +136,19 @@ class _AccountShippingDetailsPageState mainAxisAlignment: MainAxisAlignment.spaceEvenly, ), - wsTextEditingRow( - context, + TextEditingRow( heading: trans(context, "Address Line"), controller: _txtShippingAddressLine, ), Row(children: [ Flexible( - child: wsTextEditingRow( - context, + child: TextEditingRow( heading: trans(context, "City"), controller: _txtShippingCity, ), ), Flexible( - child: wsTextEditingRow( - context, + child: TextEditingRow( heading: trans(context, "State"), controller: _txtShippingState, ), @@ -174,15 +157,13 @@ class _AccountShippingDetailsPageState Row( children: [ Flexible( - child: wsTextEditingRow( - context, + child: TextEditingRow( heading: trans(context, "Postal code"), controller: _txtShippingPostalCode, ), ), Flexible( - child: wsTextEditingRow( - context, + child: TextEditingRow( heading: trans(context, "Country"), controller: _txtShippingCountry, ), @@ -218,10 +199,10 @@ class _AccountShippingDetailsPageState ), Column( children: [ - wsPrimaryButton(context, + PrimaryButton( title: trans(context, "UPDATE DETAILS"), action: - _isUpdating ? null : _updateShippingDetails), + _isUpdating ? () {} : _updateShippingDetails), ], ), ], diff --git a/LabelStoreMax/lib/pages/browse_category.dart b/LabelStoreMax/lib/pages/browse_category.dart index a459d4e..ec6c009 100644 --- a/LabelStoreMax/lib/pages/browse_category.dart +++ b/LabelStoreMax/lib/pages/browse_category.dart @@ -25,42 +25,38 @@ class BrowseCategoryPage extends StatefulWidget { : super(key: key); @override - _BrowseCategoryPageState createState() => - _BrowseCategoryPageState(productCategory); + _BrowseCategoryPageState createState() => _BrowseCategoryPageState(); } class _BrowseCategoryPageState extends State { - _BrowseCategoryPageState(this._selectedCategory); + _BrowseCategoryPageState(); List _products = []; RefreshController _refreshController = RefreshController(initialRefresh: false); - ProductCategory _selectedCategory; - int _page; - bool _shouldStopRequests, waitForNextRequest, _isLoading; + int _page = 1; + bool _shouldStopRequests = false, + waitForNextRequest = false, + _isLoading = true; @override void initState() { super.initState(); - - _isLoading = true; - - _page = 1; - _shouldStopRequests = false; - waitForNextRequest = false; _fetchMoreProducts(); } _fetchMoreProducts() async { waitForNextRequest = true; - List products = await appWooSignal((api) => api.getProducts( - perPage: 50, - category: _selectedCategory.id.toString(), - page: _page, - status: "publish", - stockStatus: "instock")); + List products = await appWooSignal( + (api) => api.getProducts( + perPage: 50, + category: widget.productCategory.id.toString(), + page: _page, + status: "publish", + stockStatus: "instock"), + ); _products.addAll(products); waitForNextRequest = false; _page = _page + 1; @@ -90,7 +86,7 @@ class _BrowseCategoryPageState extends State { children: [ Text(trans(context, "Browse"), style: Theme.of(context).primaryTextTheme.subtitle1), - Text(parseHtmlString(_selectedCategory.name), + Text(parseHtmlString(widget.productCategory.name), style: Theme.of(context).primaryTextTheme.headline6) ], ), @@ -176,32 +172,31 @@ class _BrowseCategoryPageState extends State { title: trans(context, "Sort results"), bodyWidget: ListView( children: [ - wsLinkButton(context, + LinkButton( title: trans(context, "Sort: Low to high"), action: () => _sortProducts(by: SortByType.LowToHigh)), Divider( height: 0, ), - wsLinkButton(context, + LinkButton( title: trans(context, "Sort: High to low"), action: () => _sortProducts(by: SortByType.HighToLow)), Divider( height: 0, ), - wsLinkButton(context, + LinkButton( title: trans(context, "Sort: Name A-Z"), action: () => _sortProducts(by: SortByType.NameAZ)), Divider( height: 0, ), - wsLinkButton(context, + LinkButton( title: trans(context, "Sort: Name Z-A"), action: () => _sortProducts(by: SortByType.NameZA)), Divider( height: 0, ), - wsLinkButton(context, - title: trans(context, "Cancel"), action: _dismissModal) + LinkButton(title: trans(context, "Cancel"), action: _dismissModal) ], ), ); diff --git a/LabelStoreMax/lib/pages/browse_search.dart b/LabelStoreMax/lib/pages/browse_search.dart index 59804dd..ec554d2 100644 --- a/LabelStoreMax/lib/pages/browse_search.dart +++ b/LabelStoreMax/lib/pages/browse_search.dart @@ -30,18 +30,14 @@ class _BrowseSearchState extends State { List _products = []; String _search; - int _page; - bool _shouldStopRequests, waitForNextRequest, _isLoading; + int _page = 1; + bool _shouldStopRequests = false, + waitForNextRequest = false, + _isLoading = true; @override void initState() { super.initState(); - - _isLoading = true; - _page = 1; - _shouldStopRequests = false; - waitForNextRequest = false; - _fetchProductsForSearch(); } @@ -49,11 +45,12 @@ class _BrowseSearchState extends State { waitForNextRequest = true; List products = await appWooSignal( (api) => api.getProducts( - perPage: 100, - search: _search, - page: _page, - status: "publish", - stockStatus: "instock"), + perPage: 100, + search: _search, + page: _page, + status: "publish", + stockStatus: "instock", + ), ); _products.addAll(products); waitForNextRequest = false; diff --git a/LabelStoreMax/lib/pages/cart.dart b/LabelStoreMax/lib/pages/cart.dart index e9f8f8c..e8a128f 100644 --- a/LabelStoreMax/lib/pages/cart.dart +++ b/LabelStoreMax/lib/pages/cart.dart @@ -10,9 +10,9 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:label_storemax/helpers/app_helper.dart'; import 'package:label_storemax/helpers/shared_pref/sp_auth.dart'; import 'package:label_storemax/helpers/tools.dart'; -import 'package:label_storemax/labelconfig.dart'; import 'package:label_storemax/models/cart.dart'; import 'package:label_storemax/models/cart_line_item.dart'; import 'package:label_storemax/models/checkout_session.dart'; @@ -31,15 +31,12 @@ class CartPage extends StatefulWidget { class _CartPageState extends State { _CartPageState(); - bool _isLoading = false; - bool _isCartEmpty = false; - List _cartLines; + bool _isLoading = true, _isCartEmpty = false; + List _cartLines = []; @override void initState() { super.initState(); - _cartLines = []; - _isLoading = true; _cartCheck(); } @@ -115,7 +112,8 @@ class _CartPageState extends State { sfCustomerAddress; } - if (use_wp_login == true && !(await authCheck())) { + if (AppHelper.instance.appConfig.wpLoginEnabled == 1 && + !(await authCheck())) { UserAuth.instance.redirect = "/checkout"; Navigator.pushNamed(context, "/account-landing"); return; @@ -183,7 +181,7 @@ class _CartPageState extends State { @override Widget build(BuildContext context) { return Scaffold( - resizeToAvoidBottomPadding: false, + resizeToAvoidBottomInset: false, appBar: AppBar( title: Text( trans(context, "Shopping Cart"), @@ -252,8 +250,7 @@ class _CartPageState extends State { itemCount: _cartLines.length, itemBuilder: (BuildContext context, int index) { CartLineItem cartLineItem = _cartLines[index]; - return wsCardCartItem( - context, + return CartItemContainer( cartLineItem: cartLineItem, actionIncrementQuantity: () => actionIncrementQuantity( @@ -291,8 +288,7 @@ class _CartPageState extends State { } }, ), - wsPrimaryButton( - context, + PrimaryButton( title: trans(context, "PROCEED TO CHECKOUT"), action: _actionProceedToCheckout, ), diff --git a/LabelStoreMax/lib/pages/checkout_confirmation.dart b/LabelStoreMax/lib/pages/checkout_confirmation.dart index 8140963..c134f9c 100644 --- a/LabelStoreMax/lib/pages/checkout_confirmation.dart +++ b/LabelStoreMax/lib/pages/checkout_confirmation.dart @@ -10,8 +10,8 @@ import 'package:flutter/material.dart'; import 'package:label_storemax/app_payment_methods.dart'; +import 'package:label_storemax/helpers/app_helper.dart'; import 'package:label_storemax/helpers/tools.dart'; -import 'package:label_storemax/labelconfig.dart'; import 'package:label_storemax/models/cart.dart'; import 'package:label_storemax/models/checkout_session.dart'; import 'package:label_storemax/models/customer_address.dart'; @@ -20,6 +20,7 @@ import 'package:label_storemax/widgets/app_loader.dart'; import 'package:label_storemax/widgets/buttons.dart'; import 'package:label_storemax/widgets/woosignal_ui.dart'; import 'package:woosignal/models/response/tax_rate.dart'; +import 'package:woosignal/models/response/woosignal_app.dart'; class CheckoutConfirmationPage extends StatefulWidget { CheckoutConfirmationPage({Key key}) : super(key: key); @@ -32,17 +33,18 @@ class CheckoutConfirmationPage extends StatefulWidget { class CheckoutConfirmationPageState extends State { CheckoutConfirmationPageState(); - bool _showFullLoader, _isProcessingPayment; + bool _showFullLoader = true, _isProcessingPayment = false; List _taxRates; TaxRate _taxRate; + WooSignalApp _wooSignalApp; @override void initState() { super.initState(); + _wooSignalApp = AppHelper.instance.appConfig; _taxRates = []; - _showFullLoader = true; - _isProcessingPayment = false; + if (CheckoutSession.getInstance.paymentType == null) { CheckoutSession.getInstance.paymentType = arrPaymentMethods.first; } @@ -100,29 +102,26 @@ class CheckoutConfirmationPageState extends State { TaxRate taxRate; if (shippingCountry.hasState()) { - taxRate = _taxRates.firstWhere( - (t) { - if (shippingCountry == null || - (shippingCountry?.state?.code ?? "") == "") { - return false; - } - - List stateElements = shippingCountry.state.code.split(":"); - String state = stateElements.last; - - if (t.country == shippingCountry.countryCode && - t.state == state && - t.postcode == postalCode) { - return true; - } - - if (t.country == shippingCountry.countryCode && t.state == state) { - return true; - } + taxRate = _taxRates.firstWhere((t) { + if (shippingCountry == null || + (shippingCountry?.state?.code ?? "") == "") { return false; - }, - orElse: () => null, - ); + } + + List stateElements = shippingCountry.state.code.split(":"); + String state = stateElements.last; + + if (t.country == shippingCountry.countryCode && + t.state == state && + t.postcode == postalCode) { + return true; + } + + if (t.country == shippingCountry.countryCode && t.state == state) { + return true; + } + return false; + }, orElse: () => null); } if (taxRate == null) { @@ -183,10 +182,10 @@ class CheckoutConfirmationPageState extends State { return Scaffold( appBar: AppBar( backgroundColor: Colors.transparent, - title: storeLogo(height: 50), + title: StoreLogo(height: 50), centerTitle: true, ), - resizeToAvoidBottomPadding: false, + resizeToAvoidBottomInset: false, body: SafeArea( minimum: safeAreaDefault(), child: !_showFullLoader @@ -260,7 +259,7 @@ class CheckoutConfirmationPageState extends State { context, "Select a payment method"), action: _actionPayWith, showBorderBottom: true)), - app_disable_shipping == true + _wooSignalApp.disableShipping == 1 ? null : (CheckoutSession.getInstance.shippingType != null @@ -295,7 +294,7 @@ class CheckoutConfirmationPageState extends State { wsCheckoutSubtotalWidgetFB( title: trans(context, "Subtotal"), ), - app_disable_shipping == true + _wooSignalApp.disableShipping == 1 ? null : widgetCheckoutMeta(context, title: trans(context, "Shipping fee"), @@ -316,8 +315,7 @@ class CheckoutConfirmationPageState extends State { ), ].where((e) => e != null).toList(), ), - wsPrimaryButton( - context, + PrimaryButton( title: _isProcessingPayment ? "PROCESSING..." : trans(context, "CHECKOUT"), @@ -369,7 +367,7 @@ class CheckoutConfirmationPageState extends State { return; } - if (app_disable_shipping == false && + if (_wooSignalApp.disableShipping == 1 && CheckoutSession.getInstance.shippingType == null) { showEdgeAlertWith( context, @@ -392,7 +390,7 @@ class CheckoutConfirmationPageState extends State { return; } - if (app_disable_shipping == false && + if (_wooSignalApp.disableShipping != 1 && CheckoutSession.getInstance.shippingType.minimumValue != null) { String total = await Cart.getInstance.getTotal(); if (total == null) { @@ -413,6 +411,17 @@ class CheckoutConfirmationPageState extends State { } } + bool appStatus = await appWooSignal((api) => api.checkAppStatus()); + + if (!appStatus) { + showEdgeAlertWith(context, + title: trans(context, "Sorry"), + desc: "${trans(context, "Retry later")}", + style: EdgeAlertStyle.INFO, + duration: 3); + return; + } + if (_isProcessingPayment == true) { return; } diff --git a/LabelStoreMax/lib/pages/checkout_details.dart b/LabelStoreMax/lib/pages/checkout_details.dart index 7925edd..96571c2 100644 --- a/LabelStoreMax/lib/pages/checkout_details.dart +++ b/LabelStoreMax/lib/pages/checkout_details.dart @@ -29,29 +29,28 @@ class CheckoutDetailsPage extends StatefulWidget { class _CheckoutDetailsPageState extends State { _CheckoutDetailsPageState(); - bool _hasDifferentShippingAddress = false; + bool _hasDifferentShippingAddress = false, valRememberDetails = true; int activeTabIndex = 0; // TEXT CONTROLLERS TextEditingController // billing - _txtBillingFirstName, - _txtBillingLastName, - _txtBillingAddressLine, - _txtBillingCity, - _txtBillingPostalCode, - _txtBillingEmailAddress, + _txtBillingFirstName = TextEditingController(), + _txtBillingLastName = TextEditingController(), + _txtBillingAddressLine = TextEditingController(), + _txtBillingCity = TextEditingController(), + _txtBillingPostalCode = TextEditingController(), + _txtBillingEmailAddress = TextEditingController(), // shipping - _txtShippingFirstName, - _txtShippingLastName, - _txtShippingAddressLine, - _txtShippingCity, - _txtShippingPostalCode, - _txtShippingEmailAddress; + _txtShippingFirstName = TextEditingController(), + _txtShippingLastName = TextEditingController(), + _txtShippingAddressLine = TextEditingController(), + _txtShippingCity = TextEditingController(), + _txtShippingPostalCode = TextEditingController(), + _txtShippingEmailAddress = TextEditingController(); CustomerCountry _billingCountry, _shippingCountry; - var valRememberDetails = true; Widget activeTab; Widget tabShippingDetails() => CustomerAddressInput( @@ -80,22 +79,6 @@ class _CheckoutDetailsPageState extends State { void initState() { super.initState(); - // SHIPPING - _txtShippingFirstName = TextEditingController(); - _txtShippingLastName = TextEditingController(); - _txtShippingAddressLine = TextEditingController(); - _txtShippingCity = TextEditingController(); - _txtShippingPostalCode = TextEditingController(); - _txtShippingEmailAddress = TextEditingController(); - - // BILLING - _txtBillingFirstName = TextEditingController(); - _txtBillingLastName = TextEditingController(); - _txtBillingAddressLine = TextEditingController(); - _txtBillingCity = TextEditingController(); - _txtBillingPostalCode = TextEditingController(); - _txtBillingEmailAddress = TextEditingController(); - if (CheckoutSession.getInstance.billingDetails.billingAddress == null) { CheckoutSession.getInstance.billingDetails.initSession(); CheckoutSession.getInstance.billingDetails.shippingAddress.initAddress(); @@ -130,14 +113,15 @@ class _CheckoutDetailsPageState extends State { return; } _setFields( - firstName: customerAddress.firstName, - lastName: customerAddress.lastName, - addressLine: customerAddress.addressLine, - city: customerAddress.city, - postalCode: customerAddress.postalCode, - emailAddress: customerAddress.emailAddress, - customerCountry: customerAddress.customerCountry, - type: type); + firstName: customerAddress.firstName, + lastName: customerAddress.lastName, + addressLine: customerAddress.addressLine, + city: customerAddress.city, + postalCode: customerAddress.postalCode, + emailAddress: customerAddress.emailAddress, + customerCountry: customerAddress.customerCountry, + type: type, + ); } _setFields( @@ -171,7 +155,7 @@ class _CheckoutDetailsPageState extends State { @override Widget build(BuildContext context) { return Scaffold( - resizeToAvoidBottomPadding: false, + resizeToAvoidBottomInset: false, appBar: AppBar( backgroundColor: Colors.transparent, title: Text( @@ -286,7 +270,7 @@ class _CheckoutDetailsPageState extends State { ) ], ), - wsPrimaryButton(context, + PrimaryButton( title: trans(context, "USE DETAILS"), action: () => _useDetailsTapped()), ], @@ -398,9 +382,9 @@ class _CheckoutDetailsPageState extends State { return customerShippingAddress; } - _navigateToSelectCountry({String type}) { + _navigateToSelectCountry({@required String type}) { Navigator.pushNamed(context, "/customer-countries").then((value) { - if (value == null || type == null) { + if (value == null) { return; } if (type == "billing") { diff --git a/LabelStoreMax/lib/pages/checkout_payment_type.dart b/LabelStoreMax/lib/pages/checkout_payment_type.dart index 205b45b..671ed71 100644 --- a/LabelStoreMax/lib/pages/checkout_payment_type.dart +++ b/LabelStoreMax/lib/pages/checkout_payment_type.dart @@ -39,7 +39,7 @@ class _CheckoutPaymentTypePageState extends State { @override Widget build(BuildContext context) { return Scaffold( - resizeToAvoidBottomPadding: false, + resizeToAvoidBottomInset: false, appBar: AppBar( backgroundColor: Colors.transparent, title: Text(trans(context, "Payment Method"), @@ -106,8 +106,7 @@ class _CheckoutPaymentTypePageState extends State { ), ), ), - wsLinkButton( - context, + LinkButton( title: trans(context, "CANCEL"), action: () => Navigator.pop(context), ), diff --git a/LabelStoreMax/lib/pages/checkout_shipping_type.dart b/LabelStoreMax/lib/pages/checkout_shipping_type.dart index d2eb70d..dbfd5ab 100644 --- a/LabelStoreMax/lib/pages/checkout_shipping_type.dart +++ b/LabelStoreMax/lib/pages/checkout_shipping_type.dart @@ -238,7 +238,7 @@ class _CheckoutShippingTypePageState extends State { @override Widget build(BuildContext context) { return Scaffold( - resizeToAvoidBottomPadding: false, + resizeToAvoidBottomInset: false, appBar: AppBar( backgroundColor: Colors.transparent, title: Text( @@ -383,9 +383,9 @@ class _CheckoutShippingTypePageState extends State { style: Theme.of(context) .primaryTextTheme .headline6, - textAlign: TextAlign.center))), - wsLinkButton( - context, + textAlign: TextAlign.center, + ))), + LinkButton( title: trans(context, "CANCEL"), action: () => Navigator.pop(context), ), @@ -409,13 +409,16 @@ class _CheckoutShippingTypePageState extends State { } _handleCheckoutTapped(int index) async { - ShippingType shippingType = ShippingType(); - shippingType.object = _wsShippingOptions[index]['object']; - shippingType.methodId = _wsShippingOptions[index]['method_id']; + Map shippingOptions = _wsShippingOptions[index]; + ShippingType shippingType = ShippingType( + methodId: shippingOptions['method_id'], + object: shippingOptions['object'], + cost: (await _getShippingPrice(index)), + minimumValue: null); + if (_wsShippingOptions[index]['min_amount'] != null) { shippingType.minimumValue = _wsShippingOptions[index]['min_amount']; } - shippingType.cost = await _getShippingPrice(index); CheckoutSession.getInstance.shippingType = shippingType; diff --git a/LabelStoreMax/lib/pages/checkout_status.dart b/LabelStoreMax/lib/pages/checkout_status.dart index 0fe4870..e3ab42c 100644 --- a/LabelStoreMax/lib/pages/checkout_status.dart +++ b/LabelStoreMax/lib/pages/checkout_status.dart @@ -44,7 +44,7 @@ class _CheckoutStatusState extends State { appBar: AppBar( backgroundColor: Colors.white, elevation: 0.0, - title: storeLogo(height: 60), + title: StoreLogo(height: 60), automaticallyImplyLeading: false, centerTitle: true, ), diff --git a/LabelStoreMax/lib/pages/customer_countries.dart b/LabelStoreMax/lib/pages/customer_countries.dart index 67f8044..a19a3ad 100644 --- a/LabelStoreMax/lib/pages/customer_countries.dart +++ b/LabelStoreMax/lib/pages/customer_countries.dart @@ -42,7 +42,7 @@ class _CustomerCountriesPageState extends State { @override Widget build(BuildContext context) { return Scaffold( - resizeToAvoidBottomPadding: false, + resizeToAvoidBottomInset: false, appBar: AppBar( backgroundColor: Colors.transparent, title: Text( diff --git a/LabelStoreMax/lib/pages/error_page.dart b/LabelStoreMax/lib/pages/error_page.dart index 29ce555..02994a8 100644 --- a/LabelStoreMax/lib/pages/error_page.dart +++ b/LabelStoreMax/lib/pages/error_page.dart @@ -50,7 +50,7 @@ class _ErrorPageState extends State { textAlign: TextAlign.center, ), ), - wsLinkButton(context, + LinkButton( title: trans(context, "Back"), action: () => Navigator.pop(context)), ], diff --git a/LabelStoreMax/lib/pages/home.dart b/LabelStoreMax/lib/pages/home.dart index 0c7231d..640fe7d 100644 --- a/LabelStoreMax/lib/pages/home.dart +++ b/LabelStoreMax/lib/pages/home.dart @@ -8,8 +8,8 @@ // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/material.dart'; +import 'package:label_storemax/helpers/app_helper.dart'; import 'package:label_storemax/helpers/tools.dart'; import 'package:label_storemax/widgets/app_loader.dart'; import 'package:label_storemax/widgets/cart_icon.dart'; @@ -34,15 +34,12 @@ class _HomePageState extends State { List _categories = []; final GlobalKey _key = GlobalKey(); - int _page; - bool _shouldStopRequests, waitForNextRequest, _isLoading; + int _page = 1; + bool _shouldStopRequests, waitForNextRequest, _isLoading = true; @override void initState() { super.initState(); - - _isLoading = true; - _page = 1; _home(); } @@ -86,7 +83,7 @@ class _HomePageState extends State { }); } - void _modalBottomSheetMenu() { + _modalBottomSheetMenu() { _key.currentState.setState(() {}); wsModalBottom( context, @@ -94,23 +91,22 @@ class _HomePageState extends State { bodyWidget: ListView.separated( itemCount: _categories.length, separatorBuilder: (cxt, i) => Divider(), - itemBuilder: (BuildContext context, int index) { - return ListTile( - title: Text(parseHtmlString(_categories[index].name)), - onTap: () { - Navigator.pop(context); - Navigator.pushNamed(context, "/browse-category", - arguments: _categories[index]) - .then((value) => setState(() {})); - }, - ); - }, + itemBuilder: (BuildContext context, int index) => ListTile( + title: Text(parseHtmlString(_categories[index].name)), + onTap: () { + Navigator.pop(context); + Navigator.pushNamed(context, "/browse-category", + arguments: _categories[index]) + .then((value) => setState(() {})); + }, + ), ), ); } @override Widget build(BuildContext context) { + List bannerImages = AppHelper.instance.appConfig.bannerImages; return Scaffold( appBar: AppBar( backgroundColor: Colors.transparent, @@ -121,7 +117,7 @@ class _HomePageState extends State { ), margin: EdgeInsets.only(left: 0), ), - title: storeLogo(height: 50), + title: StoreLogo(height: 55), centerTitle: true, actions: [ IconButton( @@ -144,50 +140,18 @@ class _HomePageState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Text( - capitalize(trans(context, "Shop")) + " / ", - style: Theme.of(context).primaryTextTheme.subtitle1, - maxLines: 1, - ), - AutoSizeText( - trans(context, "Newest"), - style: Theme.of(context).primaryTextTheme.bodyText2, - maxLines: 1, - ), - ], - ), - Flexible( - child: MaterialButton( - minWidth: 100, - height: 60, - child: AutoSizeText( - trans(context, "Browse categories"), - style: Theme.of(context).primaryTextTheme.bodyText1, - maxLines: 1, - textAlign: TextAlign.right, - ), - onPressed: _modalBottomSheetMenu, - ), - ) - ], - ), (_isLoading ? Expanded(child: showAppLoader()) : Expanded( - child: refreshableScroll( - context, - refreshController: _refreshController, + child: RefreshableScrollContainer( + controller: _refreshController, onRefresh: _onRefresh, onLoading: _onLoading, products: _products, onTap: _showProduct, + bannerHeight: MediaQuery.of(context).size.height / 3.5, + bannerImages: bannerImages, + modalBottomSheetMenu: _modalBottomSheetMenu, ), flex: 1, )), @@ -206,7 +170,7 @@ class _HomePageState extends State { _refreshController.refreshCompleted(); } - void _onLoading() async { + _onLoading() async { await _fetchMoreProducts(); if (mounted) { @@ -219,8 +183,7 @@ class _HomePageState extends State { } } - _showProduct(WSProduct.Product product) { - Navigator.pushNamed(context, "/product-detail", arguments: product) - .then((value) => _key.currentState.setState(() {})); - } + _showProduct(WSProduct.Product product) => + Navigator.pushNamed(context, "/product-detail", arguments: product) + .then((value) => _key.currentState.setState(() {})); } diff --git a/LabelStoreMax/lib/pages/home_menu.dart b/LabelStoreMax/lib/pages/home_menu.dart index 2614e91..1f5f134 100644 --- a/LabelStoreMax/lib/pages/home_menu.dart +++ b/LabelStoreMax/lib/pages/home_menu.dart @@ -9,8 +9,8 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. import 'package:flutter/material.dart'; +import 'package:label_storemax/helpers/app_helper.dart'; import 'package:label_storemax/helpers/shared_pref/sp_auth.dart'; -import 'package:label_storemax/labelconfig.dart'; import 'package:label_storemax/widgets/menu_item.dart'; import 'package:label_storemax/helpers/tools.dart'; @@ -53,28 +53,25 @@ class _HomeMenuPageState extends State { mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ - storeLogo(height: 100), + StoreLogo(height: 100), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - (use_wp_login - ? wsMenuItem( - context, + (AppHelper.instance.appConfig.wpLoginEnabled == 1 + ? MenuItem( title: trans(context, "Profile"), leading: Icon(Icons.account_circle), action: _actionProfile, ) : Container()), - wsMenuItem( - context, + MenuItem( title: trans(context, "Cart"), leading: Icon(Icons.shopping_cart), action: _actionCart, ), - wsMenuItem( - context, + MenuItem( title: trans(context, "About Us"), leading: Icon(Icons.account_balance), action: _actionAboutUs, @@ -97,7 +94,8 @@ class _HomeMenuPageState extends State { } void _actionProfile() async { - if (use_wp_login == true && !(await authCheck())) { + if (AppHelper.instance.appConfig.wpLoginEnabled == 1 && + !(await authCheck())) { UserAuth.instance.redirect = "/account-detail"; Navigator.pushNamed(context, "/account-landing"); return; diff --git a/LabelStoreMax/lib/pages/home_search.dart b/LabelStoreMax/lib/pages/home_search.dart index c738e9c..fb66f38 100644 --- a/LabelStoreMax/lib/pages/home_search.dart +++ b/LabelStoreMax/lib/pages/home_search.dart @@ -46,7 +46,7 @@ class _HomeSearchPageState extends State { return Scaffold( appBar: AppBar( backgroundColor: Colors.transparent, - title: storeLogo(height: 60), + title: StoreLogo(height: 55), centerTitle: true, ), body: SafeArea( @@ -69,8 +69,7 @@ class _HomeSearchPageState extends State { ), Padding( padding: const EdgeInsets.only(top: 10), - child: wsPrimaryButton( - context, + child: PrimaryButton( title: trans(context, "Search"), action: _actionSearch, ), diff --git a/LabelStoreMax/lib/pages/no_connection_page.dart b/LabelStoreMax/lib/pages/no_connection_page.dart new file mode 100644 index 0000000..14fa152 --- /dev/null +++ b/LabelStoreMax/lib/pages/no_connection_page.dart @@ -0,0 +1,73 @@ +// StoreMob +// +// Created by Anthony Gordon. +// 2021, 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/material.dart'; +import 'package:label_storemax/helpers/app_helper.dart'; +import 'package:label_storemax/helpers/tools.dart'; +import 'package:label_storemax/widgets/buttons.dart'; + +class NoConnectionPage extends StatefulWidget { + NoConnectionPage(); + + @override + _NoConnectionPageState createState() => _NoConnectionPageState(); +} + +class _NoConnectionPageState extends State { + _NoConnectionPageState(); + + @override + void initState() { + super.initState(); + print('WooCommerce site is not connected'); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SafeArea( + minimum: safeAreaDefault(), + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Icon( + Icons.error_outline, + size: 100, + color: Colors.black54, + ), + Padding( + padding: const EdgeInsets.all(16.0), + child: Text( + trans(context, "Oops, something went wrong"), + style: Theme.of(context).primaryTextTheme.bodyText2, + textAlign: TextAlign.center, + ), + ), + LinkButton(title: trans(context, "Retry"), action: _retry), + ], + ), + ), + ), + ); + } + + _retry() async { + AppHelper.instance.appConfig = await appWooSignal((api) => api.getApp()); + + if (AppHelper.instance.appConfig != null) { + Navigator.pushNamed(context, "/home"); + return; + } + showEdgeAlertWith(context, + title: trans(context, "Oops"), desc: trans(context, "Retry later")); + } +} diff --git a/LabelStoreMax/lib/pages/product_detail.dart b/LabelStoreMax/lib/pages/product_detail.dart index 5240855..48a9430 100644 --- a/LabelStoreMax/lib/pages/product_detail.dart +++ b/LabelStoreMax/lib/pages/product_detail.dart @@ -17,7 +17,6 @@ import 'package:label_storemax/models/cart_line_item.dart'; import 'package:label_storemax/widgets/app_loader.dart'; import 'package:label_storemax/widgets/buttons.dart'; import 'package:label_storemax/widgets/cart_icon.dart'; -import 'package:url_launcher/url_launcher.dart'; import 'package:woosignal/models/response/product_variation.dart' as WS; import 'package:woosignal/models/response/products.dart' as WSProduct; import 'package:flutter_swiper/flutter_swiper.dart'; @@ -201,63 +200,67 @@ class _ProductDetailState extends State { : ""), style: Theme.of(context).primaryTextTheme.subtitle1, ), - wsPrimaryButton(context, title: trans(context, "Add to cart"), + PrimaryButton( + title: trans(context, "Add to cart"), action: () { - if (_product.attributes.length != - _tmpAttributeObj.values.length) { - showEdgeAlertWith(context, - title: trans(context, "Oops"), - desc: trans(context, "Please select valid options first"), - style: EdgeAlertStyle.WARNING); - return; - } + if (_product.attributes.length != + _tmpAttributeObj.values.length) { + showEdgeAlertWith(context, + title: trans(context, "Oops"), + desc: + trans(context, "Please select valid options first"), + style: EdgeAlertStyle.WARNING); + return; + } - WS.ProductVariation productVariation = findProductVariation(); - if (productVariation == null) { - showEdgeAlertWith(context, - title: trans(context, "Oops"), - desc: trans(context, "Product variation does not exist"), - style: EdgeAlertStyle.WARNING); - return; - } + WS.ProductVariation productVariation = findProductVariation(); + if (productVariation == null) { + showEdgeAlertWith(context, + title: trans(context, "Oops"), + desc: + trans(context, "Product variation does not exist"), + style: EdgeAlertStyle.WARNING); + return; + } - if (productVariation.stockStatus != "instock") { - showEdgeAlertWith(context, - title: trans(context, "Sorry"), - desc: trans(context, "This item is not in stock"), - style: EdgeAlertStyle.WARNING); - return; - } + if (productVariation.stockStatus != "instock") { + showEdgeAlertWith(context, + title: trans(context, "Sorry"), + desc: trans(context, "This item is not in stock"), + style: EdgeAlertStyle.WARNING); + return; + } - List options = []; - _tmpAttributeObj.forEach((k, v) { - options.add("${v["name"]}: ${v["value"]}"); - }); + List options = []; + _tmpAttributeObj.forEach((k, v) { + options.add("${v["name"]}: ${v["value"]}"); + }); - CartLineItem cartLineItem = CartLineItem( - name: _product.name, - productId: _product.id, - variationId: productVariation.id, - quantity: 1, - taxStatus: productVariation.taxStatus, - shippingClassId: productVariation.shippingClassId.toString(), - subtotal: productVariation.price, - stockQuantity: productVariation.stockQuantity, - isManagedStock: productVariation.manageStock, - taxClass: productVariation.taxClass, - imageSrc: (productVariation.image != null - ? productVariation.image.src - : _product.images.length == 0 - ? app_product_placeholder_image - : _product.images.first.src), - shippingIsTaxable: _product.shippingTaxable, - variationOptions: options.join(", "), - total: productVariation.price, - ); + CartLineItem cartLineItem = CartLineItem( + name: _product.name, + productId: _product.id, + variationId: productVariation.id, + quantity: 1, + taxStatus: productVariation.taxStatus, + shippingClassId: + productVariation.shippingClassId.toString(), + subtotal: productVariation.price, + stockQuantity: productVariation.stockQuantity, + isManagedStock: productVariation.manageStock, + taxClass: productVariation.taxClass, + imageSrc: (productVariation.image != null + ? productVariation.image.src + : _product.images.length == 0 + ? app_product_placeholder_image + : _product.images.first.src), + shippingIsTaxable: _product.shippingTaxable, + variationOptions: options.join(", "), + total: productVariation.price, + ); - _itemAddToCart(cartLineItem: cartLineItem); - Navigator.of(context).pop(); - }), + _itemAddToCart(cartLineItem: cartLineItem); + Navigator.of(context).pop(); + }), ], ), margin: EdgeInsets.only(bottom: 10), @@ -285,7 +288,7 @@ class _ProductDetailState extends State { actions: [ wsCartIcon(context), ], - title: storeLogo(height: 55), + title: StoreLogo(height: 55), centerTitle: true, ), body: SafeArea( @@ -522,15 +525,13 @@ class _ProductDetailState extends State { )), _product.type == "external" ? Flexible( - child: wsPrimaryButton( - context, + child: PrimaryButton( title: trans(context, "Buy Product"), action: () => _viewExternalProduct(), ), ) : Flexible( - child: wsPrimaryButton( - context, + child: PrimaryButton( title: trans(context, "Add to cart"), action: () => _addItemToCart(), ), diff --git a/LabelStoreMax/lib/providers/razor_pay.dart b/LabelStoreMax/lib/providers/razor_pay.dart index 9b184ea..5c4bf36 100644 --- a/LabelStoreMax/lib/providers/razor_pay.dart +++ b/LabelStoreMax/lib/providers/razor_pay.dart @@ -12,11 +12,10 @@ // import 'package:flutter/widgets.dart'; +import 'package:label_storemax/helpers/app_helper.dart'; import 'package:label_storemax/helpers/data/order_wc.dart'; import 'package:label_storemax/helpers/tools.dart'; import 'package:label_storemax/labelconfig.dart'; -import 'package:label_storemax/models/cart.dart'; -import 'package:label_storemax/models/checkout_session.dart'; import 'package:label_storemax/pages/checkout_confirmation.dart'; import 'package:razorpay_flutter/razorpay_flutter.dart'; import 'package:woosignal/models/response/tax_rate.dart'; @@ -25,16 +24,16 @@ import 'package:woosignal/models/response/order.dart'; razorPay(context, {@required CheckoutConfirmationPageState state, TaxRate taxRate}) async { - Razorpay _razorpay = Razorpay(); + Razorpay razorPay = Razorpay(); - _razorpay.on(Razorpay.EVENT_PAYMENT_SUCCESS, + 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) { - _razorpay.clear(); + razorPay.clear(); Navigator.pushNamed(context, "/checkout-status", arguments: order); } else { showEdgeAlertWith(context, @@ -44,27 +43,27 @@ razorPay(context, trans(context, "Something went wrong, please contact our store"), ), style: EdgeAlertStyle.WARNING); - _razorpay.clear(); + razorPay.clear(); state.reloadState(showLoader: false); } }); - _razorpay.on(Razorpay.EVENT_PAYMENT_ERROR, (PaymentFailureResponse response) { + razorPay.on(Razorpay.EVENT_PAYMENT_ERROR, (PaymentFailureResponse response) { showEdgeAlertWith(context, title: trans(context, "Error"), desc: response.message, style: EdgeAlertStyle.WARNING); - _razorpay.clear(); + razorPay.clear(); state.reloadState(showLoader: false); }); - _razorpay.on(Razorpay.EVENT_EXTERNAL_WALLET, + razorPay.on(Razorpay.EVENT_EXTERNAL_WALLET, (ExternalWalletResponse response) { showEdgeAlertWith(context, title: trans(context, "Error"), desc: trans(context, "Not supported, try a card payment"), style: EdgeAlertStyle.WARNING); - _razorpay.clear(); + razorPay.clear(); state.reloadState(showLoader: false); }); @@ -73,7 +72,7 @@ razorPay(context, var options = { 'key': app_razor_id, 'amount': (parseWcPrice(total) * 100).toInt(), - 'name': app_name, + 'name': AppHelper.instance.appConfig.appName, 'description': await cart.cartShortDesc(), 'prefill': { "name": [ @@ -87,6 +86,6 @@ razorPay(context, state.reloadState(showLoader: true); - _razorpay.open(options); + razorPay.open(options); }); } diff --git a/LabelStoreMax/lib/widgets/buttons.dart b/LabelStoreMax/lib/widgets/buttons.dart index b7e0408..7a78021 100644 --- a/LabelStoreMax/lib/widgets/buttons.dart +++ b/LabelStoreMax/lib/widgets/buttons.dart @@ -11,64 +11,110 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; +import 'package:label_storemax/widgets/woosignal_ui.dart'; -Widget wsPrimaryButton(BuildContext context, - {@required String title, void Function() action}) { - return Container( - height: 55, - child: RaisedButton( - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0)), - padding: EdgeInsets.all(8), - child: Text( - title, - style: Theme.of(context).primaryTextTheme.button.copyWith(fontSize: 16), - maxLines: 2, - overflow: TextOverflow.ellipsis, - ), - onPressed: action ?? null, - elevation: 0, - ), - ); +class PrimaryButton extends StatelessWidget { + const PrimaryButton({ + Key key, + this.title, + this.action, + }) : super(key: key); + + final String title; + final void Function() action; + + @override + Widget build(BuildContext context) => WooSignalButton( + key: key, + title: title, + action: action, + textStyle: + Theme.of(context).primaryTextTheme.button.copyWith(fontSize: 16), + bgColor: HexColor("#529cda"), + ); } -Widget wsSecondaryButton(BuildContext context, - {String title, void Function() action}) { - return Container( - height: 60, - margin: EdgeInsets.only(top: 10), - child: RaisedButton( - child: Text( - title, - style: Theme.of(context).primaryTextTheme.bodyText1.copyWith( +class SecondaryButton extends StatelessWidget { + const SecondaryButton({ + Key key, + this.title, + this.action, + }) : super(key: key); + + final String title; + final void Function() action; + + @override + Widget build(BuildContext context) => WooSignalButton( + key: key, + title: title, + action: action, + textStyle: Theme.of(context).primaryTextTheme.bodyText1.copyWith( color: Colors.black87, ), - textAlign: TextAlign.center, - maxLines: 2, - overflow: TextOverflow.ellipsis, - ), - onPressed: action, - color: HexColor("#f6f6f9"), - elevation: 1, - ), - ); + bgColor: HexColor("#f6f6f9"), + ); } -Widget wsLinkButton(BuildContext context, - {String title, void Function() action}) { - return Container( - height: 60, - margin: EdgeInsets.only(top: 10), - child: MaterialButton( - padding: EdgeInsets.all(10), - child: Text( - title, - style: Theme.of(context).primaryTextTheme.bodyText1, - textAlign: TextAlign.left, - maxLines: 2, - overflow: TextOverflow.ellipsis, - ), - onPressed: action, - elevation: 0, - ), - ); +class LinkButton extends StatelessWidget { + const LinkButton({ + Key key, + this.title, + this.action, + }) : super(key: key); + + final String title; + final void Function() action; + + @override + Widget build(BuildContext context) => WooSignalButton( + key: key, + title: title, + action: action, + textStyle: Theme.of(context).primaryTextTheme.bodyText1, + bgColor: Colors.transparent, + ); +} + +class WooSignalButton extends StatelessWidget { + const WooSignalButton({ + Key key, + this.title, + this.action, + this.textStyle, + this.bgColor, + }) : super(key: key); + + final String title; + final void Function() action; + final TextStyle textStyle; + final Color bgColor; + + @override + Widget build(BuildContext context) { + return Container( + height: 55, + width: double.infinity, + decoration: BoxDecoration( + color: Colors.transparent, + ), + child: ElevatedButton( + style: ElevatedButton.styleFrom( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12.0)), + padding: EdgeInsets.all(8), + elevation: 0, + primary: bgColor, + shadowColor: Colors.transparent), + child: Text( + title, + style: textStyle, + maxLines: 2, + textAlign: TextAlign.center, + overflow: TextOverflow.ellipsis, + ), + onPressed: action ?? null, + ), + ); + } } diff --git a/LabelStoreMax/lib/widgets/customer_address_input.dart b/LabelStoreMax/lib/widgets/customer_address_input.dart index 2dc093c..27297f4 100644 --- a/LabelStoreMax/lib/widgets/customer_address_input.dart +++ b/LabelStoreMax/lib/widgets/customer_address_input.dart @@ -37,16 +37,14 @@ class CustomerAddressInput extends StatelessWidget { child: Row( children: [ Flexible( - child: wsTextEditingRow( - context, + child: TextEditingRow( heading: trans(context, "First Name"), controller: txtControllerFirstName, shouldAutoFocus: true, ), ), Flexible( - child: wsTextEditingRow( - context, + child: TextEditingRow( heading: trans(context, "Last Name"), controller: txtControllerLastName, ), @@ -60,15 +58,13 @@ class CustomerAddressInput extends StatelessWidget { child: Row( children: [ Flexible( - child: wsTextEditingRow( - context, + child: TextEditingRow( heading: trans(context, "Address Line"), controller: txtControllerAddressLine, ), ), Flexible( - child: wsTextEditingRow( - context, + child: TextEditingRow( heading: trans(context, "City"), controller: txtControllerCity, ), @@ -80,14 +76,13 @@ class CustomerAddressInput extends StatelessWidget { child: Row( children: [ Flexible( - child: wsTextEditingRow( - context, + child: TextEditingRow( heading: trans(context, "Postal code"), controller: txtControllerPostalCode, ), ), Flexible( - child: wsTextEditingRow(context, + child: TextEditingRow( heading: trans(context, "Email address"), keyboardType: TextInputType.emailAddress, controller: txtControllerEmailAddress), @@ -96,38 +91,62 @@ class CustomerAddressInput extends StatelessWidget { ), ), Flexible( - child: Row( - children: [ - (customerCountry.hasState() - ? Flexible( - child: Padding( - child: wsSecondaryButton( - context, - title: (customerCountry.state != null - ? "${trans(context, "Selected")}\n${customerCountry?.state?.name ?? ""}" - : trans(context, "Select state")), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 4), + child: Row( + children: [ + if (customerCountry.hasState()) + Flexible( + child: Column( + children: [ + Container( + child: Text( + trans(context, "State"), + style: Theme.of(context).primaryTextTheme.bodyText1, + textAlign: TextAlign.left, + ), + width: double.infinity, + ), + Padding( + child: SecondaryButton( + title: (customerCountry.state != null + ? "${trans(context, "Selected")}\n${customerCountry?.state?.name ?? ""}" + : trans(context, "Select state")), + action: onTapCountry, + ), + padding: EdgeInsets.all(8), + ), + ], + ), + ), + Flexible( + child: Column( + children: [ + Container( + child: Text( + trans(context, "Country"), + style: Theme.of(context).primaryTextTheme.bodyText1, + textAlign: TextAlign.left, + ), + width: double.infinity, + ), + Padding( + child: SecondaryButton( + title: (customerCountry != null && + (customerCountry?.name ?? "").isNotEmpty + ? "${trans(context, "Selected")}\n${customerCountry.name}" + : trans(context, "Select country")), action: onTapCountry, ), padding: EdgeInsets.all(8), ), - ) - : null), - Flexible( - child: Padding( - child: wsSecondaryButton( - context, - title: (customerCountry != null && - (customerCountry?.name ?? "").isNotEmpty - ? "${trans(context, "Selected")}\n${customerCountry.name}" - : trans(context, "Select country")), - action: onTapCountry, + ], ), - padding: EdgeInsets.all(8), ), - ), - ].where((element) => element != null).toList(), - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, + ].where((element) => element != null).toList(), + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + ), ), ), ].where((e) => e != null).toList(), diff --git a/LabelStoreMax/lib/widgets/menu_item.dart b/LabelStoreMax/lib/widgets/menu_item.dart index 65283f7..e5efa13 100644 --- a/LabelStoreMax/lib/widgets/menu_item.dart +++ b/LabelStoreMax/lib/widgets/menu_item.dart @@ -10,30 +10,41 @@ import 'package:flutter/material.dart'; -Widget wsMenuItem(BuildContext context, - {String title, Widget leading, void Function() action}) { - return Flexible( - child: InkWell( - child: Card( - child: Container( - width: double.infinity, - padding: EdgeInsets.only(top: 15, bottom: 15), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - leading, - Text( - " " + title, - style: Theme.of(context).primaryTextTheme.bodyText2, +class MenuItem extends StatelessWidget { + const MenuItem({ + Key key, + this.title, + this.leading, + this.action, + }) : super(key: key); + + final String title; + final Widget leading; + final void Function() action; + + @override + Widget build(BuildContext context) => Flexible( + child: InkWell( + child: Card( + child: Container( + width: double.infinity, + padding: EdgeInsets.only(top: 15, bottom: 15), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + leading, + Text( + " " + title, + style: Theme.of(context).primaryTextTheme.bodyText2, + ), + ], ), - ], + ), + elevation: 1, + margin: EdgeInsets.only(top: 8, bottom: 8, left: 8, right: 8), ), + onTap: action, ), - elevation: 1, - margin: EdgeInsets.only(top: 8, bottom: 8, left: 8, right: 8), - ), - onTap: action, - ), - ); + ); } diff --git a/LabelStoreMax/lib/widgets/woosignal_ui.dart b/LabelStoreMax/lib/widgets/woosignal_ui.dart index e849a8b..31b7274 100644 --- a/LabelStoreMax/lib/widgets/woosignal_ui.dart +++ b/LabelStoreMax/lib/widgets/woosignal_ui.dart @@ -9,13 +9,18 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. import 'package:auto_size_text/auto_size_text.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; +import 'package:flutter_swiper/flutter_swiper.dart'; import 'package:hexcolor/hexcolor.dart'; +import 'package:label_storemax/helpers/app_helper.dart'; import 'package:label_storemax/labelconfig.dart'; import 'package:label_storemax/models/cart.dart'; import 'package:label_storemax/models/cart_line_item.dart'; import 'package:label_storemax/models/checkout_session.dart'; import 'package:label_storemax/widgets/app_loader.dart'; +import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:woosignal/models/response/products.dart'; import 'package:label_storemax/helpers/tools.dart'; import 'package:cached_network_image/cached_network_image.dart'; @@ -50,13 +55,168 @@ Widget wsRow2Text(BuildContext context, {String text1, String text2}) { ); } -Widget wsNoResults(BuildContext context) { - return Column( - children: [ - Text(trans(context, "No results"), - style: Theme.of(context).primaryTextTheme.bodyText2), - ], - ); +class NoProductResults extends StatelessWidget { + const NoProductResults({ + Key key, + }) : super(key: key); + + @override + Widget build(BuildContext context) => Column( + children: [ + Text(trans(context, "No results"), + style: Theme.of(context).primaryTextTheme.bodyText2), + ], + ); +} + +class TopNav extends StatelessWidget { + const TopNav({Key key, this.onPressBrowseCategories}) : super(key: key); + + final Function() onPressBrowseCategories; + + @override + Widget build(BuildContext context) => Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + "${capitalize(trans(context, "Shop"))} / ", + style: Theme.of(context).primaryTextTheme.subtitle1, + maxLines: 1, + ), + AutoSizeText( + trans(context, "Newest"), + style: Theme.of(context).primaryTextTheme.bodyText2, + maxLines: 1, + ), + ], + ), + Flexible( + child: MaterialButton( + minWidth: 100, + height: 60, + child: AutoSizeText( + trans(context, "Browse categories"), + style: Theme.of(context).primaryTextTheme.bodyText1, + maxLines: 1, + textAlign: TextAlign.right, + ), + onPressed: onPressBrowseCategories, + ), + ) + ], + ); +} + +class RefreshableScrollContainer extends StatelessWidget { + const RefreshableScrollContainer( + {Key key, + this.controller, + this.onRefresh, + this.onLoading, + this.products, + this.onTap, + this.bannerHeight, + this.bannerImages, + this.modalBottomSheetMenu}) + : super(key: key); + + final RefreshController controller; + final Function onRefresh; + final Function onLoading; + final List products; + final Function onTap; + final double bannerHeight; + final List bannerImages; + final Function modalBottomSheetMenu; + + @override + Widget build(BuildContext context) => SmartRefresher( + enablePullDown: true, + enablePullUp: true, + footer: CustomFooter( + builder: (BuildContext context, LoadStatus mode) { + Widget body; + if (mode == LoadStatus.idle) { + body = Text(trans(context, "pull up load")); + } else if (mode == LoadStatus.loading) { + body = CupertinoActivityIndicator(); + } else if (mode == LoadStatus.failed) { + body = Text(trans(context, "Load Failed! Click retry!")); + } else if (mode == LoadStatus.canLoading) { + body = Text(trans(context, "release to load more")); + } else { + body = Text(trans(context, "No more products")); + } + return Container( + height: 55.0, + child: Center(child: body), + ); + }, + ), + controller: controller, + onRefresh: onRefresh, + onLoading: onLoading, + child: (products.length != null && products.length > 0 + ? StaggeredGridView.countBuilder( + crossAxisCount: 2, + itemCount: + (products.length + (bannerImages.length > 0 ? 2 : 0)), + itemBuilder: (BuildContext context, int index) { + if (bannerImages.length > 0 && index == 0) { + return Container( + child: Swiper( + itemBuilder: (BuildContext context, int index) { + return CachedImage( + image: bannerImages[index], + fit: BoxFit.contain, + ); + }, + itemCount: bannerImages.length, + viewportFraction: 0.8, + scale: 0.9, + ), + height: bannerHeight, + ); + } + if (bannerImages.length > 0 && index == 1 || + bannerImages.length == 0 && index == 0) { + return TopNav( + onPressBrowseCategories: modalBottomSheetMenu, + ); + } + int productIndex = + (index - (bannerImages.length > 0 ? 2 : 0)); + + return Container( + height: 200, + child: ProductItemContainer( + index: productIndex, + product: products[productIndex], + onTap: onTap, + ), + ); + }, + staggeredTileBuilder: (int index) { + if (index == 0) { + return new StaggeredTile.fit(2); + } + if (bannerImages.length == 0) { + return new StaggeredTile.fit(1); + } + if (bannerImages.length > 0 && index == 0 || index == 1) { + return new StaggeredTile.fit(2); + } + return new StaggeredTile.fit(1); + }, + mainAxisSpacing: 4.0, + crossAxisSpacing: 4.0, + ) + : NoProductResults()), + ); } Widget wsCheckoutRow(BuildContext context, @@ -130,42 +290,53 @@ Widget wsCheckoutRow(BuildContext context, ); } -Widget wsTextEditingRow(BuildContext context, - {heading: String, - TextEditingController controller, - bool shouldAutoFocus, - TextInputType keyboardType, - bool obscureText}) { - return Container( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Flexible( - child: Padding( - child: Text( - heading, - style: Theme.of(context).primaryTextTheme.bodyText1, +class TextEditingRow extends StatelessWidget { + const TextEditingRow({ + Key key, + this.heading, + this.controller, + this.shouldAutoFocus, + this.keyboardType, + this.obscureText, + }) : super(key: key); + + final String heading; + final TextEditingController controller; + final bool shouldAutoFocus; + final TextInputType keyboardType; + final bool obscureText; + + @override + Widget build(BuildContext context) => Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Flexible( + child: Padding( + child: Text( + heading, + style: Theme.of(context).primaryTextTheme.bodyText1, + ), + padding: EdgeInsets.only(bottom: 2), + ), ), - padding: EdgeInsets.only(bottom: 2), - ), + Flexible( + child: TextField( + controller: controller, + style: Theme.of(context).primaryTextTheme.subtitle1, + keyboardType: keyboardType ?? TextInputType.text, + autocorrect: false, + autofocus: shouldAutoFocus ?? false, + obscureText: obscureText ?? false, + textCapitalization: TextCapitalization.sentences, + ), + ) + ], ), - Flexible( - child: TextField( - controller: controller, - style: Theme.of(context).primaryTextTheme.subtitle1, - keyboardType: keyboardType ?? TextInputType.text, - autocorrect: false, - autofocus: shouldAutoFocus ?? false, - obscureText: obscureText ?? false, - textCapitalization: TextCapitalization.sentences, - ), - ) - ], - ), - padding: EdgeInsets.all(2), - height: 78, - ); + padding: EdgeInsets.all(2), + height: 78, + ); } Widget widgetCheckoutMeta(BuildContext context, {String title, String amount}) { @@ -191,230 +362,242 @@ Widget widgetCheckoutMeta(BuildContext context, {String title, String amount}) { ); } -List wsBoxShadow({double blurRadius}) { - return [ - BoxShadow( - color: HexColor("#e8e8e8"), - blurRadius: blurRadius ?? 15.0, - spreadRadius: 0, - offset: Offset( - 0, - 0, - ), - ) - ]; -} +List wsBoxShadow({double blurRadius}) => [ + BoxShadow( + color: HexColor("#e8e8e8"), + blurRadius: blurRadius ?? 15.0, + spreadRadius: 0, + offset: Offset( + 0, + 0, + ), + ) + ]; -Widget wsCardProductItem(BuildContext context, - {int index, Product product, onTap}) { - 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 / 2, - child: ClipRRect( - borderRadius: BorderRadius.circular(3.0), - child: Stack( - children: [ - Container( - color: Colors.grey[100], - height: double.infinity, - width: double.infinity, - ), - CachedNetworkImage( - imageUrl: (product.images.length > 0 - ? product.images.first.src - : app_product_placeholder_image), - placeholder: (context, url) => Container( - child: Center( - child: CircularProgressIndicator(), +class ProductItemContainer extends StatelessWidget { + const ProductItemContainer({ + Key key, + this.index, + this.product, + this.onTap, + }) : super(key: key); + + final int index; + final Product product; + final Function onTap; + + @override + Widget build(BuildContext context) => LayoutBuilder( + builder: (cxt, constraints) => InkWell( + child: Container( + margin: EdgeInsets.all(4), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Container( + height: constraints.maxHeight / 2, + child: ClipRRect( + borderRadius: BorderRadius.circular(3.0), + child: Stack( + children: [ + Container( + color: Colors.grey[100], + height: double.infinity, + width: double.infinity, ), - height: constraints.maxHeight / 2, - ), - errorWidget: (context, url, error) => new Icon(Icons.error), - fit: BoxFit.contain, - height: constraints.maxHeight / 2, - width: double.infinity, + CachedNetworkImage( + imageUrl: (product.images.length > 0 + ? product.images.first.src + : app_product_placeholder_image), + placeholder: (context, url) => Container( + child: Center( + child: CircularProgressIndicator(), + ), + height: constraints.maxHeight / 2, + ), + errorWidget: (context, url, error) => + new Icon(Icons.error), + fit: BoxFit.contain, + height: constraints.maxHeight / 2, + width: double.infinity, + ), + (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.bodyText1, + children: [ + TextSpan( + text: + "${workoutSaleDiscount(salePrice: product.salePrice, priceBefore: product.regularPrice)}% ${trans(context, "off")}", + style: Theme.of(context) + .textTheme + .bodyText1 + .copyWith( + color: Colors.black87, + fontSize: 11, + ), + ), + ], + ), + ), + ), + ) + : null), + ].where((e) => e != null).toList()), ), - (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.bodyText1, - children: [ + ), + Container( + margin: const EdgeInsets.only(top: 2, bottom: 2), + child: Text( + product.name, + style: Theme.of(context).textTheme.bodyText2, + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), + ), + Flexible( + child: Container( + height: 50, + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + AutoSizeText( + formatStringCurrency(total: product.price) + " ", + style: Theme.of(context) + .textTheme + .bodyText2 + .copyWith(fontWeight: FontWeight.w600), + textAlign: TextAlign.left, + ), + (product.onSale && product.type != "variable" + ? RichText( + text: TextSpan(children: [ TextSpan( - text: - "${workoutSaleDiscount(salePrice: product.salePrice, priceBefore: product.regularPrice)}% ${trans(context, "off")}", + text: '${trans(context, "Was")}: ', style: Theme.of(context) .textTheme .bodyText1 .copyWith( - color: Colors.black87, - fontSize: 11, - ), + color: Colors.black54, + fontSize: 11), ), - ], - ), - ), - ), - ) - : null), - ].where((e) => e != null).toList()), - ), - ), - Container( - margin: const EdgeInsets.only(top: 2, bottom: 2), - child: Text( - product.name, - style: Theme.of(context).textTheme.bodyText2, - maxLines: 2, - overflow: TextOverflow.ellipsis, - ), - ), - Flexible( - child: Container( - height: 50, - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - AutoSizeText( - formatStringCurrency(total: product.price) + " ", - style: Theme.of(context) - .textTheme - .bodyText2 - .copyWith(fontWeight: FontWeight.w600), - textAlign: TextAlign.left, + TextSpan( + text: formatStringCurrency( + total: product.regularPrice, + ), + style: Theme.of(context) + .textTheme + .bodyText1 + .copyWith( + decoration: + TextDecoration.lineThrough, + color: Colors.grey, + fontSize: 11), + ), + ]), + ) + : null), + ].where((e) => e != null).toList(), ), - (product.onSale && product.type != "variable" - ? RichText( - text: TextSpan(children: [ - TextSpan( - text: '${trans(context, "Was")}: ', - style: Theme.of(context) - .textTheme - .bodyText1 - .copyWith( - color: Colors.black54, fontSize: 11), - ), - TextSpan( - text: formatStringCurrency( - total: product.regularPrice, - ), - style: Theme.of(context) - .textTheme - .bodyText1 - .copyWith( - decoration: TextDecoration.lineThrough, - color: Colors.grey, - fontSize: 11), - ), - ]), - ) - : null), - ].where((e) => e != null).toList(), + ), ), - ), + ].where((e) => e != null).toList(), ), - ].where((e) => e != null).toList(), + ), + onTap: () => onTap(product), ), - ), - onTap: () => onTap(product), - ), - ); + ); } void wsModalBottom(BuildContext context, {String title, Widget bodyWidget, Widget extraWidget}) { showModalBottomSheet( - context: context, - backgroundColor: Colors.transparent, - builder: (builder) { - return SafeArea( - child: Container( - height: double.infinity, - width: double.infinity, - color: Colors.transparent, - child: new Container( - padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4), - decoration: new BoxDecoration( - color: Colors.white, - borderRadius: new BorderRadius.only( - topLeft: const Radius.circular(10.0), - topRight: const Radius.circular(10.0), - ), + context: context, + backgroundColor: Colors.transparent, + builder: (builder) { + return SafeArea( + child: Container( + height: double.infinity, + width: double.infinity, + color: Colors.transparent, + child: new Container( + padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4), + decoration: new BoxDecoration( + color: Colors.white, + borderRadius: new BorderRadius.only( + topLeft: const Radius.circular(10.0), + topRight: const Radius.circular(10.0), ), - child: Column( - children: [ - Padding( - padding: EdgeInsets.symmetric(vertical: 16), - child: Text( - title, - style: Theme.of(context) - .primaryTextTheme - .headline4 - .copyWith(fontSize: 20), - textAlign: TextAlign.left, - ), + ), + child: Column( + children: [ + Padding( + padding: EdgeInsets.symmetric(vertical: 16), + child: Text( + title, + style: Theme.of(context) + .primaryTextTheme + .headline4 + .copyWith(fontSize: 20), + textAlign: TextAlign.left, ), - Expanded( - child: Container( - padding: - EdgeInsets.symmetric(horizontal: 16, vertical: 8), - width: double.infinity, - decoration: BoxDecoration( - boxShadow: wsBoxShadow(), - color: Colors.white, - borderRadius: BorderRadius.circular(8), - ), - child: bodyWidget, + ), + Expanded( + child: Container( + padding: + EdgeInsets.symmetric(horizontal: 16, vertical: 8), + width: double.infinity, + decoration: BoxDecoration( + boxShadow: wsBoxShadow(), + color: Colors.white, + borderRadius: BorderRadius.circular(8), ), + child: bodyWidget, ), - extraWidget ?? null - ].where((t) => t != null).toList(), - )), - ), - ); - }); -} - -FutureBuilder getTotalWidget() { - return FutureBuilder( - future: Cart.getInstance.getTotal(withFormat: true), - builder: (BuildContext context, AsyncSnapshot snapshot) { - switch (snapshot.connectionState) { - case ConnectionState.waiting: - return showAppLoader(); - default: - if (snapshot.hasError) - return Text(""); - else - return new Padding( - child: wsRow2Text(context, - text1: trans(context, "Total"), text2: snapshot.data), - padding: EdgeInsets.only(bottom: 15, top: 15), - ); - } + ), + extraWidget ?? null + ].where((t) => t != null).toList(), + )), + ), + ); }, ); } +FutureBuilder getTotalWidget() => FutureBuilder( + future: Cart.getInstance.getTotal(withFormat: true), + builder: (BuildContext context, AsyncSnapshot snapshot) { + switch (snapshot.connectionState) { + case ConnectionState.waiting: + return showAppLoader(); + default: + if (snapshot.hasError) + return Text(""); + else + return new Padding( + child: wsRow2Text(context, + text1: trans(context, "Total"), text2: snapshot.data), + padding: EdgeInsets.only(bottom: 15, top: 15), + ); + } + }, + ); + FutureBuilder wsCheckoutTotalWidgetFB({String title, TaxRate taxRate}) { return FutureBuilder( future: @@ -507,7 +690,7 @@ FutureBuilder wsWidgetCartItemsFB( itemCount: snapshot.data.length, itemBuilder: (BuildContext context, int index) { CartLineItem cartLineItem = snapshot.data[index]; - return wsCardCartItem(context, + return CartItemContainer( cartLineItem: cartLineItem, actionIncrementQuantity: actionIncrementQuantity, actionDecrementQuantity: actionDecrementQuantity, @@ -518,134 +701,179 @@ FutureBuilder wsWidgetCartItemsFB( ); } -Widget wsCardCartItem(BuildContext context, - {CartLineItem cartLineItem, - void Function() actionIncrementQuantity, - void Function() actionDecrementQuantity, - void Function() actionRemoveItem}) { - return Container( - margin: EdgeInsets.only(bottom: 7), - decoration: BoxDecoration( - color: Colors.white, - border: Border( - bottom: BorderSide( - color: Colors.black12, - width: 1, - ))), - padding: EdgeInsets.symmetric(vertical: 8, horizontal: 8), - child: Column( - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Flexible( - child: CachedNetworkImage( - imageUrl: cartLineItem.imageSrc == "" - ? app_product_placeholder_image - : cartLineItem.imageSrc, - width: 100, - height: 100, - fit: BoxFit.contain, - ), - flex: 2, - ), - Flexible( - child: Padding( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - cartLineItem.name, - style: Theme.of(context).primaryTextTheme.subtitle1, - overflow: TextOverflow.ellipsis, - maxLines: 3, - ), - (cartLineItem.variationOptions != null - ? Text(cartLineItem.variationOptions, - style: Theme.of(context).primaryTextTheme.bodyText1) - : Container()), - Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - (cartLineItem.stockStatus == "outofstock" - ? trans(context, "Out of stock") - : trans(context, "In Stock")), - style: (cartLineItem.stockStatus == "outofstock" - ? Theme.of(context).textTheme.caption - : Theme.of(context).primaryTextTheme.bodyText2), - ), - Text( - formatDoubleCurrency( - total: parseWcPrice(cartLineItem.total), - ), - style: Theme.of(context).primaryTextTheme.subtitle1, - textAlign: TextAlign.center, - ) - ], - ), - ], - ), - padding: EdgeInsets.only(left: 8), - ), - flex: 5, - ) - ], - ), - Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.spaceBetween, +class CartItemContainer extends StatelessWidget { + const CartItemContainer({ + Key key, + @required this.cartLineItem, + @required this.actionIncrementQuantity, + @required this.actionDecrementQuantity, + @required this.actionRemoveItem, + }) : super(key: key); + + final CartLineItem cartLineItem; + final void Function() actionIncrementQuantity; + final void Function() actionDecrementQuantity; + final void Function() actionRemoveItem; + + @override + Widget build(BuildContext context) => Container( + margin: EdgeInsets.only(bottom: 7), + decoration: BoxDecoration( + color: Colors.white, + border: Border( + bottom: BorderSide( + color: Colors.black12, + width: 1, + ))), + padding: EdgeInsets.symmetric(vertical: 8, horizontal: 8), + child: Column( children: [ Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - IconButton( - icon: Icon(Icons.add_circle_outline), - onPressed: actionIncrementQuantity, - highlightColor: Colors.transparent, + Flexible( + child: CachedNetworkImage( + imageUrl: cartLineItem.imageSrc == "" + ? app_product_placeholder_image + : cartLineItem.imageSrc, + width: 100, + height: 100, + fit: BoxFit.contain, + ), + flex: 2, + ), + Flexible( + child: Padding( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + cartLineItem.name, + style: Theme.of(context).primaryTextTheme.subtitle1, + overflow: TextOverflow.ellipsis, + maxLines: 3, + ), + (cartLineItem.variationOptions != null + ? Text(cartLineItem.variationOptions, + style: Theme.of(context) + .primaryTextTheme + .bodyText1) + : Container()), + Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + (cartLineItem.stockStatus == "outofstock" + ? trans(context, "Out of stock") + : trans(context, "In Stock")), + style: (cartLineItem.stockStatus == "outofstock" + ? Theme.of(context).textTheme.caption + : Theme.of(context) + .primaryTextTheme + .bodyText2), + ), + Text( + formatDoubleCurrency( + total: parseWcPrice(cartLineItem.total), + ), + style: + Theme.of(context).primaryTextTheme.subtitle1, + textAlign: TextAlign.center, + ) + ], + ), + ], + ), + padding: EdgeInsets.only(left: 8), + ), + flex: 5, + ) + ], + ), + Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + IconButton( + icon: Icon(Icons.add_circle_outline), + onPressed: actionIncrementQuantity, + highlightColor: Colors.transparent, + ), + Text(cartLineItem.quantity.toString(), + style: Theme.of(context).primaryTextTheme.headline6), + IconButton( + icon: Icon(Icons.remove_circle_outline), + onPressed: actionDecrementQuantity, + highlightColor: Colors.transparent, + ), + ], ), - Text(cartLineItem.quantity.toString(), - style: Theme.of(context).primaryTextTheme.headline6), IconButton( - icon: Icon(Icons.remove_circle_outline), - onPressed: actionDecrementQuantity, + alignment: Alignment.centerRight, + icon: Icon(Icons.delete_outline, + color: Colors.deepOrangeAccent, size: 20), + onPressed: actionRemoveItem, highlightColor: Colors.transparent, ), ], - ), - IconButton( - alignment: Alignment.centerRight, - icon: Icon(Icons.delete_outline, - color: Colors.deepOrangeAccent, size: 20), - onPressed: actionRemoveItem, - highlightColor: Colors.transparent, - ), + ) ], - ) - ], - ), - ); + ), + ); } -Widget storeLogo({double height, double width}) { - return cachedImage(app_logo_url, +class StoreLogo extends StatelessWidget { + const StoreLogo({ + Key key, + this.height = 100, + this.width = 100, + this.placeholder = const CircularProgressIndicator(), + this.fit = BoxFit.contain, + }) : super(key: key); + + final double height; + final double width; + final Widget placeholder; + final BoxFit fit; + + @override + Widget build(BuildContext context) => CachedImage( + image: AppHelper.instance.appConfig.appLogo, height: height, - placeholder: Container(height: height ?? 100, width: width ?? 100)); + placeholder: Container(height: height, width: width)); } -Widget cachedImage(image, {double height, Widget placeholder, BoxFit fit}) { - return CachedNetworkImage( - imageUrl: image, - placeholder: (context, url) => - placeholder ?? new CircularProgressIndicator(), - errorWidget: (context, url, error) => new Icon(Icons.error), - height: height ?? null, - width: null, - alignment: Alignment.center, - fit: fit, - ); +class CachedImage extends StatelessWidget { + const CachedImage({ + Key key, + this.image, + this.height = 70, + this.width = 70, + this.placeholder = const CircularProgressIndicator(), + this.fit = BoxFit.contain, + }) : super(key: key); + + final String image; + final double height; + final double width; + final Widget placeholder; + final BoxFit fit; + + @override + Widget build(BuildContext context) => CachedNetworkImage( + imageUrl: image, + placeholder: (context, url) => placeholder, + errorWidget: (context, url, error) => new Icon(Icons.error), + height: height, + width: width, + alignment: Alignment.center, + fit: fit, + ); } diff --git a/LabelStoreMax/pubspec.lock b/LabelStoreMax/pubspec.lock index 62bc1d2..7bed507 100644 --- a/LabelStoreMax/pubspec.lock +++ b/LabelStoreMax/pubspec.lock @@ -21,7 +21,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety.1" + version: "2.5.0" auto_size_text: dependency: "direct main" description: @@ -35,7 +35,7 @@ packages: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" bubble_tab_indicator: dependency: "direct main" description: @@ -56,28 +56,28 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.3" + version: "1.15.0" convert: dependency: transitive description: @@ -154,7 +154,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" ffi: dependency: transitive description: @@ -314,14 +314,21 @@ packages: name: intl url: "https://pub.dartlang.org" source: hosted - version: "0.16.1" + version: "0.17.0" + js: + dependency: transitive + description: + name: js + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.3" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety.1" + version: "0.12.10" math_expressions: dependency: "direct main" description: @@ -335,7 +342,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" octo_image: dependency: transitive description: @@ -363,7 +370,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.1" + version: "1.8.0" path_provider: dependency: transitive description: @@ -447,7 +454,7 @@ packages: name: pull_to_refresh url: "https://pub.dartlang.org" source: hosted - version: "1.6.3" + version: "1.6.4" razorpay_flutter: dependency: "direct main" description: @@ -515,7 +522,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.2" + version: "1.8.0" sqflite: dependency: transitive description: @@ -536,7 +543,7 @@ packages: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.1" + version: "1.10.0" status_alert: dependency: "direct main" description: @@ -550,14 +557,14 @@ packages: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" synchronized: dependency: transitive description: @@ -571,14 +578,14 @@ packages: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety.2" + version: "0.2.19" transformer_page_view: dependency: transitive description: @@ -592,7 +599,7 @@ packages: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" url_launcher: dependency: "direct main" description: @@ -648,7 +655,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" win32: dependency: transitive description: @@ -662,7 +669,7 @@ packages: name: woosignal url: "https://pub.dartlang.org" source: hosted - version: "1.3.1" + version: "1.4.0" woosignal_stripe: dependency: "direct main" description: @@ -699,5 +706,5 @@ packages: source: hosted version: "2.2.1" sdks: - dart: ">=2.10.0 <2.11.0" - flutter: ">=1.22.0 <2.0.0" + dart: ">=2.12.0-0.0 <3.0.0" + flutter: ">=1.22.0" diff --git a/LabelStoreMax/pubspec.yaml b/LabelStoreMax/pubspec.yaml index 3fde0a2..8b750f0 100644 --- a/LabelStoreMax/pubspec.yaml +++ b/LabelStoreMax/pubspec.yaml @@ -1,14 +1,14 @@ # Official WooSignal App Template for WooCommerce # Label StoreMax -# Version 2.6.0 +# Version 3.0.0 # Homepage: https://woosignal.com # Author: Anthony Gordon # Documentation: https://woosignal.com/docs/app/ios/label-storemax ### Change App Icon # 1 Replace: assets/icon/appicon.png (1024px1024px icon size) -# 2 Run this command from terminal: "flutter pub run flutter_launcher_icons:main" +# 2 Run this command from the terminal: "flutter pub run flutter_launcher_icons:main" ### Uploading the IOS/Android app # IOS https://flutter.dev/docs/deployment/ios @@ -19,11 +19,13 @@ description: LabelStoreMAX version: 1.0.0+1 +publish_to: none + environment: - sdk: ">=2.1.0 <3.0.0" + sdk: ">=2.7.0 <3.0.0" dependencies: - woosignal: ^1.3.1 + woosignal: ^1.4.0 woosignal_stripe: ^0.1.0 razorpay_flutter: 1.2.3 wp_json_api: ^2.0.0 @@ -35,8 +37,8 @@ dependencies: flutter_money_formatter: ^0.8.3 platform_alert_dialog: ^1.0.0+2 flutter_web_browser: ^0.13.1 - pull_to_refresh: 1.6.3 - intl: ^0.16.1 + pull_to_refresh: 1.6.4 + intl: ^0.17.0 flutter_swiper: ^1.1.6 edge_alert: ^0.0.1 bubble_tab_indicator: ^0.1.4 @@ -67,7 +69,7 @@ flutter_icons: image_path: "assets/icon/appicon.png" dependency_overrides: - intl: + intl: ^0.17.0-nullsafety.2 flutter: diff --git a/README.md b/README.md index 176f405..311bcf7 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ # WooCommerce App: Label StoreMax -### Label StoreMax - v2.6.0 +### Label StoreMax - v3.0.0 [Official WooSignal WooCommerce App](https://woosignal.com) @@ -19,7 +19,7 @@ Label StoreMax is a WooCommerce Flutter App template, built exclusively for online shopping and it offers a great variety of options to customise the look and feel of the App. Label StoreMax supports product views, multi-variation products, category searches + more. -1. Supports the latest WooCommerce (3.0+) +1. Supports the latest WooCommerce (3.5+) 2. [Documentation available](https://woosignal.com/docs/app/ios/label-storemax) ## Some features integrated