Skip to content

Commit 0968caf

Browse files
committed
v2.5.0 - Ability to add image placeholders on products + more
1 parent 6106e18 commit 0968caf

File tree

15 files changed

+125
-89
lines changed

15 files changed

+125
-89
lines changed

LabelStoreMax/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## [2.5.0] - 2020-12-23
2+
3+
* Ability to add image placeholders on products
4+
* Dart code formatted
5+
* Pubspec.yaml dependency updates
6+
17
## [2.4.1] - 2020-12-20
28

39
* Fix subtotal bug on order creation

LabelStoreMax/android/app/src/debug/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
<uses-permission android:name="android.permission.INTERNET" />
77
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
88
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
9+
<uses-permission android:name="android.permission.VIBRATE"/>
910
</manifest>

LabelStoreMax/android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<uses-permission android:name="android.permission.INTERNET" />
99
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
1010
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
11+
<uses-permission android:name="android.permission.VIBRATE"/>
1112

1213
<application
1314
android:name="io.flutter.app.FlutterApplication"

LabelStoreMax/android/app/src/profile/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
<uses-permission android:name="android.permission.INTERNET" />
77
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
88
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
9+
<uses-permission android:name="android.permission.VIBRATE"/>
910
</manifest>

LabelStoreMax/lib/helpers/data/order_wc.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ Future<OrderWC> buildOrderWC({TaxRate taxRate, bool markPaid = true}) async {
5050

5151
tmpLineItem.total =
5252
(cartItem.quantity > 1 ? cartItem.getCartTotal() : cartItem.subtotal);
53-
tmpLineItem.subtotal = (parseWcPrice(cartItem.subtotal) * cartItem.quantity).toString();
53+
tmpLineItem.subtotal =
54+
(parseWcPrice(cartItem.subtotal) * cartItem.quantity).toString();
5455

5556
lineItems.add(tmpLineItem);
5657
});

LabelStoreMax/lib/labelconfig.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import 'dart:ui';
1616
Developer Notes
1717
1818
SUPPORT EMAIL - [email protected]
19-
VERSION - 2.4.1
19+
VERSION - 2.5.0
2020
https://woosignal.com
2121
*/
2222

