Skip to content

Commit d49f8a6

Browse files
committed
v6.12.1
1 parent 34a2608 commit d49f8a6

21 files changed

+600
-527
lines changed

LabelStoreMax/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## [6.12.1] - 2023-12-01
2+
3+
* Migrate code to Nylo v5.11.1
4+
* Update `CartLineItem` model
5+
* Dart format in /resources/pages
6+
* Pubspec.yaml dependency updates
7+
18
## [6.12.0] - 2023-10-31
29

310
* Update design for Toast Notifications

LabelStoreMax/lib/app/models/cart_line_item.dart

Lines changed: 77 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,45 @@ class CartLineItem {
3030
String? variationOptions;
3131
List<ws_product.Category>? categories;
3232
bool? onSale;
33+
String? salePrice;
34+
String? regularPrice;
3335
String? stockStatus;
34-
Object? metaData = {};
36+
List<Map<String?, dynamic>> metaData = [];
37+
List<Map<String?, dynamic>> appMetaData = [];
3538

3639
CartLineItem(
3740
{this.name,
38-
this.productId,
39-
this.variationId,
40-
this.isManagedStock,
41-
this.stockQuantity,
42-
this.quantity = 1,
43-
this.stockStatus,
44-
this.shippingClassId,
45-
this.taxStatus,
46-
this.taxClass,
47-
this.categories,
48-
this.shippingIsTaxable,
49-
this.variationOptions,
50-
this.imageSrc,
51-
this.subtotal,
52-
this.onSale,
53-
this.total,
54-
this.metaData});
41+
this.productId,
42+
this.variationId,
43+
this.isManagedStock,
44+
this.stockQuantity,
45+
this.quantity = 1,
46+
this.stockStatus,
47+
this.shippingClassId,
48+
this.taxStatus,
49+
this.taxClass,
50+
this.categories,
51+
this.shippingIsTaxable,
52+
this.variationOptions,
53+
this.imageSrc,
54+
this.subtotal,
55+
this.onSale,
56+
this.salePrice,
57+
this.regularPrice,
58+
this.total,
59+
this.metaData = const []});
5560

5661
String getCartTotal() {
5762
return (quantity * parseWcPrice(subtotal)).toStringAsFixed(2);
5863
}
5964

