Skip to content

Commit

Permalink
Merge pull request #35 from woosignal/master
Browse files Browse the repository at this point in the history
v6.0.0 updates
  • Loading branch information
agordn52 authored May 19, 2022
2 parents 249f987 + b2abd22 commit 7a77a0c
Show file tree
Hide file tree
Showing 127 changed files with 2,231 additions and 2,123 deletions.
8 changes: 8 additions & 0 deletions LabelStoreMax/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## [6.0.0] - 2022-05-19

* Migrate to Nylo 3.x
* Null safety
* Min dart version 2.17
* Refactor product detail screen
* Pubspec.yaml dependency updates

## [5.8.0] - 2022-03-29

* Add phone number to customer input form
Expand Down
2 changes: 1 addition & 1 deletion LabelStoreMax/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# WooCommerce App: Label StoreMax

### Label StoreMax - v5.8.0
### Label StoreMax - v6.0.0


[Official WooSignal WooCommerce App](https://woosignal.com)
Expand Down
2 changes: 2 additions & 0 deletions LabelStoreMax/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,7 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
</dict>
</plist>
2 changes: 1 addition & 1 deletion LabelStoreMax/lib/app/controllers/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +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:nylo_support/controllers/controller.dart';
import 'package:nylo_framework/nylo_framework.dart';

/// Base Controller for the Nylo
/// See more on controllers here - https://nylo.dev/docs/2.x/controllers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
// 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/cupertino.dart';
import 'package:flutter_app/app/controllers/woosignal_api_loader_controller.dart';
import 'package:woosignal/models/response/order.dart';

Expand All @@ -17,9 +15,9 @@ class CustomerOrdersLoaderController
CustomerOrdersLoaderController();

Future<void> loadOrders(
{@required bool Function(bool hasProducts) hasResults,
@required void Function() didFinish,
@required String userId}) async {
{required bool Function(bool hasProducts) hasResults,
required void Function() didFinish,
required String userId}) async {
await load(
hasResults: hasResults,
didFinish: didFinish,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ import 'controller.dart';
import 'package:flutter/widgets.dart';

class LeaveReviewController extends Controller {

@override
construct(BuildContext context) {
super.construct(context);

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// 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:flutter_app/app/controllers/woosignal_api_loader_controller.dart';
import 'package:woosignal/models/response/product_category.dart';
import 'package:woosignal/models/response/products.dart';
Expand All @@ -18,19 +17,19 @@ class ProductCategorySearchLoaderController
ProductCategorySearchLoaderController();

Future<void> loadProducts(
{@required bool Function(bool hasProducts) hasResults,
@required void Function() didFinish,
@required ProductCategory productCategory}) async {
{required bool Function(bool hasProducts) hasResults,
required void Function() didFinish,
required ProductCategory? productCategory}) async {
await load(
hasResults: hasResults,
didFinish: didFinish,
apiQuery: (api) => api.getProducts(
perPage: 50,
category: productCategory.id.toString(),
page: page,
status: "publish",
stockStatus: "instock",
),
hasResults: hasResults,
didFinish: didFinish,
apiQuery: (api) => api.getProducts(
perPage: 50,
category: productCategory!.id.toString(),
page: page,
status: "publish",
stockStatus: "instock",
),
);
}
}
57 changes: 31 additions & 26 deletions LabelStoreMax/lib/app/controllers/product_detail_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,44 +16,46 @@ import 'package:flutter_app/bootstrap/helpers.dart';
import 'package:nylo_framework/nylo_framework.dart';
import 'package:woosignal/models/response/products.dart';
import 'package:woosignal/models/response/product_variation.dart'
as ws_product_variation;
as ws_product_variation;

import 'controller.dart';

class ProductDetailController extends Controller {
int quantity = 1;
Product product;
Product? product;

@override
construct(BuildContext context) {
super.construct(context);
product = data() as Product;
product = data() as Product?;
}

viewExternalProduct() {
if (product.externalUrl != null && product.externalUrl.isNotEmpty) {
openBrowserTab(url: product.externalUrl);
if (product!.externalUrl != null && product!.externalUrl!.isNotEmpty) {
openBrowserTab(url: product!.externalUrl!);
}
}

itemAddToCart({@required CartLineItem cartLineItem, @required Function onSuccess}) async {
itemAddToCart(
{required CartLineItem cartLineItem, required Function onSuccess}) async {
await Cart.getInstance.addToCart(cartLineItem: cartLineItem);
showStatusAlert(context,
title: trans("Success"),
subtitle: trans("Added to cart"),
duration: 1,
icon: Icons.add_shopping_cart,
showStatusAlert(
context,
title: trans("Success"),
subtitle: trans("Added to cart"),
duration: 1,
icon: Icons.add_shopping_cart,
);
onSuccess();
}

addQuantityTapped({@required Function onSuccess}) {
if (product.manageStock != null && product.manageStock == true) {
if (quantity >= product.stockQuantity) {
showToastNotification(context,
addQuantityTapped({required Function onSuccess}) {
if (product!.manageStock != null && product!.manageStock == true) {
if (quantity >= product!.stockQuantity!) {
showToastNotification(context!,
title: trans("Maximum quantity reached"),
description:
"${trans("Sorry, only")} ${product.stockQuantity} ${trans("left")}",
"${trans("Sorry, only")} ${product!.stockQuantity} ${trans("left")}",
style: ToastNotificationStyleType.INFO);
return;
}
Expand All @@ -64,14 +66,16 @@ class ProductDetailController extends Controller {
}
}

removeQuantityTapped({@required Function onSuccess}) {
removeQuantityTapped({required Function onSuccess}) {
if ((quantity - 1) >= 1) {
quantity--;
onSuccess();
}
}

toggleWishList({@required Function onSuccess, @required WishlistAction wishlistAction}) async {
toggleWishList(
{required Function onSuccess,
required WishlistAction wishlistAction}) async {
String subtitleMsg;
if (wishlistAction == WishlistAction.remove) {
await removeWishlistProduct(product: product);
Expand All @@ -80,7 +84,8 @@ class ProductDetailController extends Controller {
await saveWishlistProduct(product: product);
subtitleMsg = trans("This product has been added to your wishlist");
}
showStatusAlert(context,
showStatusAlert(
context,
title: trans("Success"),
subtitle: subtitleMsg,
icon: Icons.favorite,
Expand All @@ -90,18 +95,18 @@ class ProductDetailController extends Controller {
onSuccess();
}

ws_product_variation.ProductVariation findProductVariation(
{@required Map<int, dynamic> tmpAttributeObj,
@required List<ws_product_variation.ProductVariation> productVariations}) {
ws_product_variation.ProductVariation tmpProductVariation;
ws_product_variation.ProductVariation? findProductVariation(
{required Map<int, dynamic> tmpAttributeObj,
required List<ws_product_variation.ProductVariation> productVariations}) {
ws_product_variation.ProductVariation? tmpProductVariation;

Map<String, dynamic> tmpSelectedObj = {};
Map<String?, dynamic> tmpSelectedObj = {};
for (var attributeObj in tmpAttributeObj.values) {
tmpSelectedObj[attributeObj["name"]] = attributeObj["value"];
}

for (var productVariation in productVariations) {
Map<String, dynamic> tmpVariations = {};
Map<String?, dynamic> tmpVariations = {};

for (var attr in productVariation.attributes) {
tmpVariations[attr.name] = attr.option;
Expand All @@ -114,4 +119,4 @@ class ProductDetailController extends Controller {

return tmpProductVariation;
}
}
}
10 changes: 4 additions & 6 deletions LabelStoreMax/lib/app/controllers/product_loader_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,16 @@
// 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:flutter_app/app/controllers/woosignal_api_loader_controller.dart';
import 'package:woosignal/models/response/products.dart';

class ProductLoaderController extends WooSignalApiLoaderController<Product> {
ProductLoaderController();

Future<void> loadProducts({
@required bool Function(bool hasProducts) hasResults,
@required void Function() didFinish,
List<int> productIds = const []
}) async {
Future<void> loadProducts(
{required bool Function(bool hasProducts) hasResults,
required void Function() didFinish,
List<int>? productIds = const []}) async {
await load(
hasResults: hasResults,
didFinish: didFinish,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ import 'controller.dart';
import 'package:flutter/widgets.dart';

class ProductReviewsController extends Controller {

@override
construct(BuildContext context) {
super.construct(context);

}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@
// 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:flutter_app/app/controllers/woosignal_api_loader_controller.dart';
import 'package:woosignal/models/response/product_review.dart';
import 'package:woosignal/models/response/products.dart';

class ProductReviewsLoaderController extends WooSignalApiLoaderController<ProductReview> {
class ProductReviewsLoaderController
extends WooSignalApiLoaderController<ProductReview> {
ProductReviewsLoaderController();

Future<void> loadProductReviews({
@required Product product,
@required bool Function(bool hasProducts) hasResults,
@required void Function() didFinish,
required Product? product,
required bool Function(bool hasProducts) hasResults,
required void Function() didFinish,
}) async {
await load(
hasResults: hasResults,
didFinish: didFinish,
apiQuery: (api) => api.getProductReviews(
product: [product.id],
perPage: 50,
page: page,
status: "approved",
));
product: [product!.id!],
perPage: 50,
page: page,
status: "approved",
));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// 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:flutter_app/app/controllers/woosignal_api_loader_controller.dart';
import 'package:woosignal/models/response/products.dart';

Expand All @@ -17,9 +16,9 @@ class ProductSearchLoaderController
ProductSearchLoaderController();

Future<void> loadProducts(
{@required bool Function(bool hasProducts) hasResults,
@required void Function() didFinish,
@required String search}) async {
{required bool Function(bool hasProducts) hasResults,
required void Function() didFinish,
required String? search}) async {
await load(
hasResults: hasResults,
didFinish: didFinish,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// 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:flutter_app/bootstrap/helpers.dart';
import 'package:woosignal/woosignal.dart';

Expand All @@ -20,15 +19,15 @@ class WooSignalApiLoaderController<T> {
WooSignalApiLoaderController();

Future<void> load(
{@required bool Function(bool hasProducts) hasResults,
@required void Function() didFinish,
@required Future<List<T>> Function(WooSignal query) apiQuery}) async {
{required bool Function(bool hasProducts) hasResults,
required void Function() didFinish,
required Future<List<T>> Function(WooSignal query) apiQuery}) async {
if (_waitForNextRequest) {
return;
}
_waitForNextRequest = true;

List<T> apiResults = await appWooSignal((api) => apiQuery(api));
List<T> apiResults = await (appWooSignal((api) => apiQuery(api)));

if (!hasResults(apiResults.isNotEmpty)) {
return;
Expand All @@ -41,9 +40,7 @@ class WooSignalApiLoaderController<T> {
didFinish();
}

List<T> getResults() {
return _results;
}
List<T> getResults() => _results;

void clear() {
_results = [];
Expand Down
15 changes: 15 additions & 0 deletions LabelStoreMax/lib/app/events/login_event.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'package:nylo_framework/nylo_framework.dart';

class LoginEvent implements NyEvent {
@override
final listeners = {
DefaultListener: DefaultListener(),
};
}

class DefaultListener extends NyListener {
@override
handle(dynamic event) async {
// handle the payload from event
}
}
Loading

0 comments on commit 7a77a0c

Please sign in to comment.