New product view, Improved product sale appearance, Bug fixes

This commit is contained in:
WooSignal 2020-05-17 14:11:15 +01:00
parent fc2041d450
commit 0681097f9b
9 changed files with 113 additions and 74 deletions

View File

@ -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 ## [2.0.5] - 2020-05-16
* RazorPay checkout added * RazorPay checkout added

View File

@ -150,5 +150,7 @@
"Ship to a different address?": "Ship to a different address?", "Ship to a different address?": "Ship to a different address?",
"USE DETAILS": "USE DETAILS", "USE DETAILS": "USE DETAILS",
"Not supported, try a card payment": "Not supported, try a card payment", "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"
} }

View File

@ -151,6 +151,12 @@ String formatStringCurrency({@required String total}) {
return fmf.output.symbolOnLeft; 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 { openBrowserTab({@required String url}) async {
await FlutterWebBrowser.openWebPage( await FlutterWebBrowser.openWebPage(
url: url, androidToolbarColor: Colors.white70); url: url, androidToolbarColor: Colors.white70);
@ -499,17 +505,30 @@ Widget refreshableScroll(context,
child: (products.length != null && products.length > 0 child: (products.length != null && products.length > 0
? GridView.count( ? GridView.count(
crossAxisCount: 2, crossAxisCount: 2,
childAspectRatio: calAspectRatio(context),
shrinkWrap: true,
children: List.generate( children: List.generate(
products.length, products.length,
(index) { (index) => wsCardProductItem(context,
return wsCardProductItem(context, index: index, product: products[index], onTap: onTap),
index: index, product: products[index], onTap: onTap);
},
)) ))
: wsNoResults(context)), : 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 { class UserAuth {
UserAuth._privateConstructor(); UserAuth._privateConstructor();
static final UserAuth instance = UserAuth._privateConstructor(); static final UserAuth instance = UserAuth._privateConstructor();

View File

@ -16,7 +16,7 @@ import 'dart:ui';
Developer Notes Developer Notes
SUPPORT EMAIL - support@woosignal.com SUPPORT EMAIL - support@woosignal.com
VERSION - 2.0.5 VERSION - 2.0.6
https://woosignal.com https://woosignal.com
*/ */

View File

@ -58,9 +58,7 @@ class _HomePageState extends State<HomePage> {
} }
_fetchCategories() async { _fetchCategories() async {
_categories = await appWooSignal((api) { _categories = await appWooSignal((api) => api.getProductCategories());
return api.getProductCategories();
});
} }
_fetchMoreProducts() async { _fetchMoreProducts() async {
@ -90,9 +88,7 @@ class _HomePageState extends State<HomePage> {
title: trans(context, "Categories"), title: trans(context, "Categories"),
bodyWidget: ListView.separated( bodyWidget: ListView.separated(
itemCount: _categories.length, itemCount: _categories.length,
separatorBuilder: (cxt, i) { separatorBuilder: (cxt, i) => Divider(),
return Divider();
},
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return ListTile( return ListTile(
title: Text(parseHtmlString(_categories[index].name)), title: Text(parseHtmlString(_categories[index].name)),
@ -133,7 +129,7 @@ class _HomePageState extends State<HomePage> {
onPressed: () => Navigator.pushNamed(context, "/home-search") onPressed: () => Navigator.pushNamed(context, "/home-search")
.then((value) => _key.currentState.setState(() {})), .then((value) => _key.currentState.setState(() {})),
), ),
wsCartIcon(context, key: _key) wsCartIcon(context, key: _key),
], ],
), ),
body: SafeArea( body: SafeArea(
@ -150,7 +146,7 @@ class _HomePageState extends State<HomePage> {
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Text(trans(context, "Shop") + " / ", Text(trans(context, "Shop") + " / ",
style: Theme.of(context).primaryTextTheme.subtitle1), style: Theme.of(context).primaryTextTheme.subtitle1,),
Text( Text(
trans(context, "Newest"), trans(context, "Newest"),
style: Theme.of(context).primaryTextTheme.bodyText2, style: Theme.of(context).primaryTextTheme.bodyText2,
@ -176,7 +172,7 @@ class _HomePageState extends State<HomePage> {
onRefresh: _onRefresh, onRefresh: _onRefresh,
onLoading: _onLoading, onLoading: _onLoading,
products: _products, products: _products,
onTap: _showProduct), onTap: _showProduct,),
flex: 1, flex: 1,
)), )),
], ],

View File

@ -303,10 +303,12 @@ class _ProductDetailState extends State<ProductDetailPage> {
return CachedNetworkImage( return CachedNetworkImage(
imageUrl: _product.images[index].src, imageUrl: _product.images[index].src,
placeholder: (context, url) => placeholder: (context, url) =>
new CircularProgressIndicator( Center(
child: new CircularProgressIndicator(
strokeWidth: 2, strokeWidth: 2,
backgroundColor: Colors.black12, backgroundColor: Colors.black12,
), ),
),
errorWidget: (context, url, error) => errorWidget: (context, url, error) =>
new Icon(Icons.error), new Icon(Icons.error),
fit: BoxFit.contain, fit: BoxFit.contain,
@ -359,7 +361,7 @@ class _ProductDetailState extends State<ProductDetailPage> {
), ),
textAlign: TextAlign.right, textAlign: TextAlign.right,
), ),
(_product.onSale == true (_product.onSale == true && _product.type != "variable"
? Text( ? Text(
formatStringCurrency( formatStringCurrency(
total: _product.regularPrice), total: _product.regularPrice),

View File

@ -205,68 +205,82 @@ List<BoxShadow> wsBoxShadow({double blurRadius}) {
Widget wsCardProductItem(BuildContext context, Widget wsCardProductItem(BuildContext context,
{int index, Product product, onTap}) { {int index, Product product, onTap}) {
return InkWell( return LayoutBuilder(
builder: (cxt,constraints) => InkWell(
child: Container( child: Container(
padding: EdgeInsets.all(10), margin: EdgeInsets.all(4),
margin: EdgeInsets.all(5),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(5),
boxShadow: wsBoxShadow(blurRadius: 4),
),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Flexible( ClipRRect(
borderRadius: BorderRadius.circular(3.0),
child: CachedNetworkImage( child: CachedNetworkImage(
imageUrl: imageUrl:
(product.images.length > 0 ? product.images.first.src : ""), (product.images.length > 0 ? product.images.first.src : ""),
placeholder: (context, url) => new CircularProgressIndicator(), placeholder: (context, url) => Center(child: CircularProgressIndicator()),
errorWidget: (context, url, error) => new Icon(Icons.error), errorWidget: (context, url, error) => new Icon(Icons.error),
fit: BoxFit.contain, fit: BoxFit.cover,
height: constraints.maxHeight / 1.8,
width: double.infinity,
), ),
flex: 4,
), ),
Flexible( Padding(
child: Row( padding: const EdgeInsets.only(top: 1),
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
formatStringCurrency(total: product.price),
style: Theme.of(context).textTheme.bodyText1,
textAlign: TextAlign.center,
),
(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,
),
)
: null),
].where((t) => t != null).toList(),
),
flex: 1,
),
Expanded(
child: Text( child: Text(
product.name, product.name,
style: Theme.of(context).textTheme.bodyText2, style: Theme.of(context).textTheme.bodyText2,
overflow: TextOverflow.clip, overflow: TextOverflow.ellipsis,
maxLines: 1, maxLines: 2,
textAlign: TextAlign.left,
), ),
flex: 1, ),
) Flexible(
child: Padding(
padding: const EdgeInsets.only(top: 1),
child: Text(
formatStringCurrency(total: product.price),
style: Theme.of(context).textTheme.bodyText1.copyWith(
fontWeight: FontWeight.w600,
fontSize: 16
),
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>[
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),
width: double.infinity,
),
),
].where((e) => e != null).toList(),
),
), ),
onTap: () => onTap(product), onTap: () => onTap(product),
),
); );
} }

View File

@ -1,5 +1,5 @@
# Label StoreMax # Label StoreMax
# Version 2.0.5 # Version 2.0.6
#authors: - "Anthony Gordon" #authors: - "Anthony Gordon"
#documentation: https://woosignal.com/docs/app/ios/label-storemax #documentation: https://woosignal.com/docs/app/ios/label-storemax
#homepage: https://woosignal.com/ #homepage: https://woosignal.com/