65+
String getPrice({bool formatToCurrency = false}) {
66+
if (formatToCurrency) {
67+
return formatStringCurrency(total: (parseWcPrice(subtotal)).toStringAsFixed(2));
68+
}
69+
return (parseWcPrice(subtotal)).toStringAsFixed(2);
70+
}
71+
6072
CartLineItem.fromProduct(
6173
{int? quantityAmount, required ws_product.Product product}) {
6274
name = product.name;
@@ -69,18 +81,24 @@ class CartLineItem {
6981
categories = product.categories;
7082
isManagedStock = product.manageStock;
7183
stockQuantity = product.stockQuantity;
84+
salePrice = product.salePrice;
85+
onSale = product.onSale;
86+
regularPrice = product.regularPrice;
7287
shippingIsTaxable = product.shippingTaxable;
88+
List<Map<String?, String?>> data = product.metaData.map((e) => {e.key: e.value}).toList();
89+
metaData.addAll(data);
7390
imageSrc = product.images.isEmpty
7491
? getEnv("PRODUCT_PLACEHOLDER_IMAGE")
7592
: product.images.first.src;
7693
total = product.price;
94+
appMetaData = product.metaData.map((e) => {e.key: e.value}).toList();
7795
}
7896

7997
CartLineItem.fromProductVariation(
8098
{int? quantityAmount,
81-
required List<String> options,
82-
required ws_product.Product product,
83-
required ProductVariation productVariation}) {
99+
required List<String> options,
100+
required ws_product.Product product,
101+
required ProductVariation productVariation}) {
84102
String? imageSrc = getEnv("PRODUCT_PLACEHOLDER_IMAGE");
85103
if (product.images.isNotEmpty) {
86104
imageSrc = product.images.first.src;
@@ -99,38 +117,49 @@ class CartLineItem {
99117
isManagedStock = productVariation.manageStock;
100118
categories = product.categories;
101119
taxClass = productVariation.taxClass;
120+
onSale = productVariation.onSale;
102121
this.imageSrc = imageSrc;
122+
salePrice = productVariation.salePrice;
123+
List<Map<String?, String?>> data = product.metaData.map((e) => {e.key: e.value}).toList();
124+
metaData.addAll(data);
125+
regularPrice = productVariation.regularPrice;
103126
shippingIsTaxable = product.shippingTaxable;
104127
variationOptions = options.join("; ");
105128
total = productVariation.price;
129+
appMetaData = product.metaData.map((e) => {"key": e.key, "value": e.value}).toList();
130+
}
131+
132+
CartLineItem.fromJson(Map<String, dynamic> json) {
133+
name = json['name'];
134+
productId = json['product_id'];
135+
variationId = json['variation_id'];
136+
quantity = json['quantity'];
137+
shippingClassId = json['shipping_class_id'].toString();
138+
taxStatus = json['tax_status'];
139+
stockQuantity = json['stock_quantity'];
140+
isManagedStock = (json['is_managed_stock'] != null &&
141+
json['is_managed_stock'] is bool) ? json['is_managed_stock'] : false;
142+
shippingIsTaxable = json['shipping_is_taxable'];
143+
subtotal = json['subtotal'];
144+
total = json['total'];
145+
taxClass = json['tax_class'];
146+
stockStatus = json['stock_status'];
147+
imageSrc = json['image_src'];
148+
salePrice = json['sale_price'];
149+
regularPrice = json['regular_price'];
150+
categories = json['categories'] == null ? null : List.of(json['categories'] as List).map((e) => ws_product.Category.fromJson(e)).toList();
151+
onSale = json['on_sale'];
152+
variationOptions = json['variation_options'];
153+
metaData = [];
154+
if (json['meta_data'] != null) {
155+
metaData = List.from(json['meta_data']).cast<Map<String, dynamic>>();
156+
}
157+
appMetaData = [];
158+
if (json['app_meta_data'] != null) {
159+
appMetaData = List.from(json['app_meta_data']).cast<Map<String, dynamic>>();
160+
}
106161
}
107162

108-
CartLineItem.fromJson(Map<String, dynamic> json)
109-
: name = json['name'],
110-
productId = json['product_id'],
111-
variationId = json['variation_id'],
112-
quantity = json['quantity'],
113-
shippingClassId = json['shipping_class_id'].toString(),
114-
taxStatus = json['tax_status'],
115-
stockQuantity = json['stock_quantity'],
116-
isManagedStock = (json['is_managed_stock'] != null &&
117-
json['is_managed_stock'] is bool)
118-
? json['is_managed_stock']
119-
: false,
120-
shippingIsTaxable = json['shipping_is_taxable'],
121-
subtotal = json['subtotal'],
122-
total = json['total'],
123-
taxClass = json['tax_class'],
124-
stockStatus = json['stock_status'],
125-
imageSrc = json['image_src'],
126-
categories = json['categories'] == null
127-
? null
128-
: List.of(json['categories'] as List)
129-
.map((e) => ws_product.Category.fromJson(e))
130-
.toList(),
131-
onSale = json['on_sale'],
132-
variationOptions = json['variation_options'],
133-
metaData = json['metaData'];
134163

135164
Map<String, dynamic> toJson() => {
136165
'name': name,
@@ -153,5 +182,6 @@ class CartLineItem {
153182
'on_sale': onSale,
154183
'total': total,
155184
'meta_data': metaData,
185+
'app_meta_data': appMetaData,
156186
};
157187
}

LabelStoreMax/lib/app/networking/api_service.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import 'package:flutter/material.dart';
2-
import 'package:flutter_app/app/networking/dio/base_api_service.dart';
32
import 'package:flutter_app/app/networking/dio/interceptors/logging_interceptor.dart';
43
import 'package:nylo_framework/nylo_framework.dart';
54

@@ -12,7 +11,7 @@ import 'package:nylo_framework/nylo_framework.dart';
1211
|--------------------------------------------------------------------------
1312
*/
1413

15-
class ApiService extends BaseApiService {
14+
class ApiService extends NyApiService {
1615
ApiService({BuildContext? buildContext}) : super(buildContext);
1716

1817
@override

LabelStoreMax/lib/app/networking/dio/base_api_service.dart

Lines changed: 0 additions & 19 deletions
This file was deleted.

LabelStoreMax/lib/config/decoders.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import 'package:flutter_app/app/controllers/product_image_viewer_controller.dart
77
import 'package:flutter_app/app/controllers/product_reviews_controller.dart';
88
import 'package:flutter_app/app/models/user.dart';
99
import 'package:flutter_app/app/networking/api_service.dart';
10-
import 'package:flutter_app/app/networking/dio/base_api_service.dart';
1110
import 'package:nylo_framework/nylo_framework.dart';
1211

1312
/*
@@ -34,7 +33,7 @@ final Map<Type, dynamic> modelDecoders = {
3433
|--------------------------------------------------------------------------
3534
*/
3635

37-
final Map<Type, BaseApiService> apiDecoders = {
36+
final Map<Type, NyApiService> apiDecoders = {
3837
ApiService: ApiService(),
3938

4039
// ...

LabelStoreMax/lib/resources/pages/account_delete_page.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ class _AccountDeletePageState extends NyState<AccountDeletePage> {
6565
mainAxisAlignment: MainAxisAlignment.spaceAround,
6666
children: [
6767
PrimaryButton(
68-
title: trans("Yes, delete my account"),
69-
isLoading: isLocked('delete_account'),
70-
action: _deleteAccount,
68+
title: trans("Yes, delete my account"),
69+
isLoading: isLocked('delete_account'),
70+
action: _deleteAccount,
7171
),
7272
LinkButton(title: trans("Back"), action: pop)
7373
],

0 commit comments

Comments
 (0)