From 4269c5b7e016b72a5668e6bdae3d5c5975ee34e9 Mon Sep 17 00:00:00 2001 From: WooSignal Date: Wed, 22 Jul 2020 22:54:12 +0100 Subject: [PATCH] v2.1.0 update for RazorPay, FreeShipping minimum value, new grid --- LabelStoreMax/CHANGELOG.md | 6 ++ 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 +- LabelStoreMax/lib/helpers/tools.dart | 40 ++++--- LabelStoreMax/lib/labelconfig.dart | 2 +- LabelStoreMax/lib/models/shipping_type.dart | 11 +- .../lib/pages/checkout_confirmation.dart | 24 +++++ .../lib/pages/checkout_shipping_type.dart | 101 ++++++++++++------ LabelStoreMax/lib/pages/home.dart | 4 +- LabelStoreMax/lib/widgets/woosignal_ui.dart | 15 ++- LabelStoreMax/pubspec.lock | 29 +++-- LabelStoreMax/pubspec.yaml | 7 +- README.md | 4 +- 18 files changed, 196 insertions(+), 75 deletions(-) diff --git a/LabelStoreMax/CHANGELOG.md b/LabelStoreMax/CHANGELOG.md index c647fe6..95b4400 100644 --- a/LabelStoreMax/CHANGELOG.md +++ b/LabelStoreMax/CHANGELOG.md @@ -1,3 +1,9 @@ +## [2.1.0] - 2020-07-22 + +* Pubspec.yaml update for RazorPay +* FreeShipping minimum value feature +* New grid collection layout + ## [2.0.9] - 2020-06-19 * New UI for home products diff --git a/LabelStoreMax/lang/de.json b/LabelStoreMax/lang/de.json index 737c17a..0a20ad1 100644 --- a/LabelStoreMax/lang/de.json +++ b/LabelStoreMax/lang/de.json @@ -169,5 +169,7 @@ "That email is taken, try another": "Diese E-Mail wird genommen, versuchen Sie es mit einer anderen", "The email field is empty": "Das E-Mail-Feld ist leer", "No more orders": "Keine Bestellungen mehr", - "Account updated": "Konto aktualisiert" + "Account updated": "Konto aktualisiert", + "Spend a minimum of": "Geben Sie mindestens ein", + "for": "zum" } \ No newline at end of file diff --git a/LabelStoreMax/lang/en.json b/LabelStoreMax/lang/en.json index 48eccd3..792a1d0 100644 --- a/LabelStoreMax/lang/en.json +++ b/LabelStoreMax/lang/en.json @@ -169,5 +169,7 @@ "That email is taken, try another": "That email is taken, try another", "The email field is empty": "The email field is empty", "No more orders": "No more orders", - "Account updated": "Account updated" + "Account updated": "Account updated", + "Spend a minimum of": "Spend a minimum of", + "for": "for" } \ No newline at end of file diff --git a/LabelStoreMax/lang/es.json b/LabelStoreMax/lang/es.json index 2243345..f47aa6b 100644 --- a/LabelStoreMax/lang/es.json +++ b/LabelStoreMax/lang/es.json @@ -169,5 +169,7 @@ "That email is taken, try another": "Ese correo electrónico está tomado, prueba con otro", "The email field is empty": "El campo de correo electrónico está vacío.", "No more orders": "No mas pedidos", - "Account updated": "Cuenta actualizada" + "Account updated": "Cuenta actualizada", + "Spend a minimum of": "Gasta un mínimo de", + "for": "para" } \ No newline at end of file diff --git a/LabelStoreMax/lang/fr.json b/LabelStoreMax/lang/fr.json index 708be8b..ec4c248 100644 --- a/LabelStoreMax/lang/fr.json +++ b/LabelStoreMax/lang/fr.json @@ -169,5 +169,7 @@ "That email is taken, try another": "Cet e-mail est pris, essayez un autre", "The email field is empty": "Le champ e-mail est vide", "No more orders": "Plus de commandes", - "Account updated": "Compte mis à jour" + "Account updated": "Compte mis à jour", + "Spend a minimum of": "Dépensez un minimum de", + "for": "pour" } \ No newline at end of file diff --git a/LabelStoreMax/lang/hi.json b/LabelStoreMax/lang/hi.json index ba991c9..45350cb 100644 --- a/LabelStoreMax/lang/hi.json +++ b/LabelStoreMax/lang/hi.json @@ -169,5 +169,7 @@ "That email is taken, try another": "vah eemel liya gaya hai, doosara prayaas karen", "The email field is empty": "eemel feeld khaalee hai", "No more orders": "aur koee aadesh nahin", - "Account updated": "khaata apadet kiya gaya" + "Account updated": "khaata apadet kiya gaya", + "Spend a minimum of": "kam se kam kharch karen", + "for": "ke liye" } \ No newline at end of file diff --git a/LabelStoreMax/lang/it.json b/LabelStoreMax/lang/it.json index 896dd7b..8a4091d 100644 --- a/LabelStoreMax/lang/it.json +++ b/LabelStoreMax/lang/it.json @@ -169,5 +169,7 @@ "That email is taken, try another": "Quell'e-mail è stata presa, provane un'altra", "The email field is empty": "Il campo email è vuoto", "No more orders": "Niente più ordini", - "Account updated": "Account aggiornato" + "Account updated": "Account aggiornato", + "Spend a minimum of": "Spendi un minimo di", + "for": "per" } \ No newline at end of file diff --git a/LabelStoreMax/lang/pt.json b/LabelStoreMax/lang/pt.json index 8623879..9075bea 100644 --- a/LabelStoreMax/lang/pt.json +++ b/LabelStoreMax/lang/pt.json @@ -169,5 +169,7 @@ "That email is taken, try another": "Esse e-mail foi recebido, tente outro", "The email field is empty": "O campo de email está vazio", "No more orders": "Não há mais pedidos", - "Account updated": "Conta atualizada" + "Account updated": "Conta atualizada", + "Spend a minimum of": "Gaste um mínimo de", + "for": "para" } \ No newline at end of file diff --git a/LabelStoreMax/lib/helpers/tools.dart b/LabelStoreMax/lib/helpers/tools.dart index d7d79fd..38c66bb 100644 --- a/LabelStoreMax/lib/helpers/tools.dart +++ b/LabelStoreMax/lib/helpers/tools.dart @@ -11,6 +11,7 @@ import 'dart:developer'; 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_localizations.dart'; @@ -78,7 +79,12 @@ class EdgeAlertStyle { } void showEdgeAlertWith(context, - {title = "", desc = "", int gravity = 1, int style = 1, IconData icon}) { + {title = "", + desc = "", + int gravity = 1, + int style = 1, + IconData icon, + int duration}) { switch (style) { case 1: // SUCCESS EdgeAlert.show(context, @@ -87,7 +93,7 @@ void showEdgeAlertWith(context, gravity: gravity, backgroundColor: Colors.green, icon: icon ?? Icons.check, - duration: EdgeAlert.LENGTH_LONG); + duration: duration ?? EdgeAlert.LENGTH_LONG); break; case 2: // WARNING EdgeAlert.show(context, @@ -96,7 +102,7 @@ void showEdgeAlertWith(context, gravity: gravity, backgroundColor: Colors.orange, icon: icon ?? Icons.error_outline, - duration: EdgeAlert.LENGTH_LONG); + duration: duration ?? EdgeAlert.LENGTH_LONG); break; case 3: // INFO EdgeAlert.show(context, @@ -105,7 +111,7 @@ void showEdgeAlertWith(context, gravity: gravity, backgroundColor: Colors.teal, icon: icon ?? Icons.info, - duration: EdgeAlert.LENGTH_LONG); + duration: duration ?? EdgeAlert.LENGTH_LONG); break; case 4: // DANGER EdgeAlert.show(context, @@ -114,7 +120,7 @@ void showEdgeAlertWith(context, gravity: gravity, backgroundColor: Colors.redAccent, icon: icon ?? Icons.warning, - duration: EdgeAlert.LENGTH_LONG); + duration: duration ?? EdgeAlert.LENGTH_LONG); break; default: break; @@ -509,14 +515,24 @@ Widget refreshableScroll(context, onRefresh: onRefresh, onLoading: onLoading, child: (products.length != null && products.length > 0 - ? GridView.count( + ? StaggeredGridView.countBuilder( crossAxisCount: 2, - shrinkWrap: true, - children: List.generate( - products.length, - (index) => wsCardProductItem(context, - index: index, product: products[index], onTap: onTap), - )) + itemCount: products.length, + itemBuilder: (BuildContext context, int index) { + return Container( + height: 200, + child: wsCardProductItem( + context, + index: (index), + product: products[index], + onTap: onTap, + ), + ); + }, + staggeredTileBuilder: (int index) => new StaggeredTile.fit(1), + mainAxisSpacing: 4.0, + crossAxisSpacing: 4.0, + ) : wsNoResults(context)), ); } diff --git a/LabelStoreMax/lib/labelconfig.dart b/LabelStoreMax/lib/labelconfig.dart index e89d792..446b548 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.0.9 + VERSION - 2.1.0 https://woosignal.com */ diff --git a/LabelStoreMax/lib/models/shipping_type.dart b/LabelStoreMax/lib/models/shipping_type.dart index 50a70cc..0229ef3 100644 --- a/LabelStoreMax/lib/models/shipping_type.dart +++ b/LabelStoreMax/lib/models/shipping_type.dart @@ -15,12 +15,17 @@ import '../helpers/tools.dart'; class ShippingType { String methodId; String cost; + String minimumValue; dynamic object; - ShippingType({this.methodId, this.object, this.cost}); + ShippingType({this.methodId, this.object, this.cost, this.minimumValue}); - Map toJson() => - {'methodId': methodId, 'object': object, 'cost': cost}; + Map toJson() => { + 'methodId': methodId, + 'object': object, + 'cost': cost, + 'minimumValue': minimumValue + }; String getTotal({bool withFormatting}) { if (this.methodId != null && this.object != null) { diff --git a/LabelStoreMax/lib/pages/checkout_confirmation.dart b/LabelStoreMax/lib/pages/checkout_confirmation.dart index f76b0b5..98918d3 100644 --- a/LabelStoreMax/lib/pages/checkout_confirmation.dart +++ b/LabelStoreMax/lib/pages/checkout_confirmation.dart @@ -12,6 +12,7 @@ import 'package:flutter/material.dart'; import 'package:label_storemax/app_payment_methods.dart'; import 'package:label_storemax/app_state_options.dart'; import 'package:label_storemax/helpers/tools.dart'; +import 'package:label_storemax/models/cart.dart'; import 'package:label_storemax/models/checkout_session.dart'; import 'package:label_storemax/models/customer_address.dart'; import 'package:label_storemax/widgets/app_loader.dart'; @@ -376,6 +377,29 @@ class CheckoutConfirmationPageState extends State { return; } + if (CheckoutSession.getInstance.shippingType.minimumValue != null) { + String total = await Cart.getInstance.getTotal(); + if (total == null) { + return; + } + double doubleTotal = double.parse(total); + double doubleMinimumValue = + double.parse(CheckoutSession.getInstance.shippingType.minimumValue); + + if (doubleTotal < doubleMinimumValue) { + showEdgeAlertWith(context, + title: trans(context, "Sorry"), + desc: trans(context, "Spend a minimum of") + + " " + + formatDoubleCurrency(total: doubleMinimumValue) + + " ${trans(context, "for")} " + + CheckoutSession.getInstance.shippingType.getTitle(), + style: EdgeAlertStyle.INFO, + duration: 3); + return; + } + } + if (_isProcessingPayment == true) { return; } diff --git a/LabelStoreMax/lib/pages/checkout_shipping_type.dart b/LabelStoreMax/lib/pages/checkout_shipping_type.dart index b840225..af0107b 100644 --- a/LabelStoreMax/lib/pages/checkout_shipping_type.dart +++ b/LabelStoreMax/lib/pages/checkout_shipping_type.dart @@ -119,13 +119,15 @@ class _CheckoutShippingTypePageState extends State { .where((t) => t != null) .toList() .forEach((freeShipping) { - if (isNumeric(freeShipping.cost)) { + if (isNumeric(freeShipping.cost) || + freeShipping.cost == 'min_amount') { Map tmpShippingOption = {}; tmpShippingOption = { "id": freeShipping.id, "method_id": "free_shipping", "title": freeShipping.title, - "cost": freeShipping.cost, + "cost": "0.00", + "min_amount": freeShipping.minimumOrderAmount, "object": freeShipping }; _wsShippingOptions.add(tmpShippingOption); @@ -246,11 +248,11 @@ class _CheckoutShippingTypePageState extends State { contentPadding: EdgeInsets.only( left: 16, right: 16), title: Text( - _wsShippingOptions[index] - ['title'], - style: Theme.of(context) - .primaryTextTheme - .subtitle1), + _wsShippingOptions[index]['title'], + style: Theme.of(context) + .primaryTextTheme + .subtitle1, + ), selected: true, subtitle: FutureBuilder( future: _getShippingPrice(index), @@ -267,14 +269,52 @@ class _CheckoutShippingTypePageState extends State { case ConnectionState.done: if (snapshot.hasError) return Text(''); - return Text( - trans(context, "Price") + - ": " + - formatStringCurrency( - total: snapshot - .data)); + return RichText( + text: TextSpan( + text: '', + style: DefaultTextStyle.of( + context) + .style, + children: [ + (_wsShippingOptions[index] + ["object"] + is FreeShipping + ? TextSpan( + text: + "Free postage") + : TextSpan( + text: trans( + context, + "Price") + + ": " + + formatStringCurrency( + total: snapshot + .data), + )), + _wsShippingOptions[index][ + "min_amount"] != + null + ? TextSpan( + text: "\nSpend a minimum of " + + formatStringCurrency( + total: _wsShippingOptions[ + index] + [ + "min_amount"]), + style: Theme.of( + context) + .primaryTextTheme + .bodyText2 + .copyWith( + fontSize: + 14)) + : null, + ] + .where((e) => e != null) + .toList(), + )); } - return null; // unreachable + return null; }, ), trailing: (CheckoutSession.getInstance @@ -288,23 +328,8 @@ class _CheckoutShippingTypePageState extends State { ["object"] ? Icon(Icons.check) : null), - onTap: () async { - ShippingType shippingType = - ShippingType(); - shippingType.object = - _wsShippingOptions[index] - ['object']; - shippingType.methodId = - _wsShippingOptions[index] - ['method_id']; - shippingType.cost = - await _getShippingPrice(index); - - CheckoutSession.getInstance - .shippingType = shippingType; - - Navigator.pop(context); - }, + onTap: () => + _handleCheckoutTapped(index), ); }, ), @@ -339,4 +364,18 @@ class _CheckoutShippingTypePageState extends State { ), ); } + + _handleCheckoutTapped(int index) async { + ShippingType shippingType = ShippingType(); + shippingType.object = _wsShippingOptions[index]['object']; + shippingType.methodId = _wsShippingOptions[index]['method_id']; + if (_wsShippingOptions[index]['min_amount'] != null) { + shippingType.minimumValue = _wsShippingOptions[index]['min_amount']; + } + shippingType.cost = await _getShippingPrice(index); + + CheckoutSession.getInstance.shippingType = shippingType; + + Navigator.pop(context); + } } diff --git a/LabelStoreMax/lib/pages/home.dart b/LabelStoreMax/lib/pages/home.dart index bf27b70..5b61c02 100644 --- a/LabelStoreMax/lib/pages/home.dart +++ b/LabelStoreMax/lib/pages/home.dart @@ -59,7 +59,8 @@ class _HomePageState extends State { } _fetchCategories() async { - _categories = await appWooSignal((api) => api.getProductCategories()); + _categories = + await appWooSignal((api) => api.getProductCategories(page: 100)); } _fetchMoreProducts() async { @@ -133,6 +134,7 @@ class _HomePageState extends State { wsCartIcon(context, key: _key), ], ), + backgroundColor: Colors.white, body: SafeArea( minimum: safeAreaDefault(), child: Column( diff --git a/LabelStoreMax/lib/widgets/woosignal_ui.dart b/LabelStoreMax/lib/widgets/woosignal_ui.dart index a5e1eae..7f00731 100644 --- a/LabelStoreMax/lib/widgets/woosignal_ui.dart +++ b/LabelStoreMax/lib/widgets/woosignal_ui.dart @@ -220,6 +220,11 @@ Widget wsCardProductItem(BuildContext context, 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 @@ -237,11 +242,11 @@ Widget wsCardProductItem(BuildContext context, ), (product.onSale && product.type != "variable" ? Positioned( - bottom: 5, - left: 8, - right: 8, + bottom: 0, + left: 0, + right: 0, child: Container( - padding: EdgeInsets.all(2), + padding: EdgeInsets.all(3), decoration: BoxDecoration( color: Colors.white70, borderRadius: BorderRadius.circular(4), @@ -273,7 +278,7 @@ Widget wsCardProductItem(BuildContext context, ), ), Container( - margin: const EdgeInsets.only(top: 8, bottom: 8), + margin: const EdgeInsets.only(top: 2, bottom: 2), child: Text( product.name, style: Theme.of(context).textTheme.bodyText2, diff --git a/LabelStoreMax/pubspec.lock b/LabelStoreMax/pubspec.lock index bae1fba..019353b 100644 --- a/LabelStoreMax/pubspec.lock +++ b/LabelStoreMax/pubspec.lock @@ -127,6 +127,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.4" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" file: dependency: transitive description: @@ -193,6 +200,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.1.2+1" + flutter_staggered_grid_view: + dependency: "direct main" + description: + name: flutter_staggered_grid_view + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.1" flutter_swiper: dependency: "direct main" description: @@ -293,7 +307,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.6.4" + version: "1.7.0" path_provider: dependency: transitive description: @@ -385,20 +399,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.5.8" - quiver: - dependency: transitive - description: - name: quiver - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.3" razorpay_flutter: dependency: "direct main" description: name: razorpay_flutter url: "https://pub.dartlang.org" source: hosted - version: "1.2.1" + version: "1.2.2" rxdart: dependency: transitive description: @@ -508,7 +515,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.15" + version: "0.2.16" transformer_page_view: dependency: transitive description: @@ -571,7 +578,7 @@ packages: name: woosignal url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.2" woosignal_stripe: dependency: "direct main" description: diff --git a/LabelStoreMax/pubspec.yaml b/LabelStoreMax/pubspec.yaml index 7a195cb..3e6cb53 100644 --- a/LabelStoreMax/pubspec.yaml +++ b/LabelStoreMax/pubspec.yaml @@ -1,5 +1,5 @@ # Label StoreMax -# Version 2.0.9 +# Version 2.1.0 #authors: - "Anthony Gordon" #documentation: https://woosignal.com/docs/app/ios/label-storemax #homepage: https://woosignal.com/ @@ -24,9 +24,9 @@ environment: sdk: ">=2.1.0 <3.0.0" dependencies: - woosignal: ^1.1.0 + woosignal: ^1.1.2 woosignal_stripe: ^0.0.6 - razorpay_flutter: ^1.2.1 + razorpay_flutter: ^1.2.2 wp_json_api: ^0.1.4 shared_preferences: ^0.5.7+3 cached_network_image: ^2.2.0+1 @@ -47,6 +47,7 @@ dependencies: flutter_launcher_icons: ^0.7.5 auto_size_text: ^2.1.0 html: ^0.14.0+3 + flutter_staggered_grid_view: ^0.3.1 flutter: sdk: flutter diff --git a/README.md b/README.md index 23f2506..2522dc0 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,9 @@

# WooCommerce App: Label StoreMax -### Label StoreMax - v2.0.9 + +### Label StoreMax - v2.1.0 + [Official WooSignal WooCommerce App](https://woosignal.com)