From 0681097f9b5ecdd715ddcc6c6904018b53e79d9f Mon Sep 17 00:00:00 2001 From: WooSignal Date: Sun, 17 May 2020 14:11:15 +0100 Subject: [PATCH] New product view, Improved product sale appearance, Bug fixes --- LabelStoreMax/CHANGELOG.md | 6 + .../android/app/src/main/AndroidManifest.xml | 2 +- LabelStoreMax/lang/en.json | 4 +- LabelStoreMax/lib/helpers/tools.dart | 27 +++- LabelStoreMax/lib/labelconfig.dart | 2 +- LabelStoreMax/lib/pages/home.dart | 14 +- LabelStoreMax/lib/pages/product_detail.dart | 6 +- LabelStoreMax/lib/widgets/woosignal_ui.dart | 124 ++++++++++-------- LabelStoreMax/pubspec.yaml | 2 +- 9 files changed, 113 insertions(+), 74 deletions(-) diff --git a/LabelStoreMax/CHANGELOG.md b/LabelStoreMax/CHANGELOG.md index 65bc8fb..5c0d30d 100644 --- a/LabelStoreMax/CHANGELOG.md +++ b/LabelStoreMax/CHANGELOG.md @@ -1,3 +1,9 @@ +## [2.0.6] - 2020-05-17 + +* New product view +* Improved product sale appearance +* Bug fixes + ## [2.0.5] - 2020-05-16 * RazorPay checkout added diff --git a/LabelStoreMax/android/app/src/main/AndroidManifest.xml b/LabelStoreMax/android/app/src/main/AndroidManifest.xml index 804e012..a4095b0 100644 --- a/LabelStoreMax/android/app/src/main/AndroidManifest.xml +++ b/LabelStoreMax/android/app/src/main/AndroidManifest.xml @@ -45,4 +45,4 @@ - + \ No newline at end of file diff --git a/LabelStoreMax/lang/en.json b/LabelStoreMax/lang/en.json index b80819a..c8d4fbd 100644 --- a/LabelStoreMax/lang/en.json +++ b/LabelStoreMax/lang/en.json @@ -150,5 +150,7 @@ "Ship to a different address?": "Ship to a different address?", "USE DETAILS": "USE DETAILS", "Not supported, try a card payment": "Not supported, try a card payment", - "Invalid shipping address, please check your shipping details": "Invalid shipping address, please check your shipping details" + "Invalid shipping address, please check your shipping details": "Invalid shipping address, please check your shipping details", + "Was": "Was", + "off": "off" } \ No newline at end of file diff --git a/LabelStoreMax/lib/helpers/tools.dart b/LabelStoreMax/lib/helpers/tools.dart index fa5dde2..bbb77aa 100644 --- a/LabelStoreMax/lib/helpers/tools.dart +++ b/LabelStoreMax/lib/helpers/tools.dart @@ -151,6 +151,12 @@ String formatStringCurrency({@required String total}) { return fmf.output.symbolOnLeft; } +String workoutSaleDiscount({@required String salePrice, @required String priceBefore}) { + double dSalePrice = parseWcPrice(salePrice); + double dPriceBefore = parseWcPrice(priceBefore); + return ((dPriceBefore-dSalePrice) * (100 / dPriceBefore)).toStringAsFixed(0); +} + openBrowserTab({@required String url}) async { await FlutterWebBrowser.openWebPage( url: url, androidToolbarColor: Colors.white70); @@ -499,17 +505,30 @@ Widget refreshableScroll(context, child: (products.length != null && products.length > 0 ? GridView.count( crossAxisCount: 2, + childAspectRatio: calAspectRatio(context), + shrinkWrap: true, children: List.generate( products.length, - (index) { - return wsCardProductItem(context, - index: index, product: products[index], onTap: onTap); - }, + (index) => wsCardProductItem(context, + index: index, product: products[index], onTap: onTap), )) : wsNoResults(context)), ); } +double calAspectRatio(BuildContext context) { + if (MediaQuery.of(context).size.height > 800) { + return MediaQuery.of(context).size.width / + (MediaQuery.of(context).size.height / 1.85); + } + if (MediaQuery.of(context).size.height > 700) { + return MediaQuery.of(context).size.width / + (MediaQuery.of(context).size.height / 1.5); + } + return MediaQuery.of(context).size.width / + (MediaQuery.of(context).size.height / 1.3); +} + class UserAuth { UserAuth._privateConstructor(); static final UserAuth instance = UserAuth._privateConstructor(); diff --git a/LabelStoreMax/lib/labelconfig.dart b/LabelStoreMax/lib/labelconfig.dart index d899471..42386f5 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.5 + VERSION - 2.0.6 https://woosignal.com */ diff --git a/LabelStoreMax/lib/pages/home.dart b/LabelStoreMax/lib/pages/home.dart index 053370e..3702713 100644 --- a/LabelStoreMax/lib/pages/home.dart +++ b/LabelStoreMax/lib/pages/home.dart @@ -58,9 +58,7 @@ class _HomePageState extends State { } _fetchCategories() async { - _categories = await appWooSignal((api) { - return api.getProductCategories(); - }); + _categories = await appWooSignal((api) => api.getProductCategories()); } _fetchMoreProducts() async { @@ -90,9 +88,7 @@ class _HomePageState extends State { title: trans(context, "Categories"), bodyWidget: ListView.separated( itemCount: _categories.length, - separatorBuilder: (cxt, i) { - return Divider(); - }, + separatorBuilder: (cxt, i) => Divider(), itemBuilder: (BuildContext context, int index) { return ListTile( title: Text(parseHtmlString(_categories[index].name)), @@ -133,7 +129,7 @@ class _HomePageState extends State { onPressed: () => Navigator.pushNamed(context, "/home-search") .then((value) => _key.currentState.setState(() {})), ), - wsCartIcon(context, key: _key) + wsCartIcon(context, key: _key), ], ), body: SafeArea( @@ -150,7 +146,7 @@ class _HomePageState extends State { mainAxisAlignment: MainAxisAlignment.start, children: [ Text(trans(context, "Shop") + " / ", - style: Theme.of(context).primaryTextTheme.subtitle1), + style: Theme.of(context).primaryTextTheme.subtitle1,), Text( trans(context, "Newest"), style: Theme.of(context).primaryTextTheme.bodyText2, @@ -176,7 +172,7 @@ class _HomePageState extends State { onRefresh: _onRefresh, onLoading: _onLoading, products: _products, - onTap: _showProduct), + onTap: _showProduct,), flex: 1, )), ], diff --git a/LabelStoreMax/lib/pages/product_detail.dart b/LabelStoreMax/lib/pages/product_detail.dart index a2cd725..def3b45 100644 --- a/LabelStoreMax/lib/pages/product_detail.dart +++ b/LabelStoreMax/lib/pages/product_detail.dart @@ -303,10 +303,12 @@ class _ProductDetailState extends State { return CachedNetworkImage( imageUrl: _product.images[index].src, placeholder: (context, url) => - new CircularProgressIndicator( + Center( + child: new CircularProgressIndicator( strokeWidth: 2, backgroundColor: Colors.black12, ), + ), errorWidget: (context, url, error) => new Icon(Icons.error), fit: BoxFit.contain, @@ -359,7 +361,7 @@ class _ProductDetailState extends State { ), textAlign: TextAlign.right, ), - (_product.onSale == true + (_product.onSale == true && _product.type != "variable" ? Text( formatStringCurrency( total: _product.regularPrice), diff --git a/LabelStoreMax/lib/widgets/woosignal_ui.dart b/LabelStoreMax/lib/widgets/woosignal_ui.dart index 4791b7b..43e51c7 100644 --- a/LabelStoreMax/lib/widgets/woosignal_ui.dart +++ b/LabelStoreMax/lib/widgets/woosignal_ui.dart @@ -205,68 +205,82 @@ List wsBoxShadow({double blurRadius}) { Widget wsCardProductItem(BuildContext context, {int index, Product product, onTap}) { - return InkWell( - child: Container( - padding: EdgeInsets.all(10), - margin: EdgeInsets.all(5), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(5), - boxShadow: wsBoxShadow(blurRadius: 4), - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Flexible( - child: CachedNetworkImage( - imageUrl: - (product.images.length > 0 ? product.images.first.src : ""), - placeholder: (context, url) => new CircularProgressIndicator(), - errorWidget: (context, url, error) => new Icon(Icons.error), - fit: BoxFit.contain, + return LayoutBuilder( + builder: (cxt,constraints) => InkWell( + child: Container( + margin: EdgeInsets.all(4), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ClipRRect( + borderRadius: BorderRadius.circular(3.0), + child: CachedNetworkImage( + imageUrl: + (product.images.length > 0 ? product.images.first.src : ""), + placeholder: (context, url) => Center(child: CircularProgressIndicator()), + errorWidget: (context, url, error) => new Icon(Icons.error), + fit: BoxFit.cover, + height: constraints.maxHeight / 1.8, + width: double.infinity, + ), ), - flex: 4, - ), - Flexible( - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( + Padding( + padding: const EdgeInsets.only(top: 1), + child: Text( + product.name, + style: Theme.of(context).textTheme.bodyText2, + overflow: TextOverflow.ellipsis, + maxLines: 2, + textAlign: TextAlign.left, + ), + ), + Flexible( + child: Padding( + padding: const EdgeInsets.only(top: 1), + child: Text( formatStringCurrency(total: product.price), - style: Theme.of(context).textTheme.bodyText1, - textAlign: TextAlign.center, + style: Theme.of(context).textTheme.bodyText1.copyWith( + fontWeight: FontWeight.w600, + fontSize: 16 + ), + textAlign: TextAlign.left, ), - (product.onSale - ? Padding( - padding: const EdgeInsets.only(left: 8), - child: Text( - formatStringCurrency(total: product.regularPrice), - style: Theme.of(context).textTheme.bodyText1.copyWith( - decoration: TextDecoration.lineThrough, - color: Colors.grey, - ), - textAlign: TextAlign.left, - ), - ) + ), + ), + Flexible( + child: Container( + child: (product.onSale && product.type != "variable" + ? RichText( + textAlign: TextAlign.left, + text: TextSpan( + text: '', + style: Theme.of(context).textTheme.bodyText1, + 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 + ),), + 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((t) => t != null).toList(), + width: double.infinity, + ), ), - flex: 1, - ), - Expanded( - child: Text( - product.name, - style: Theme.of(context).textTheme.bodyText2, - overflow: TextOverflow.clip, - maxLines: 1, - ), - flex: 1, - ) - ], + ].where((e) => e != null).toList(), + ), ), + onTap: () => onTap(product), ), - onTap: () => onTap(product), ); } diff --git a/LabelStoreMax/pubspec.yaml b/LabelStoreMax/pubspec.yaml index b72cee3..75f8674 100644 --- a/LabelStoreMax/pubspec.yaml +++ b/LabelStoreMax/pubspec.yaml @@ -1,5 +1,5 @@ # Label StoreMax -# Version 2.0.5 +# Version 2.0.6 #authors: - "Anthony Gordon" #documentation: https://woosignal.com/docs/app/ios/label-storemax #homepage: https://woosignal.com/