diff --git a/apps/health_campaign_field_worker_app/lib/pages/login.dart b/apps/health_campaign_field_worker_app/lib/pages/login.dart index cb1277d204..2b9ceaa920 100644 --- a/apps/health_campaign_field_worker_app/lib/pages/login.dart +++ b/apps/health_campaign_field_worker_app/lib/pages/login.dart @@ -1,3 +1,5 @@ +import 'dart:convert'; + import 'package:digit_components/digit_components.dart'; import 'package:digit_components/models/privacy_notice/privacy_notice_model.dart'; import 'package:digit_components/widgets/atoms/digit_toaster.dart'; @@ -134,6 +136,7 @@ class _LoginPageState extends LocalizedState { (AppConfiguration appConfiguration, _, __) => appConfiguration.privacyPolicyConfig, orElse: () => null); + if (privacyPolicyJson?.active == false) { return const SizedBox.shrink(); } diff --git a/apps/health_campaign_field_worker_app/lib/router/app_router.dart b/apps/health_campaign_field_worker_app/lib/router/app_router.dart index c882ac15f0..c42747f75a 100644 --- a/apps/health_campaign_field_worker_app/lib/router/app_router.dart +++ b/apps/health_campaign_field_worker_app/lib/router/app_router.dart @@ -111,6 +111,11 @@ class AppRouter extends _$AppRouter { AutoRoute( page: HouseholdLocationRoute.page, path: 'household-location', + // initial: true, + ), + AutoRoute( + page: ExtendedFormRoute.page, + path: 'extended-form', initial: true, ), AutoRoute( diff --git a/apps/health_campaign_field_worker_app/pubspec.lock b/apps/health_campaign_field_worker_app/pubspec.lock index 0ec0517ab1..fac1004857 100644 --- a/apps/health_campaign_field_worker_app/pubspec.lock +++ b/apps/health_campaign_field_worker_app/pubspec.lock @@ -37,18 +37,18 @@ packages: dependency: transitive description: name: ansicolor - sha256: "8bf17a8ff6ea17499e40a2d2542c2f481cd7615760c6d34065cb22bfd22e6880" + sha256: "50e982d500bc863e1d703448afdbf9e5a72eb48840a4f766fa361ffd6877055f" url: "https://pub.dev" source: hosted - version: "2.0.2" + version: "2.0.3" archive: dependency: transitive description: name: archive - sha256: "6bd38d335f0954f5fad9c79e614604fbf03a0e5b975923dd001b6ea965ef5b4b" + sha256: cb6a278ef2dbb298455e1a713bda08524a175630ec643a242c399c932a0a1f7d url: "https://pub.dev" source: hosted - version: "3.6.0" + version: "3.6.1" args: dependency: transitive description: @@ -156,10 +156,10 @@ packages: dependency: transitive description: name: battery_plus_platform_interface - sha256: "942707f90e2f7481dcb178df02e22a9c6971b3562b848d6a1b8c7cff9f1a1fec" + sha256: e8342c0f32de4b1dfd0223114b6785e48e579bfc398da9471c9179b907fa4910 url: "https://pub.dev" source: hosted - version: "2.0.0" + version: "2.0.1" bloc: dependency: transitive description: @@ -284,18 +284,18 @@ packages: dependency: transitive description: name: camera_platform_interface - sha256: a250314a48ea337b35909a4c9d5416a208d736dcb01d0b02c6af122be66660b0 + sha256: b3ede1f171532e0d83111fe0980b46d17f1aa9788a07a2fbed07366bbdbb9061 url: "https://pub.dev" source: hosted - version: "2.7.4" + version: "2.8.0" camera_web: dependency: transitive description: name: camera_web - sha256: "9e9aba2fbab77ce2472924196ff8ac4dd8f9126c4f9a3096171cd1d870d6b26c" + sha256: b9235ec0a2ce949daec546f1f3d86f05c3921ed31c7d9ab6b7c03214d152fc2d url: "https://pub.dev" source: hosted - version: "0.3.3" + version: "0.3.4" characters: dependency: transitive description: @@ -426,10 +426,10 @@ packages: dependency: "direct main" description: name: dart_mappable - sha256: "47269caf2060533c29b823ff7fa9706502355ffcb61e7f2a374e3a0fb2f2c3f0" + sha256: f69a961ae8589724ebb542e588f228ae844c5f78028899cbe2cc718977c1b382 url: "https://pub.dev" source: hosted - version: "4.2.2" + version: "4.3.0" dart_mappable_builder: dependency: "direct dev" description: @@ -481,10 +481,10 @@ packages: dependency: transitive description: name: device_info_plus_platform_interface - sha256: d3b01d5868b50ae571cd1dc6e502fc94d956b665756180f7b16ead09e836fd64 + sha256: "282d3cf731045a2feb66abfe61bbc40870ae50a3ed10a4d3d217556c35c8c2ba" url: "https://pub.dev" source: hosted - version: "7.0.0" + version: "7.0.1" diff_match_patch: dependency: transitive description: @@ -517,9 +517,10 @@ packages: digit_firebase_services: dependency: "direct main" description: - path: "../../packages/digit_firebase_services" - relative: true - source: path + name: digit_firebase_services + sha256: ce76521d797e123b6fc95c9dfad7d4a918a93b97f57aecd0e1d517b46190909d + url: "https://pub.dev" + source: hosted version: "0.0.1" digit_location_tracker: dependency: "direct main" @@ -546,10 +547,18 @@ packages: dependency: "direct main" description: name: dio - sha256: "11e40df547d418cc0c4900a9318b26304e665da6fa4755399a9ff9efd09034b5" + sha256: "5598aa796bbf4699afd5c67c0f5f6e2ed542afc956884b9cd58c306966efc260" url: "https://pub.dev" source: hosted - version: "5.4.3+1" + version: "5.7.0" + dio_web_adapter: + dependency: transitive + description: + name: dio_web_adapter + sha256: "36c5b2d79eb17cdae41e974b7a8284fec631651d2a6f39a8a2ff22327e90aeac" + url: "https://pub.dev" + source: hosted + version: "1.0.1" disable_battery_optimization: dependency: "direct main" description: @@ -650,10 +659,10 @@ packages: dependency: transitive description: name: firebase_core_platform_interface - sha256: c437ae5d17e6b5cc7981cf6fd458a5db4d12979905f9aafd1fea930428a9fe63 + sha256: e30da58198a6d4b49d5bce4e852f985c32cb10db329ebef9473db2b9f09ce810 url: "https://pub.dev" source: hosted - version: "5.0.0" + version: "5.3.0" firebase_core_web: dependency: transitive description: @@ -682,10 +691,10 @@ packages: dependency: transitive description: name: fixnum - sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" + sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.1" flutter: dependency: "direct main" description: flutter @@ -727,18 +736,18 @@ packages: dependency: "direct main" description: name: flutter_bloc - sha256: f0ecf6e6eb955193ca60af2d5ca39565a86b8a142452c5b24d96fb477428f4d2 + sha256: b594505eac31a0518bdcb4b5b79573b8d9117b193cc80cc12e17d639b10aa27a url: "https://pub.dev" source: hosted - version: "8.1.5" + version: "8.1.6" flutter_dotenv: dependency: "direct main" description: name: flutter_dotenv - sha256: "9357883bdd153ab78cbf9ffa07656e336b8bbb2b5a3ca596b0b27e119f7c7d77" + sha256: b7c7be5cd9f6ef7a78429cabd2774d3c4af50e79cb2b7593e3d5d763ef95c61b url: "https://pub.dev" source: hosted - version: "5.1.0" + version: "5.2.1" flutter_driver: dependency: transitive description: flutter @@ -828,18 +837,18 @@ packages: dependency: transitive description: name: flutter_local_notifications_linux - sha256: "33f741ef47b5f63cc7f78fe75eeeac7e19f171ff3c3df054d84c1e38bedb6a03" + sha256: c49bd06165cad9beeb79090b18cd1eb0296f4bf4b23b84426e37dd7c027fc3af url: "https://pub.dev" source: hosted - version: "4.0.0+1" + version: "4.0.1" flutter_local_notifications_platform_interface: dependency: transitive description: name: flutter_local_notifications_platform_interface - sha256: "340abf67df238f7f0ef58f4a26d2a83e1ab74c77ab03cd2b2d5018ac64db30b7" + sha256: "85f8d07fe708c1bdcf45037f2c0109753b26ae077e9d9e899d55971711a4ea66" url: "https://pub.dev" source: hosted - version: "7.1.0" + version: "7.2.0" flutter_localizations: dependency: "direct main" description: flutter @@ -971,10 +980,10 @@ packages: dependency: "direct main" description: name: freezed_annotation - sha256: c3fd9336eb55a38cc1bbd79ab17573113a8deccd0ecbbf926cca3c62803b5c2d + sha256: c2e2d632dd9b8a2b7751117abcfc2b4888ecfe181bd9fca7170d9ef02e595fe2 url: "https://pub.dev" source: hosted - version: "2.4.1" + version: "2.4.4" frontend_server_client: dependency: transitive description: @@ -1040,10 +1049,10 @@ packages: dependency: "direct main" description: name: gs1_barcode_parser - sha256: "9aaff47bdab7177deaf9248cc861ef41cf611d3f828498cb40b64bedcbf53391" + sha256: ff171bc40038de3f7178fbc32eaf9eebc3d35a3c4c00bb0281fe4a976d853a42 url: "https://pub.dev" source: hosted - version: "1.0.5" + version: "1.1.0" horizontal_data_table: dependency: transitive description: @@ -1056,10 +1065,10 @@ packages: dependency: transitive description: name: hrk_batteries - sha256: "8ecfdee8268d480a700153a006f7c622c922fbfba4d8f576438c8c41ea9efdf2" + sha256: "35bc2be10bb64284b04d3cd944c24eecf304747fc64b34e2d27ef1a3ac75ab49" url: "https://pub.dev" source: hosted - version: "0.9.2" + version: "2.2.0" hrk_flutter_test_batteries: dependency: "direct dev" description: @@ -1072,10 +1081,10 @@ packages: dependency: transitive description: name: hrk_logging - sha256: "7ea3d02ed46f19533a8cae075cafe636757548a300a0e404193f6dd142c024b5" + sha256: "2e6501f4b78439bec4c367a94b14f792fd17fe1c94f18d903086c7b8a48402f5" url: "https://pub.dev" source: hosted - version: "0.1.3" + version: "0.3.1" http: dependency: transitive description: @@ -1104,10 +1113,10 @@ packages: dependency: transitive description: name: image - sha256: "4c68bfd5ae83e700b5204c1e74451e7bf3cf750e6843c6e158289cf56bda018e" + sha256: f31d52537dc417fdcde36088fdf11d191026fd5e4fae742491ebd40e5a8bea7d url: "https://pub.dev" source: hosted - version: "4.1.7" + version: "4.3.0" integration_test: dependency: "direct dev" description: flutter @@ -1268,18 +1277,18 @@ packages: dependency: transitive description: name: mime - sha256: "2e123074287cc9fd6c09de8336dae606d1ddb88d9ac47358826db698c176a1f2" + sha256: "801fd0b26f14a4a58ccb09d5892c3fbdeff209594300a542492cf13fba9d247a" url: "https://pub.dev" source: hosted - version: "1.0.5" + version: "1.0.6" mocktail: dependency: "direct dev" description: name: mocktail - sha256: c4b5007d91ca4f67256e720cb1b6d704e79a510183a12fa551021f652577dce6 + sha256: "890df3f9688106f25755f26b1c60589a92b3ab91a22b8b224947ad041bf172d8" url: "https://pub.dev" source: hosted - version: "1.0.3" + version: "1.0.4" nested: dependency: "direct main" description: @@ -1356,10 +1365,10 @@ packages: dependency: "direct main" description: name: path_provider - sha256: c9e7d3a4cd1410877472158bee69963a4579f78b68c65a2b7d40d1a7a88bb161 + sha256: fec0d61223fba3154d87759e3cc27fe2c8dc498f6386c6d6fc80d1afdd1bf378 url: "https://pub.dev" source: hosted - version: "2.1.3" + version: "2.1.4" path_provider_android: dependency: transitive description: @@ -1396,10 +1405,10 @@ packages: dependency: transitive description: name: path_provider_windows - sha256: "8bc9f22eee8690981c22aa7fc602f5c85b497a6fb2ceb35ee5a5e5ed85ad8170" + sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7 url: "https://pub.dev" source: hosted - version: "2.2.1" + version: "2.3.0" pedantic: dependency: transitive description: @@ -1420,10 +1429,10 @@ packages: dependency: transitive description: name: permission_handler_android - sha256: "76e4ab092c1b240d31177bb64d2b0bea43f43d0e23541ec866151b9f7b2490fa" + sha256: "71bbecfee799e65aff7c744761a57e817e73b738fedf62ab7afd5593da21f9f1" url: "https://pub.dev" source: hosted - version: "12.0.12" + version: "12.0.13" permission_handler_apple: dependency: transitive description: @@ -1508,10 +1517,10 @@ packages: dependency: "direct main" description: name: pretty_dio_logger - sha256: "00b80053063935cf9a6190da344c5373b9d0e92da4c944c878ff2fbef0ef6dc2" + sha256: "36f2101299786d567869493e2f5731de61ce130faa14679473b26905a92b6407" url: "https://pub.dev" source: hosted - version: "1.3.1" + version: "1.4.0" process: dependency: transitive description: @@ -1540,10 +1549,10 @@ packages: dependency: transitive description: name: pubspec_parse - sha256: c63b2876e58e194e4b0828fcb080ad0e06d051cb607a6be51a9e084f47cb9367 + sha256: c799b721d79eb6ee6fa56f00c04b472dcd44a30d258fac2174a6ec57302678f8 url: "https://pub.dev" source: hosted - version: "1.2.3" + version: "1.3.0" qr: dependency: transitive description: @@ -1642,18 +1651,18 @@ packages: dependency: transitive description: name: shared_preferences_linux - sha256: "9f2cbcf46d4270ea8be39fa156d86379077c8a5228d9dfdb1164ae0bb93f1faa" + sha256: "2ba0510d3017f91655b7543e9ee46d48619de2a2af38e5c790423f7007c7ccc1" url: "https://pub.dev" source: hosted - version: "2.3.2" + version: "2.4.0" shared_preferences_platform_interface: dependency: transitive description: name: shared_preferences_platform_interface - sha256: "22e2ecac9419b4246d7c22bfbbda589e3acf5c0351137d87dd2939d984d37c3b" + sha256: "57cbf196c486bc2cf1f02b85784932c6094376284b3ad5779d1b1c6c6a816b80" url: "https://pub.dev" source: hosted - version: "2.3.2" + version: "2.4.1" shared_preferences_web: dependency: transitive description: @@ -1666,10 +1675,10 @@ packages: dependency: transitive description: name: shared_preferences_windows - sha256: "841ad54f3c8381c480d0c9b508b89a34036f512482c407e6df7a9c4aa2ef8f59" + sha256: "398084b47b7f92110683cac45c6dc4aae853db47e470e5ddcd52cab7f7196ab2" url: "https://pub.dev" source: hosted - version: "2.3.2" + version: "2.4.0" shelf: dependency: transitive description: @@ -1767,10 +1776,10 @@ packages: dependency: transitive description: name: speech_to_text_platform_interface - sha256: a0df1a907091ea09880077dc25aae02af9f79811264e6e97ddb08639b7f771c2 + sha256: a1935847704e41ee468aad83181ddd2423d0833abe55d769c59afca07adb5114 url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "2.3.0" sqlite3: dependency: transitive description: @@ -1783,10 +1792,10 @@ packages: dependency: "direct main" description: name: sqlite3_flutter_libs - sha256: fb2a106a2ea6042fe57de2c47074cc31539a941819c91e105b864744605da3f5 + sha256: "7ae52b23366e5295005022e62fa093f64bfe190810223ea0ebf733a4cd140bce" url: "https://pub.dev" source: hosted - version: "0.5.21" + version: "0.5.26" sqlparser: dependency: transitive description: @@ -1894,10 +1903,10 @@ packages: dependency: transitive description: name: timezone - sha256: a6ccda4a69a442098b602c44e61a1e2b4bf6f5516e875bbf0f427d5df14745d5 + sha256: "2236ec079a174ce07434e89fcd3fcda430025eb7692244139a9cf54fdcf1fc7d" url: "https://pub.dev" source: hosted - version: "0.9.3" + version: "0.9.4" timing: dependency: transitive description: @@ -1934,10 +1943,10 @@ packages: dependency: "direct main" description: name: url_launcher - sha256: "6ce1e04375be4eed30548f10a315826fd933c1e493206eab82eed01f438c8d2e" + sha256: "21b704ce5fa560ea9f3b525b43601c678728ba46725bab9b01187b4831377ed3" url: "https://pub.dev" source: hosted - version: "6.2.6" + version: "6.3.0" url_launcher_android: dependency: transitive description: @@ -1990,10 +1999,10 @@ packages: dependency: transitive description: name: url_launcher_windows - sha256: ecf9725510600aa2bb6d7ddabe16357691b6d2805f66216a97d1b881e21beff7 + sha256: "49c10f879746271804767cb45551ec5592cdab00ee105c06dddde1a98f73b185" url: "https://pub.dev" source: hosted - version: "3.1.1" + version: "3.1.2" uuid: dependency: "direct main" description: @@ -2126,10 +2135,10 @@ packages: dependency: transitive description: name: xxh3 - sha256: a92b30944a9aeb4e3d4f3c3d4ddb3c7816ca73475cd603682c4f8149690f56d7 + sha256: cbeb0e1d10f4c6bf67b650f395eac0cc689425b5efc2ba0cc3d3e069a0beaeec url: "https://pub.dev" source: hosted - version: "1.0.1" + version: "1.1.0" yaml: dependency: transitive description: diff --git a/packages/digit_components/example/pubspec.lock b/packages/digit_components/example/pubspec.lock index 87767b83cb..9939c4849f 100644 --- a/packages/digit_components/example/pubspec.lock +++ b/packages/digit_components/example/pubspec.lock @@ -231,7 +231,7 @@ packages: path: ".." relative: true source: path - version: "1.0.2" + version: "1.0.2+1" easy_stepper: dependency: transitive description: diff --git a/packages/digit_dss/pubspec.yaml b/packages/digit_dss/pubspec.yaml index 60bc32ecdf..7382295609 100644 --- a/packages/digit_dss/pubspec.yaml +++ b/packages/digit_dss/pubspec.yaml @@ -5,7 +5,7 @@ homepage: https://github.com/egovernments/health-campaign-field-worker-app/tree/ repository: https://github.com/egovernments/health-campaign-field-worker-app environment: - sdk: '>=3.2.3 <4.0.0' + sdk: '>=3.2.0 <4.0.0' flutter: ">=1.17.0" dependencies: diff --git a/packages/digit_location_tracker/pubspec.yaml b/packages/digit_location_tracker/pubspec.yaml index 8b8c120c72..034dbdddef 100644 --- a/packages/digit_location_tracker/pubspec.yaml +++ b/packages/digit_location_tracker/pubspec.yaml @@ -5,7 +5,7 @@ homepage: https://github.com/egovernments/health-campaign-field-worker-app/tree/ repository: https://github.com/egovernments/health-campaign-field-worker-app environment: - sdk: '>=3.2.3 <4.0.0' + sdk: '>=3.2.0 <4.0.0' flutter: ">=1.17.0" dependencies: diff --git a/packages/digit_scanner/example/pubspec.lock b/packages/digit_scanner/example/pubspec.lock index 600e452149..75da90ebe5 100644 --- a/packages/digit_scanner/example/pubspec.lock +++ b/packages/digit_scanner/example/pubspec.lock @@ -1093,5 +1093,5 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.2.3 <3.9.0" + dart: ">=3.2.0 <3.9.0" flutter: ">=3.16.0" diff --git a/packages/digit_scanner/example/pubspec.yaml b/packages/digit_scanner/example/pubspec.yaml index 4cecc309b7..a61d03b657 100644 --- a/packages/digit_scanner/example/pubspec.yaml +++ b/packages/digit_scanner/example/pubspec.yaml @@ -19,7 +19,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: '>=3.2.3 <4.0.0' + sdk: '>=3.2.0 <4.0.0' # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions diff --git a/packages/registration_delivery/lib/pages/beneficiary_registration/extended_class.dart b/packages/registration_delivery/lib/pages/beneficiary_registration/extended_class.dart new file mode 100644 index 0000000000..a584ba1efa --- /dev/null +++ b/packages/registration_delivery/lib/pages/beneficiary_registration/extended_class.dart @@ -0,0 +1,59 @@ +import 'package:auto_route/annotations.dart'; +import 'package:flutter/cupertino.dart'; +import 'household_location.dart'; + +@RoutePage() +class ExtendedFormPage extends HouseholdLocationPage { + ExtendedFormPage() + : super( + // Call the parent class constructor with the widget + widgetConfig: { + 'administrationArea': { + 'isEnabled': false, + 'readOnly': true, + 'isRequired': false, + 'order': 3, + }, + 'accuracy': { + 'isEnabled': true, + 'readOnly': true, + 'isRequired': true, + 'order': 2, + }, + 'addressLine1': { + 'isEnabled': true, + 'readOnly': false, + 'isRequired': false, + 'order': 1, + }, + 'postalCode': { + 'isEnabled': true, + 'readOnly': false, + 'isRequired': false, + 'regex': ["^\\d+\$"], + "errorMessage": "Invalid input", + 'order': 1, + }, + }, + ); + + @override + _ExtendedFormPageState createState() => _ExtendedFormPageState(); +} + +class _ExtendedFormPageState extends HouseholdLocationPageState { + _ExtendedFormPageState() : super(); + @override + void initState() { + super.initState(); + } + + @override + Widget build(BuildContext context) { + return super.build(context); + } +} + + + +// HouseHold LOcation diff --git a/packages/registration_delivery/lib/pages/beneficiary_registration/house_details.dart b/packages/registration_delivery/lib/pages/beneficiary_registration/house_details.dart index 55d7627310..0cec7bc187 100644 --- a/packages/registration_delivery/lib/pages/beneficiary_registration/house_details.dart +++ b/packages/registration_delivery/lib/pages/beneficiary_registration/house_details.dart @@ -10,7 +10,11 @@ import 'package:registration_delivery/router/registration_delivery_router.gm.dar import 'package:registration_delivery/utils/extensions/extensions.dart'; import '../../models/entities/additional_fields_type.dart'; +import '../../utils/formController.dart'; import '../../utils/i18_key_constants.dart' as i18; +import '../../utils/models/widget_config_model.dart'; +import '../../utils/utils.dart'; +import '../../utils/widgetfactory.dart'; import '../../widgets/back_navigation_help_header.dart'; import '../../widgets/localized.dart'; import '../../widgets/showcase/config/showcase_constants.dart'; @@ -18,10 +22,27 @@ import '../../widgets/showcase/showcase_button.dart'; @RoutePage() class HouseDetailsPage extends LocalizedStatefulWidget { - const HouseDetailsPage({ + final Map> widgetConfig; + + HouseDetailsPage({ + Map>? widgetConfig, super.key, super.appLocalizations, - }); + }) : widgetConfig = widgetConfig ?? + { + 'householdStructure': { + 'isEnabled': true, + 'readOnly': false, + 'isRequired': true, + 'order': 1, + }, + 'noOfRooms': { + 'isEnabled': true, + 'readOnly': false, + 'isRequired': true, + 'order': 2, + } + }; @override State createState() => HouseDetailsPageState(); @@ -39,6 +60,106 @@ class HouseDetailsPageState extends LocalizedState { super.initState(); } + List buildWidgetsFromConfig(WidgetConfigModel model) { + List widgets = []; + + // Sort the config keys by the 'order' key + var sortedKeys = model.config.keys.toList(); + sortedKeys.sort( + (a, b) => model.config[a]['order'].compareTo(model.config[b]['order'])); + + for (var key in sortedKeys) { + var fieldConfig = model.config[key]; + + if (fieldConfig['isEnabled'] == true) { + Widget widget; + + // Generate the widget based on the fieldConfig['type'] using a switch case + switch (key) { + case _householdStructureKey: + widget = houseShowcaseData.typeOfStructure.buildWith( + child: AbsorbPointer( + absorbing: fieldConfig['readOnly'] ?? false, + child: Opacity( + opacity: fieldConfig['readOnly'] ?? false ? 0.5 : 1, + child: SelectionBox( + title: + '${localizations.translate(i18.householdDetails.typeOfStructure)}${fieldConfig['isRequired'] ?? false ? '*' : ''}', + equalWidthOptions: true, + allowMultipleSelection: false, + options: + RegistrationDeliverySingleton().houseStructureTypes ?? + [], + initialSelection: model.form + .control(_householdStructureKey) + .value != + null + ? [...model.form.control(_householdStructureKey).value] + : [], + onSelectionChanged: (values) { + model.form + .control(_householdStructureKey) + .markAsTouched(); + if (values.isEmpty) { + model.form.control(_householdStructureKey).value = null; + setState(() { + model.form + .control(_householdStructureKey) + .setErrors({'': true}); + }); + } else { + setState(() { + model.form.control(_householdStructureKey).value = + values; + }); + } + }, + valueMapper: (value) { + return localizations.translate(value.toString()); + }, + errorMessage: model.form + .control(_householdStructureKey) + .hasErrors && + model.form.control(_householdStructureKey).touched + ? localizations.translate( + i18.householdDetails.selectStructureTypeError) + : null, + ), + ), + ), + ); + break; + case _noOfRoomsKey: + widget = houseShowcaseData.noOfRooms.buildWith( + child: AbsorbPointer( + absorbing: fieldConfig['readOnly'], + child: Opacity( + opacity: fieldConfig['readOnly'] ?? false ? 0.5 : 1, + child: DigitIntegerFormPicker( + minimum: 1, + maximum: 20, + form: model.form, + formControlName: _noOfRoomsKey, + label: '${localizations.translate( + i18.householdDetails.noOfRoomsLabel, + )}${fieldConfig['isRequired'] ?? false ? '*' : ''}', + incrementer: true, + ), + ), + ), + ); + break; + default: + throw Exception("Unsupported widget type: ${key}"); + } + + widgets.add(widget); + } + } + + return widgets; + } + @override Widget build(BuildContext context) { final theme = Theme.of(context); @@ -69,7 +190,10 @@ class HouseDetailsPageState extends LocalizedState { onPressed: () { form.markAllAsTouched(); if (form.control(_householdStructureKey).value == - null) { + null && + (widget.widgetConfig[_householdStructureKey] + ?['isRequired'] ?? + false)) { setState(() { form .control(_householdStructureKey) @@ -227,68 +351,11 @@ class HouseDetailsPageState extends LocalizedState { style: theme.textTheme.displayMedium, ), ), - Column(children: [ - houseShowcaseData.typeOfStructure.buildWith( - child: SelectionBox( - isRequired: true, - title: localizations.translate( - i18.householdDetails.typeOfStructure), - equalWidthOptions: true, - allowMultipleSelection: false, - options: RegistrationDeliverySingleton() - .houseStructureTypes ?? - [], - initialSelection: form.control(_householdStructureKey).value!= null ? [...form.control(_householdStructureKey).value ] : [], - onSelectionChanged: (values) { - form - .control(_householdStructureKey) - .markAsTouched(); - if (values.isEmpty) { - form - .control(_householdStructureKey) - .value = null; - setState(() { - form - .control(_householdStructureKey) - .setErrors({'': true}); - }); - } else { - setState(() { - form - .control(_householdStructureKey) - .value = values; - }); - } - }, - valueMapper: (value) { - return localizations - .translate(value.toString()); - }, - errorMessage: form - .control(_householdStructureKey) - .hasErrors && - form - .control(_householdStructureKey) - .touched - ? localizations.translate(i18 - .householdDetails - .selectStructureTypeError) - : null, - ), - ), - houseShowcaseData.noOfRooms.buildWith( - child: DigitIntegerFormPicker( - minimum: 1, - maximum: 20, - form: form, - formControlName: _noOfRoomsKey, - label: localizations.translate( - i18.householdDetails.noOfRoomsLabel, - ), - incrementer: true, - ), - ), - ]), + Column( + children: buildWidgetsFromConfig( + WidgetConfigModel( + config: widget.widgetConfig, + form: form))) ], ), ), @@ -301,7 +368,7 @@ class HouseDetailsPageState extends LocalizedState { } FormGroup buildForm(BeneficiaryRegistrationState state) { - return fb.group({ + final formGroup = fb.group({ _noOfRoomsKey: FormControl( value: state.householdModel?.additionalFields?.fields .where((h) => @@ -327,5 +394,50 @@ class HouseDetailsPageState extends LocalizedState { .split("|"), ) }); + + widget.widgetConfig.forEach((key, fieldConfig) { + final formControl = formGroup.control(key); + + // Get current validators + final currentValidators = formControl.validators; + + dynamic updatedValidators = currentValidators.where((validator) { + // Check if the validator is of the same type as Validators.required + return validator.runtimeType != Validators.required.runtimeType; + }).toList(); + + if (fieldConfig['isRequired'] == true) { + // Add the new validator to the list + updatedValidators = [ + ...currentValidators, + Validators.required // Example new validator + ]; + } + + // If JSON config has regex, add it as a validator + if (fieldConfig.containsKey('regex') && fieldConfig['regex'] is List) { + List regexList = fieldConfig['regex']; + String errorMessages = fieldConfig['errorMessage']; + + regexList.asMap().forEach((index, regexPattern) { + updatedValidators.add((control) { + final value = control.value; + if (value != null && value.isNotEmpty && !RegExp(regexPattern).hasMatch(value)) { + // Ensure there's a matching error message for this index + return {'customError': errorMessages}; + } + return null; + }); + }); + } + + // Set the updated validators back to the form control + formControl.setValidators(updatedValidators); + + // Re-run validation with the new validators + formControl.updateValueAndValidity(); + }); + + return formGroup; } } diff --git a/packages/registration_delivery/lib/pages/beneficiary_registration/household_details.dart b/packages/registration_delivery/lib/pages/beneficiary_registration/household_details.dart index 8d0f29b231..d3fe53a70d 100644 --- a/packages/registration_delivery/lib/pages/beneficiary_registration/household_details.dart +++ b/packages/registration_delivery/lib/pages/beneficiary_registration/household_details.dart @@ -15,6 +15,7 @@ import '../../blocs/beneficiary_registration/beneficiary_registration.dart'; import '../../models/entities/household.dart'; import '../../router/registration_delivery_router.gm.dart'; import '../../utils/i18_key_constants.dart' as i18; +import '../../utils/models/widget_config_model.dart'; import '../../utils/utils.dart'; import '../../widgets/back_navigation_help_header.dart'; import '../../widgets/localized.dart'; @@ -23,10 +24,39 @@ import '../../widgets/showcase/showcase_button.dart'; @RoutePage() class HouseHoldDetailsPage extends LocalizedStatefulWidget { - const HouseHoldDetailsPage({ + final Map> widgetConfig; + + HouseHoldDetailsPage({ + Map>? widgetConfig, super.key, super.appLocalizations, - }); + }) : widgetConfig = widgetConfig ?? + { + 'dateOfRegistration': { + 'isEnabled': true, + 'readOnly': true, + 'isRequired': true, + 'order': 4, + }, + 'memberCount': { + 'isEnabled': true, + 'readOnly': false, + 'isRequired': true, + 'order': 1, + }, + 'pregnantWomenCount': { + 'isEnabled': true, + 'readOnly': false, + 'isRequired': true, + 'order': 2, + }, + 'childrenCount': { + 'isEnabled': true, + 'readOnly': false, + 'isRequired': false, + 'order': 4, + }, + }; @override State createState() => HouseHoldDetailsPageState(); @@ -38,6 +68,158 @@ class HouseHoldDetailsPageState extends LocalizedState { static const _pregnantWomenCountKey = 'pregnantWomenCount'; static const _childrenCountKey = 'childrenCount'; + List buildWidgetsFromConfig(WidgetConfigModel model) { + List widgets = []; + + // Sort the config keys by the 'order' key + var sortedKeys = model.config.keys.toList(); + sortedKeys.sort( + (a, b) => model.config[a]['order'].compareTo(model.config[b]['order'])); + + for (var key in sortedKeys) { + var fieldConfig = model.config[key]; + + if (fieldConfig['isEnabled'] == true) { + Widget widget; + + // Generate the widget based on the fieldConfig['type'] using a switch case + switch (key) { + case _dateOfRegistrationKey: + widget = householdDetailsShowcaseData.dateOfRegistration.buildWith( + child: DigitDateFormPicker( + isEnabled: (fieldConfig['readOnly'] ?? false) != true, + formControlName: _dateOfRegistrationKey, + label: localizations.translate( + i18.householdDetails.dateOfRegistrationLabel, + ), + isRequired: fieldConfig['isRequired'] ?? false, + confirmText: localizations.translate( + i18.common.coreCommonOk, + ), + cancelText: localizations.translate( + i18.common.coreCommonCancel, + ), + ), + ); + break; + case _memberCountKey: + int pregnantWomen = + model.form.control(_pregnantWomenCountKey).value; + int children = model.form.control(_childrenCountKey).value; + widget = householdDetailsShowcaseData + .numberOfMembersLivingInHousehold + .buildWith( + child: AbsorbPointer( + absorbing: fieldConfig['readOnly'] ?? false, + child: Opacity( + opacity: fieldConfig['readOnly'] ?? false ? 0.5 : 1, + child: DigitIntegerFormPicker( + minimum: children + pregnantWomen != 0 + ? children + pregnantWomen + : 1, + maximum: 30, + onChange: () { + int pregnantWomen = + model.form.control(_pregnantWomenCountKey).value; + int children = + model.form.control(_childrenCountKey).value; + int memberCount = + model.form.control(_memberCountKey).value; + if (memberCount <= pregnantWomen + children) { + model.form.control(_memberCountKey).value = + (children + pregnantWomen); + } + }, + form: model.form, + formControlName: _memberCountKey, + label: localizations.translate( + i18.householdDetails.noOfMembersCountLabel, + ), + incrementer: true, + ), + ), + ), + ); + break; + case _pregnantWomenCountKey: + widget = householdDetailsShowcaseData + .numberOfPregnantWomenInHousehold + .buildWith( + child: AbsorbPointer( + absorbing: fieldConfig['readOnly'] ?? false, + child: Opacity( + opacity: fieldConfig['readOnly'] ?? false ? 0.5 : 1, + child: DigitIntegerFormPicker( + minimum: 0, + maximum: 10, + onChange: () { + int pregnantWomen = + model.form.control(_pregnantWomenCountKey).value; + int children = + model.form.control(_childrenCountKey).value; + int memberCount = + model.form.control(_memberCountKey).value; + model.form.control(_memberCountKey).value = + memberCount < (children + pregnantWomen) + ? children + pregnantWomen + : memberCount; + }, + form: model.form, + formControlName: _pregnantWomenCountKey, + label: '${localizations.translate( + i18.householdDetails.noOfPregnantWomenCountLabel, + )}${fieldConfig['isRequired'] ?? false ? '*' : ''}', + incrementer: true, + ), + ), + ), + ); + break; + case _childrenCountKey: + widget = householdDetailsShowcaseData + .numberOfChildrenBelow5InHousehold + .buildWith( + child: AbsorbPointer( + absorbing: fieldConfig['readOnly'] ?? false, + child: Opacity( + opacity: fieldConfig['readOnly'] ?? false ? 0.5 : 1, + child: DigitIntegerFormPicker( + minimum: 0, + maximum: 20, + onChange: () { + int pregnantWomen = + model.form.control(_pregnantWomenCountKey).value; + int children = + model.form.control(_childrenCountKey).value; + int memberCount = + model.form.control(_memberCountKey).value; + model.form.control(_memberCountKey).value = + memberCount <= (children + pregnantWomen) + ? children + pregnantWomen + : memberCount; + }, + form: model.form, + formControlName: _childrenCountKey, + label: '${localizations.translate( + i18.householdDetails.noOfChildrenBelow5YearsLabel, + )}${fieldConfig['isRequired'] ?? false ? '*' : ''}', + incrementer: true, + ), + ), + ), + ); + break; + default: + throw Exception("Unsupported widget type: ${key}"); + } + + widgets.add(widget); + } + } + + return widgets; + } + @override Widget build(BuildContext context) { final theme = Theme.of(context); @@ -54,28 +236,24 @@ class HouseHoldDetailsPageState extends LocalizedState { return BlocConsumer( listener: (context, state) { - if (state is BeneficiaryRegistrationPersistedState && state.isEdit) { - final overviewBloc = - context.read(); + if (state is BeneficiaryRegistrationPersistedState && + state.isEdit) { + final overviewBloc = context.read(); overviewBloc.add( HouseholdOverviewReloadEvent( - projectId: RegistrationDeliverySingleton() - .projectId - .toString(), + projectId: + RegistrationDeliverySingleton().projectId.toString(), projectBeneficiaryType: - RegistrationDeliverySingleton() - .beneficiaryType ?? - BeneficiaryType.household, + RegistrationDeliverySingleton().beneficiaryType ?? + BeneficiaryType.household, ), ); HouseholdMemberWrapper memberWrapper = overviewBloc.state.householdMemberWrapper; final route = router.parent() as StackRouter; - route.popUntilRouteWithName( - SearchBeneficiaryRoute.name); - route.push(BeneficiaryWrapperRoute( - wrapper: memberWrapper)); + route.popUntilRouteWithName(SearchBeneficiaryRoute.name); + route.push(BeneficiaryWrapperRoute(wrapper: memberWrapper)); } }, builder: (context, registrationState) { @@ -330,7 +508,6 @@ class HouseHoldDetailsPageState extends LocalizedState { ), ), ); - }, ); } @@ -364,111 +541,11 @@ class HouseHoldDetailsPageState extends LocalizedState { i18.householdDetails.householdDetailsDescription, ), ), - Column(children: [ - householdDetailsShowcaseData.dateOfRegistration - .buildWith( - child: DigitDateFormPicker( - isEnabled: false, - formControlName: _dateOfRegistrationKey, - label: localizations.translate( - i18.householdDetails.dateOfRegistrationLabel, - ), - isRequired: false, - confirmText: localizations.translate( - i18.common.coreCommonOk, - ), - cancelText: localizations.translate( - i18.common.coreCommonCancel, - ), - ), - ), - //[TODO: Use pregnant women form value based on project config - householdDetailsShowcaseData - .numberOfPregnantWomenInHousehold - .buildWith( - child: DigitIntegerFormPicker( - minimum: 0, - maximum: 10, - onChange: () { - int pregnantWomen = form - .control(_pregnantWomenCountKey) - .value; - int children = - form.control(_childrenCountKey).value; - int memberCount = - form.control(_memberCountKey).value; - form.control(_memberCountKey).value = - memberCount < (children + pregnantWomen) - ? children + pregnantWomen - : memberCount; - }, - form: form, - formControlName: _pregnantWomenCountKey, - label: localizations.translate( - i18.householdDetails - .noOfPregnantWomenCountLabel, - ), - incrementer: true, - ), - ), - householdDetailsShowcaseData - .numberOfChildrenBelow5InHousehold - .buildWith( - child: DigitIntegerFormPicker( - minimum: 0, - maximum: 20, - onChange: () { - int pregnantWomen = form - .control(_pregnantWomenCountKey) - .value; - int children = - form.control(_childrenCountKey).value; - int memberCount = - form.control(_memberCountKey).value; - form.control(_memberCountKey).value = - memberCount <= (children + pregnantWomen) - ? children + pregnantWomen - : memberCount; - }, - form: form, - formControlName: _childrenCountKey, - label: localizations.translate( - i18.householdDetails - .noOfChildrenBelow5YearsLabel, - ), - incrementer: true, - ), - ), - householdDetailsShowcaseData - .numberOfMembersLivingInHousehold - .buildWith( - child: DigitIntegerFormPicker( - minimum: children + pregnantWomen != 0 - ? children + pregnantWomen - : 1, - maximum: 30, - onChange: () { - int pregnantWomen = form - .control(_pregnantWomenCountKey) - .value; - int children = - form.control(_childrenCountKey).value; - int memberCount = - form.control(_memberCountKey).value; - if (memberCount <= pregnantWomen + children) { - form.control(_memberCountKey).value = - (children + pregnantWomen); - } - }, - form: form, - formControlName: _memberCountKey, - label: localizations.translate( - i18.householdDetails.noOfMembersCountLabel, - ), - incrementer: true, - ), - ), - ]), + Column( + children: buildWidgetsFromConfig( + WidgetConfigModel( + config: widget.widgetConfig, + form: form))), const SizedBox(height: 16), ], ), diff --git a/packages/registration_delivery/lib/pages/beneficiary_registration/household_location.dart b/packages/registration_delivery/lib/pages/beneficiary_registration/household_location.dart index 59a3eb2061..1e07c6217c 100644 --- a/packages/registration_delivery/lib/pages/beneficiary_registration/household_location.dart +++ b/packages/registration_delivery/lib/pages/beneficiary_registration/household_location.dart @@ -13,6 +13,7 @@ import 'package:registration_delivery/utils/extensions/extensions.dart'; import '../../blocs/beneficiary_registration/beneficiary_registration.dart'; import '../../router/registration_delivery_router.gm.dart'; import '../../utils/i18_key_constants.dart' as i18; +import '../../utils/models/widget_config_model.dart'; import '../../utils/utils.dart'; import '../../widgets/back_navigation_help_header.dart'; import '../../widgets/localized.dart'; @@ -21,10 +22,39 @@ import '../../widgets/showcase/showcase_button.dart'; @RoutePage() class HouseholdLocationPage extends LocalizedStatefulWidget { - const HouseholdLocationPage({ + final Map> widgetConfig; + + HouseholdLocationPage({ + Map>? widgetConfig, super.key, super.appLocalizations, - }); + }) : widgetConfig = widgetConfig ?? + { + 'administrationArea': { + 'isEnabled': false, + 'readOnly': true, + 'isRequired': false, + 'order': 3, + }, + 'accuracy': { + 'isEnabled': true, + 'readOnly': true, + 'isRequired': true, + 'order': 2, + }, + 'addressLine1': { + 'isEnabled': true, + 'readOnly': false, + 'isRequired': false, + 'order': 1, + }, + 'postalCode': { + 'isEnabled': true, + 'readOnly': false, + 'isRequired': false, + 'order': 1, + } + }; @override State createState() => HouseholdLocationPageState(); @@ -62,6 +92,174 @@ class HouseholdLocationPageState extends LocalizedState { super.initState(); } + List buildWidgetsFromConfig(WidgetConfigModel model) { + List widgets = []; + + // Sort the config keys by the 'order' key + var sortedKeys = model.config.keys.toList(); + sortedKeys.sort( + (a, b) => model.config[a]['order'].compareTo(model.config[b]['order'])); + + for (var key in sortedKeys) { + var fieldConfig = model.config[key]; + + if (fieldConfig['isEnabled'] == true) { + Widget widget; + + // Generate the widget based on the fieldConfig['type'] using a switch case + switch (key) { + case _administrationAreaKey: + widget = householdLocationShowcaseData.administrativeArea.buildWith( + child: DigitTextFormField( + formControlName: _administrationAreaKey, + label: localizations.translate( + i18.householdLocation.administrationAreaFormLabel, + ), + isRequired: fieldConfig['isRequired'] ?? false, + readOnly: fieldConfig['readOnly'] ?? false, + validationMessages: { + 'required': (_) => localizations.translate( + i18.householdLocation + .administrationAreaRequiredValidation, + ), + 'customError': (object) => localizations.translate( + fieldConfig['errorMessage'] ?? '', + ) + }, + )); + break; + case _accuracyKey: + widget = householdLocationShowcaseData.gpsAccuracy.buildWith( + child: DigitTextFormField( + key: const Key(_accuracyKey), + formControlName: _accuracyKey, + label: localizations.translate( + i18.householdLocation.gpsAccuracyLabel, + ), + readOnly: fieldConfig['readOnly'] ?? false, + isRequired: fieldConfig['isRequired'] ?? false, + validationMessages: { + 'required': (_) => localizations.translate( + i18.common.corecommonRequired, + ), + 'customError': (object) => localizations.translate( + fieldConfig['errorMessage'] ?? '', + ) + }, + ), + ); + break; + case _addressLine1Key: + widget = householdLocationShowcaseData.addressLine1.buildWith( + child: DigitTextFormField( + formControlName: _addressLine1Key, + label: localizations.translate( + i18.householdLocation.householdAddressLine1LabelText, + ), + readOnly: fieldConfig['readOnly'] ?? false, + isRequired: fieldConfig['isRequired'] ?? false, + validationMessages: { + 'required': (_) => localizations.translate( + i18.common.min2CharsRequired, + ), + 'maxLength': (object) => localizations + .translate(i18.common.maxCharsRequired) + .replaceAll('{}', maxLength.toString()), + 'customError': (object) => localizations.translate( + fieldConfig['errorMessage'] ?? '', + ) + }, + ), + ); + break; + case _addressLine2Key: + widget = householdLocationShowcaseData.addressLine2.buildWith( + child: DigitTextFormField( + formControlName: _addressLine2Key, + label: localizations.translate( + i18.householdLocation.householdAddressLine2LabelText, + ), + readOnly: fieldConfig['readOnly'] ?? false, + isRequired: fieldConfig['isRequired'] ?? false, + validationMessages: { + 'required': (_) => localizations.translate( + i18.common.min2CharsRequired, + ), + 'maxLength': (object) => localizations + .translate(i18.common.maxCharsRequired) + .replaceAll('{}', maxLength.toString()), + 'customError': (object) => localizations.translate( + fieldConfig['errorMessage'] ?? '', + ) + }, + ), + ); + break; + case _landmarkKey: + widget = householdLocationShowcaseData.postalCode.buildWith( + child: DigitTextFormField( + keyboardType: TextInputType.text, + formControlName: _postalCodeKey, + label: localizations.translate( + i18.householdLocation.postalCodeFormLabel, + ), + readOnly: fieldConfig['readOnly'] ?? false, + isRequired: fieldConfig['isRequired'] ?? false, + validationMessages: { + 'required': (_) => localizations.translate( + i18.common.min2CharsRequired, + ), + 'maxLength': (object) => localizations + .translate(i18.common.maxCharsRequired) + .replaceAll('{}', '6'), + 'customError': (object) => localizations.translate( + fieldConfig['errorMessage'] ?? '', + ) + }, + // inputFormatters: [ + // FilteringTextInputFormatter.digitsOnly, + // ], + ), + ); + break; + case _postalCodeKey: + widget = householdLocationShowcaseData.postalCode.buildWith( + child: DigitTextFormField( + keyboardType: TextInputType.number, + formControlName: _postalCodeKey, + label: localizations.translate( + i18.householdLocation.postalCodeFormLabel, + ), + readOnly: fieldConfig['readOnly'] ?? false, + isRequired: fieldConfig['isRequired'] ?? false, + validationMessages: { + 'required': (_) => localizations.translate( + i18.common.min2CharsRequired, + ), + 'maxLength': (object) => localizations + .translate(i18.common.maxCharsRequired) + .replaceAll('{}', '6'), + 'customError': (object) => localizations.translate( + fieldConfig['errorMessage'] ?? '', + ) + }, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + ], + ), + ); + break; + default: + throw Exception("Unsupported widget type: ${key}"); + } + + widgets.add(widget); + } + } + + return widgets; + } + @override Widget build(BuildContext context) { final theme = Theme.of(context); @@ -277,109 +475,9 @@ class HouseholdLocationPageState extends LocalizedState { i18.householdLocation .householdLocationDescriptionText, )), - Column(children: [ - householdLocationShowcaseData.administrativeArea - .buildWith( - child: DigitTextFormField( - formControlName: _administrationAreaKey, - label: localizations.translate( - i18.householdLocation - .administrationAreaFormLabel, - ), - readOnly: true, - validationMessages: { - 'required': (_) => localizations.translate( - i18.householdLocation - .administrationAreaRequiredValidation, - ), - }, - ), - ), - householdLocationShowcaseData.gpsAccuracy.buildWith( - child: DigitTextFormField( - formControlName: _accuracyKey, - label: localizations.translate( - i18.householdLocation.gpsAccuracyLabel, - ), - readOnly: true, - validationMessages: { - 'required': (_) => localizations.translate( - i18.common.corecommonRequired, - ), - }, - ), - ), - householdLocationShowcaseData.addressLine1.buildWith( - child: DigitTextFormField( - formControlName: _addressLine1Key, - label: localizations.translate( - i18.householdLocation - .householdAddressLine1LabelText, - ), - validationMessages: { - 'required': (_) => localizations.translate( - i18.common.min2CharsRequired, - ), - 'maxLength': (object) => localizations - .translate(i18.common.maxCharsRequired) - .replaceAll('{}', maxLength.toString()), - }, - ), - ), - householdLocationShowcaseData.addressLine2.buildWith( - child: DigitTextFormField( - formControlName: _addressLine2Key, - label: localizations.translate( - i18.householdLocation - .householdAddressLine2LabelText, - ), - validationMessages: { - 'required': (_) => localizations.translate( - i18.common.min2CharsRequired, - ), - 'maxLength': (object) => localizations - .translate(i18.common.maxCharsRequired) - .replaceAll('{}', maxLength.toString()), - }, - ), - ), - householdLocationShowcaseData.landmark.buildWith( - child: DigitTextFormField( - formControlName: _landmarkKey, - label: localizations.translate( - i18.householdLocation.landmarkFormLabel, - ), - validationMessages: { - 'required': (_) => localizations.translate( - i18.common.min2CharsRequired, - ), - 'maxLength': (object) => localizations - .translate(i18.common.maxCharsRequired) - .replaceAll('{}', maxLength.toString()), - }, - ), - ), - householdLocationShowcaseData.postalCode.buildWith( - child: DigitTextFormField( - keyboardType: TextInputType.text, - formControlName: _postalCodeKey, - label: localizations.translate( - i18.householdLocation.postalCodeFormLabel, - ), - validationMessages: { - 'required': (_) => localizations.translate( - i18.common.min2CharsRequired, - ), - 'maxLength': (object) => localizations - .translate(i18.common.maxCharsRequired) - .replaceAll('{}', '6'), - }, - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly, - ], - ), - ), - ]), + Column( + children: buildWidgetsFromConfig(WidgetConfigModel( + config: widget.widgetConfig, form: form))) ], ), ), @@ -397,17 +495,19 @@ class HouseholdLocationPageState extends LocalizedState { editHousehold: (value) => value.addressModel, ); - return fb.group({ + final formGroup = fb.group({ _administrationAreaKey: FormControl( - value: localizations.translate( - RegistrationDeliverySingleton().boundary!.code ?? ''), + value: localizations + .translate(RegistrationDeliverySingleton().boundary!.code ?? ''), validators: [Validators.required], ), - _addressLine1Key: - FormControl(value: addressModel?.addressLine1, validators: [ - CustomValidator.requiredMin, - Validators.maxLength(64), - ]), + _addressLine1Key: FormControl( + value: addressModel?.addressLine1, + validators: [ + CustomValidator.requiredMin, + Validators.maxLength(64), + Validators.required + ]), _addressLine2Key: FormControl( value: addressModel?.addressLine2, validators: [ @@ -435,5 +535,51 @@ class HouseholdLocationPageState extends LocalizedState { value: addressModel?.locationAccuracy, ), }); + + widget.widgetConfig.forEach((key, fieldConfig) { + final formControl = formGroup.control(key); + + // Get current validators + final currentValidators = formControl.validators; + + dynamic updatedValidators = currentValidators.where((validator) { + // Check if the validator is of the same type as Validators.required + return validator.runtimeType != Validators.required.runtimeType; + }).toList(); + + if (fieldConfig['isRequired'] == true) { + // Add the new validator to the list + updatedValidators = [ + ...currentValidators, + Validators.required // Example new validator + ]; + } + + + // If JSON config has regex, add it as a validator + if (fieldConfig.containsKey('regex') && fieldConfig['regex'] is List) { + List regexList = fieldConfig['regex']; + String errorMessages = fieldConfig['errorMessage']; + + regexList.asMap().forEach((index, regexPattern) { + updatedValidators.add((control) { + final value = control.value; + if (value != null && value.isNotEmpty && !RegExp(regexPattern).hasMatch(value)) { + // Ensure there's a matching error message for this index + return {'customError': errorMessages}; + } + return null; + }); + }); + } + + // Set the updated validators back to the form control + formControl.setValidators(updatedValidators); + + // Re-run validation with the new validators + formControl.updateValueAndValidity(); + }); + + return formGroup; } } diff --git a/packages/registration_delivery/lib/pages/beneficiary_registration/individual_details.dart b/packages/registration_delivery/lib/pages/beneficiary_registration/individual_details.dart index ec37fdfebc..7fb87c6b48 100644 --- a/packages/registration_delivery/lib/pages/beneficiary_registration/individual_details.dart +++ b/packages/registration_delivery/lib/pages/beneficiary_registration/individual_details.dart @@ -22,6 +22,7 @@ import '../../blocs/beneficiary_registration/beneficiary_registration.dart'; import '../../blocs/household_overview/household_overview.dart'; import '../../router/registration_delivery_router.gm.dart'; import '../../utils/i18_key_constants.dart' as i18; +import '../../utils/models/widget_config_model.dart'; import '../../utils/utils.dart'; import '../../widgets/back_navigation_help_header.dart'; import '../../widgets/localized.dart'; @@ -30,13 +31,52 @@ import '../../widgets/showcase/showcase_button.dart'; @RoutePage() class IndividualDetailsPage extends LocalizedStatefulWidget { + final Map> widgetConfig; final bool isHeadOfHousehold; - const IndividualDetailsPage({ + IndividualDetailsPage({ + Map>? widgetConfig, super.key, super.appLocalizations, this.isHeadOfHousehold = false, - }); + }) : widgetConfig = widgetConfig ?? + { + 'individualName': { + 'isEnabled': true, + 'readOnly': true, + 'order': 1, + }, + 'idType': { + 'isEnabled': true, + 'readOnly': false, + 'isRequired': true, + 'order': 2, + }, + 'idNumber': { + 'isEnabled': true, + 'readOnly': false, + 'isRequired': true, + 'regex': ["^\\d+\$"], + "errorMessage": "Invalid input", + 'order': 3, + }, + 'dob': { + 'isEnabled': true, + 'readOnly': false, + 'order': 4, + }, + 'gender': { + 'isEnabled': true, + 'readOnly': false, + 'isRequired': true, + 'order': 5, + }, + 'mobileNumber': { + 'isEnabled': true, + 'readOnly': false, + 'order': 6, + }, + }; @override State createState() => IndividualDetailsPageState(); @@ -53,6 +93,266 @@ class IndividualDetailsPageState extends LocalizedState { static const maxLength = 200; final clickedStatus = ValueNotifier(false); DateTime now = DateTime.now(); + bool isHeadOfHousehold = false; + + @override + void initState() { + isHeadOfHousehold = widget.isHeadOfHousehold; + super.initState(); + } + + List buildWidgetsFromConfig(WidgetConfigModel model) { + List widgets = []; + + // Sort the config keys by the 'order' key + var sortedKeys = model.config.keys.toList(); + sortedKeys.sort( + (a, b) => model.config[a]['order'].compareTo(model.config[b]['order'])); + + for (var key in sortedKeys) { + var fieldConfig = model.config[key]; + + if (fieldConfig['isEnabled'] == true) { + Widget widget; + + // Generate the widget based on the fieldConfig['type'] using a switch case + switch (key) { + case _individualNameKey: + widget = DigitTextFormField( + formControlName: _individualNameKey, + label: localizations.translate( + i18.individualDetails.nameLabelText, + ), + isRequired: fieldConfig['isRequired'] ?? false, + readOnly: fieldConfig['readOnly'] ?? false, + validationMessages: { + 'required': (object) => localizations.translate( + '${i18.individualDetails.nameLabelText}_IS_REQUIRED', + ), + 'maxLength': (object) => localizations + .translate(i18.common.maxCharsRequired) + .replaceAll('{}', maxLength.toString()), + 'customError': (object) => localizations.translate( + fieldConfig['errorMessage'] ?? '', + ) + }, + ); + if (isHeadOfHousehold) { + widgets.add(widget); + widget = Offstage( + offstage: !isHeadOfHousehold, + child: DigitCheckbox( + label: localizations.translate( + i18.individualDetails.checkboxLabelText, + ), + value: isHeadOfHousehold, + ), + ); + } + break; + case _idTypeKey: + widget = DigitReactiveSearchDropdown( + enabled: (fieldConfig['readOnly'] ?? false) != true, + label: localizations.translate( + i18.individualDetails.idTypeLabelText, + ), + form: model.form, + menuItems: RegistrationDeliverySingleton().idTypeOptions!.map( + (e) { + return e; + }, + ).toList(), + formControlName: _idTypeKey, + valueMapper: (value) { + return localizations.translate(value); + }, + onSelected: (value) { + setState(() { + if (value == 'DEFAULT') { + model.form.control(_idNumberKey).value = + IdGen.i.identifier.toString(); + } else { + model.form.control(_idNumberKey).value = null; + } + }); + }, + isRequired: fieldConfig['isRequired'] ?? false, + validationMessage: model.form.control(_idTypeKey).hasErrors && + model.form.control(_idTypeKey).touched + ? localizations.translate( + i18.common.corecommonRequired, + ) + : null, + emptyText: localizations.translate(i18.common.noMatchFound), + ); + break; + case _idNumberKey: + widget = model.form.control(_idTypeKey).value != 'DEFAULT' + ? Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ReactiveFormConsumer( + builder: (context, formGroup, child) { + return DigitTextFormField( + readOnly: fieldConfig['readOnly'] ?? false, + isRequired: fieldConfig['isRequired'] ?? false, + formControlName: _idNumberKey, + label: localizations.translate( + i18.individualDetails.idNumberLabelText, + ), + validationMessages: { + 'required': (object) => localizations.translate( + '${i18.individualDetails.idNumberLabelText}_IS_REQUIRED', + ), + 'customError': (object) => localizations.translate( + fieldConfig['errorMessage'] ?? '', + ) + }, + padding: const EdgeInsets.only( + top: kPadding * 2, + left: kPadding / 2, + right: kPadding / 2, + ), + ); + }, + ), + ], + ) + : const SizedBox(height: 4); + break; + case _dobKey: + DateTime before150Years = + DateTime(now.year - 150, now.month, now.day); + widget = individualDetailsShowcaseData.dateOfBirth.buildWith( + child: AbsorbPointer( + absorbing: fieldConfig['readOnly'] ?? false, + child: Opacity( + opacity: fieldConfig['readOnly'] ?? false ? 0.5 : 1, + child: DigitDobPicker( + datePickerFormControl: _dobKey, + datePickerLabel: localizations.translate( + i18.individualDetails.dobLabelText, + ), + ageFieldLabel: localizations.translate( + i18.individualDetails.ageLabelText, + ), + yearsHintLabel: localizations.translate( + i18.individualDetails.yearsHintText, + ), + monthsHintLabel: localizations.translate( + i18.individualDetails.monthsHintText, + ), + separatorLabel: localizations.translate( + i18.individualDetails.separatorLabelText, + ), + yearsAndMonthsErrMsg: localizations.translate( + i18.individualDetails.yearsAndMonthsErrorText, + ), + initialDate: before150Years, + onChangeOfFormControl: (formControl) { + // Handle changes to the control's value here + final value = formControl.value; + if (value == null) { + formControl.setErrors({'': true}); + } else { + DigitDOBAge age = DigitDateUtils.calculateAge(value); + if ((age.years == 0 && age.months == 0) || + age.months > 11 || + (age.years >= 150 && age.months >= 0)) { + formControl.setErrors({'': true}); + } else { + formControl.removeError(''); + } + } + }, + cancelText: + localizations.translate(i18.common.coreCommonCancel), + confirmText: + localizations.translate(i18.common.coreCommonOk), + ), + ), + ), + ); + break; + case _genderKey: + widget = AbsorbPointer( + absorbing: fieldConfig['readOnly'] ?? false, + child: Opacity( + opacity: (fieldConfig['readOnly'] ?? false) ? 0.5 : 1, + child: SelectionBox( + title: '${localizations.translate( + i18.individualDetails.genderLabelText, + )}${fieldConfig['isRequired'] ?? false ? '*' : ''}', + allowMultipleSelection: false, + width: 126, + initialSelection: model.form.control(_genderKey).value != null + ? [model.form.control(_genderKey).value] + : [], + options: RegistrationDeliverySingleton() + .genderOptions! + .map( + (e) => e, + ) + .toList(), + onSelectionChanged: (value) { + setState(() { + if (value.isNotEmpty) { + model.form.control(_genderKey).value = value.first; + } else { + model.form.control(_genderKey).value = null; + setState(() { + model.form.control(_genderKey).setErrors({'': true}); + }); + } + }); + }, + valueMapper: (value) { + return localizations.translate(value); + }, + errorMessage: model.form.control(_genderKey).hasErrors && + model.form.control(_genderKey).touched + ? localizations.translate(i18.common.corecommonRequired) + : null, + ), + ), + ); + break; + case _mobileNumberKey: + widget = individualDetailsShowcaseData.mobile.buildWith( + child: DigitTextFormField( + isRequired: fieldConfig['isRequired'] ?? false, + readOnly: fieldConfig['readOnly'] ?? false, + keyboardType: TextInputType.number, + formControlName: _mobileNumberKey, + maxLength: 10, + label: localizations.translate( + i18.individualDetails.mobileNumberLabelText, + ), + validationMessages: { + 'maxLength': (object) => localizations.translate(i18 + .individualDetails.mobileNumberLengthValidationMessage), + 'minLength': (object) => localizations.translate(i18 + .individualDetails.mobileNumberLengthValidationMessage), + 'customError': (object) => localizations.translate( + fieldConfig['errorMessage'] ?? '', + ) + }, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + ], + ), + ); + break; + default: + throw Exception("Unsupported widget type: ${key}"); + } + + widgets.add(widget); + } + } + + return widgets; + } @override Widget build(BuildContext context) { @@ -114,14 +414,20 @@ class IndividualDetailsPageState extends LocalizedState { final age = DigitDateUtils.calculateAge( form.control(_dobKey).value as DateTime?, ); - if ((age.years == 0 && age.months == 0) || - age.years >= 150 && age.months > 0) { + if ((widget.widgetConfig[_dobKey]?['isRequired'] ?? + false) && + ((age.years == 0 && age.months == 0) || + (age.years >= 150 && age.months > 0))) { form.control(_dobKey).setErrors({'': true}); } - if (form.control(_idTypeKey).value == null) { + if (form.control(_idTypeKey).value == null && + (widget.widgetConfig[_idTypeKey]?['isRequired'] ?? + false)) { form.control(_idTypeKey).setErrors({'': true}); } - if (form.control(_genderKey).value == null) { + if (form.control(_genderKey).value == null && + (widget.widgetConfig[_genderKey]?['isRequired'] ?? + false)) { setState(() { form.control(_genderKey).setErrors({'': true}); }); @@ -340,212 +646,9 @@ class IndividualDetailsPageState extends LocalizedState { style: theme.textTheme.displayMedium, ), ), - Column(children: [ - individualDetailsShowcaseData.nameOfIndividual - .buildWith( - child: DigitTextFormField( - formControlName: _individualNameKey, - label: localizations.translate( - i18.individualDetails.nameLabelText, - ), - isRequired: true, - validationMessages: { - 'required': (object) => localizations.translate( - '${i18.individualDetails.nameLabelText}_IS_REQUIRED', - ), - 'maxLength': (object) => localizations - .translate(i18.common.maxCharsRequired) - .replaceAll('{}', maxLength.toString()), - }, - ), - ), - Offstage( - offstage: !widget.isHeadOfHousehold, - child: DigitCheckbox( - label: localizations.translate( - i18.individualDetails.checkboxLabelText, - ), - value: widget.isHeadOfHousehold, - ), - ), - DigitReactiveSearchDropdown( - label: localizations.translate( - i18.individualDetails.idTypeLabelText, - ), - form: form, - menuItems: RegistrationDeliverySingleton() - .idTypeOptions! - .map( - (e) { - return e; - }, - ).toList(), - formControlName: _idTypeKey, - valueMapper: (value) { - return localizations.translate(value); - }, - onSelected: (value) { - setState(() { - if (value == 'DEFAULT') { - form.control(_idNumberKey).value = - IdGen.i.identifier.toString(); - } else { - form.control(_idNumberKey).value = null; - } - }); - }, - isRequired: true, - validationMessage: localizations.translate( - i18.common.corecommonRequired, - ), - emptyText: localizations - .translate(i18.common.noMatchFound), - ), - if (form.control(_idTypeKey).value != 'DEFAULT') - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ReactiveFormConsumer( - builder: (context, formGroup, child) { - return DigitTextFormField( - readOnly: - form.control(_idTypeKey).value == - 'DEFAULT', - isRequired: form - .control(_idNumberKey) - .validators - .isNotEmpty, - formControlName: _idNumberKey, - label: localizations.translate( - i18.individualDetails.idNumberLabelText, - ), - validationMessages: { - 'required': (object) => - localizations.translate( - '${i18.individualDetails.idNumberLabelText}_IS_REQUIRED', - ), - }, - padding: const EdgeInsets.only( - top: kPadding * 2, - left: kPadding / 2, - right: kPadding / 2, - ), - ); - }, - ), - const SizedBox(height: 4), - ], - ), - if (form.control(_idTypeKey).value == 'DEFAULT') - const SizedBox( - height: kPadding, - ), - individualDetailsShowcaseData.dateOfBirth.buildWith( - child: DigitDobPicker( - datePickerFormControl: _dobKey, - datePickerLabel: localizations.translate( - i18.individualDetails.dobLabelText, - ), - ageFieldLabel: localizations.translate( - i18.individualDetails.ageLabelText, - ), - yearsHintLabel: localizations.translate( - i18.individualDetails.yearsHintText, - ), - monthsHintLabel: localizations.translate( - i18.individualDetails.monthsHintText, - ), - separatorLabel: localizations.translate( - i18.individualDetails.separatorLabelText, - ), - yearsAndMonthsErrMsg: localizations.translate( - i18.individualDetails.yearsAndMonthsErrorText, - ), - initialDate: before150Years, - onChangeOfFormControl: (formControl) { - // Handle changes to the control's value here - final value = formControl.value; - if (value == null) { - formControl.setErrors({'': true}); - } else { - DigitDOBAge age = - DigitDateUtils.calculateAge(value); - if ((age.years == 0 && age.months == 0) || - age.months > 11 || - (age.years >= 150 && age.months >= 0)) { - formControl.setErrors({'': true}); - } else { - formControl.removeError(''); - } - } - }, - cancelText: localizations - .translate(i18.common.coreCommonCancel), - confirmText: localizations - .translate(i18.common.coreCommonOk), - ), - ), - SelectionBox( - isRequired: true, - title: localizations.translate( - i18.individualDetails.genderLabelText, - ), - allowMultipleSelection: false, - width: 126, - initialSelection: - form.control(_genderKey).value != null - ? [form.control(_genderKey).value] - : [], - options: RegistrationDeliverySingleton() - .genderOptions! - .map( - (e) => e, - ) - .toList(), - onSelectionChanged: (value) { - setState(() { - if (value.isNotEmpty) { - form.control(_genderKey).value = value.first; - } else { - form.control(_genderKey).value = null; - setState(() { - form - .control(_genderKey) - .setErrors({'': true}); - }); - } - }); - }, - valueMapper: (value) { - return localizations.translate(value); - }, - errorMessage: form.control(_genderKey).hasErrors - ? localizations - .translate(i18.common.corecommonRequired) - : null, - ), - ]), - individualDetailsShowcaseData.mobile.buildWith( - child: DigitTextFormField( - keyboardType: TextInputType.number, - formControlName: _mobileNumberKey, - maxLength: 10, - label: localizations.translate( - i18.individualDetails.mobileNumberLabelText, - ), - validationMessages: { - 'maxLength': (object) => localizations.translate( - i18.individualDetails - .mobileNumberLengthValidationMessage), - 'minLength': (object) => localizations.translate( - i18.individualDetails - .mobileNumberLengthValidationMessage), - }, - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly, - ], - ), - ), + Column( + children: buildWidgetsFromConfig(WidgetConfigModel( + config: widget.widgetConfig, form: form))), const SizedBox(height: 16), if ((RegistrationDeliverySingleton().beneficiaryType == BeneficiaryType.household && @@ -766,7 +869,7 @@ class IndividualDetailsPageState extends LocalizedState { }, ); - return fb.group({ + final formGroup = fb.group({ _individualNameKey: FormControl( validators: [ Validators.required, @@ -797,6 +900,53 @@ class IndividualDetailsPageState extends LocalizedState { Validators.maxLength(10) ]), }); + + widget.widgetConfig.forEach((key, fieldConfig) { + final formControl = formGroup.control(key); + + // Get current validators + final currentValidators = formControl.validators; + + dynamic updatedValidators = currentValidators.where((validator) { + // Check if the validator is of the same type as Validators.required + return validator.runtimeType != Validators.required.runtimeType; + }).toList(); + + if (fieldConfig['isRequired'] == true) { + // Add the new validator to the list + updatedValidators = [ + ...currentValidators, + Validators.required // Example new validator + ]; + } + + // If JSON config has regex, add it as a validator + if (fieldConfig.containsKey('regex') && fieldConfig['regex'] is List) { + List regexList = fieldConfig['regex']; + String errorMessages = fieldConfig['errorMessage']; + + regexList.asMap().forEach((index, regexPattern) { + updatedValidators.add((control) { + final value = control.value; + if (value != null && + value.isNotEmpty && + !RegExp(regexPattern).hasMatch(value)) { + // Ensure there's a matching error message for this index + return {'customError': errorMessages}; + } + return null; + }); + }); + } + + // Set the updated validators back to the form control + formControl.setValidators(updatedValidators); + + // Re-run validation with the new validators + formControl.updateValueAndValidity(); + }); + + return formGroup; } getGenderOptions(IndividualModel? individual) { diff --git a/packages/registration_delivery/lib/router/registration_delivery_router.dart b/packages/registration_delivery/lib/router/registration_delivery_router.dart index 14d14e52f9..53b3451f24 100644 --- a/packages/registration_delivery/lib/router/registration_delivery_router.dart +++ b/packages/registration_delivery/lib/router/registration_delivery_router.dart @@ -34,6 +34,11 @@ class RegistrationDeliveryRoute extends $RegistrationDeliveryRoute { AutoRoute( page: HouseholdLocationRoute.page, path: 'household-location', + // initial: true, + ), + AutoRoute( + page: ExtendedFormRoute.page, + path: 'extended-form', initial: true, ), AutoRoute( diff --git a/packages/registration_delivery/lib/router/registration_delivery_router.gm.dart b/packages/registration_delivery/lib/router/registration_delivery_router.gm.dart index 9f75943287..19a49aa114 100644 --- a/packages/registration_delivery/lib/router/registration_delivery_router.gm.dart +++ b/packages/registration_delivery/lib/router/registration_delivery_router.gm.dart @@ -8,13 +8,13 @@ // coverage:ignore-file // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'package:auto_route/auto_route.dart' as _i25; -import 'package:digit_data_model/data_model.dart' as _i30; -import 'package:flutter/material.dart' as _i26; -import 'package:registration_delivery/blocs/app_localization.dart' as _i27; +import 'package:auto_route/auto_route.dart' as _i26; +import 'package:digit_data_model/data_model.dart' as _i31; +import 'package:flutter/material.dart' as _i27; +import 'package:registration_delivery/blocs/app_localization.dart' as _i28; import 'package:registration_delivery/blocs/search_households/search_households.dart' - as _i29; -import 'package:registration_delivery/models/entities/task.dart' as _i31; + as _i30; +import 'package:registration_delivery/models/entities/task.dart' as _i32; import 'package:registration_delivery/pages/beneficiary/beneficiary_checklist.dart' as _i2; import 'package:registration_delivery/pages/beneficiary/beneficiary_details.dart' @@ -28,47 +28,49 @@ import 'package:registration_delivery/pages/beneficiary/delivery_summary_page.da import 'package:registration_delivery/pages/beneficiary/dose_administered.dart' as _i8; import 'package:registration_delivery/pages/beneficiary/facility_selection.dart' - as _i9; + as _i10; import 'package:registration_delivery/pages/beneficiary/household_overview.dart' - as _i14; + as _i15; import 'package:registration_delivery/pages/beneficiary/record_past_delivery_details.dart' - as _i17; -import 'package:registration_delivery/pages/beneficiary/refer_beneficiary.dart' as _i18; -import 'package:registration_delivery/pages/beneficiary/refused_delivery.dart' +import 'package:registration_delivery/pages/beneficiary/refer_beneficiary.dart' as _i19; +import 'package:registration_delivery/pages/beneficiary/refused_delivery.dart' + as _i20; import 'package:registration_delivery/pages/beneficiary/side_effects.dart' - as _i22; + as _i23; import 'package:registration_delivery/pages/beneficiary/widgets/household_acknowledgement.dart' - as _i12; + as _i13; import 'package:registration_delivery/pages/beneficiary/widgets/splash_acknowledgement.dart' - as _i23; + as _i24; import 'package:registration_delivery/pages/beneficiary_registration/beneficiary_acknowledgement.dart' as _i1; import 'package:registration_delivery/pages/beneficiary_registration/beneficiary_registration_wrapper.dart' as _i4; +import 'package:registration_delivery/pages/beneficiary_registration/extended_class.dart' + as _i9; import 'package:registration_delivery/pages/beneficiary_registration/house_details.dart' - as _i10; -import 'package:registration_delivery/pages/beneficiary_registration/household_details.dart' as _i11; +import 'package:registration_delivery/pages/beneficiary_registration/household_details.dart' + as _i12; import 'package:registration_delivery/pages/beneficiary_registration/household_location.dart' - as _i13; + as _i14; import 'package:registration_delivery/pages/beneficiary_registration/individual_details.dart' - as _i15; -import 'package:registration_delivery/pages/reason_for_deletion.dart' as _i16; + as _i16; +import 'package:registration_delivery/pages/reason_for_deletion.dart' as _i17; import 'package:registration_delivery/pages/registration_delivery_wrapper.dart' - as _i20; -import 'package:registration_delivery/pages/search_beneficiary.dart' as _i21; -import 'package:registration_delivery/pages/summary_page.dart' as _i24; -import 'package:registration_delivery/registration_delivery.dart' as _i28; + as _i21; +import 'package:registration_delivery/pages/search_beneficiary.dart' as _i22; +import 'package:registration_delivery/pages/summary_page.dart' as _i25; +import 'package:registration_delivery/registration_delivery.dart' as _i29; -abstract class $RegistrationDeliveryRoute extends _i25.AutoRouterModule { +abstract class $RegistrationDeliveryRoute extends _i26.AutoRouterModule { @override - final Map pagesMap = { + final Map pagesMap = { BeneficiaryAcknowledgementRoute.name: (routeData) { final args = routeData.argsAs( orElse: () => const BeneficiaryAcknowledgementRouteArgs()); - return _i25.AutoRoutePage( + return _i26.AutoRoutePage( routeData: routeData, child: _i1.BeneficiaryAcknowledgementPage( key: args.key, @@ -80,7 +82,7 @@ abstract class $RegistrationDeliveryRoute extends _i25.AutoRouterModule { BeneficiaryChecklistRoute.name: (routeData) { final args = routeData.argsAs( orElse: () => const BeneficiaryChecklistRouteArgs()); - return _i25.AutoRoutePage( + return _i26.AutoRoutePage( routeData: routeData, child: _i2.BeneficiaryChecklistPage( key: args.key, @@ -92,7 +94,7 @@ abstract class $RegistrationDeliveryRoute extends _i25.AutoRouterModule { BeneficiaryDetailsRoute.name: (routeData) { final args = routeData.argsAs( orElse: () => const BeneficiaryDetailsRouteArgs()); - return _i25.AutoRoutePage( + return _i26.AutoRoutePage( routeData: routeData, child: _i3.BeneficiaryDetailsPage( key: args.key, @@ -102,9 +104,9 @@ abstract class $RegistrationDeliveryRoute extends _i25.AutoRouterModule { }, BeneficiaryRegistrationWrapperRoute.name: (routeData) { final args = routeData.argsAs(); - return _i25.AutoRoutePage( + return _i26.AutoRoutePage( routeData: routeData, - child: _i25.WrappedRoute( + child: _i26.WrappedRoute( child: _i4.BeneficiaryRegistrationWrapperPage( key: args.key, initialState: args.initialState, @@ -113,7 +115,7 @@ abstract class $RegistrationDeliveryRoute extends _i25.AutoRouterModule { }, BeneficiaryWrapperRoute.name: (routeData) { final args = routeData.argsAs(); - return _i25.AutoRoutePage( + return _i26.AutoRoutePage( routeData: routeData, child: _i5.BeneficiaryWrapperPage( key: args.key, @@ -125,7 +127,7 @@ abstract class $RegistrationDeliveryRoute extends _i25.AutoRouterModule { DeliverInterventionRoute.name: (routeData) { final args = routeData.argsAs( orElse: () => const DeliverInterventionRouteArgs()); - return _i25.AutoRoutePage( + return _i26.AutoRoutePage( routeData: routeData, child: _i6.DeliverInterventionPage( key: args.key, @@ -137,7 +139,7 @@ abstract class $RegistrationDeliveryRoute extends _i25.AutoRouterModule { DeliverySummaryRoute.name: (routeData) { final args = routeData.argsAs( orElse: () => const DeliverySummaryRouteArgs()); - return _i25.AutoRoutePage( + return _i26.AutoRoutePage( routeData: routeData, child: _i7.DeliverySummaryPage( key: args.key, @@ -148,7 +150,7 @@ abstract class $RegistrationDeliveryRoute extends _i25.AutoRouterModule { DoseAdministeredRoute.name: (routeData) { final args = routeData.argsAs( orElse: () => const DoseAdministeredRouteArgs()); - return _i25.AutoRoutePage( + return _i26.AutoRoutePage( routeData: routeData, child: _i8.DoseAdministeredPage( key: args.key, @@ -156,11 +158,17 @@ abstract class $RegistrationDeliveryRoute extends _i25.AutoRouterModule { ), ); }, + ExtendedFormRoute.name: (routeData) { + return _i26.AutoRoutePage( + routeData: routeData, + child: _i9.ExtendedFormPage(), + ); + }, FacilitySelectionRoute.name: (routeData) { final args = routeData.argsAs(); - return _i25.AutoRoutePage( + return _i26.AutoRoutePage( routeData: routeData, - child: _i9.FacilitySelectionPage( + child: _i10.FacilitySelectionPage( key: args.key, facilities: args.facilities, ), @@ -169,9 +177,10 @@ abstract class $RegistrationDeliveryRoute extends _i25.AutoRouterModule { HouseDetailsRoute.name: (routeData) { final args = routeData.argsAs( orElse: () => const HouseDetailsRouteArgs()); - return _i25.AutoRoutePage( + return _i26.AutoRoutePage( routeData: routeData, - child: _i10.HouseDetailsPage( + child: _i11.HouseDetailsPage( + widgetConfig: args.widgetConfig, key: args.key, appLocalizations: args.appLocalizations, ), @@ -180,9 +189,10 @@ abstract class $RegistrationDeliveryRoute extends _i25.AutoRouterModule { HouseHoldDetailsRoute.name: (routeData) { final args = routeData.argsAs( orElse: () => const HouseHoldDetailsRouteArgs()); - return _i25.AutoRoutePage( + return _i26.AutoRoutePage( routeData: routeData, - child: _i11.HouseHoldDetailsPage( + child: _i12.HouseHoldDetailsPage( + widgetConfig: args.widgetConfig, key: args.key, appLocalizations: args.appLocalizations, ), @@ -191,9 +201,9 @@ abstract class $RegistrationDeliveryRoute extends _i25.AutoRouterModule { HouseholdAcknowledgementRoute.name: (routeData) { final args = routeData.argsAs( orElse: () => const HouseholdAcknowledgementRouteArgs()); - return _i25.AutoRoutePage( + return _i26.AutoRoutePage( routeData: routeData, - child: _i12.HouseholdAcknowledgementPage( + child: _i13.HouseholdAcknowledgementPage( key: args.key, appLocalizations: args.appLocalizations, enableViewHousehold: args.enableViewHousehold, @@ -203,9 +213,10 @@ abstract class $RegistrationDeliveryRoute extends _i25.AutoRouterModule { HouseholdLocationRoute.name: (routeData) { final args = routeData.argsAs( orElse: () => const HouseholdLocationRouteArgs()); - return _i25.AutoRoutePage( + return _i26.AutoRoutePage( routeData: routeData, - child: _i13.HouseholdLocationPage( + child: _i14.HouseholdLocationPage( + widgetConfig: args.widgetConfig, key: args.key, appLocalizations: args.appLocalizations, ), @@ -214,9 +225,9 @@ abstract class $RegistrationDeliveryRoute extends _i25.AutoRouterModule { HouseholdOverviewRoute.name: (routeData) { final args = routeData.argsAs( orElse: () => const HouseholdOverviewRouteArgs()); - return _i25.AutoRoutePage( + return _i26.AutoRoutePage( routeData: routeData, - child: _i14.HouseholdOverviewPage( + child: _i15.HouseholdOverviewPage( key: args.key, appLocalizations: args.appLocalizations, ), @@ -225,9 +236,10 @@ abstract class $RegistrationDeliveryRoute extends _i25.AutoRouterModule { IndividualDetailsRoute.name: (routeData) { final args = routeData.argsAs( orElse: () => const IndividualDetailsRouteArgs()); - return _i25.AutoRoutePage( + return _i26.AutoRoutePage( routeData: routeData, - child: _i15.IndividualDetailsPage( + child: _i16.IndividualDetailsPage( + widgetConfig: args.widgetConfig, key: args.key, appLocalizations: args.appLocalizations, isHeadOfHousehold: args.isHeadOfHousehold, @@ -237,9 +249,9 @@ abstract class $RegistrationDeliveryRoute extends _i25.AutoRouterModule { ReasonForDeletionRoute.name: (routeData) { final args = routeData.argsAs( orElse: () => const ReasonForDeletionRouteArgs()); - return _i25.AutoRoutePage( + return _i26.AutoRoutePage( routeData: routeData, - child: _i16.ReasonForDeletionPage( + child: _i17.ReasonForDeletionPage( key: args.key, appLocalizations: args.appLocalizations, isHousholdDelete: args.isHousholdDelete, @@ -249,9 +261,9 @@ abstract class $RegistrationDeliveryRoute extends _i25.AutoRouterModule { RecordPastDeliveryDetailsRoute.name: (routeData) { final args = routeData.argsAs( orElse: () => const RecordPastDeliveryDetailsRouteArgs()); - return _i25.AutoRoutePage( + return _i26.AutoRoutePage( routeData: routeData, - child: _i17.RecordPastDeliveryDetailsPage( + child: _i18.RecordPastDeliveryDetailsPage( key: args.key, appLocalizations: args.appLocalizations, tasks: args.tasks, @@ -260,9 +272,9 @@ abstract class $RegistrationDeliveryRoute extends _i25.AutoRouterModule { }, ReferBeneficiaryRoute.name: (routeData) { final args = routeData.argsAs(); - return _i25.AutoRoutePage( + return _i26.AutoRoutePage( routeData: routeData, - child: _i18.ReferBeneficiaryPage( + child: _i19.ReferBeneficiaryPage( key: args.key, appLocalizations: args.appLocalizations, isEditing: args.isEditing, @@ -273,26 +285,26 @@ abstract class $RegistrationDeliveryRoute extends _i25.AutoRouterModule { RefusedDeliveryRoute.name: (routeData) { final args = routeData.argsAs( orElse: () => const RefusedDeliveryRouteArgs()); - return _i25.AutoRoutePage( + return _i26.AutoRoutePage( routeData: routeData, - child: _i19.RefusedDeliveryPage( + child: _i20.RefusedDeliveryPage( key: args.key, appLocalizations: args.appLocalizations, ), ); }, RegistrationDeliveryWrapperRoute.name: (routeData) { - return _i25.AutoRoutePage( + return _i26.AutoRoutePage( routeData: routeData, - child: const _i20.RegistrationDeliveryWrapperPage(), + child: const _i21.RegistrationDeliveryWrapperPage(), ); }, SearchBeneficiaryRoute.name: (routeData) { final args = routeData.argsAs( orElse: () => const SearchBeneficiaryRouteArgs()); - return _i25.AutoRoutePage( + return _i26.AutoRoutePage( routeData: routeData, - child: _i21.SearchBeneficiaryPage( + child: _i22.SearchBeneficiaryPage( key: args.key, appLocalizations: args.appLocalizations, ), @@ -300,9 +312,9 @@ abstract class $RegistrationDeliveryRoute extends _i25.AutoRouterModule { }, SideEffectsRoute.name: (routeData) { final args = routeData.argsAs(); - return _i25.AutoRoutePage( + return _i26.AutoRoutePage( routeData: routeData, - child: _i22.SideEffectsPage( + child: _i23.SideEffectsPage( key: args.key, appLocalizations: args.appLocalizations, tasks: args.tasks, @@ -313,9 +325,9 @@ abstract class $RegistrationDeliveryRoute extends _i25.AutoRouterModule { SplashAcknowledgementRoute.name: (routeData) { final args = routeData.argsAs( orElse: () => const SplashAcknowledgementRouteArgs()); - return _i25.AutoRoutePage( + return _i26.AutoRoutePage( routeData: routeData, - child: _i23.SplashAcknowledgementPage( + child: _i24.SplashAcknowledgementPage( key: args.key, appLocalizations: args.appLocalizations, enableBackToSearch: args.enableBackToSearch, @@ -325,9 +337,9 @@ abstract class $RegistrationDeliveryRoute extends _i25.AutoRouterModule { SummaryRoute.name: (routeData) { final args = routeData.argsAs( orElse: () => const SummaryRouteArgs()); - return _i25.AutoRoutePage( + return _i26.AutoRoutePage( routeData: routeData, - child: _i24.SummaryPage( + child: _i25.SummaryPage( key: args.key, appLocalizations: args.appLocalizations, ), @@ -339,12 +351,12 @@ abstract class $RegistrationDeliveryRoute extends _i25.AutoRouterModule { /// generated route for /// [_i1.BeneficiaryAcknowledgementPage] class BeneficiaryAcknowledgementRoute - extends _i25.PageRouteInfo { + extends _i26.PageRouteInfo { BeneficiaryAcknowledgementRoute({ - _i26.Key? key, - _i27.RegistrationDeliveryLocalization? appLocalizations, + _i27.Key? key, + _i28.RegistrationDeliveryLocalization? appLocalizations, bool? enableViewHousehold, - List<_i25.PageRouteInfo>? children, + List<_i26.PageRouteInfo>? children, }) : super( BeneficiaryAcknowledgementRoute.name, args: BeneficiaryAcknowledgementRouteArgs( @@ -357,8 +369,8 @@ class BeneficiaryAcknowledgementRoute static const String name = 'BeneficiaryAcknowledgementRoute'; - static const _i25.PageInfo page = - _i25.PageInfo(name); + static const _i26.PageInfo page = + _i26.PageInfo(name); } class BeneficiaryAcknowledgementRouteArgs { @@ -368,9 +380,9 @@ class BeneficiaryAcknowledgementRouteArgs { this.enableViewHousehold, }); - final _i26.Key? key; + final _i27.Key? key; - final _i27.RegistrationDeliveryLocalization? appLocalizations; + final _i28.RegistrationDeliveryLocalization? appLocalizations; final bool? enableViewHousehold; @@ -383,12 +395,12 @@ class BeneficiaryAcknowledgementRouteArgs { /// generated route for /// [_i2.BeneficiaryChecklistPage] class BeneficiaryChecklistRoute - extends _i25.PageRouteInfo { + extends _i26.PageRouteInfo { BeneficiaryChecklistRoute({ - _i26.Key? key, + _i27.Key? key, String? beneficiaryClientRefId, - _i27.RegistrationDeliveryLocalization? appLocalizations, - List<_i25.PageRouteInfo>? children, + _i28.RegistrationDeliveryLocalization? appLocalizations, + List<_i26.PageRouteInfo>? children, }) : super( BeneficiaryChecklistRoute.name, args: BeneficiaryChecklistRouteArgs( @@ -401,8 +413,8 @@ class BeneficiaryChecklistRoute static const String name = 'BeneficiaryChecklistRoute'; - static const _i25.PageInfo page = - _i25.PageInfo(name); + static const _i26.PageInfo page = + _i26.PageInfo(name); } class BeneficiaryChecklistRouteArgs { @@ -412,11 +424,11 @@ class BeneficiaryChecklistRouteArgs { this.appLocalizations, }); - final _i26.Key? key; + final _i27.Key? key; final String? beneficiaryClientRefId; - final _i27.RegistrationDeliveryLocalization? appLocalizations; + final _i28.RegistrationDeliveryLocalization? appLocalizations; @override String toString() { @@ -427,11 +439,11 @@ class BeneficiaryChecklistRouteArgs { /// generated route for /// [_i3.BeneficiaryDetailsPage] class BeneficiaryDetailsRoute - extends _i25.PageRouteInfo { + extends _i26.PageRouteInfo { BeneficiaryDetailsRoute({ - _i26.Key? key, - _i27.RegistrationDeliveryLocalization? appLocalizations, - List<_i25.PageRouteInfo>? children, + _i27.Key? key, + _i28.RegistrationDeliveryLocalization? appLocalizations, + List<_i26.PageRouteInfo>? children, }) : super( BeneficiaryDetailsRoute.name, args: BeneficiaryDetailsRouteArgs( @@ -443,8 +455,8 @@ class BeneficiaryDetailsRoute static const String name = 'BeneficiaryDetailsRoute'; - static const _i25.PageInfo page = - _i25.PageInfo(name); + static const _i26.PageInfo page = + _i26.PageInfo(name); } class BeneficiaryDetailsRouteArgs { @@ -453,9 +465,9 @@ class BeneficiaryDetailsRouteArgs { this.appLocalizations, }); - final _i26.Key? key; + final _i27.Key? key; - final _i27.RegistrationDeliveryLocalization? appLocalizations; + final _i28.RegistrationDeliveryLocalization? appLocalizations; @override String toString() { @@ -466,11 +478,11 @@ class BeneficiaryDetailsRouteArgs { /// generated route for /// [_i4.BeneficiaryRegistrationWrapperPage] class BeneficiaryRegistrationWrapperRoute - extends _i25.PageRouteInfo { + extends _i26.PageRouteInfo { BeneficiaryRegistrationWrapperRoute({ - _i26.Key? key, - required _i28.BeneficiaryRegistrationState initialState, - List<_i25.PageRouteInfo>? children, + _i27.Key? key, + required _i29.BeneficiaryRegistrationState initialState, + List<_i26.PageRouteInfo>? children, }) : super( BeneficiaryRegistrationWrapperRoute.name, args: BeneficiaryRegistrationWrapperRouteArgs( @@ -482,8 +494,8 @@ class BeneficiaryRegistrationWrapperRoute static const String name = 'BeneficiaryRegistrationWrapperRoute'; - static const _i25.PageInfo page = - _i25.PageInfo(name); + static const _i26.PageInfo page = + _i26.PageInfo(name); } class BeneficiaryRegistrationWrapperRouteArgs { @@ -492,9 +504,9 @@ class BeneficiaryRegistrationWrapperRouteArgs { required this.initialState, }); - final _i26.Key? key; + final _i27.Key? key; - final _i28.BeneficiaryRegistrationState initialState; + final _i29.BeneficiaryRegistrationState initialState; @override String toString() { @@ -505,12 +517,12 @@ class BeneficiaryRegistrationWrapperRouteArgs { /// generated route for /// [_i5.BeneficiaryWrapperPage] class BeneficiaryWrapperRoute - extends _i25.PageRouteInfo { + extends _i26.PageRouteInfo { BeneficiaryWrapperRoute({ - _i26.Key? key, - required _i29.HouseholdMemberWrapper wrapper, + _i27.Key? key, + required _i30.HouseholdMemberWrapper wrapper, bool isEditing = false, - List<_i25.PageRouteInfo>? children, + List<_i26.PageRouteInfo>? children, }) : super( BeneficiaryWrapperRoute.name, args: BeneficiaryWrapperRouteArgs( @@ -523,8 +535,8 @@ class BeneficiaryWrapperRoute static const String name = 'BeneficiaryWrapperRoute'; - static const _i25.PageInfo page = - _i25.PageInfo(name); + static const _i26.PageInfo page = + _i26.PageInfo(name); } class BeneficiaryWrapperRouteArgs { @@ -534,9 +546,9 @@ class BeneficiaryWrapperRouteArgs { this.isEditing = false, }); - final _i26.Key? key; + final _i27.Key? key; - final _i29.HouseholdMemberWrapper wrapper; + final _i30.HouseholdMemberWrapper wrapper; final bool isEditing; @@ -549,12 +561,12 @@ class BeneficiaryWrapperRouteArgs { /// generated route for /// [_i6.DeliverInterventionPage] class DeliverInterventionRoute - extends _i25.PageRouteInfo { + extends _i26.PageRouteInfo { DeliverInterventionRoute({ - _i26.Key? key, - _i27.RegistrationDeliveryLocalization? appLocalizations, + _i27.Key? key, + _i28.RegistrationDeliveryLocalization? appLocalizations, bool isEditing = false, - List<_i25.PageRouteInfo>? children, + List<_i26.PageRouteInfo>? children, }) : super( DeliverInterventionRoute.name, args: DeliverInterventionRouteArgs( @@ -567,8 +579,8 @@ class DeliverInterventionRoute static const String name = 'DeliverInterventionRoute'; - static const _i25.PageInfo page = - _i25.PageInfo(name); + static const _i26.PageInfo page = + _i26.PageInfo(name); } class DeliverInterventionRouteArgs { @@ -578,9 +590,9 @@ class DeliverInterventionRouteArgs { this.isEditing = false, }); - final _i26.Key? key; + final _i27.Key? key; - final _i27.RegistrationDeliveryLocalization? appLocalizations; + final _i28.RegistrationDeliveryLocalization? appLocalizations; final bool isEditing; @@ -593,11 +605,11 @@ class DeliverInterventionRouteArgs { /// generated route for /// [_i7.DeliverySummaryPage] class DeliverySummaryRoute - extends _i25.PageRouteInfo { + extends _i26.PageRouteInfo { DeliverySummaryRoute({ - _i26.Key? key, - _i27.RegistrationDeliveryLocalization? appLocalizations, - List<_i25.PageRouteInfo>? children, + _i27.Key? key, + _i28.RegistrationDeliveryLocalization? appLocalizations, + List<_i26.PageRouteInfo>? children, }) : super( DeliverySummaryRoute.name, args: DeliverySummaryRouteArgs( @@ -609,8 +621,8 @@ class DeliverySummaryRoute static const String name = 'DeliverySummaryRoute'; - static const _i25.PageInfo page = - _i25.PageInfo(name); + static const _i26.PageInfo page = + _i26.PageInfo(name); } class DeliverySummaryRouteArgs { @@ -619,9 +631,9 @@ class DeliverySummaryRouteArgs { this.appLocalizations, }); - final _i26.Key? key; + final _i27.Key? key; - final _i27.RegistrationDeliveryLocalization? appLocalizations; + final _i28.RegistrationDeliveryLocalization? appLocalizations; @override String toString() { @@ -632,11 +644,11 @@ class DeliverySummaryRouteArgs { /// generated route for /// [_i8.DoseAdministeredPage] class DoseAdministeredRoute - extends _i25.PageRouteInfo { + extends _i26.PageRouteInfo { DoseAdministeredRoute({ - _i26.Key? key, - _i27.RegistrationDeliveryLocalization? appLocalizations, - List<_i25.PageRouteInfo>? children, + _i27.Key? key, + _i28.RegistrationDeliveryLocalization? appLocalizations, + List<_i26.PageRouteInfo>? children, }) : super( DoseAdministeredRoute.name, args: DoseAdministeredRouteArgs( @@ -648,8 +660,8 @@ class DoseAdministeredRoute static const String name = 'DoseAdministeredRoute'; - static const _i25.PageInfo page = - _i25.PageInfo(name); + static const _i26.PageInfo page = + _i26.PageInfo(name); } class DoseAdministeredRouteArgs { @@ -658,9 +670,9 @@ class DoseAdministeredRouteArgs { this.appLocalizations, }); - final _i26.Key? key; + final _i27.Key? key; - final _i27.RegistrationDeliveryLocalization? appLocalizations; + final _i28.RegistrationDeliveryLocalization? appLocalizations; @override String toString() { @@ -669,13 +681,27 @@ class DoseAdministeredRouteArgs { } /// generated route for -/// [_i9.FacilitySelectionPage] +/// [_i9.ExtendedFormPage] +class ExtendedFormRoute extends _i26.PageRouteInfo { + const ExtendedFormRoute({List<_i26.PageRouteInfo>? children}) + : super( + ExtendedFormRoute.name, + initialChildren: children, + ); + + static const String name = 'ExtendedFormRoute'; + + static const _i26.PageInfo page = _i26.PageInfo(name); +} + +/// generated route for +/// [_i10.FacilitySelectionPage] class FacilitySelectionRoute - extends _i25.PageRouteInfo { + extends _i26.PageRouteInfo { FacilitySelectionRoute({ - _i26.Key? key, - required List<_i30.FacilityModel> facilities, - List<_i25.PageRouteInfo>? children, + _i27.Key? key, + required List<_i31.FacilityModel> facilities, + List<_i26.PageRouteInfo>? children, }) : super( FacilitySelectionRoute.name, args: FacilitySelectionRouteArgs( @@ -687,8 +713,8 @@ class FacilitySelectionRoute static const String name = 'FacilitySelectionRoute'; - static const _i25.PageInfo page = - _i25.PageInfo(name); + static const _i26.PageInfo page = + _i26.PageInfo(name); } class FacilitySelectionRouteArgs { @@ -697,9 +723,9 @@ class FacilitySelectionRouteArgs { required this.facilities, }); - final _i26.Key? key; + final _i27.Key? key; - final List<_i30.FacilityModel> facilities; + final List<_i31.FacilityModel> facilities; @override String toString() { @@ -708,15 +734,17 @@ class FacilitySelectionRouteArgs { } /// generated route for -/// [_i10.HouseDetailsPage] -class HouseDetailsRoute extends _i25.PageRouteInfo { +/// [_i11.HouseDetailsPage] +class HouseDetailsRoute extends _i26.PageRouteInfo { HouseDetailsRoute({ - _i26.Key? key, - _i27.RegistrationDeliveryLocalization? appLocalizations, - List<_i25.PageRouteInfo>? children, + Map>? widgetConfig, + _i27.Key? key, + _i28.RegistrationDeliveryLocalization? appLocalizations, + List<_i26.PageRouteInfo>? children, }) : super( HouseDetailsRoute.name, args: HouseDetailsRouteArgs( + widgetConfig: widgetConfig, key: key, appLocalizations: appLocalizations, ), @@ -725,37 +753,42 @@ class HouseDetailsRoute extends _i25.PageRouteInfo { static const String name = 'HouseDetailsRoute'; - static const _i25.PageInfo page = - _i25.PageInfo(name); + static const _i26.PageInfo page = + _i26.PageInfo(name); } class HouseDetailsRouteArgs { const HouseDetailsRouteArgs({ + this.widgetConfig, this.key, this.appLocalizations, }); - final _i26.Key? key; + final Map>? widgetConfig; - final _i27.RegistrationDeliveryLocalization? appLocalizations; + final _i27.Key? key; + + final _i28.RegistrationDeliveryLocalization? appLocalizations; @override String toString() { - return 'HouseDetailsRouteArgs{key: $key, appLocalizations: $appLocalizations}'; + return 'HouseDetailsRouteArgs{widgetConfig: $widgetConfig, key: $key, appLocalizations: $appLocalizations}'; } } /// generated route for -/// [_i11.HouseHoldDetailsPage] +/// [_i12.HouseHoldDetailsPage] class HouseHoldDetailsRoute - extends _i25.PageRouteInfo { + extends _i26.PageRouteInfo { HouseHoldDetailsRoute({ - _i26.Key? key, - _i27.RegistrationDeliveryLocalization? appLocalizations, - List<_i25.PageRouteInfo>? children, + Map>? widgetConfig, + _i27.Key? key, + _i28.RegistrationDeliveryLocalization? appLocalizations, + List<_i26.PageRouteInfo>? children, }) : super( HouseHoldDetailsRoute.name, args: HouseHoldDetailsRouteArgs( + widgetConfig: widgetConfig, key: key, appLocalizations: appLocalizations, ), @@ -764,35 +797,38 @@ class HouseHoldDetailsRoute static const String name = 'HouseHoldDetailsRoute'; - static const _i25.PageInfo page = - _i25.PageInfo(name); + static const _i26.PageInfo page = + _i26.PageInfo(name); } class HouseHoldDetailsRouteArgs { const HouseHoldDetailsRouteArgs({ + this.widgetConfig, this.key, this.appLocalizations, }); - final _i26.Key? key; + final Map>? widgetConfig; + + final _i27.Key? key; - final _i27.RegistrationDeliveryLocalization? appLocalizations; + final _i28.RegistrationDeliveryLocalization? appLocalizations; @override String toString() { - return 'HouseHoldDetailsRouteArgs{key: $key, appLocalizations: $appLocalizations}'; + return 'HouseHoldDetailsRouteArgs{widgetConfig: $widgetConfig, key: $key, appLocalizations: $appLocalizations}'; } } /// generated route for -/// [_i12.HouseholdAcknowledgementPage] +/// [_i13.HouseholdAcknowledgementPage] class HouseholdAcknowledgementRoute - extends _i25.PageRouteInfo { + extends _i26.PageRouteInfo { HouseholdAcknowledgementRoute({ - _i26.Key? key, - _i27.RegistrationDeliveryLocalization? appLocalizations, + _i27.Key? key, + _i28.RegistrationDeliveryLocalization? appLocalizations, bool? enableViewHousehold, - List<_i25.PageRouteInfo>? children, + List<_i26.PageRouteInfo>? children, }) : super( HouseholdAcknowledgementRoute.name, args: HouseholdAcknowledgementRouteArgs( @@ -805,8 +841,8 @@ class HouseholdAcknowledgementRoute static const String name = 'HouseholdAcknowledgementRoute'; - static const _i25.PageInfo page = - _i25.PageInfo(name); + static const _i26.PageInfo page = + _i26.PageInfo(name); } class HouseholdAcknowledgementRouteArgs { @@ -816,9 +852,9 @@ class HouseholdAcknowledgementRouteArgs { this.enableViewHousehold, }); - final _i26.Key? key; + final _i27.Key? key; - final _i27.RegistrationDeliveryLocalization? appLocalizations; + final _i28.RegistrationDeliveryLocalization? appLocalizations; final bool? enableViewHousehold; @@ -829,16 +865,18 @@ class HouseholdAcknowledgementRouteArgs { } /// generated route for -/// [_i13.HouseholdLocationPage] +/// [_i14.HouseholdLocationPage] class HouseholdLocationRoute - extends _i25.PageRouteInfo { + extends _i26.PageRouteInfo { HouseholdLocationRoute({ - _i26.Key? key, - _i27.RegistrationDeliveryLocalization? appLocalizations, - List<_i25.PageRouteInfo>? children, + Map>? widgetConfig, + _i27.Key? key, + _i28.RegistrationDeliveryLocalization? appLocalizations, + List<_i26.PageRouteInfo>? children, }) : super( HouseholdLocationRoute.name, args: HouseholdLocationRouteArgs( + widgetConfig: widgetConfig, key: key, appLocalizations: appLocalizations, ), @@ -847,34 +885,37 @@ class HouseholdLocationRoute static const String name = 'HouseholdLocationRoute'; - static const _i25.PageInfo page = - _i25.PageInfo(name); + static const _i26.PageInfo page = + _i26.PageInfo(name); } class HouseholdLocationRouteArgs { const HouseholdLocationRouteArgs({ + this.widgetConfig, this.key, this.appLocalizations, }); - final _i26.Key? key; + final Map>? widgetConfig; - final _i27.RegistrationDeliveryLocalization? appLocalizations; + final _i27.Key? key; + + final _i28.RegistrationDeliveryLocalization? appLocalizations; @override String toString() { - return 'HouseholdLocationRouteArgs{key: $key, appLocalizations: $appLocalizations}'; + return 'HouseholdLocationRouteArgs{widgetConfig: $widgetConfig, key: $key, appLocalizations: $appLocalizations}'; } } /// generated route for -/// [_i14.HouseholdOverviewPage] +/// [_i15.HouseholdOverviewPage] class HouseholdOverviewRoute - extends _i25.PageRouteInfo { + extends _i26.PageRouteInfo { HouseholdOverviewRoute({ - _i26.Key? key, - _i27.RegistrationDeliveryLocalization? appLocalizations, - List<_i25.PageRouteInfo>? children, + _i27.Key? key, + _i28.RegistrationDeliveryLocalization? appLocalizations, + List<_i26.PageRouteInfo>? children, }) : super( HouseholdOverviewRoute.name, args: HouseholdOverviewRouteArgs( @@ -886,8 +927,8 @@ class HouseholdOverviewRoute static const String name = 'HouseholdOverviewRoute'; - static const _i25.PageInfo page = - _i25.PageInfo(name); + static const _i26.PageInfo page = + _i26.PageInfo(name); } class HouseholdOverviewRouteArgs { @@ -896,9 +937,9 @@ class HouseholdOverviewRouteArgs { this.appLocalizations, }); - final _i26.Key? key; + final _i27.Key? key; - final _i27.RegistrationDeliveryLocalization? appLocalizations; + final _i28.RegistrationDeliveryLocalization? appLocalizations; @override String toString() { @@ -907,17 +948,19 @@ class HouseholdOverviewRouteArgs { } /// generated route for -/// [_i15.IndividualDetailsPage] +/// [_i16.IndividualDetailsPage] class IndividualDetailsRoute - extends _i25.PageRouteInfo { + extends _i26.PageRouteInfo { IndividualDetailsRoute({ - _i26.Key? key, - _i27.RegistrationDeliveryLocalization? appLocalizations, + Map>? widgetConfig, + _i27.Key? key, + _i28.RegistrationDeliveryLocalization? appLocalizations, bool isHeadOfHousehold = false, - List<_i25.PageRouteInfo>? children, + List<_i26.PageRouteInfo>? children, }) : super( IndividualDetailsRoute.name, args: IndividualDetailsRouteArgs( + widgetConfig: widgetConfig, key: key, appLocalizations: appLocalizations, isHeadOfHousehold: isHeadOfHousehold, @@ -927,38 +970,41 @@ class IndividualDetailsRoute static const String name = 'IndividualDetailsRoute'; - static const _i25.PageInfo page = - _i25.PageInfo(name); + static const _i26.PageInfo page = + _i26.PageInfo(name); } class IndividualDetailsRouteArgs { const IndividualDetailsRouteArgs({ + this.widgetConfig, this.key, this.appLocalizations, this.isHeadOfHousehold = false, }); - final _i26.Key? key; + final Map>? widgetConfig; + + final _i27.Key? key; - final _i27.RegistrationDeliveryLocalization? appLocalizations; + final _i28.RegistrationDeliveryLocalization? appLocalizations; final bool isHeadOfHousehold; @override String toString() { - return 'IndividualDetailsRouteArgs{key: $key, appLocalizations: $appLocalizations, isHeadOfHousehold: $isHeadOfHousehold}'; + return 'IndividualDetailsRouteArgs{widgetConfig: $widgetConfig, key: $key, appLocalizations: $appLocalizations, isHeadOfHousehold: $isHeadOfHousehold}'; } } /// generated route for -/// [_i16.ReasonForDeletionPage] +/// [_i17.ReasonForDeletionPage] class ReasonForDeletionRoute - extends _i25.PageRouteInfo { + extends _i26.PageRouteInfo { ReasonForDeletionRoute({ - _i26.Key? key, - _i27.RegistrationDeliveryLocalization? appLocalizations, + _i27.Key? key, + _i28.RegistrationDeliveryLocalization? appLocalizations, bool isHousholdDelete = false, - List<_i25.PageRouteInfo>? children, + List<_i26.PageRouteInfo>? children, }) : super( ReasonForDeletionRoute.name, args: ReasonForDeletionRouteArgs( @@ -971,8 +1017,8 @@ class ReasonForDeletionRoute static const String name = 'ReasonForDeletionRoute'; - static const _i25.PageInfo page = - _i25.PageInfo(name); + static const _i26.PageInfo page = + _i26.PageInfo(name); } class ReasonForDeletionRouteArgs { @@ -982,9 +1028,9 @@ class ReasonForDeletionRouteArgs { this.isHousholdDelete = false, }); - final _i26.Key? key; + final _i27.Key? key; - final _i27.RegistrationDeliveryLocalization? appLocalizations; + final _i28.RegistrationDeliveryLocalization? appLocalizations; final bool isHousholdDelete; @@ -995,14 +1041,14 @@ class ReasonForDeletionRouteArgs { } /// generated route for -/// [_i17.RecordPastDeliveryDetailsPage] +/// [_i18.RecordPastDeliveryDetailsPage] class RecordPastDeliveryDetailsRoute - extends _i25.PageRouteInfo { + extends _i26.PageRouteInfo { RecordPastDeliveryDetailsRoute({ - _i26.Key? key, - _i27.RegistrationDeliveryLocalization? appLocalizations, - List<_i31.TaskModel>? tasks, - List<_i25.PageRouteInfo>? children, + _i27.Key? key, + _i28.RegistrationDeliveryLocalization? appLocalizations, + List<_i32.TaskModel>? tasks, + List<_i26.PageRouteInfo>? children, }) : super( RecordPastDeliveryDetailsRoute.name, args: RecordPastDeliveryDetailsRouteArgs( @@ -1015,8 +1061,8 @@ class RecordPastDeliveryDetailsRoute static const String name = 'RecordPastDeliveryDetailsRoute'; - static const _i25.PageInfo page = - _i25.PageInfo(name); + static const _i26.PageInfo page = + _i26.PageInfo(name); } class RecordPastDeliveryDetailsRouteArgs { @@ -1026,11 +1072,11 @@ class RecordPastDeliveryDetailsRouteArgs { this.tasks, }); - final _i26.Key? key; + final _i27.Key? key; - final _i27.RegistrationDeliveryLocalization? appLocalizations; + final _i28.RegistrationDeliveryLocalization? appLocalizations; - final List<_i31.TaskModel>? tasks; + final List<_i32.TaskModel>? tasks; @override String toString() { @@ -1039,15 +1085,15 @@ class RecordPastDeliveryDetailsRouteArgs { } /// generated route for -/// [_i18.ReferBeneficiaryPage] +/// [_i19.ReferBeneficiaryPage] class ReferBeneficiaryRoute - extends _i25.PageRouteInfo { + extends _i26.PageRouteInfo { ReferBeneficiaryRoute({ - _i26.Key? key, - _i27.RegistrationDeliveryLocalization? appLocalizations, + _i27.Key? key, + _i28.RegistrationDeliveryLocalization? appLocalizations, bool isEditing = false, required String projectBeneficiaryClientRefId, - List<_i25.PageRouteInfo>? children, + List<_i26.PageRouteInfo>? children, }) : super( ReferBeneficiaryRoute.name, args: ReferBeneficiaryRouteArgs( @@ -1061,8 +1107,8 @@ class ReferBeneficiaryRoute static const String name = 'ReferBeneficiaryRoute'; - static const _i25.PageInfo page = - _i25.PageInfo(name); + static const _i26.PageInfo page = + _i26.PageInfo(name); } class ReferBeneficiaryRouteArgs { @@ -1073,9 +1119,9 @@ class ReferBeneficiaryRouteArgs { required this.projectBeneficiaryClientRefId, }); - final _i26.Key? key; + final _i27.Key? key; - final _i27.RegistrationDeliveryLocalization? appLocalizations; + final _i28.RegistrationDeliveryLocalization? appLocalizations; final bool isEditing; @@ -1088,13 +1134,13 @@ class ReferBeneficiaryRouteArgs { } /// generated route for -/// [_i19.RefusedDeliveryPage] +/// [_i20.RefusedDeliveryPage] class RefusedDeliveryRoute - extends _i25.PageRouteInfo { + extends _i26.PageRouteInfo { RefusedDeliveryRoute({ - _i26.Key? key, - _i27.RegistrationDeliveryLocalization? appLocalizations, - List<_i25.PageRouteInfo>? children, + _i27.Key? key, + _i28.RegistrationDeliveryLocalization? appLocalizations, + List<_i26.PageRouteInfo>? children, }) : super( RefusedDeliveryRoute.name, args: RefusedDeliveryRouteArgs( @@ -1106,8 +1152,8 @@ class RefusedDeliveryRoute static const String name = 'RefusedDeliveryRoute'; - static const _i25.PageInfo page = - _i25.PageInfo(name); + static const _i26.PageInfo page = + _i26.PageInfo(name); } class RefusedDeliveryRouteArgs { @@ -1116,9 +1162,9 @@ class RefusedDeliveryRouteArgs { this.appLocalizations, }); - final _i26.Key? key; + final _i27.Key? key; - final _i27.RegistrationDeliveryLocalization? appLocalizations; + final _i28.RegistrationDeliveryLocalization? appLocalizations; @override String toString() { @@ -1127,9 +1173,9 @@ class RefusedDeliveryRouteArgs { } /// generated route for -/// [_i20.RegistrationDeliveryWrapperPage] -class RegistrationDeliveryWrapperRoute extends _i25.PageRouteInfo { - const RegistrationDeliveryWrapperRoute({List<_i25.PageRouteInfo>? children}) +/// [_i21.RegistrationDeliveryWrapperPage] +class RegistrationDeliveryWrapperRoute extends _i26.PageRouteInfo { + const RegistrationDeliveryWrapperRoute({List<_i26.PageRouteInfo>? children}) : super( RegistrationDeliveryWrapperRoute.name, initialChildren: children, @@ -1137,17 +1183,17 @@ class RegistrationDeliveryWrapperRoute extends _i25.PageRouteInfo { static const String name = 'RegistrationDeliveryWrapperRoute'; - static const _i25.PageInfo page = _i25.PageInfo(name); + static const _i26.PageInfo page = _i26.PageInfo(name); } /// generated route for -/// [_i21.SearchBeneficiaryPage] +/// [_i22.SearchBeneficiaryPage] class SearchBeneficiaryRoute - extends _i25.PageRouteInfo { + extends _i26.PageRouteInfo { SearchBeneficiaryRoute({ - _i26.Key? key, - _i27.RegistrationDeliveryLocalization? appLocalizations, - List<_i25.PageRouteInfo>? children, + _i27.Key? key, + _i28.RegistrationDeliveryLocalization? appLocalizations, + List<_i26.PageRouteInfo>? children, }) : super( SearchBeneficiaryRoute.name, args: SearchBeneficiaryRouteArgs( @@ -1159,8 +1205,8 @@ class SearchBeneficiaryRoute static const String name = 'SearchBeneficiaryRoute'; - static const _i25.PageInfo page = - _i25.PageInfo(name); + static const _i26.PageInfo page = + _i26.PageInfo(name); } class SearchBeneficiaryRouteArgs { @@ -1169,9 +1215,9 @@ class SearchBeneficiaryRouteArgs { this.appLocalizations, }); - final _i26.Key? key; + final _i27.Key? key; - final _i27.RegistrationDeliveryLocalization? appLocalizations; + final _i28.RegistrationDeliveryLocalization? appLocalizations; @override String toString() { @@ -1180,14 +1226,14 @@ class SearchBeneficiaryRouteArgs { } /// generated route for -/// [_i22.SideEffectsPage] -class SideEffectsRoute extends _i25.PageRouteInfo { +/// [_i23.SideEffectsPage] +class SideEffectsRoute extends _i26.PageRouteInfo { SideEffectsRoute({ - _i26.Key? key, - _i27.RegistrationDeliveryLocalization? appLocalizations, - required List<_i31.TaskModel> tasks, + _i27.Key? key, + _i28.RegistrationDeliveryLocalization? appLocalizations, + required List<_i32.TaskModel> tasks, bool isEditing = false, - List<_i25.PageRouteInfo>? children, + List<_i26.PageRouteInfo>? children, }) : super( SideEffectsRoute.name, args: SideEffectsRouteArgs( @@ -1201,8 +1247,8 @@ class SideEffectsRoute extends _i25.PageRouteInfo { static const String name = 'SideEffectsRoute'; - static const _i25.PageInfo page = - _i25.PageInfo(name); + static const _i26.PageInfo page = + _i26.PageInfo(name); } class SideEffectsRouteArgs { @@ -1213,11 +1259,11 @@ class SideEffectsRouteArgs { this.isEditing = false, }); - final _i26.Key? key; + final _i27.Key? key; - final _i27.RegistrationDeliveryLocalization? appLocalizations; + final _i28.RegistrationDeliveryLocalization? appLocalizations; - final List<_i31.TaskModel> tasks; + final List<_i32.TaskModel> tasks; final bool isEditing; @@ -1228,14 +1274,14 @@ class SideEffectsRouteArgs { } /// generated route for -/// [_i23.SplashAcknowledgementPage] +/// [_i24.SplashAcknowledgementPage] class SplashAcknowledgementRoute - extends _i25.PageRouteInfo { + extends _i26.PageRouteInfo { SplashAcknowledgementRoute({ - _i26.Key? key, - _i27.RegistrationDeliveryLocalization? appLocalizations, + _i27.Key? key, + _i28.RegistrationDeliveryLocalization? appLocalizations, bool? enableBackToSearch, - List<_i25.PageRouteInfo>? children, + List<_i26.PageRouteInfo>? children, }) : super( SplashAcknowledgementRoute.name, args: SplashAcknowledgementRouteArgs( @@ -1248,8 +1294,8 @@ class SplashAcknowledgementRoute static const String name = 'SplashAcknowledgementRoute'; - static const _i25.PageInfo page = - _i25.PageInfo(name); + static const _i26.PageInfo page = + _i26.PageInfo(name); } class SplashAcknowledgementRouteArgs { @@ -1259,9 +1305,9 @@ class SplashAcknowledgementRouteArgs { this.enableBackToSearch, }); - final _i26.Key? key; + final _i27.Key? key; - final _i27.RegistrationDeliveryLocalization? appLocalizations; + final _i28.RegistrationDeliveryLocalization? appLocalizations; final bool? enableBackToSearch; @@ -1272,12 +1318,12 @@ class SplashAcknowledgementRouteArgs { } /// generated route for -/// [_i24.SummaryPage] -class SummaryRoute extends _i25.PageRouteInfo { +/// [_i25.SummaryPage] +class SummaryRoute extends _i26.PageRouteInfo { SummaryRoute({ - _i26.Key? key, - _i27.RegistrationDeliveryLocalization? appLocalizations, - List<_i25.PageRouteInfo>? children, + _i27.Key? key, + _i28.RegistrationDeliveryLocalization? appLocalizations, + List<_i26.PageRouteInfo>? children, }) : super( SummaryRoute.name, args: SummaryRouteArgs( @@ -1289,8 +1335,8 @@ class SummaryRoute extends _i25.PageRouteInfo { static const String name = 'SummaryRoute'; - static const _i25.PageInfo page = - _i25.PageInfo(name); + static const _i26.PageInfo page = + _i26.PageInfo(name); } class SummaryRouteArgs { @@ -1299,9 +1345,9 @@ class SummaryRouteArgs { this.appLocalizations, }); - final _i26.Key? key; + final _i27.Key? key; - final _i27.RegistrationDeliveryLocalization? appLocalizations; + final _i28.RegistrationDeliveryLocalization? appLocalizations; @override String toString() { diff --git a/packages/registration_delivery/lib/utils/formController.dart b/packages/registration_delivery/lib/utils/formController.dart new file mode 100644 index 0000000000..1e4a517d0d --- /dev/null +++ b/packages/registration_delivery/lib/utils/formController.dart @@ -0,0 +1,45 @@ +import 'package:reactive_forms/reactive_forms.dart'; + +class FormControlFactory { + // This static method generates a FormControl based on the given type. + static FormControl createFormControl({ + required String type, + required dynamic initialValue, + required List validators, + }) { + switch (type) { + case 'String': + return FormControl( + value: initialValue as String?, + validators: validators, + ); + case 'int': + return FormControl( + value: initialValue as int?, + validators: validators, + ); + case 'double': + return FormControl( + value: initialValue as double?, + validators: validators, + ); + case 'bool': + return FormControl( + value: initialValue as bool?, + validators: validators, + ); + case 'DateTime': + return FormControl( + value: initialValue as DateTime?, + validators: validators, + ); + case 'List': + return FormControl>( + value: initialValue as List?, + validators: validators, + ); + default: + throw Exception("Unsupported type $type"); + } + } +} diff --git a/packages/registration_delivery/lib/utils/models/widget_config_model.dart b/packages/registration_delivery/lib/utils/models/widget_config_model.dart new file mode 100644 index 0000000000..275b784226 --- /dev/null +++ b/packages/registration_delivery/lib/utils/models/widget_config_model.dart @@ -0,0 +1,14 @@ +import 'package:flutter/material.dart'; + +class WidgetConfigModel { + final Map config; + final dynamic form; + final Function? func; + + WidgetConfigModel({ + required this.config, + required this.form, + this.func, + }); +} + diff --git a/packages/registration_delivery/lib/utils/widgetfactory.dart b/packages/registration_delivery/lib/utils/widgetfactory.dart new file mode 100644 index 0000000000..632ee82675 --- /dev/null +++ b/packages/registration_delivery/lib/utils/widgetfactory.dart @@ -0,0 +1,148 @@ +import 'package:digit_components/widgets/atoms/digit_date_form_picker.dart'; +import 'package:digit_components/widgets/atoms/digit_integer_form_picker.dart'; +import 'package:digit_components/widgets/atoms/digit_text_form_field.dart'; +import 'package:digit_components/widgets/atoms/selection_card.dart'; +import 'package:flutter/material.dart'; + +import 'models/widget_config_model.dart'; + +class WidgetBuilderFactory { + // This static method generates a list of widgets based on the provided configuration. + static List buildWidgetsFromConfig(WidgetConfigModel model) { + List widgets = []; + + // Sort the config keys by the 'order' key + var sortedKeys = model.config.keys.toList(); + sortedKeys.sort((a, b) => model.config[a]['order'].compareTo(model.config[b]['order'])); + + for (var key in sortedKeys) { + var fieldConfig = model.config[key]; + + if (fieldConfig['isEnabled'] == true) { + Widget widget; + + // Generate the widget based on the fieldConfig['type'] using a switch case + switch (fieldConfig['component']) { + case 'textField': + widget = DigitTextFormField( + formControlName: key, + label: fieldConfig['label'], + readOnly: fieldConfig['readOnly'] ?? false, + isRequired: fieldConfig['isRequired'] ?? false, + validationMessages: fieldConfig['validationMessages'], + ); + break; + + case 'checkbox': + widget = CheckboxListTile( + title: Text(fieldConfig['label']), + value: fieldConfig['initialValue'] ?? false, + onChanged: fieldConfig['readOnly'] == true + ? null + : (bool? value) { + // Handle checkbox state change + }, + ); + break; + + case 'dropdown': + widget = DropdownButtonFormField( + value: fieldConfig['initialValue'], + items: (fieldConfig['options'] as List).map((option) { + return DropdownMenuItem( + value: option, + child: Text(option), + ); + }).toList(), + onChanged: fieldConfig['readOnly'] == true + ? null + : (value) { + // Handle dropdown selection + }, + decoration: InputDecoration(labelText: fieldConfig['label']), + ); + break; + + case 'integerFormPicker': + widget = DigitIntegerFormPicker( + minimum: fieldConfig['minimum'], + maximum: fieldConfig['maximum'], + form: model.form, + onChange: () => model.func?.call(model.form), + formControlName: key, + label: fieldConfig['label'], + incrementer: fieldConfig['incrementer'], + ); + break; + + case 'dateFormPicker': + widget = DigitDateFormPicker( + isEnabled: !fieldConfig['readOnly'], + formControlName: key, + label: fieldConfig['label'], + isRequired: fieldConfig['isRequired'] ?? false, + confirmText: fieldConfig['confirmText'], + cancelText: fieldConfig['cancelText'], + ); + break; + + // case 'selectionbox': + // widget = SelectionBox( + // isRequired: fieldConfig['isRequired'] ?? false, + // title: fieldConfig['label'], + // equalWidthOptions: fieldConfig['equalWidthOptions'] ?? false, + // allowMultipleSelection: fieldConfig['allowMultipleSelection'] ?? false, + // options: fieldConfig['options'] ?? + // [], + // initialSelection: model.form.control(key).value!= null ? [...model.form.control(key).value ] : [], + // onSelectionChanged: (values) { + // model.form + // .control(key) + // .markAsTouched(); + // if (values.isEmpty) { + // model.form + // .control(key) + // .value = null; + // setState(() { + // model.form + // .control(key) + // .setErrors({'': true}); + // }); + // } else { + // setState(() { + // model.form + // .control(key) + // .value = values; + // }); + // } + // }, + // valueMapper: (value) { + // return value.toString(); + // }, + // errorMessage: model.form + // .control(key) + // .hasErrors && + // model.form + // .control(key) + // .touched + // ? fieldConfig['errorMessage'] + // : null, + // ); + // break; + + default: + throw Exception("Unsupported widget type: ${fieldConfig['type']}"); + } + + widgets.add(widget); + } + } + + return widgets; + } +} + +extension Extension on SelectionBox { + +} +