diff --git a/LabelStoreMax/.env b/LabelStoreMax/.env index 952eaaa..f1b76ed 100644 --- a/LabelStoreMax/.env +++ b/LabelStoreMax/.env @@ -52,4 +52,7 @@ PRODUCT_PLACEHOLDER_IMAGE="https://woosignal.com/images/woocommerce-placeholder. # Sets the default placeholder image for products with no image AUTH_USER_KEY="AUTH_USER" -FCM_ENABLED=false \ No newline at end of file +FCM_ENABLED=null + +ENCRYPT_KEY=null +ENCRYPT_SECRET=null \ No newline at end of file diff --git a/LabelStoreMax/CHANGELOG.md b/LabelStoreMax/CHANGELOG.md index 5d3a20e..d78e937 100644 --- a/LabelStoreMax/CHANGELOG.md +++ b/LabelStoreMax/CHANGELOG.md @@ -1,3 +1,10 @@ +## [6.9.0] - 2023-07-13 + +* Pull firebase config via woosignal api +* New encrypt key and secret added to .env +* fix fetchRelated to return "publish" products +* Pubspec.yaml dependency updates + ## [6.8.2] - 2023-07-04 * Update gradle + kotlin versions. diff --git a/LabelStoreMax/lib/app/providers/app_provider.dart b/LabelStoreMax/lib/app/providers/app_provider.dart index 5f4cc2d..0780814 100644 --- a/LabelStoreMax/lib/app/providers/app_provider.dart +++ b/LabelStoreMax/lib/app/providers/app_provider.dart @@ -22,7 +22,10 @@ class AppProvider implements NyProvider { ]); await WooSignal.instance - .init(appKey: getEnv('APP_KEY'), debugMode: getEnv('APP_DEBUG')); + .init(appKey: getEnv('APP_KEY'), debugMode: getEnv('APP_DEBUG'), + encryptKey: getEnv('ENCRYPT_KEY', defaultValue: null), + encryptSecret: getEnv('ENCRYPT_SECRET', defaultValue: null) + ); AppHelper.instance.appConfig = WooSignalApp(); AppHelper.instance.appConfig!.themeFont = "Poppins"; @@ -46,7 +49,7 @@ class AppProvider implements NyProvider { }; // WooSignal Setup - WooSignalApp? wooSignalApp = await (appWooSignal((api) => api.getApp())); + WooSignalApp? wooSignalApp = await (appWooSignal((api) => api.getApp(encrypted: shouldEncrypt()))); Locale locale = Locale('en'); if (wooSignalApp != null) { diff --git a/LabelStoreMax/lib/app/providers/firebase_provider.dart b/LabelStoreMax/lib/app/providers/firebase_provider.dart index 866e533..863dea0 100644 --- a/LabelStoreMax/lib/app/providers/firebase_provider.dart +++ b/LabelStoreMax/lib/app/providers/firebase_provider.dart @@ -1,5 +1,6 @@ import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; +import 'package:flutter_app/bootstrap/app_helper.dart'; import 'package:flutter_app/firebase_options.dart'; import 'package:nylo_framework/nylo_framework.dart'; import 'package:woosignal/woosignal.dart'; @@ -14,7 +15,12 @@ class FirebaseProvider implements NyProvider { @override afterBoot(Nylo nylo) async { - if (getEnv('FCM_ENABLED', defaultValue: false) != true) return; + bool? firebaseFcmIsEnabled = AppHelper.instance.appConfig?.firebaseFcmIsEnabled; + if (firebaseFcmIsEnabled == null) { + firebaseFcmIsEnabled = getEnv('FCM_ENABLED', defaultValue: false); + } + + if (firebaseFcmIsEnabled != true) return; await Firebase.initializeApp( options: DefaultFirebaseOptions.currentPlatform, diff --git a/LabelStoreMax/lib/app/providers/payments/stripe_pay.dart b/LabelStoreMax/lib/app/providers/payments/stripe_pay.dart index b58c1af..a583519 100644 --- a/LabelStoreMax/lib/app/providers/payments/stripe_pay.dart +++ b/LabelStoreMax/lib/app/providers/payments/stripe_pay.dart @@ -118,7 +118,7 @@ stripePay(context, return; } - Navigator.pushNamed(context, "/checkout-status", arguments: order); + routeTo('/checkout-status', navigationType: NavigationType.pushAndForgetAll, data: order); } on StripeException catch (e) { if (getEnv('APP_DEBUG', defaultValue: true)) { NyLogger.error(e.error.message!); diff --git a/LabelStoreMax/lib/bootstrap/helpers.dart b/LabelStoreMax/lib/bootstrap/helpers.dart index 340827f..e43543f 100644 --- a/LabelStoreMax/lib/bootstrap/helpers.dart +++ b/LabelStoreMax/lib/bootstrap/helpers.dart @@ -667,4 +667,16 @@ bool isProductNew(Product? product) { NyLogger.error(e.toString()); } return false; +} + +bool shouldEncrypt() { + String? encryptKey = getEnv('ENCRYPT_KEY', defaultValue: ""); + if (encryptKey == null || encryptKey == "") { + return false; + } + String? encryptSecret = getEnv('ENCRYPT_KEY', defaultValue: ""); + if (encryptSecret == null || encryptSecret == "") { + return false; + } + return true; } \ No newline at end of file diff --git a/LabelStoreMax/lib/firebase_options.dart b/LabelStoreMax/lib/firebase_options.dart index 022be6f..104e2c8 100644 --- a/LabelStoreMax/lib/firebase_options.dart +++ b/LabelStoreMax/lib/firebase_options.dart @@ -2,6 +2,7 @@ import 'package:firebase_core/firebase_core.dart' show FirebaseOptions; import 'package:flutter/foundation.dart' show defaultTargetPlatform, kIsWeb, TargetPlatform; +import 'package:flutter_app/bootstrap/app_helper.dart'; /// Default [FirebaseOptions] for use with your Firebase apps. class DefaultFirebaseOptions { @@ -14,9 +15,33 @@ class DefaultFirebaseOptions { } switch (defaultTargetPlatform) { case TargetPlatform.android: - return android; + if (AppHelper.instance.appConfig?.firebaseOptionsAndroid == null) { + throw UnsupportedError( + 'Add a valid Firebase json config on https://woosignal.com for your WooCommerce store', + ); + } + return FirebaseOptions( + apiKey: AppHelper.instance.appConfig!.firebaseOptionsAndroid!['apiKey'], + appId: AppHelper.instance.appConfig!.firebaseOptionsAndroid!['appId'], + messagingSenderId: AppHelper.instance.appConfig!.firebaseOptionsAndroid!['messagingSenderId'], + projectId: AppHelper.instance.appConfig!.firebaseOptionsAndroid!['projectId'], + storageBucket: AppHelper.instance.appConfig!.firebaseOptionsAndroid!['storageBucket'], + ); case TargetPlatform.iOS: - return ios; + if (AppHelper.instance.appConfig?.firebaseOptionsIos == null) { + throw UnsupportedError( + 'Add a valid Firebase plist config on https://woosignal.com for your WooCommerce store', + ); + } + return FirebaseOptions( + apiKey: AppHelper.instance.appConfig!.firebaseOptionsIos!['apiKey'], + appId: AppHelper.instance.appConfig!.firebaseOptionsIos!['appId'], + messagingSenderId: AppHelper.instance.appConfig!.firebaseOptionsIos!['messagingSenderId'], + projectId: AppHelper.instance.appConfig!.firebaseOptionsIos!['projectId'], + storageBucket: AppHelper.instance.appConfig!.firebaseOptionsIos!['storageBucket'], + iosClientId: AppHelper.instance.appConfig!.firebaseOptionsIos!['iosClientId'], + iosBundleId: AppHelper.instance.appConfig!.firebaseOptionsIos!['iosBundleId'], + ); case TargetPlatform.macOS: throw UnsupportedError( 'DefaultFirebaseOptions have not been configured for macos - ' @@ -38,22 +63,4 @@ class DefaultFirebaseOptions { ); } } - - static const FirebaseOptions android = FirebaseOptions( - apiKey: '', - appId: '', - messagingSenderId: '', - projectId: '', - storageBucket: '', - ); - - static const FirebaseOptions ios = FirebaseOptions( - apiKey: '', - appId: '', - messagingSenderId: '', - projectId: '', - storageBucket: '', - iosClientId: '', - iosBundleId: '', - ); } diff --git a/LabelStoreMax/lib/main.dart b/LabelStoreMax/lib/main.dart index 8285b27..56889da 100644 --- a/LabelStoreMax/lib/main.dart +++ b/LabelStoreMax/lib/main.dart @@ -15,4 +15,4 @@ void main() async { debugShowCheckedModeBanner: false, ), ); -} +} \ No newline at end of file diff --git a/LabelStoreMax/lib/resources/widgets/product_detail_related_products_widget.dart b/LabelStoreMax/lib/resources/widgets/product_detail_related_products_widget.dart index 3fecc6c..9a03872 100644 --- a/LabelStoreMax/lib/resources/widgets/product_detail_related_products_widget.dart +++ b/LabelStoreMax/lib/resources/widgets/product_detail_related_products_widget.dart @@ -75,6 +75,6 @@ class ProductDetailRelatedProductsWidget extends StatelessWidget { } Future> fetchRelated() async => await (appWooSignal( - (api) => api.getProducts(perPage: 100, include: product!.relatedIds), + (api) => api.getProducts(perPage: 100, include: product!.relatedIds, status: "publish"), )); } diff --git a/LabelStoreMax/pubspec.lock b/LabelStoreMax/pubspec.lock index 955374e..6845afd 100644 --- a/LabelStoreMax/pubspec.lock +++ b/LabelStoreMax/pubspec.lock @@ -49,6 +49,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.4.2" + asn1lib: + dependency: transitive + description: + name: asn1lib + sha256: b74e3842a52c61f8819a1ec8444b4de5419b41a7465e69d4aa681445377398b0 + url: "https://pub.dev" + source: hosted + version: "1.4.1" async: dependency: transitive description: @@ -209,6 +217,14 @@ packages: url: "https://pub.dev" source: hosted version: "5.2.1+1" + encrypt: + dependency: transitive + description: + name: encrypt + sha256: "4fd4e4fdc21b9d7d4141823e1e6515cd94e7b8d84749504c232999fba25d9bbb" + url: "https://pub.dev" + source: hosted + version: "5.0.1" eventify: dependency: transitive description: @@ -617,18 +633,18 @@ packages: dependency: "direct main" description: name: nylo_framework - sha256: a10e1ea240e04aa64a90a6170bc2eebd585b9c0f85b1557e323c5a49312add2b + sha256: cfd9f98313672d06ccee6db7dfe75e584e1f72d7465c649b9bb765b1112f9f2a url: "https://pub.dev" source: hosted - version: "5.1.1" + version: "5.1.2" nylo_support: dependency: transitive description: name: nylo_support - sha256: "09c5eace0c4fa4cef5148b3b7820fd0a8b24154c964c34c1396372315ef815d6" + sha256: "35e4938f7c18f518a9cc09dc02cadd85183530c95217fa05fe6de08d8f25fbfe" url: "https://pub.dev" source: hosted - version: "5.3.1" + version: "5.4.0" octo_image: dependency: transitive description: @@ -998,10 +1014,10 @@ packages: dependency: "direct main" description: name: url_launcher - sha256: eb1e00ab44303d50dd487aab67ebc575456c146c6af44422f9c13889984c00f3 + sha256: "781bd58a1eb16069412365c98597726cd8810ae27435f04b3b4d3a470bacd61e" url: "https://pub.dev" source: hosted - version: "6.1.11" + version: "6.1.12" url_launcher_android: dependency: transitive description: @@ -1142,10 +1158,10 @@ packages: dependency: "direct main" description: name: woosignal - sha256: "5059a0f531149e3bd9ee70a24e76315644663462509c84771d3bb8ca403726ab" + sha256: "089a373122ae0e202e64e214ce4a549af29e589128bdc8c8a54f3da68a2355aa" url: "https://pub.dev" source: hosted - version: "3.7.1" + version: "3.8.0" wp_json_api: dependency: "direct main" description: @@ -1180,4 +1196,4 @@ packages: version: "3.1.2" sdks: dart: ">=3.0.0 <4.0.0" - flutter: ">=3.7.0-0" + flutter: ">=3.10.0" diff --git a/LabelStoreMax/pubspec.yaml b/LabelStoreMax/pubspec.yaml index 02d2e53..c2b6966 100644 --- a/LabelStoreMax/pubspec.yaml +++ b/LabelStoreMax/pubspec.yaml @@ -1,7 +1,7 @@ # Official WooSignal App Template for WooCommerce # Label StoreMax -# Version: 6.8.2 +# Version: 6.9.0 # Author: Anthony Gordon # Homepage: https://woosignal.com # Documentation: https://woosignal.com/docs/app/label-storemax @@ -29,8 +29,8 @@ dependencies: google_fonts: ^4.0.5 analyzer: ^5.12.0 intl: ^0.18.0 - nylo_framework: ^5.1.1 - woosignal: ^3.7.1 + nylo_framework: ^5.1.2 + woosignal: ^3.8.0 wp_json_api: ^3.3.2 cached_network_image: ^3.2.3 package_info_plus: ^4.0.2 @@ -38,7 +38,7 @@ dependencies: flutter_web_browser: ^0.17.1 webview_flutter: 3.0.4 pull_to_refresh_flutter3: 2.0.1 - url_launcher: ^6.1.6 + url_launcher: ^6.1.12 bubble_tab_indicator: ^0.1.5 status_alert: ^1.0.1 math_expressions: ^2.4.0