From c72cc3250caf9ec7791a081598049e61007dd3a4 Mon Sep 17 00:00:00 2001 From: Anthony Date: Tue, 29 Mar 2022 23:53:37 +0100 Subject: [PATCH] v5.8.0 updates --- LabelStoreMax/CHANGELOG.md | 6 + LabelStoreMax/README.md | 2 +- LabelStoreMax/android/build.gradle | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- .../lib/app/models/checkout_session.dart | 8 +- .../lib/app/models/customer_address.dart | 9 + .../lib/bootstrap/data/order_wc.dart | 3 + .../lib/resources/pages/checkout_details.dart | 45 +++-- .../widgets/customer_address_input.dart | 179 +++++++++--------- LabelStoreMax/pubspec.yaml | 6 +- README.md | 2 +- 11 files changed, 150 insertions(+), 114 deletions(-) diff --git a/LabelStoreMax/CHANGELOG.md b/LabelStoreMax/CHANGELOG.md index 79efdcf..e412825 100644 --- a/LabelStoreMax/CHANGELOG.md +++ b/LabelStoreMax/CHANGELOG.md @@ -1,3 +1,9 @@ +## [5.8.0] - 2022-03-29 + +* Add phone number to customer input form +* Gradle version bump +* Pubspec.yaml dependency updates + ## [5.7.3] - 2022-02-21 * Fix builds for Flutter 2.10.2 diff --git a/LabelStoreMax/README.md b/LabelStoreMax/README.md index 5574fa5..77e2641 100644 --- a/LabelStoreMax/README.md +++ b/LabelStoreMax/README.md @@ -4,7 +4,7 @@ # WooCommerce App: Label StoreMax -### Label StoreMax - v5.7.3 +### Label StoreMax - v5.8.0 [Official WooSignal WooCommerce App](https://woosignal.com) diff --git a/LabelStoreMax/android/build.gradle b/LabelStoreMax/android/build.gradle index b3a325d..5cf596f 100644 --- a/LabelStoreMax/android/build.gradle +++ b/LabelStoreMax/android/build.gradle @@ -6,7 +6,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:4.2.2' + classpath 'com.android.tools.build:gradle:7.0.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/LabelStoreMax/android/gradle/wrapper/gradle-wrapper.properties b/LabelStoreMax/android/gradle/wrapper/gradle-wrapper.properties index 3df6b33..b8793d3 100644 --- a/LabelStoreMax/android/gradle/wrapper/gradle-wrapper.properties +++ b/LabelStoreMax/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip diff --git a/LabelStoreMax/lib/app/models/checkout_session.dart b/LabelStoreMax/lib/app/models/checkout_session.dart index 58239a2..6f7f68c 100644 --- a/LabelStoreMax/lib/app/models/checkout_session.dart +++ b/LabelStoreMax/lib/app/models/checkout_session.dart @@ -44,7 +44,7 @@ class CheckoutSession { coupon = null; } - void saveBillingAddress() async { + saveBillingAddress() async { CustomerAddress customerAddress = CheckoutSession.getInstance.billingDetails.billingAddress; @@ -66,7 +66,7 @@ class CheckoutSession { return null; } - void clearBillingAddress() async => + clearBillingAddress() async => await NyStorage.delete(SharedKey.customerBillingDetails); saveShippingAddress() async { @@ -88,8 +88,8 @@ class CheckoutSession { return null; } - void clearShippingAddress() async => - NyStorage.delete(SharedKey.customerShippingDetails); + clearShippingAddress() async => + await NyStorage.delete(SharedKey.customerShippingDetails); Future total({bool withFormat = false, TaxRate taxRate}) async { double totalCart = parseWcPrice(await Cart.getInstance.getTotal()); diff --git a/LabelStoreMax/lib/app/models/customer_address.dart b/LabelStoreMax/lib/app/models/customer_address.dart index 8ab6f7a..714f33e 100644 --- a/LabelStoreMax/lib/app/models/customer_address.dart +++ b/LabelStoreMax/lib/app/models/customer_address.dart @@ -17,6 +17,7 @@ class CustomerAddress { String city; String postalCode; String emailAddress; + String phoneNumber; CustomerCountry customerCountry; CustomerAddress( @@ -26,6 +27,7 @@ class CustomerAddress { this.city, this.postalCode, this.emailAddress, + this.phoneNumber, this.customerCountry}); void initAddress() { @@ -36,6 +38,7 @@ class CustomerAddress { postalCode = ""; customerCountry = CustomerCountry(); emailAddress = ""; + phoneNumber = ""; } bool hasMissingFields() => @@ -85,6 +88,9 @@ class CustomerAddress { addressLine = json['address_line']; city = json['city']; postalCode = json['postal_code']; + if (json['phone_number'] != null) { + phoneNumber = json['phone_number']; + } customerCountry = CustomerCountry.fromJson(json['customer_country']); emailAddress = json['email_address']; } @@ -98,6 +104,9 @@ class CustomerAddress { data['postal_code'] = postalCode; data['state'] = customerCountry.state; data['country'] = customerCountry.name; + if (phoneNumber != null && phoneNumber != "") { + data['phone_number'] = phoneNumber; + } data['email_address'] = emailAddress; data['customer_country'] = null; if (customerCountry != null) { diff --git a/LabelStoreMax/lib/bootstrap/data/order_wc.dart b/LabelStoreMax/lib/bootstrap/data/order_wc.dart index 8904fcf..a453c06 100644 --- a/LabelStoreMax/lib/bootstrap/data/order_wc.dart +++ b/LabelStoreMax/lib/bootstrap/data/order_wc.dart @@ -65,6 +65,9 @@ Future buildOrderWC({TaxRate taxRate, bool markPaid = true}) async { billing.city = billingDetails.billingAddress.city; billing.postcode = billingDetails.billingAddress.postalCode; billing.email = billingDetails.billingAddress.emailAddress; + if (billingDetails.billingAddress.phoneNumber != "") { + billing.phone = billingDetails.billingAddress.phoneNumber; + } if (billingDetails.billingAddress.customerCountry.hasState()) { billing.state = billingDetails.billingAddress.customerCountry.state.name; } diff --git a/LabelStoreMax/lib/resources/pages/checkout_details.dart b/LabelStoreMax/lib/resources/pages/checkout_details.dart index 576f98f..cc4fa86 100644 --- a/LabelStoreMax/lib/resources/pages/checkout_details.dart +++ b/LabelStoreMax/lib/resources/pages/checkout_details.dart @@ -44,6 +44,7 @@ class _CheckoutDetailsPageState extends State { _txtBillingCity = TextEditingController(), _txtBillingPostalCode = TextEditingController(), _txtBillingEmailAddress = TextEditingController(), + _txtBillingPhoneNumber = TextEditingController(), // shipping _txtShippingFirstName = TextEditingController(), _txtShippingLastName = TextEditingController(), @@ -74,6 +75,7 @@ class _CheckoutDetailsPageState extends State { txtControllerCity: _txtBillingCity, txtControllerPostalCode: _txtBillingPostalCode, txtControllerEmailAddress: _txtBillingEmailAddress, + txtControllerPhoneNumber: _txtBillingPhoneNumber, customerCountry: _billingCountry, onTapCountry: () => _navigateToSelectCountry(type: "billing"), ); @@ -107,6 +109,9 @@ class _CheckoutDetailsPageState extends State { CustomerAddress sfCustomerShippingAddress = await CheckoutSession.getInstance.getShippingAddress(); _setFieldsFromCustomerAddress(sfCustomerShippingAddress, type: "shipping"); + setState(() { + + }); } _setFieldsFromCustomerAddress(CustomerAddress customerAddress, @@ -122,6 +127,7 @@ class _CheckoutDetailsPageState extends State { city: customerAddress.city, postalCode: customerAddress.postalCode, emailAddress: customerAddress.emailAddress, + phoneNumber: customerAddress.phoneNumber, customerCountry: customerAddress.customerCountry, type: type, ); @@ -134,6 +140,7 @@ class _CheckoutDetailsPageState extends State { @required String city, @required String postalCode, @required String emailAddress, + @required String phoneNumber, @required CustomerCountry customerCountry, String type}) { if (type == "billing") { @@ -142,6 +149,7 @@ class _CheckoutDetailsPageState extends State { _txtBillingAddressLine.text = addressLine; _txtBillingCity.text = city; _txtBillingPostalCode.text = postalCode; + _txtBillingPhoneNumber.text = phoneNumber; _txtBillingEmailAddress.text = emailAddress; _billingCountry = customerCountry; } else if (type == "shipping") { @@ -172,20 +180,19 @@ class _CheckoutDetailsPageState extends State { crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Flexible( - fit: FlexFit.tight, + Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.start, children: [ + if (_hasDifferentShippingAddress) Container( margin: EdgeInsets.symmetric(vertical: 0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - (_hasDifferentShippingAddress - ? Padding( + Padding( child: Row( crossAxisAlignment: CrossAxisAlignment.center, @@ -212,14 +219,12 @@ class _CheckoutDetailsPageState extends State { ].where((e) => e != null).toList(), ), padding: EdgeInsets.symmetric(vertical: 4), - ) - : null), + ), ].where((e) => e != null).toList(), ), height: 60, ), - Flexible( - fit: FlexFit.tight, + Expanded( child: Container( decoration: BoxDecoration( color: ThemeColor.get(context).backgroundContainer, @@ -230,7 +235,8 @@ class _CheckoutDetailsPageState extends State { : null, ), padding: EdgeInsets.only(left: 8, right: 8, top: 8), - child: (activeTab ?? tabBillingDetails()), + margin: EdgeInsets.only(top: 8), + child: (activeTab ?? tabBillingDetails()) ), ), ], @@ -274,7 +280,7 @@ class _CheckoutDetailsPageState extends State { ), PrimaryButton( title: trans("USE DETAILS"), - action: () => _useDetailsTapped(), + action: _useDetailsTapped, ), ], ), @@ -286,15 +292,17 @@ class _CheckoutDetailsPageState extends State { ); } - _useDetailsTapped() { + _useDetailsTapped() async { CustomerAddress customerBillingAddress = _setCustomerAddress( firstName: _txtBillingFirstName.text, lastName: _txtBillingLastName.text, addressLine: _txtBillingAddressLine.text, city: _txtBillingCity.text, postalCode: _txtBillingPostalCode.text, + phoneNumber: _txtBillingPhoneNumber.text, emailAddress: _txtBillingEmailAddress.text, - customerCountry: _billingCountry); + customerCountry: _billingCountry, + ); CheckoutSession.getInstance.billingDetails.shippingAddress = customerBillingAddress; @@ -350,11 +358,11 @@ class _CheckoutDetailsPageState extends State { } if (valRememberDetails == true) { - CheckoutSession.getInstance.saveBillingAddress(); - CheckoutSession.getInstance.saveShippingAddress(); + await CheckoutSession.getInstance.saveBillingAddress(); + await CheckoutSession.getInstance.saveShippingAddress(); } else { - CheckoutSession.getInstance.clearBillingAddress(); - CheckoutSession.getInstance.clearShippingAddress(); + await CheckoutSession.getInstance.clearBillingAddress(); + await CheckoutSession.getInstance.clearShippingAddress(); } CheckoutSession.getInstance.billingDetails.rememberDetails = @@ -380,6 +388,7 @@ class _CheckoutDetailsPageState extends State { addressLine: "", city: "", postalCode: "", + phoneNumber: "", emailAddress: "", customerCountry: CustomerCountry()); } @@ -393,6 +402,7 @@ class _CheckoutDetailsPageState extends State { @required String city, @required String postalCode, @required String emailAddress, + String phoneNumber, @required CustomerCountry customerCountry}) { CustomerAddress customerShippingAddress = CustomerAddress(); customerShippingAddress.firstName = firstName; @@ -400,6 +410,9 @@ class _CheckoutDetailsPageState extends State { customerShippingAddress.addressLine = addressLine; customerShippingAddress.city = city; customerShippingAddress.postalCode = postalCode; + if (phoneNumber != null && phoneNumber != "") { + customerShippingAddress.phoneNumber = phoneNumber; + } customerShippingAddress.customerCountry = customerCountry; customerShippingAddress.emailAddress = emailAddress; return customerShippingAddress; diff --git a/LabelStoreMax/lib/resources/widgets/customer_address_input.dart b/LabelStoreMax/lib/resources/widgets/customer_address_input.dart index b5c9bf5..447a341 100644 --- a/LabelStoreMax/lib/resources/widgets/customer_address_input.dart +++ b/LabelStoreMax/lib/resources/widgets/customer_address_input.dart @@ -23,6 +23,7 @@ class CustomerAddressInput extends StatelessWidget { @required this.txtControllerCity, @required this.txtControllerPostalCode, @required this.txtControllerEmailAddress, + this.txtControllerPhoneNumber, @required this.customerCountry, @required this.onTapCountry}) : super(key: key); @@ -32,111 +33,92 @@ class CustomerAddressInput extends StatelessWidget { txtControllerAddressLine, txtControllerCity, txtControllerPostalCode, - txtControllerEmailAddress; + txtControllerEmailAddress, + txtControllerPhoneNumber; final CustomerCountry customerCountry; final Function() onTapCountry; @override Widget build(BuildContext context) { - return Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.start, + return ListView( + shrinkWrap: true, children: [ - Flexible( - child: Row( - children: [ - Flexible( - child: TextEditingRow( - heading: trans("First Name"), - controller: txtControllerFirstName, - shouldAutoFocus: true, - ), + Row( + children: [ + Flexible( + child: TextEditingRow( + heading: trans("First Name"), + controller: txtControllerFirstName, + shouldAutoFocus: true, ), - Flexible( - child: TextEditingRow( - heading: trans("Last Name"), - controller: txtControllerLastName, - ), + ), + Flexible( + child: TextEditingRow( + heading: trans("Last Name"), + controller: txtControllerLastName, ), - ], - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - ), + ), + ], + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, ), - Flexible( - child: Row( - children: [ - Flexible( - child: TextEditingRow( - heading: trans("Address Line"), - controller: txtControllerAddressLine, - ), + Row( + children: [ + Flexible( + child: TextEditingRow( + heading: trans("Address Line"), + controller: txtControllerAddressLine, ), - Flexible( - child: TextEditingRow( - heading: trans("City"), - controller: txtControllerCity, - ), + ), + Flexible( + child: TextEditingRow( + heading: trans("City"), + controller: txtControllerCity, ), - ], - ), + ), + ], ), - Flexible( - child: Row( + Row( + children: [ + Flexible( + child: TextEditingRow( + heading: trans("Postal code"), + controller: txtControllerPostalCode, + ), + ), + Flexible( + child: TextEditingRow( + heading: trans("Email address"), + keyboardType: TextInputType.emailAddress, + controller: txtControllerEmailAddress), + ), + ], + ), + if (txtControllerPhoneNumber != null) + Row( children: [ Flexible( child: TextEditingRow( - heading: trans("Postal code"), - controller: txtControllerPostalCode, + heading: "Phone Number", + controller: txtControllerPhoneNumber, + keyboardType:TextInputType.phone, ), ), - Flexible( - child: TextEditingRow( - heading: trans("Email address"), - keyboardType: TextInputType.emailAddress, - controller: txtControllerEmailAddress), - ), ], ), - ), - Flexible( - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 4), - child: Row( - children: [ - if (customerCountry.hasState()) - Flexible( - child: Column( - children: [ - Container( - height: 23, - child: Text( - trans("State"), - style: Theme.of(context).textTheme.bodyText1, - textAlign: TextAlign.left, - ), - width: double.infinity, - ), - Padding( - child: SecondaryButton( - title: (customerCountry.state != null - ? (customerCountry?.state?.name ?? "") - : trans("Select state")), - action: onTapCountry, - ), - padding: EdgeInsets.all(8), - ), - ], - ), - ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 4), + child: Row( + children: [ + if (customerCountry.hasState()) Flexible( child: Column( children: [ Container( height: 23, child: Text( - trans("Country"), + trans("State"), style: Theme.of(context).textTheme.bodyText1, textAlign: TextAlign.left, ), @@ -144,10 +126,9 @@ class CustomerAddressInput extends StatelessWidget { ), Padding( child: SecondaryButton( - title: (customerCountry != null && - (customerCountry?.name ?? "").isNotEmpty - ? customerCountry.name - : trans("Select country")), + title: (customerCountry.state != null + ? (customerCountry?.state?.name ?? "") + : trans("Select state")), action: onTapCountry, ), padding: EdgeInsets.all(8), @@ -155,10 +136,34 @@ class CustomerAddressInput extends StatelessWidget { ], ), ), - ].where((element) => element != null).toList(), - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - ), + Flexible( + child: Column( + children: [ + Container( + height: 23, + child: Text( + trans("Country"), + style: Theme.of(context).textTheme.bodyText1, + textAlign: TextAlign.left, + ), + width: double.infinity, + ), + Padding( + child: SecondaryButton( + title: (customerCountry != null && + (customerCountry?.name ?? "").isNotEmpty + ? customerCountry.name + : trans("Select country")), + action: onTapCountry, + ), + padding: EdgeInsets.all(8), + ), + ], + ), + ), + ].where((element) => element != null).toList(), + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, ), ), ].where((e) => e != null).toList(), diff --git a/LabelStoreMax/pubspec.yaml b/LabelStoreMax/pubspec.yaml index fa14b8a..4cabaeb 100644 --- a/LabelStoreMax/pubspec.yaml +++ b/LabelStoreMax/pubspec.yaml @@ -1,7 +1,7 @@ # Official WooSignal App Template for WooCommerce # Label StoreMax -# Version: 5.7.3 +# Version: 5.8.0 # Author: Anthony Gordon # Homepage: https://woosignal.com # Documentation: https://woosignal.com/docs/app/label-storemax @@ -29,9 +29,9 @@ dependencies: analyzer: ^1.5.0 intl: ^0.17.0 page_transition: ^2.0.5 - nylo_framework: ^2.1.4 + nylo_framework: ^2.2.0 woosignal: ^3.0.5 - flutter_stripe: ^2.1.1 + flutter_stripe: ^2.4.0 wp_json_api: ^3.1.3 cached_network_image: ^3.2.0 package_info: ^2.0.2 diff --git a/README.md b/README.md index b5d63b7..832f023 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ # WooCommerce App: Label StoreMax -### Label StoreMax - v5.7.3 +### Label StoreMax - v5.8.0 [Official WooSignal WooCommerce App](https://woosignal.com)