From 5c7f5a99e1492335358361b3a7cf8d18e824ed3a Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Fri, 12 Jan 2024 21:51:48 -0500 Subject: [PATCH 1/3] Attempt to fix form input issues for recursive forms (NOT FULLY TESTED) --- lib/components/generated_form.dart | 95 +++++++++++++++++++++++++++--- 1 file changed, 86 insertions(+), 9 deletions(-) diff --git a/lib/components/generated_form.dart b/lib/components/generated_form.dart index 5ac21f8..9316345 100644 --- a/lib/components/generated_form.dart +++ b/lib/components/generated_form.dart @@ -13,6 +13,7 @@ abstract class GeneratedFormItem { late dynamic defaultValue; List additionalValidators; dynamic ensureType(dynamic val); + GeneratedFormItem clone(); GeneratedFormItem(this.key, {this.label = 'Input', @@ -44,6 +45,20 @@ class GeneratedFormTextField extends GeneratedFormItem { String ensureType(val) { return val.toString(); } + + @override + GeneratedFormTextField clone() { + return GeneratedFormTextField(key, + label: label, + belowWidgets: belowWidgets, + defaultValue: defaultValue, + additionalValidators: List.from(additionalValidators), + required: required, + max: max, + hint: hint, + password: password, + textInputType: textInputType); + } } class GeneratedFormDropdown extends GeneratedFormItem { @@ -64,6 +79,20 @@ class GeneratedFormDropdown extends GeneratedFormItem { String ensureType(val) { return val.toString(); } + + @override + GeneratedFormDropdown clone() { + return GeneratedFormDropdown( + key, + opts?.map((e) => MapEntry(e.key, e.value)).toList(), + label: label, + belowWidgets: belowWidgets, + defaultValue: defaultValue, + disabledOptKeys: + disabledOptKeys != null ? List.from(disabledOptKeys!) : null, + additionalValidators: List.from(additionalValidators), + ); + } } class GeneratedFormSwitch extends GeneratedFormItem { @@ -79,6 +108,15 @@ class GeneratedFormSwitch extends GeneratedFormItem { bool ensureType(val) { return val == true || val == 'true'; } + + @override + GeneratedFormSwitch clone() { + return GeneratedFormSwitch(key, + label: label, + belowWidgets: belowWidgets, + defaultValue: defaultValue, + additionalValidators: List.from(additionalValidators)); + } } class GeneratedFormTagInput extends GeneratedFormItem { @@ -103,6 +141,20 @@ class GeneratedFormTagInput extends GeneratedFormItem { Map> ensureType(val) { return val is Map> ? val : {}; } + + @override + GeneratedFormTagInput clone() { + return GeneratedFormTagInput(key, + label: label, + belowWidgets: belowWidgets, + defaultValue: defaultValue, + additionalValidators: List.from(additionalValidators), + deleteConfirmationMessage: deleteConfirmationMessage, + singleSelect: singleSelect, + alignment: alignment, + emptyMessage: emptyMessage, + showLabelWhenNotEmpty: showLabelWhenNotEmpty); + } } typedef OnValueChanges = void Function( @@ -119,6 +171,19 @@ class GeneratedForm extends StatefulWidget { State createState() => _GeneratedFormState(); } +List> cloneFormItems( + List> items) { + List> clonedItems = []; + items.forEach((row) { + List clonedRow = []; + row.forEach((it) { + clonedRow.add(it.clone()); + }); + clonedItems.add(clonedRow); + }); + return clonedItems; +} + class GeneratedFormSubForm extends GeneratedFormItem { final List> items; @@ -129,6 +194,12 @@ class GeneratedFormSubForm extends GeneratedFormItem { ensureType(val) { return val; // Not easy to validate List> } + + @override + GeneratedFormSubForm clone() { + return GeneratedFormSubForm(key, cloneFormItems(items), + label: label, belowWidgets: belowWidgets, defaultValue: defaultValue); + } } // Generates a color in the HSLuv (Pastel) color space @@ -510,15 +581,12 @@ class _GeneratedFormState extends State { ]); } else if (widget.items[r][e] is GeneratedFormSubForm) { List subformColumn = []; - var formItems = (widget.items[r][e] as GeneratedFormSubForm).items; - var compact = formItems.length == 1 && formItems[0].length == 1; + var compact = (widget.items[r][e] as GeneratedFormSubForm) + .items + .length == + 1 && + (widget.items[r][e] as GeneratedFormSubForm).items[0].length == 1; for (int i = 0; i < values[fieldKey].length; i++) { - var items = formItems - .map((x) => x.map((y) { - y.defaultValue = values[fieldKey]?[i]?[y.key]; - return y; - }).toList()) - .toList(); var internalFormKey = ValueKey(generateRandomNumber( values[fieldKey].length, seed2: i, @@ -537,8 +605,17 @@ class _GeneratedFormState extends State { ), GeneratedForm( key: internalFormKey, - items: items, + items: cloneFormItems( + (widget.items[r][e] as GeneratedFormSubForm).items) + .map((x) => x.map((y) { + y.defaultValue = values[fieldKey]?[i]?[y.key]; + y.key = '${y.key.toString()},$internalFormKey'; + return y; + }).toList()) + .toList(), onValueChanges: (values, valid, isBuilding) { + values = values.map( + (key, value) => MapEntry(key.split(',')[0], value)); if (valid) { this.values[fieldKey]?[i] = values; } From d46f0a1c3367427458773859aee1b62f7d97a1bd Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Fri, 12 Jan 2024 22:16:06 -0500 Subject: [PATCH 2/3] HTML Source bugfix (related to #1259) --- lib/app_sources/html.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/app_sources/html.dart b/lib/app_sources/html.dart index 1e8b1e9..106be54 100644 --- a/lib/app_sources/html.dart +++ b/lib/app_sources/html.dart @@ -149,6 +149,7 @@ class HTML extends AppSource { [ GeneratedFormTextField('requestHeader', label: tr('requestHeader'), + required: false, additionalValidators: [ (value) { if ((value ?? 'empty:valid') @@ -301,16 +302,15 @@ class HTML extends AppSource { } var rel = links.last.key; String? version; - if (additionalSettings['supportFixedAPKURL'] != true) { - version = rel.hashCode.toString(); - } version = extractVersion( additionalSettings['versionExtractionRegEx'] as String?, additionalSettings['matchGroupToUse'] as String?, additionalSettings['versionExtractWholePage'] == true ? res.body.split('\r\n').join('\n').split('\n').join('\\n') : rel); - version ??= (await checkDownloadHash(rel)).toString(); + version ??= additionalSettings['supportFixedAPKURL'] != true + ? rel.hashCode.toString() + : (await checkDownloadHash(rel)).toString(); return APKDetails(version, [rel].map((e) => MapEntry(e, e)).toList(), AppNames(uri.host, tr('app'))); } From a25c04b3909bc861ca174eb5d78a32aa1e4a6883 Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Fri, 12 Jan 2024 22:32:33 -0500 Subject: [PATCH 3/3] Update packages, increment version, dart fix --- lib/components/generated_form.dart | 8 ++++---- lib/main.dart | 2 +- pubspec.lock | 20 ++++++++++---------- pubspec.yaml | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/components/generated_form.dart b/lib/components/generated_form.dart index 9316345..8c36b3f 100644 --- a/lib/components/generated_form.dart +++ b/lib/components/generated_form.dart @@ -174,13 +174,13 @@ class GeneratedForm extends StatefulWidget { List> cloneFormItems( List> items) { List> clonedItems = []; - items.forEach((row) { + for (var row in items) { List clonedRow = []; - row.forEach((it) { + for (var it in row) { clonedRow.add(it.clone()); - }); + } clonedItems.add(clonedRow); - }); + } return clonedItems; } diff --git a/lib/main.dart b/lib/main.dart index df577ff..13a4f63 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -19,7 +19,7 @@ import 'package:easy_localization/src/easy_localization_controller.dart'; // ignore: implementation_imports import 'package:easy_localization/src/localization.dart'; -const String currentVersion = '0.15.9'; +const String currentVersion = '0.15.10'; const String currentReleaseTag = 'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES diff --git a/pubspec.lock b/pubspec.lock index 8743138..aeed1b5 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -410,10 +410,10 @@ packages: dependency: transitive description: name: image - sha256: "028f61960d56f26414eb616b48b04eb37d700cbe477b7fb09bf1d7ce57fd9271" + sha256: "004a2e90ce080f8627b5a04aecb4cdfac87d2c3f3b520aa291260be5a32c033d" url: "https://pub.dev" source: hosted - version: "4.1.3" + version: "4.1.4" intl: dependency: transitive description: @@ -530,10 +530,10 @@ packages: dependency: transitive description: name: path_provider_foundation - sha256: "19314d595120f82aca0ba62787d58dde2cc6b5df7d2f0daf72489e38d1b57f2d" + sha256: "5a7999be66e000916500be4f15a3633ebceb8302719b47b9cc49ce924125350f" url: "https://pub.dev" source: hosted - version: "2.3.1" + version: "2.3.2" path_provider_linux: dependency: transitive description: @@ -682,10 +682,10 @@ packages: dependency: transitive description: name: shared_preferences_foundation - sha256: "7bf53a9f2d007329ee6f3df7268fd498f8373602f943c975598bbb34649b62a7" + sha256: "7708d83064f38060c7b39db12aefe449cb8cdc031d6062280087bc4cdb988f5c" url: "https://pub.dev" source: hosted - version: "2.3.4" + version: "2.3.5" shared_preferences_linux: dependency: transitive description: @@ -847,10 +847,10 @@ packages: dependency: transitive description: name: url_launcher_ios - sha256: cdb7b6da34483f9b2c9f8b2b29bc468fa7271d92e2021607ca0c4d3bcb04cdd4 + sha256: "75bb6fe3f60070407704282a2d295630cab232991eb52542b18347a8a941df03" url: "https://pub.dev" source: hosted - version: "6.2.3" + version: "6.2.4" url_launcher_linux: dependency: transitive description: @@ -943,10 +943,10 @@ packages: dependency: transitive description: name: webview_flutter_wkwebview - sha256: "02d8f3ebbc842704b2b662377b3ee11c0f8f1bbaa8eab6398262f40049819160" + sha256: "4d062ad505390ecef1c4bfb6001cd857a51e00912cc9dfb66edb1886a9ebd80c" url: "https://pub.dev" source: hosted - version: "3.10.1" + version: "3.10.2" win32: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 287afec..067531c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 0.15.9+245 # When changing this, update the tag in main() accordingly +version: 0.15.10+246 # When changing this, update the tag in main() accordingly environment: sdk: '>=3.0.0 <4.0.0'