@@ -57,6 +57,8 @@ const List<Locale> app_locales_supported = [
5757
// then create a new lang json file using keys from en.json
5858
// e.g. lang/es.json
5959

60+
const app_product_placeholder_image = "https://woosignal.com/images/woocommerce-placeholder.png";
61+
6062
/*<! ------ PAYMENT GATEWAYS ------!>*/
6163

6264
// Available: "Stripe", "CashOnDelivery", "RazorPay"

LabelStoreMax/lib/pages/about.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ class _AboutPageState extends State<AboutPage> {
3939
icon: Icon(Icons.close),
4040
onPressed: () => Navigator.pop(context),
4141
),
42-
title: Text(trans(context, "About"),
43-
style: Theme.of(context).primaryTextTheme.headline6),
42+
title: Text(
43+
trans(context, "About"),
44+
style: Theme.of(context).primaryTextTheme.headline6,
45+
),
4446
centerTitle: true,
4547
),
4648
body: SafeArea(
@@ -84,9 +86,7 @@ class _AboutPageState extends State<AboutPage> {
8486
if (snapshot.hasError) return Text("");
8587
return Padding(
8688
child: Text(
87-
trans(context, "Version") +
88-
": " +
89-
snapshot.data.version,
89+
"${trans(context, "Version")}: ${snapshot.data.version}",
9090
style: Theme.of(context)
9191
.primaryTextTheme
9292
.bodyText1),

LabelStoreMax/lib/pages/cart.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,11 @@ class _CartPageState extends State<CartPage> {
7676

7777
void _actionProceedToCheckout() async {
7878
List<CartLineItem> cartLineItems = await Cart.getInstance.getCart();
79+
7980
if (_isLoading == true) {
8081
return;
8182
}
83+
8284
if (cartLineItems.length <= 0) {
8385
showEdgeAlertWith(
8486
context,
@@ -89,6 +91,7 @@ class _CartPageState extends State<CartPage> {
8991
);
9092
return;
9193
}
94+
9295
if (!cartLineItems.every(
9396
(c) => c.stockStatus == 'instock' || c.stockStatus == 'onbackorder')) {
9497
showEdgeAlertWith(
@@ -100,20 +103,24 @@ class _CartPageState extends State<CartPage> {
100103
);
101104
return;
102105
}
106+
103107
CheckoutSession.getInstance.initSession();
104108
CustomerAddress sfCustomerAddress =
105109
await CheckoutSession.getInstance.getBillingAddress();
110+
106111
if (sfCustomerAddress != null) {
107112
CheckoutSession.getInstance.billingDetails.billingAddress =
108113
sfCustomerAddress;
109114
CheckoutSession.getInstance.billingDetails.shippingAddress =
110115
sfCustomerAddress;
111116
}
117+
112118
if (use_wp_login == true && !(await authCheck())) {
113119
UserAuth.instance.redirect = "/checkout";
114120
Navigator.pushNamed(context, "/account-landing");
115121
return;
116122
}
123+
117124
Navigator.pushNamed(context, "/checkout");
118125
}
119126

@@ -236,7 +243,9 @@ class _CartPageState extends State<CartPage> {
236243
),
237244
)
238245
: (_isLoading
239-
? Expanded(child: showAppLoader())
246+
? Expanded(
247+
child: showAppLoader(),
248+
)
240249
: Expanded(
241250
child: ListView.builder(
242251
padding: const EdgeInsets.all(8),

LabelStoreMax/lib/pages/home.dart

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import 'package:label_storemax/widgets/app_loader.dart';
1515
import 'package:label_storemax/widgets/cart_icon.dart';
1616
import 'package:pull_to_refresh/pull_to_refresh.dart';
1717
import 'package:woosignal/models/response/product_category.dart' as WS;
18-
import 'package:woosignal/models/response/products.dart' as WS;
18+
import 'package:woosignal/models/response/products.dart' as WSProduct;
1919
import 'package:label_storemax/widgets/woosignal_ui.dart';
2020

2121
class HomePage extends StatefulWidget {
@@ -30,7 +30,7 @@ class _HomePageState extends State<HomePage> {
3030

3131
RefreshController _refreshController =
3232
RefreshController(initialRefresh: false);
33-
List<WS.Product> _products = [];
33+
List<WSProduct.Product> _products = [];
3434
List<WS.ProductCategory> _categories = [];
3535
final GlobalKey _key = GlobalKey();
3636

@@ -72,8 +72,12 @@ class _HomePageState extends State<HomePage> {
7272
}
7373
waitForNextRequest = true;
7474

75-
List<WS.Product> products = await appWooSignal((api) => api.getProducts(
76-
perPage: 50, page: _page, status: "publish", stockStatus: "instock"));
75+
List<WSProduct.Product> products = await appWooSignal((api) =>
76+
api.getProducts(
77+
perPage: 50,
78+
page: _page,
79+
status: "publish",
80+
stockStatus: "instock"));
7781
_page = _page + 1;
7882
if (products.length == 0) {
7983
_shouldStopRequests = true;
@@ -217,7 +221,7 @@ class _HomePageState extends State<HomePage> {
217221
}
218222
}
219223

220-
_showProduct(WS.Product product) {
224+
_showProduct(WSProduct.Product product) {
221225
Navigator.pushNamed(context, "/product-detail", arguments: product)
222226
.then((value) => _key.currentState.setState(() {}));
223227
}

LabelStoreMax/lib/pages/product_detail.dart

Lines changed: 45 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,20 @@
1111
import 'package:flutter/material.dart';
1212
import 'package:flutter/painting.dart';
1313
import 'package:label_storemax/helpers/tools.dart';
14+
import 'package:label_storemax/labelconfig.dart';
1415
import 'package:label_storemax/models/cart.dart';
1516
import 'package:label_storemax/models/cart_line_item.dart';
1617
import 'package:label_storemax/widgets/app_loader.dart';
1718
import 'package:label_storemax/widgets/buttons.dart';
1819
import 'package:label_storemax/widgets/cart_icon.dart';
1920
import 'package:woosignal/models/response/product_variation.dart' as WS;
20-
import 'package:woosignal/models/response/products.dart' as WS;
21+
import 'package:woosignal/models/response/products.dart' as WSProduct;
2122
import 'package:flutter_swiper/flutter_swiper.dart';
2223
import 'package:label_storemax/widgets/woosignal_ui.dart';
2324
import 'package:cached_network_image/cached_network_image.dart';
2425

2526
class ProductDetailPage extends StatefulWidget {
26-
final WS.Product product;
27+
final WSProduct.Product product;
2728
const ProductDetailPage({Key key, @required this.product}) : super(key: key);
2829

2930
@override
@@ -34,7 +35,7 @@ class _ProductDetailState extends State<ProductDetailPage> {
3435
_ProductDetailState(this._product);
3536

3637
bool _isLoading;
37-
WS.Product _product;
38+
WSProduct.Product _product;
3839
int _quantityIndicator = 1;
3940
List<WS.ProductVariation> _productVariations = [];
4041

@@ -103,9 +104,8 @@ class _ProductDetailState extends State<ProductDetailPage> {
103104
void _modalBottomSheetOptionsForAttribute(int attributeIndex) {
104105
wsModalBottom(
105106
context,
106-
title: trans(context, "Select a") +
107-
" " +
108-
_product.attributes[attributeIndex].name,
107+
title:
108+
"${trans(context, "Select a")} ${_product.attributes[attributeIndex].name}",
109109
bodyWidget: ListView.separated(
110110
itemCount: _product.attributes[attributeIndex].options.length,
111111
separatorBuilder: (BuildContext context, int index) => Divider(),
@@ -164,9 +164,8 @@ class _ProductDetailState extends State<ProductDetailPage> {
164164
_tmpAttributeObj.containsKey(index))
165165
? Text(_tmpAttributeObj[index]["value"],
166166
style: Theme.of(context).primaryTextTheme.bodyText1)
167-
: Text(trans(context, "Select a") +
168-
" " +
169-
_product.attributes[index].name),
167+
: Text(
168+
"${trans(context, "Select a")} ${_product.attributes[index].name}"),
170169
trailing: (_tmpAttributeObj.isNotEmpty &&
171170
_tmpAttributeObj.containsKey(index))
172171
? Icon(Icons.check, color: Colors.blueAccent)
@@ -212,47 +211,48 @@ class _ProductDetailState extends State<ProductDetailPage> {
212211
return;
213212
}
214213

215-
if (findProductVariation() == null) {
214+
WS.ProductVariation productVariation = findProductVariation();
215+
if (productVariation == null) {
216216
showEdgeAlertWith(context,
217217
title: trans(context, "Oops"),
218218
desc: trans(context, "Product variation does not exist"),
219219
style: EdgeAlertStyle.WARNING);
220220
return;
221221
}
222222

223-
if (findProductVariation() != null) {
224-
if (findProductVariation().stockStatus != "instock") {
225-
showEdgeAlertWith(context,
226-
title: trans(context, "Sorry"),
227-
desc: trans(context, "This item is not in stock"),
228-
style: EdgeAlertStyle.WARNING);
229-
return;
230-
}
223+
if (productVariation.stockStatus != "instock") {
224+
showEdgeAlertWith(context,
225+
title: trans(context, "Sorry"),
226+
desc: trans(context, "This item is not in stock"),
227+
style: EdgeAlertStyle.WARNING);
228+
return;
231229
}
232230

233231
List<String> options = [];
234232
_tmpAttributeObj.forEach((k, v) {
235-
options.add(v["name"] + ": " + v["value"]);
233+
options.add("${v["name"]}: ${v["value"]}");
236234
});
237235

238236
CartLineItem cartLineItem = CartLineItem(
239-
name: _product.name,
240-
productId: _product.id,
241-
variationId: findProductVariation().id,
242-
quantity: 1,
243-
taxStatus: findProductVariation().taxStatus,
244-
shippingClassId:
245-
findProductVariation().shippingClassId.toString(),
246-
subtotal: findProductVariation().price,
247-
stockQuantity: findProductVariation().stockQuantity,
248-
isManagedStock: findProductVariation().manageStock,
249-
taxClass: findProductVariation().taxClass,
250-
imageSrc: (findProductVariation().image != null
251-
? findProductVariation().image.src
252-
: _product.images.first.src),
253-
shippingIsTaxable: _product.shippingTaxable,
254-
variationOptions: options.join(", "),
255-
total: findProductVariation().price);
237+
name: _product.name,
238+
productId: _product.id,
239+
variationId: productVariation.id,
240+
quantity: 1,
241+
taxStatus: productVariation.taxStatus,
242+
shippingClassId: productVariation.shippingClassId.toString(),
243+
subtotal: productVariation.price,
244+
stockQuantity: productVariation.stockQuantity,
245+
isManagedStock: productVariation.manageStock,
246+
taxClass: productVariation.taxClass,
247+
imageSrc: (productVariation.image != null
248+
? productVariation.image.src
249+
: _product.images.length == 0
250+
? app_product_placeholder_image
251+
: _product.images.first.src),
252+
shippingIsTaxable: _product.shippingTaxable,
253+
variationOptions: options.join(", "),
254+
total: productVariation.price,
255+
);
256256

257257
_itemAddToCart(cartLineItem: cartLineItem);
258258
Navigator.of(context).pop();
@@ -303,7 +303,9 @@ class _ProductDetailState extends State<ProductDetailPage> {
303303
child: new Swiper(
304304
itemBuilder: (BuildContext context, int index) {
305305
return CachedNetworkImage(
306-
imageUrl: _product.images[index].src,
306+
imageUrl: _product.images.length == 0
307+
? app_product_placeholder_image
308+
: _product.images[index].src,
307309
placeholder: (context, url) => Center(
308310
child: new CircularProgressIndicator(
309311
strokeWidth: 2,
@@ -315,7 +317,9 @@ class _ProductDetailState extends State<ProductDetailPage> {
315317
fit: BoxFit.contain,
316318
);
317319
},
318-
itemCount: _product.images.length,
320+
itemCount: _product.images.length == 0
321+
? 1
322+
: _product.images.length,
319323
viewportFraction: 0.85,
320324
scale: 0.9,
321325
onTap: _productImageTapped,
@@ -542,7 +546,9 @@ class _ProductDetailState extends State<ProductDetailPage> {
542546
isManagedStock: _product.manageStock,
543547
stockQuantity: _product.stockQuantity,
544548
shippingIsTaxable: _product.shippingTaxable,
545-
imageSrc: _product.images.first.src,
549+
imageSrc: _product.images.length == 0
550+
? app_product_placeholder_image
551+
: _product.images.first.src,
546552
total: _product.price,
547553
);
548554

0 commit comments

Comments
 (0)