From fb0b817cf9666e5a93f18309efa1478c88a31b5a Mon Sep 17 00:00:00 2001 From: "mr.mojtaba" Date: Wed, 31 Dec 2025 13:36:13 +0330 Subject: [PATCH] feat: refactor SDUI widget model to use sealed classes for type-safe handling, enhance form widget with stepper support, and improve error handling in SDUIFormWidget --- .../presentation/pages/new_page/logic.dart | 136 +- .../presentation/pages/new_page/view.dart | 24 +- .../widget/sdui/form/sdui_form_widget.dart | 1222 +++++++++++++---- .../form/sdui_form_widget_controller.dart | 38 + .../widget/sdui/form/ts1 copy.json | 1099 +++++++++++++++ .../widget/sdui/form/ts_with_stepper.json | 1108 +++++++++++++++ .../widget/sdui/model/sdui_widget.dart | 150 ++ .../sdui/model/sdui_widget.freezed.dart | 1198 ++++++++++++++++ .../widget/sdui/model/sdui_widget.g.dart | 178 +++ .../widget/sdui/model/sdui_widget_model.dart | 18 - .../sdui/model/sdui_widget_model.freezed.dart | 313 ----- .../sdui/model/sdui_widget_model.g.dart | 27 - .../lib/presentation/widget/sdui/sdui.dart | 3 +- .../sdui/widgets/stepper/stepper_sdui.dart | 19 +- 14 files changed, 4879 insertions(+), 654 deletions(-) create mode 100644 packages/chicken/lib/presentation/widget/sdui/form/ts1 copy.json create mode 100644 packages/chicken/lib/presentation/widget/sdui/form/ts_with_stepper.json create mode 100644 packages/chicken/lib/presentation/widget/sdui/model/sdui_widget.dart create mode 100644 packages/chicken/lib/presentation/widget/sdui/model/sdui_widget.freezed.dart create mode 100644 packages/chicken/lib/presentation/widget/sdui/model/sdui_widget.g.dart delete mode 100644 packages/chicken/lib/presentation/widget/sdui/model/sdui_widget_model.dart delete mode 100644 packages/chicken/lib/presentation/widget/sdui/model/sdui_widget_model.freezed.dart delete mode 100644 packages/chicken/lib/presentation/widget/sdui/model/sdui_widget_model.g.dart diff --git a/packages/chicken/lib/features/vet_farm/presentation/pages/new_page/logic.dart b/packages/chicken/lib/features/vet_farm/presentation/pages/new_page/logic.dart index db24e0d..c22fbec 100644 --- a/packages/chicken/lib/features/vet_farm/presentation/pages/new_page/logic.dart +++ b/packages/chicken/lib/features/vet_farm/presentation/pages/new_page/logic.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:rasadyar_chicken/features/vet_farm/presentation/pages/root/logic.dart'; -import 'package:rasadyar_chicken/presentation/widget/sdui/model/sdui_widget_model.dart'; +import 'package:rasadyar_chicken/presentation/widget/sdui/model/sdui_widget.dart'; + import 'package:rasadyar_core/core.dart'; class NewPageLogic extends GetxController { @@ -14,19 +15,11 @@ class NewPageLogic extends GetxController { @override void onInit() { super.onInit(); - getSDUIForm(); } - @override - void onReady() { - super.onReady(); - // Ready logic here - } - @override void onClose() { - // Dispose all controllers for (var controller in controllers.values) { controller.dispose(); } @@ -40,10 +33,6 @@ class NewPageLogic extends GetxController { onSuccess: (result) { if (result.data != null) { try { - iLog('SDUI JSON received: ${result.data}'); - - // Extract SDUI data from info structure - // JSON structure: { "info": { "type": "column", "visible": true, "data": {...}, "children": [...] } } Map? sduiData; if (result.data!['info'] != null && result.data!['info'] is Map) { final infoMap = result.data!['info'] as Map; @@ -68,9 +57,63 @@ class NewPageLogic extends GetxController { if (sduiData != null) { iLog('SDUI data to parse: $sduiData'); - sduiModel.value = SDUIWidgetModel.fromJson(sduiData); + sduiModel.value = SDUIWidgetModel.fromRawJson(sduiData); + + // Log model info using pattern matching + final modelType = + sduiModel.value?.maybeWhen( + textFormField: (data, visible) => 'text_form_field', + cardLabelItem: + (data, child, children, visible, visibleCondition) => + 'card_label_item', + chipSelection: (data, visible) => 'chip_selection', + dropdown: (data, visible) => 'dropdown', + imagePicker: (data, visible) => 'image_picker', + column: + ( + children, + spacing, + mainAxisSize, + crossAxisAlignment, + visible, + paddingHorizontal, + paddingVertical, + ) => 'column', + row: (children, spacing, mainAxisAlignment, visible) => + 'row', + sizedBox: (width, height, visible) => 'sized_box', + stepper: (data, children, visible, index) => 'stepper', + pageView: (data, children, visible) => 'page_view', + orElse: () => 'unknown', + ) ?? + 'null'; + + final childrenCount = + sduiModel.value?.maybeWhen( + column: + ( + children, + spacing, + mainAxisSize, + crossAxisAlignment, + visible, + paddingHorizontal, + paddingVertical, + ) => children.length, + row: (children, spacing, mainAxisAlignment, visible) => + children.length, + cardLabelItem: + (data, child, children, visible, visibleCondition) => + (child != null ? 1 : 0) + (children?.length ?? 0), + stepper: (data, children, visible, index) => + children?.length ?? 0, + pageView: (data, children, visible) => children.length, + orElse: () => 0, + ) ?? + 0; + iLog( - 'SDUI Model parsed successfully. Type: ${sduiModel.value?.type}, Visible: ${sduiModel.value?.visible}, Children count: ${sduiModel.value?.children?.length ?? 0}', + 'SDUI Model parsed successfully. Type: $modelType, Visible: ${sduiModel.value?.visible}, Children count: $childrenCount', ); _initializeControllers(sduiModel.value!); } else { @@ -98,23 +141,54 @@ class NewPageLogic extends GetxController { } void _extractTextFields(SDUIWidgetModel model) { - if (model.type == 'text_form_field' && model.data != null) { - final key = model.data!['key'] as String?; - final value = model.data!['value'] as String?; - if (key != null && !controllers.containsKey(key)) { - controllers[key] = TextEditingController(text: value ?? ''); - } - } + // Extract text form field using pattern matching + model.maybeWhen( + textFormField: (data, visible) { + final key = data.key; + final value = data.value; + if (key != null && !controllers.containsKey(key)) { + controllers[key] = TextEditingController(text: value ?? ''); + } + }, + orElse: () {}, + ); - if (model.child != null) { - _extractTextFields(SDUIWidgetModel.fromJson(model.child!)); - } - - if (model.children != null) { - for (var child in model.children!) { - _extractTextFields(SDUIWidgetModel.fromJson(child)); - } - } + // Recursively extract from children using pattern matching + model.maybeWhen( + column: (children, spacing, mainAxisSize, crossAxisAlignment, visible, paddingHorizontal, paddingVertical) { + for (var child in children) { + _extractTextFields(child); + } + }, + row: (children, spacing, mainAxisAlignment, visible) { + for (var child in children) { + _extractTextFields(child); + } + }, + cardLabelItem: (data, child, children, visible, visibleCondition) { + if (child != null) { + _extractTextFields(child); + } + if (children != null) { + for (var child in children) { + _extractTextFields(child); + } + } + }, + stepper: (data, children, visible, index) { + if (children != null) { + for (var child in children) { + _extractTextFields(child); + } + } + }, + pageView: (data, children, visible) { + for (var child in children) { + _extractTextFields(child); + } + }, + orElse: () {}, + ); } void onButtonPressed() { diff --git a/packages/chicken/lib/features/vet_farm/presentation/pages/new_page/view.dart b/packages/chicken/lib/features/vet_farm/presentation/pages/new_page/view.dart index 3f9f9a0..1aa6088 100644 --- a/packages/chicken/lib/features/vet_farm/presentation/pages/new_page/view.dart +++ b/packages/chicken/lib/features/vet_farm/presentation/pages/new_page/view.dart @@ -34,10 +34,9 @@ class NewPage extends GetView { isScrollControlled: true, enableDrag: true, - BaseBottomSheet( height: Get.height * 0.8, - child: ObxValue((data) { + rootChild: ObxValue((data) { if (data.value == null) { return Center(child: CircularProgressIndicator()); } @@ -61,6 +60,27 @@ class NewPage extends GetView { }, ), SizedBox(height: 24.h), + + RElevated( + text: '222222222222دکمه نمونه', + onPressed: () { + Get.bottomSheet( + isScrollControlled: true, + enableDrag: true, + + BaseBottomSheet( + height: Get.height * 0.8, + rootChild: Column( + children: [ + Container(height: 100, width: 100, color: Colors.red), + Expanded(child: Container(color: Colors.blue)), + Container(height: 100, width: 100, color: Colors.green), + ], + ), + ), + ); + }, + ), ], ), ); diff --git a/packages/chicken/lib/presentation/widget/sdui/form/sdui_form_widget.dart b/packages/chicken/lib/presentation/widget/sdui/form/sdui_form_widget.dart index 66174a4..fa7aeff 100644 --- a/packages/chicken/lib/presentation/widget/sdui/form/sdui_form_widget.dart +++ b/packages/chicken/lib/presentation/widget/sdui/form/sdui_form_widget.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:rasadyar_chicken/presentation/widget/sdui/model/sdui_widget_model.dart'; +import 'package:rasadyar_chicken/presentation/widget/sdui/model/sdui_widget.dart'; import 'package:rasadyar_chicken/presentation/widget/sdui/widgets/card_label_item/card_label_item_sdui.dart'; import 'package:rasadyar_chicken/presentation/widget/sdui/widgets/card_label_item/model/card_label_item_sdui_model.dart'; import 'package:rasadyar_chicken/presentation/widget/sdui/widgets/chip_selection/chip_selection_sdui.dart'; @@ -14,8 +14,22 @@ import 'package:rasadyar_chicken/presentation/widget/sdui/widgets/stepper/steppe import 'package:rasadyar_chicken/presentation/widget/sdui/widgets/stepper/model/stepper_sdui_model.dart'; import 'package:rasadyar_chicken/presentation/widget/sdui/widgets/page_view/page_view_sdui.dart'; import 'package:rasadyar_chicken/presentation/widget/sdui/widgets/page_view/model/page_view_sdui_model.dart'; +import 'package:rasadyar_chicken/presentation/widget/sdui/form/sdui_form_widget_controller.dart'; import 'package:rasadyar_core/core.dart'; +// Helper class to store stepper information +class _StepperInfo { + final SDUIWidgetModel stepperModel; + final StepperSDUIModel stepperData; + final SDUIWidgetModel? parentModel; + + _StepperInfo({ + required this.stepperModel, + required this.stepperData, + this.parentModel, + }); +} + class SDUIFormWidget extends StatelessWidget { final SDUIWidgetModel model; final Map? controllers; @@ -42,64 +56,98 @@ class SDUIFormWidget extends StatelessWidget { return const SizedBox.shrink(); } + // Check if model has children using pattern matching + final hasChildren = model.maybeWhen( + column: + ( + children, + spacing, + mainAxisSize, + crossAxisAlignment, + paddingHorizontal, + paddingVertical, + visible, + ) => children.isNotEmpty, + row: (children, spacing, mainAxisAlignment, visible) => + children.isNotEmpty, + cardLabelItem: (data, child, children, visible, visibleCondition) => + child != null || (children != null && children.isNotEmpty), + stepper: (data, children, visible, index) => + children != null && children.isNotEmpty, + pageView: (data, children, visible) => children.isNotEmpty, + orElse: () => false, + ); + + if (!hasChildren) { + return Container( + padding: EdgeInsets.all(16), + color: Colors.red.withAlpha(10), + child: Text('!خطا فرم دارای ویجیت نیست'), + ); + } + try { + // Check if there's a stepper in the root or first level + final stepperInfo = _findStepperInTree(model); + if (stepperInfo != null) { + return _buildWithStepperLayout(stepperInfo); + } + return _buildWidget(model); } catch (e, stackTrace) { iLog('Error in SDUIFormWidget.build: $e'); iLog('Stack trace: $stackTrace'); return Container( padding: EdgeInsets.all(16), - color: Colors.red.withOpacity(0.1), - child: Text('Error: $e'), + color: Colors.red.withAlpha(10), + child: Text('!! فرم دارای خطا است '), ); } } - Widget _buildWidget(SDUIWidgetModel widgetModel) { - final type = widgetModel.type; - - if (type == null || type.isEmpty) { - iLog('SDUIWidgetModel type is null or empty'); + /// متد اصلی build با استفاده از pattern matching روی sealed class + /// این متد بسیار تمیزتر و type-safe‌تر از switch-case قبلی است + Widget _buildWidget(SDUIWidgetModel widget) { + if (!widget.visible) { return const SizedBox.shrink(); } - switch (type) { - case 'text_form_field': - return _buildTextFormField(widgetModel); - case 'card_label_item': - return _buildCardLabelItem(widgetModel); - case 'chip_selection': - return _buildChipSelection(widgetModel); - case 'dropdown': - return _buildDropdown(widgetModel); - case 'image_picker': - return _buildImagePicker(widgetModel); - case 'column': - return _buildColumn(widgetModel); - case 'row': - return _buildRow(widgetModel); - case 'sized_box': - return _buildSizedBox(widgetModel); - case 'stepper': - return _buildStepper(widgetModel); - case 'page_view': - return _buildPageView(widgetModel); - default: - iLog('Unknown SDUI widget type: $type'); - return const SizedBox.shrink(); - } + return widget.map( + // ویجت‌های فرم + textFormField: (value) => _buildTextFormField(value.data), + cardLabelItem: (value) => _buildCardLabelItem( + value.data, + value.child, + value.children, + value.visibleCondition, + ), + chipSelection: (value) => _buildChipSelection(value.data), + dropdown: (value) => _buildDropdown(value.data), + imagePicker: (value) => _buildImagePicker(value.data), + + // ویجت‌های layout + column: (value) => _buildColumn( + value.children, + value.spacing, + value.mainAxisSize, + value.crossAxisAlignment, + value.paddingHorizontal, + value.paddingVertical, + ), + row: (value) => + _buildRow(value.children, value.spacing, value.mainAxisAlignment), + sizedBox: (value) => _buildSizedBox(value.width, value.height), + + // ویجت‌های پیچیده + stepper: (value) => _buildStepper(value.data, value.children), + pageView: (value) => _buildPageView(value.data, value.children), + ); } - Widget _buildTextFormField(SDUIWidgetModel widgetModel) { - if (widgetModel.data == null) { - return const SizedBox.shrink(); - } - + Widget _buildTextFormField(TextFormFieldSDUIModel data) { try { - final textFieldModel = TextFormFieldSDUIModel.fromJson(widgetModel.data!); - // Use provided controller or create a new one - final key = textFieldModel.key ?? ''; + final key = data.key ?? ''; TextEditingController controller; if (controllers != null && @@ -107,50 +155,49 @@ class SDUIFormWidget extends StatelessWidget { controllers!.containsKey(key)) { controller = controllers![key]!; } else { - controller = TextEditingController(text: textFieldModel.value ?? ''); + controller = TextEditingController(text: data.value ?? ''); // Store the controller in the map if controllers map is provided if (controllers != null && key.isNotEmpty) { controllers![key] = controller; } } - return textFormFiledSDUI(model: textFieldModel, controller: controller); + return textFormFiledSDUI(model: data, controller: controller); } catch (e) { iLog('Error building text_form_field: $e'); return const SizedBox.shrink(); } } - Widget _buildCardLabelItem(SDUIWidgetModel widgetModel) { + Widget _buildCardLabelItem( + CardLabelItemData data, + SDUIWidgetModel? child, + List? children, + String? visibleCondition, + ) { try { - // Check visible_condition if present in data - if (widgetModel.data != null) { - final visibleCondition = - widgetModel.data!['visible_condition'] as String?; - if (visibleCondition != null && visibleCondition.isNotEmpty) { - if (state != null) { - return Obx(() { - if (!_evaluateVisibleCondition(visibleCondition)) { - return const SizedBox.shrink(); - } - return _buildCardLabelItemInternal(widgetModel); - }); - } else { - // If state is null, only show first step (0) by default - // This allows the form to work even without state initialization - if (visibleCondition.contains('activeStepperIndex == 0')) { - return _buildCardLabelItemInternal(widgetModel); + // Check visible_condition if present + if (visibleCondition != null && visibleCondition.isNotEmpty) { + if (state != null) { + return Obx(() { + if (!_evaluateVisibleCondition(visibleCondition)) { + return const SizedBox.shrink(); } - return const SizedBox.shrink(); + return _buildCardLabelItemInternal(data, child, children); + }); + } else { + // If state is null, only show first step (0) by default + if (visibleCondition.contains('activeStepperIndex == 0')) { + return _buildCardLabelItemInternal(data, child, children); } + return const SizedBox.shrink(); } } - return _buildCardLabelItemInternal(widgetModel); + return _buildCardLabelItemInternal(data, child, children); } catch (e, stackTrace) { iLog('Error building card_label_item: $e'); iLog('Stack trace: $stackTrace'); - iLog('WidgetModel data: ${widgetModel.data}'); return Container( padding: EdgeInsets.all(16), color: Colors.orange.withOpacity(0.1), @@ -159,211 +206,168 @@ class SDUIFormWidget extends StatelessWidget { } } - Widget _buildCardLabelItemInternal(SDUIWidgetModel widgetModel) { + Widget _buildCardLabelItemInternal( + CardLabelItemData data, + SDUIWidgetModel? child, + List? children, + ) { try { - // Remove visible_condition from data before creating CardLabelItemData - // because it's not part of the model - final dataWithoutCondition = widgetModel.data != null - ? Map.from(widgetModel.data!) - : null; - if (dataWithoutCondition != null) { - dataWithoutCondition.remove('visible_condition'); - } - - final cardModel = CardLabelItemSDUI.fromJson({ - 'type': widgetModel.type, - 'visible': widgetModel.visible, - 'data': dataWithoutCondition, - 'child': widgetModel.child, - }); + final cardModel = CardLabelItemSDUI( + type: 'card_label_item', + visible: true, + data: data, + child: null, + ); // If there's a child, build it recursively Widget? childWidget; - if (widgetModel.child != null) { + if (child != null) { try { - childWidget = SDUIFormWidget( - model: SDUIWidgetModel.fromJson(widgetModel.child!), - controllers: controllers, - state: state, - onStateChanged: onStateChanged, - images: images, - onImagesChanged: onImagesChanged, - ); + childWidget = _buildWidget(child); } catch (e) { iLog('Error building card_label_item child: $e'); - iLog('Child data: ${widgetModel.child}'); } - } else if (widgetModel.children != null && - widgetModel.children!.isNotEmpty) { + } else if (children != null && children.isNotEmpty) { // If there are children, build them as a column try { childWidget = Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, - children: widgetModel.children! - .map( - (child) => SDUIFormWidget( - model: SDUIWidgetModel.fromJson(child), - controllers: controllers, - state: state, - onStateChanged: onStateChanged, - images: images, - onImagesChanged: onImagesChanged, - ), - ) - .toList(), + children: children.map((c) => _buildWidget(c)).toList(), ); } catch (e) { iLog('Error building card_label_item children: $e'); } } - // Create a modified card model with the child widget return cardLabelItemSDUI(model: cardModel, child: childWidget); } catch (e, stackTrace) { iLog('Error building card_label_item: $e'); iLog('Stack trace: $stackTrace'); - iLog('WidgetModel data: ${widgetModel.data}'); return Container( padding: EdgeInsets.all(16), - color: Colors.orange.withOpacity(0.1), + color: Colors.orange.withAlpha(10), child: Text('Card Error: $e'), ); } } - Widget _buildColumn(SDUIWidgetModel widgetModel) { - if (widgetModel.children == null || widgetModel.children!.isEmpty) { + Widget _buildColumn( + List children, + double spacing, + String mainAxisSize, + String crossAxisAlignment, + double paddingHorizontal, + double paddingVertical, + ) { + if (children.isEmpty) { iLog('Column has no children'); return const SizedBox.shrink(); } try { - final spacing = widgetModel.data?['spacing']; - final spacingValue = spacing is int - ? spacing.toDouble() - : (spacing as double?) ?? 0.0; - - final mainAxisSize = widgetModel.data?['mainAxisSize'] == 'min' + final mainAxisSizeEnum = mainAxisSize == 'min' ? MainAxisSize.min : MainAxisSize.max; - final crossAxisAlignment = _parseCrossAxisAlignment( - widgetModel.data?['crossAxisAlignment'], + final crossAxisAlignmentEnum = _parseCrossAxisAlignment( + crossAxisAlignment, ); - final children = widgetModel.children!.map((child) { + final builtChildren = children.map((child) { try { - return SDUIFormWidget( - model: SDUIWidgetModel.fromJson(child), - controllers: controllers, - state: state, - onStateChanged: onStateChanged, - images: images, - onImagesChanged: onImagesChanged, - pageControllers: pageControllers, - ); + return _buildWidget(child); } catch (e) { iLog('Error building column child: $e'); - iLog('Child data: $child'); return Container( padding: EdgeInsets.all(8), - color: Colors.yellow.withOpacity(0.1), + color: Colors.yellow.withAlpha(10), child: Text('Child Error'), ); } }).toList(); // Add spacing between children - if (spacingValue > 0 && children.length > 1) { - final spacedChildren = []; - for (int i = 0; i < children.length; i++) { - spacedChildren.add(children[i]); - if (i < children.length - 1) { - spacedChildren.add(SizedBox(height: spacingValue)); + final columnChildren = spacing > 0 && builtChildren.length > 1 + ? [] + : builtChildren; + + if (spacing > 0 && builtChildren.length > 1) { + for (int i = 0; i < builtChildren.length; i++) { + columnChildren.add(builtChildren[i]); + if (i < builtChildren.length - 1) { + columnChildren.add(SizedBox(height: spacing)); } } - return Column( - mainAxisSize: mainAxisSize, - crossAxisAlignment: crossAxisAlignment, - children: spacedChildren, - ); } - return Column( - mainAxisSize: mainAxisSize, - crossAxisAlignment: crossAxisAlignment, - children: children, + final column = Column( + mainAxisSize: mainAxisSizeEnum, + crossAxisAlignment: crossAxisAlignmentEnum, + children: columnChildren, + ); + + // Wrap column in SingleChildScrollView for scrollable content + return SingleChildScrollView( + padding: EdgeInsets.symmetric( + horizontal: paddingHorizontal, + vertical: paddingVertical, + ), + physics: const BouncingScrollPhysics(), + child: column, ); } catch (e, stackTrace) { iLog('Error building column: $e'); iLog('Stack trace: $stackTrace'); return Container( padding: EdgeInsets.all(16), - color: Colors.blue.withOpacity(0.1), + color: Colors.blue.withAlpha(10), child: Text('Column Error: $e'), ); } } - Widget _buildRow(SDUIWidgetModel widgetModel) { - if (widgetModel.children == null || widgetModel.children!.isEmpty) { + Widget _buildRow( + List children, + double spacing, + String mainAxisAlignment, + ) { + if (children.isEmpty) { return const SizedBox.shrink(); } - final spacing = widgetModel.data?['spacing'] as double? ?? 0.0; - final mainAxisAlignment = _parseMainAxisAlignment( - widgetModel.data?['mainAxisAlignment'], - ); + final mainAxisAlignmentEnum = _parseMainAxisAlignment(mainAxisAlignment); - final children = widgetModel.children! - .map( - (child) => SDUIFormWidget( - model: SDUIWidgetModel.fromJson(child), - controllers: controllers, - state: state, - onStateChanged: onStateChanged, - images: images, - onImagesChanged: onImagesChanged, - ), - ) - .toList(); + final builtChildren = children.map((child) => _buildWidget(child)).toList(); // Add spacing between children - if (spacing > 0 && children.length > 1) { + if (spacing > 0 && builtChildren.length > 1) { final spacedChildren = []; - for (int i = 0; i < children.length; i++) { - spacedChildren.add(children[i]); - if (i < children.length - 1) { + for (int i = 0; i < builtChildren.length; i++) { + spacedChildren.add(builtChildren[i]); + if (i < builtChildren.length - 1) { spacedChildren.add(SizedBox(width: spacing)); } } return Row( - mainAxisAlignment: mainAxisAlignment, + mainAxisAlignment: mainAxisAlignmentEnum, children: spacedChildren, ); } - return Row(mainAxisAlignment: mainAxisAlignment, children: children); + return Row( + mainAxisAlignment: mainAxisAlignmentEnum, + children: builtChildren, + ); } - Widget _buildSizedBox(SDUIWidgetModel widgetModel) { - final data = widgetModel.data ?? {}; - final width = data['width'] as double?; - final height = data['height'] as double?; - + Widget _buildSizedBox(double? width, double? height) { return SizedBox(width: width, height: height); } - Widget _buildChipSelection(SDUIWidgetModel widgetModel) { - if (widgetModel.data == null) { - return const SizedBox.shrink(); - } - + Widget _buildChipSelection(ChipSelectionSDUIModel data) { try { - final chipModel = ChipSelectionSDUIModel.fromJson(widgetModel.data!); - return ChipSelectionSDUI( - model: chipModel, + model: data, state: state, onChanged: (key, index, value) { if (onStateChanged != null) { @@ -376,22 +380,16 @@ class SDUIFormWidget extends StatelessWidget { iLog('Stack trace: $stackTrace'); return Container( padding: EdgeInsets.all(16), - color: Colors.purple.withOpacity(0.1), + color: Colors.purple.withAlpha(10), child: Text('Chip Selection Error: $e'), ); } } - Widget _buildDropdown(SDUIWidgetModel widgetModel) { - if (widgetModel.data == null) { - return const SizedBox.shrink(); - } - + Widget _buildDropdown(DropdownSDUIModel data) { try { - final dropdownModel = DropdownSDUIModel.fromJson(widgetModel.data!); - return DropdownSDUI( - model: dropdownModel, + model: data, state: state, onChanged: (key, value) { if (onStateChanged != null) { @@ -404,22 +402,16 @@ class SDUIFormWidget extends StatelessWidget { iLog('Stack trace: $stackTrace'); return Container( padding: EdgeInsets.all(16), - color: Colors.blue.withOpacity(0.1), + color: Colors.blue.withAlpha(10), child: Text('Dropdown Error: $e'), ); } } - Widget _buildImagePicker(SDUIWidgetModel widgetModel) { - if (widgetModel.data == null) { - return const SizedBox.shrink(); - } - + Widget _buildImagePicker(ImagePickerSDUIModel data) { try { - final imagePickerModel = ImagePickerSDUIModel.fromJson(widgetModel.data!); - return ImagePickerSDUI( - model: imagePickerModel, + model: data, images: images, onImagesChanged: (key, imageList) { if (onImagesChanged != null) { @@ -438,9 +430,8 @@ class SDUIFormWidget extends StatelessWidget { } } - CrossAxisAlignment _parseCrossAxisAlignment(dynamic value) { - if (value == null) return CrossAxisAlignment.center; - switch (value.toString()) { + CrossAxisAlignment _parseCrossAxisAlignment(String value) { + switch (value) { case 'start': return CrossAxisAlignment.start; case 'end': @@ -454,9 +445,8 @@ class SDUIFormWidget extends StatelessWidget { } } - MainAxisAlignment _parseMainAxisAlignment(dynamic value) { - if (value == null) return MainAxisAlignment.start; - switch (value.toString()) { + MainAxisAlignment _parseMainAxisAlignment(String value) { + switch (value) { case 'start': return MainAxisAlignment.start; case 'end': @@ -474,71 +464,50 @@ class SDUIFormWidget extends StatelessWidget { } } - Widget _buildStepper(SDUIWidgetModel widgetModel) { - if (widgetModel.data == null) { - return const SizedBox.shrink(); - } - + Widget _buildStepper(StepperSDUIModel data, List? children) { try { - final stepperModel = StepperSDUIModel.fromJson(widgetModel.data!); - - return StepperSDUI(model: stepperModel, state: state); + return StepperSDUI(model: data, state: state); } catch (e, stackTrace) { iLog('Error building stepper: $e'); iLog('Stack trace: $stackTrace'); return Container( padding: EdgeInsets.all(16), - color: Colors.orange.withOpacity(0.1), + color: Colors.orange.withAlpha(10), child: Text('Stepper Error: $e'), ); } } - Widget _buildPageView(SDUIWidgetModel widgetModel) { - if (widgetModel.data == null) { - return const SizedBox.shrink(); - } - + Widget _buildPageView( + PageViewSDUIModel data, + List children, + ) { try { - final pageViewModel = PageViewSDUIModel.fromJson(widgetModel.data!); - // Get PageController from map if key is provided PageController? pageController; - if (pageViewModel.key != null && - pageViewModel.key!.isNotEmpty && + if (data.key != null && + data.key!.isNotEmpty && pageControllers != null && - pageControllers!.containsKey(pageViewModel.key!)) { - pageController = pageControllers![pageViewModel.key!]; + pageControllers!.containsKey(data.key!)) { + pageController = pageControllers![data.key!]; } - // Build children if they exist - List pageChildren = []; - if (widgetModel.children != null && widgetModel.children!.isNotEmpty) { - pageChildren = widgetModel.children!.map((child) { - try { - return SDUIFormWidget( - model: SDUIWidgetModel.fromJson(child), - controllers: controllers, - state: state, - onStateChanged: onStateChanged, - images: images, - onImagesChanged: onImagesChanged, - pageControllers: pageControllers, - ); - } catch (e) { - iLog('Error building page_view child: $e'); - iLog('Child data: $child'); - return Container( - padding: EdgeInsets.all(8), - color: Colors.yellow.withOpacity(0.1), - child: Text('Child Error'), - ); - } - }).toList(); - } + // Build children + final pageChildren = children.map((child) { + try { + return _buildWidget(child); + } catch (e) { + iLog('Error building page_view child: $e'); + return Container( + padding: EdgeInsets.all(8), + color: Colors.yellow.withOpacity(0.1), + child: Text('Child Error'), + ); + } + }).toList(); return PageViewSDUI( - model: pageViewModel, + model: data, controller: pageController, children: pageChildren, state: state, @@ -617,4 +586,753 @@ class SDUIFormWidget extends StatelessWidget { return false; } } + + // Find stepper in the widget tree + _StepperInfo? _findStepperInTree(SDUIWidgetModel widgetModel) { + // Check if current widget is a stepper + return widgetModel.maybeWhen( + stepper: (data, children, visible, index) { + try { + return _StepperInfo( + stepperModel: widgetModel, + stepperData: data, + parentModel: null, + ); + } catch (e) { + iLog('Error parsing stepper model: $e'); + return null; + } + }, + orElse: () => null, + ) ?? + // Check in children + widgetModel.maybeWhen( + column: + ( + children, + spacing, + mainAxisSize, + crossAxisAlignment, + visible, + paddingHorizontal, + paddingVertical, + ) { + for (var child in children) { + final stepperInfo = _findStepperInTree(child); + if (stepperInfo != null) { + return _StepperInfo( + stepperModel: stepperInfo.stepperModel, + stepperData: stepperInfo.stepperData, + parentModel: widgetModel, + ); + } + } + return null; + }, + row: (children, spacing, mainAxisAlignment, visible) { + for (var child in children) { + final stepperInfo = _findStepperInTree(child); + if (stepperInfo != null) { + return _StepperInfo( + stepperModel: stepperInfo.stepperModel, + stepperData: stepperInfo.stepperData, + parentModel: widgetModel, + ); + } + } + return null; + }, + cardLabelItem: (data, child, children, visible, visibleCondition) { + if (child != null) { + final stepperInfo = _findStepperInTree(child); + if (stepperInfo != null) { + return _StepperInfo( + stepperModel: stepperInfo.stepperModel, + stepperData: stepperInfo.stepperData, + parentModel: widgetModel, + ); + } + } + if (children != null) { + for (var child in children) { + final stepperInfo = _findStepperInTree(child); + if (stepperInfo != null) { + return _StepperInfo( + stepperModel: stepperInfo.stepperModel, + stepperData: stepperInfo.stepperData, + parentModel: widgetModel, + ); + } + } + } + return null; + }, + stepper: (data, children, visible, index) { + if (children != null) { + for (var child in children) { + final stepperInfo = _findStepperInTree(child); + if (stepperInfo != null) { + return _StepperInfo( + stepperModel: stepperInfo.stepperModel, + stepperData: stepperInfo.stepperData, + parentModel: widgetModel, + ); + } + } + } + return null; + }, + pageView: (data, children, visible) { + for (var child in children) { + final stepperInfo = _findStepperInTree(child); + if (stepperInfo != null) { + return _StepperInfo( + stepperModel: stepperInfo.stepperModel, + stepperData: stepperInfo.stepperData, + parentModel: widgetModel, + ); + } + } + return null; + }, + orElse: () => null, + ); + } + + // Count all steppers in the widget tree to determine total steps + int _countSteppersInTree(SDUIWidgetModel widgetModel) { + int count = 0; + + // Check if current widget is a stepper + count += + widgetModel.maybeWhen( + stepper: (data, children, visible, index) => 1, + orElse: () => 0, + ) ?? + 0; + + // Count steppers in children + count += + widgetModel.maybeWhen( + column: + ( + children, + spacing, + mainAxisSize, + crossAxisAlignment, + visible, + paddingHorizontal, + paddingVertical, + ) { + int childCount = 0; + for (var child in children) { + childCount += _countSteppersInTree(child); + } + return childCount; + }, + row: (children, spacing, mainAxisAlignment, visible) { + int childCount = 0; + for (var child in children) { + childCount += _countSteppersInTree(child); + } + return childCount; + }, + cardLabelItem: (data, child, children, visible, visibleCondition) { + int childCount = 0; + if (child != null) { + childCount += _countSteppersInTree(child); + } + if (children != null) { + for (var child in children) { + childCount += _countSteppersInTree(child); + } + } + return childCount; + }, + stepper: (data, children, visible, index) { + int childCount = 0; + if (children != null) { + for (var child in children) { + childCount += _countSteppersInTree(child); + } + } + return childCount; + }, + pageView: (data, children, visible) { + int childCount = 0; + for (var child in children) { + childCount += _countSteppersInTree(child); + } + return childCount; + }, + orElse: () => 0, + ) ?? + 0; + + return count; + } + + // Build layout with stepper + Widget _buildWithStepperLayout(_StepperInfo stepperInfo) { + final controllerTag = + 'sdui_form_stepper_${stepperInfo.stepperData.key ?? 'default'}'; + SDUIFormWidgetController formController; + + try { + formController = Get.find(tag: controllerTag); + } catch (_) { + formController = Get.put(SDUIFormWidgetController(), tag: controllerTag); + } + + // Calculate totalSteps: use from model, or count steppers, or count unique step indices + int totalSteps = stepperInfo.stepperData.totalSteps ?? 0; + if (totalSteps == 0) { + // Count all steppers in the tree + totalSteps = _countSteppersInTree(model); + // If still 0, count unique step indices from visible_condition + if (totalSteps == 0) { + final stepIndices = _collectStepIndicesFromVisibleConditions(model); + if (stepIndices.isNotEmpty) { + // Return max index + 1 (since indices are 0-based) + totalSteps = stepIndices.reduce((a, b) => a > b ? a : b) + 1; + } + } + // Default to 5 if still 0 + if (totalSteps == 0) { + totalSteps = 5; + } + } + + final stepperKey = stepperInfo.stepperData.key ?? 'activeStepperIndex'; + formController.initializeStepper(totalSteps, stepperKey); + + if (state != null && !state!.containsKey(stepperKey)) { + state![stepperKey] = 0; + } + + // Create scroll controller for auto-scrolling to active step + final scrollController = ScrollController(); + + // Map to store GlobalKeys for each step widget + final stepKeys = {}; + for (int i = 0; i < totalSteps; i++) { + stepKeys[i] = GlobalKey(); + } + + // Build content excluding stepper widgets with keys + final contentWidgets = _buildContentWithoutStepper( + model, + stepperInfo, + stepKeys: stepKeys, + ); + + // Listen to step changes and scroll to active step + return Obx(() { + final currentStep = formController.currentStep.value; + + // Scroll to active step after build + WidgetsBinding.instance.addPostFrameCallback((_) { + if (stepKeys.containsKey(currentStep)) { + final key = stepKeys[currentStep]!; + final context = key.currentContext; + if (context != null && scrollController.hasClients) { + Scrollable.ensureVisible( + context, + duration: const Duration(milliseconds: 300), + curve: Curves.easeInOut, + ); + } + } + }); + + return Column( + mainAxisSize: MainAxisSize.min, + children: [ + Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 16.h), + child: _buildStepper(stepperInfo.stepperData, null), + ), + Flexible( + child: SingleChildScrollView( + controller: scrollController, + physics: BouncingScrollPhysics(), + padding: EdgeInsets.all(16.w), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: contentWidgets, + ), + ), + ), + _buildNavigationButtons(formController, stepperKey), + ], + ); + }); + } + + // Collect unique step indices from visible_condition in the tree + Set _collectStepIndicesFromVisibleConditions( + SDUIWidgetModel widgetModel, + ) { + final stepIndices = {}; + + // Check current widget's visible_condition + widgetModel.maybeWhen( + cardLabelItem: (data, child, children, visible, visibleCondition) { + if (visibleCondition != null && + visibleCondition.contains('activeStepperIndex ==')) { + final match = RegExp( + r'activeStepperIndex\s*==\s*(\d+)', + ).firstMatch(visibleCondition); + if (match != null) { + final stepIndex = int.tryParse(match.group(1) ?? ''); + if (stepIndex != null) { + stepIndices.add(stepIndex); + } + } + } + }, + orElse: () {}, + ); + + // Check children + widgetModel.maybeWhen( + column: + ( + children, + spacing, + mainAxisSize, + crossAxisAlignment, + visible, + paddingHorizontal, + paddingVertical, + ) { + for (var child in children) { + stepIndices.addAll( + _collectStepIndicesFromVisibleConditions(child), + ); + } + }, + row: (children, spacing, mainAxisAlignment, visible) { + for (var child in children) { + stepIndices.addAll(_collectStepIndicesFromVisibleConditions(child)); + } + }, + cardLabelItem: (data, child, children, visible, visibleCondition) { + if (child != null) { + stepIndices.addAll(_collectStepIndicesFromVisibleConditions(child)); + } + if (children != null) { + for (var child in children) { + stepIndices.addAll(_collectStepIndicesFromVisibleConditions(child)); + } + } + }, + stepper: (data, children, visible, index) { + if (children != null) { + for (var child in children) { + stepIndices.addAll(_collectStepIndicesFromVisibleConditions(child)); + } + } + }, + pageView: (data, children, visible) { + for (var child in children) { + stepIndices.addAll(_collectStepIndicesFromVisibleConditions(child)); + } + }, + orElse: () {}, + ); + + return stepIndices; + } + + // Build layout without stepper (scrollable column) + // ignore: unused_element + Widget _buildWithoutStepper() { + return SingleChildScrollView( + physics: BouncingScrollPhysics(), + padding: EdgeInsets.all(16.w), + child: _buildWidget(model), + ); + } + + // Build content widgets excluding the stepper + List _buildContentWithoutStepper( + SDUIWidgetModel widgetModel, + _StepperInfo stepperInfo, { + Map? stepKeys, + }) { + final widgets = []; + final stepperKey = stepperInfo.stepperData.key; + + // Helper to check if a model is the stepper we want to exclude + bool isStepperToExclude(SDUIWidgetModel model) { + return model.maybeWhen( + stepper: (data, children, visible, index) { + return data.key == stepperKey; + }, + orElse: () => false, + ); + } + + // Helper to extract step index from visible_condition + int? extractStepIndex(String? visibleCondition) { + if (visibleCondition == null) return null; + final match = RegExp( + r'activeStepperIndex\s*==\s*(\d+)', + ).firstMatch(visibleCondition); + if (match != null) { + return int.tryParse(match.group(1) ?? ''); + } + return null; + } + + // Helper to wrap widget with key if step index exists + Widget wrapWithKeyIfNeeded(Widget widget, int? stepIndex) { + if (stepIndex != null && + stepKeys != null && + stepKeys.containsKey(stepIndex)) { + return Container(key: stepKeys[stepIndex], child: widget); + } + return widget; + } + + return widgetModel.maybeWhen( + column: + ( + children, + spacing, + mainAxisSize, + crossAxisAlignment, + visible, + paddingHorizontal, + paddingVertical, + ) { + for (var child in children) { + if (isStepperToExclude(child)) { + // If stepper has children, build those children + child.maybeWhen( + stepper: (data, stepperChildren, visible, index) { + if (stepperChildren != null) { + int childIndex = 0; + for (var stepperChild in stepperChildren) { + // Extract step index from stepper child's visible_condition + final stepIndex = stepperChild.maybeWhen( + cardLabelItem: + ( + data, + child, + children, + visible, + visibleCondition, + ) { + return extractStepIndex(visibleCondition); + }, + orElse: () => index != null ? index : childIndex, + ); + + widgets.add( + wrapWithKeyIfNeeded( + SDUIFormWidget( + model: stepperChild, + controllers: controllers, + state: state, + onStateChanged: onStateChanged, + images: images, + onImagesChanged: onImagesChanged, + pageControllers: pageControllers, + ), + stepIndex, + ), + ); + childIndex++; + } + } + }, + orElse: () {}, + ); + continue; + } + widgets.add( + SDUIFormWidget( + model: child, + controllers: controllers, + state: state, + onStateChanged: onStateChanged, + images: images, + onImagesChanged: onImagesChanged, + pageControllers: pageControllers, + ), + ); + } + return widgets; + }, + row: (children, spacing, mainAxisAlignment, visible) { + for (var child in children) { + if (isStepperToExclude(child)) { + child.maybeWhen( + stepper: (data, stepperChildren, visible, index) { + if (stepperChildren != null) { + for (var stepperChild in stepperChildren) { + widgets.add( + SDUIFormWidget( + model: stepperChild, + controllers: controllers, + state: state, + onStateChanged: onStateChanged, + images: images, + onImagesChanged: onImagesChanged, + pageControllers: pageControllers, + ), + ); + } + } + }, + orElse: () {}, + ); + continue; + } + widgets.add( + SDUIFormWidget( + model: child, + controllers: controllers, + state: state, + onStateChanged: onStateChanged, + images: images, + onImagesChanged: onImagesChanged, + pageControllers: pageControllers, + ), + ); + } + return widgets; + }, + cardLabelItem: (data, child, children, visible, visibleCondition) { + final stepIndex = extractStepIndex(visibleCondition); + + if (child != null) { + if (isStepperToExclude(child)) { + child.maybeWhen( + stepper: (stepperData, stepperChildren, visible, index) { + if (stepperChildren != null) { + for (var stepperChild in stepperChildren) { + widgets.add( + wrapWithKeyIfNeeded( + SDUIFormWidget( + model: stepperChild, + controllers: controllers, + state: state, + onStateChanged: onStateChanged, + images: images, + onImagesChanged: onImagesChanged, + pageControllers: pageControllers, + ), + stepIndex, + ), + ); + } + } + }, + orElse: () {}, + ); + } else { + widgets.add( + wrapWithKeyIfNeeded( + SDUIFormWidget( + model: child, + controllers: controllers, + state: state, + onStateChanged: onStateChanged, + images: images, + onImagesChanged: onImagesChanged, + pageControllers: pageControllers, + ), + stepIndex, + ), + ); + } + } + if (children != null) { + for (var child in children) { + if (isStepperToExclude(child)) { + child.maybeWhen( + stepper: (stepperData, stepperChildren, visible, index) { + if (stepperChildren != null) { + for (var stepperChild in stepperChildren) { + widgets.add( + wrapWithKeyIfNeeded( + SDUIFormWidget( + model: stepperChild, + controllers: controllers, + state: state, + onStateChanged: onStateChanged, + images: images, + onImagesChanged: onImagesChanged, + pageControllers: pageControllers, + ), + stepIndex, + ), + ); + } + } + }, + orElse: () {}, + ); + continue; + } + widgets.add( + wrapWithKeyIfNeeded( + SDUIFormWidget( + model: child, + controllers: controllers, + state: state, + onStateChanged: onStateChanged, + images: images, + onImagesChanged: onImagesChanged, + pageControllers: pageControllers, + ), + stepIndex, + ), + ); + } + } + return widgets; + }, + stepper: (data, children, visible, index) { + if (children != null) { + for (var child in children) { + widgets.add( + SDUIFormWidget( + model: child, + controllers: controllers, + state: state, + onStateChanged: onStateChanged, + images: images, + onImagesChanged: onImagesChanged, + pageControllers: pageControllers, + ), + ); + } + } + return widgets; + }, + pageView: (data, children, visible) { + for (var child in children) { + if (isStepperToExclude(child)) { + child.maybeWhen( + stepper: (stepperData, stepperChildren, visible, index) { + if (stepperChildren != null) { + for (var stepperChild in stepperChildren) { + widgets.add( + SDUIFormWidget( + model: stepperChild, + controllers: controllers, + state: state, + onStateChanged: onStateChanged, + images: images, + onImagesChanged: onImagesChanged, + pageControllers: pageControllers, + ), + ); + } + } + }, + orElse: () {}, + ); + continue; + } + widgets.add( + SDUIFormWidget( + model: child, + controllers: controllers, + state: state, + onStateChanged: onStateChanged, + images: images, + onImagesChanged: onImagesChanged, + pageControllers: pageControllers, + ), + ); + } + return widgets; + }, + orElse: () { + // If no children, build the widget itself (but not if it's the stepper) + if (!isStepperToExclude(widgetModel)) { + widgets.add(_buildWidget(widgetModel)); + } + return widgets; + }, + ) ?? + widgets; + } + + // Build navigation buttons + Widget _buildNavigationButtons( + SDUIFormWidgetController formController, + String stepperKey, + ) { + return Obx(() { + final isLastStep = formController.isLastStep; + final canGoPrevious = formController.canGoPrevious; + + return Container( + padding: EdgeInsets.all(8.w), + decoration: BoxDecoration( + color: Colors.white, + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.05), + blurRadius: 10, + offset: Offset(0, -2), + ), + ], + ), + child: Row( + spacing: 10.w, + children: [ + Expanded( + flex: 2, + child: RElevated( + height: 40.h, + onPressed: () { + if (isLastStep) { + // Handle final submission if needed + iLog('Last step reached - form submission'); + } else { + formController.nextStep(state); + if (onStateChanged != null) { + onStateChanged!( + stepperKey, + formController.currentStep.value, + ); + } + } + }, + child: Text(isLastStep ? 'ثبت' : 'بعدی'), + backgroundColor: AppColor.blueNormal, + ), + ), + Expanded( + child: ROutlinedElevated( + height: 40.h, + enabled: canGoPrevious, + onPressed: canGoPrevious + ? () { + formController.previousStep(state); + if (onStateChanged != null) { + onStateChanged!( + stepperKey, + formController.currentStep.value, + ); + } + } + : null, + child: Text('قبلی'), + borderColor: AppColor.blueNormal, + ), + ), + ], + ), + ); + }); + } } diff --git a/packages/chicken/lib/presentation/widget/sdui/form/sdui_form_widget_controller.dart b/packages/chicken/lib/presentation/widget/sdui/form/sdui_form_widget_controller.dart index e69de29..d9998ba 100644 --- a/packages/chicken/lib/presentation/widget/sdui/form/sdui_form_widget_controller.dart +++ b/packages/chicken/lib/presentation/widget/sdui/form/sdui_form_widget_controller.dart @@ -0,0 +1,38 @@ +import 'package:rasadyar_core/core.dart'; + +class SDUIFormWidgetController extends GetxController { + RxInt currentStep = 0.obs; + int totalSteps = 0; + String? stepperKey; + + void initializeStepper(int totalSteps, String? key) { + this.totalSteps = totalSteps; + this.stepperKey = key; + currentStep.value = 0; + } + + void nextStep(RxMap? state) { + if (currentStep.value < totalSteps - 1) { + currentStep.value++; + if (state != null && stepperKey != null) { + state[stepperKey!] = currentStep.value; + } + } + } + + void previousStep(RxMap? state) { + if (currentStep.value > 0) { + currentStep.value--; + if (state != null && stepperKey != null) { + state[stepperKey!] = currentStep.value; + } + } + } + + bool get canGoNext => currentStep.value < totalSteps - 1; + bool get canGoPrevious => currentStep.value > 0; + bool get isLastStep => currentStep.value == totalSteps - 1; +} + + + diff --git a/packages/chicken/lib/presentation/widget/sdui/form/ts1 copy.json b/packages/chicken/lib/presentation/widget/sdui/form/ts1 copy.json new file mode 100644 index 0000000..3c5af55 --- /dev/null +++ b/packages/chicken/lib/presentation/widget/sdui/form/ts1 copy.json @@ -0,0 +1,1099 @@ +{ + "info": { + "type": "column", + "visible": true, + "data": { + "spacing": 30.0 + }, + "children": [ + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "اطلاعات پایه واحد", + "padding_horizontal": 12.0, + "padding_vertical": 11.0, + "visible_condition": "activeStepperIndex == 0" + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "unit_name", + "label": "نام واحد مرغداری", + "keyboard_type": "text", + "readonly": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "breeding_unique_id", + "label": "کد یکتا / شناسه واحد", + "keyboard_type": "text", + "readonly": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "health_license", + "label": "پروانه بهداشتی", + "keyboard_type": "text" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "tenant_status", + "label": "وضعیت مستاجر", + "keyboard_type": "text" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "tenant_name", + "label": "نام مستاجر", + "keyboard_type": "text", + "visible_condition": "tenant_status == 'دارد'" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "tenant_national_id", + "label": "کد ملی مستاجر", + "keyboard_type": "text", + "visible_condition": "tenant_status == 'دارد'" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "tenant_phone_number", + "label": "شماره تماس مستاجر", + "keyboard_type": "text", + "visible_condition": "tenant_status == 'دارد'" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "owner_national_code", + "label": "کد ملی بهره‌بردار", + "keyboard_type": "text", + "readonly": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "owner_phone_number", + "label": "شماره تماس بهره‌بردار", + "keyboard_type": "text", + "readonly": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "total_capacity", + "label": "ظرفیت اسمی سالن‌ها", + "keyboard_type": "number", + "comma_separator": true + } + } + ] + } + }, + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "اطلاعات جوجه ریزی", + "visible_condition": "activeStepperIndex == 1", + "padding_horizontal": 12.0, + "padding_vertical": 11.0 + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "hatching_date", + "label": "تاریخ جوجه ریزی", + "keyboard_type": "text", + "readonly": true, + "type": "date_picker" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "visit_date", + "label": "تاریخ بازدید", + "keyboard_type": "text", + "readonly": true, + "type": "date_picker" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "hatching_count", + "label": "تعداد جوجه‌ریزی اولیه", + "keyboard_type": "number", + "readonly": true, + "comma_separator": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "hatching_breed", + "label": "نوع نژاد", + "keyboard_type": "text" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "hatching_average_weight", + "label": "میانگین وزن جوجه", + "keyboard_type": "number", + "comma_separator": true + } + } + ] + } + }, + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "وضعیت عمومی سالن", + "visible_condition": "activeStepperIndex == 2", + "padding_horizontal": 12.0, + "padding_vertical": 11.0 + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "image_picker", + "visible": true, + "data": { + "key": "pultry_images", + "label": "تعداد موجود فعلی" + } + }, + { + "type": "chip_selection", + "visible": true, + "data": { + "key": "sanitary_condition_of_the_hall", + "label": "وضعیت بهداشتی سالن", + "selectedIndex": -1, + "options": [ + { + "index": 0, + "label": "عالی", + "value": "عالی" + }, + { + "index": 1, + "label": "خوب", + "value": "خوب" + }, + { + "index": 2, + "label": "متوسط", + "value": "متوسط" + }, + { + "index": 3, + "label": "ضعیف", + "value": "ضعیف" + } + ] + } + }, + { + "type": "chip_selection", + "visible": true, + "data": { + "key": "ventilation_status", + "label": "وضعیت تهویه", + "selectedIndex": -1, + "options": [ + { + "index": 0, + "label": "عالی", + "value": "عالی" + }, + { + "index": 1, + "label": "خوب", + "value": "خوب" + }, + { + "index": 2, + "label": "متوسط", + "value": "متوسط" + }, + { + "index": 3, + "label": "ضعیف", + "value": "ضعیف" + } + ] + } + }, + { + "type": "chip_selection", + "visible": true, + "data": { + "key": "bedding_status", + "label": "وضعیت بستر", + "selectedIndex": -1, + "options": [ + { + "index": 0, + "label": "خشک", + "value": "خشک" + }, + { + "index": 1, + "label": "نیمه‌مرطوب", + "value": "نیمه‌مرطوب" + }, + { + "index": 2, + "label": "مرطوب", + "value": "مرطوب" + } + ] + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "hatching_temperature", + "label": "دمای سالن", + "keyboard_type": "number" + } + }, + { + "type": "chip_selection", + "visible": true, + "data": { + "key": "water_quality", + "label": "آب مصرفی", + "selectedIndex": -1, + "options": [ + { + "index": 0, + "label": "چاه", + "value": "چاه" + }, + { + "index": 1, + "label": "شهری", + "value": "شهری" + }, + { + "index": 2, + "label": "تصفیه‌شده", + "value": "تصفیه‌شده" + }, + { + "index": 3, + "label": "حمل تانکر", + "value": "حمل تانکر" + } + ] + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "water_hardness", + "label": "درصد سختی آب (PPM)", + "keyboard_type": "number", + "decimal": true + } + } + ] + } + }, + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "تلفات", + "visible_condition": "activeStepperIndex == 3", + "padding_horizontal": 12.0, + "padding_vertical": 11.0 + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "normal_losses", + "label": "تعداد تلفات عادی دوره", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "abnormal_losses", + "label": "تلفات غیرعادی", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "dropdown", + "visible": true, + "data": { + "key": "cause_of_unusual_casualties", + "label": "علت تلفات غیرعادی", + "placeholder": "علت تلفات غیرعادی", + "items": [ + "بیماری", + "قطعی برق", + "استرس گرمایی", + "مشکلات دان", + "کیفیت جوجه", + "سایر (شرح…)" + ], + "selectedValue": null, + "enabled": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "other_cause_of_unusual_casualties", + "label": "علت تلفات غیرعادی", + "keyboard_type": "text", + "visible_condition": "cause_of_unusual_casualties == 'سایر (شرح…)'" + } + }, + { + "type": "dropdown", + "visible": true, + "data": { + "key": "type_of_disease", + "label": "نوع بیماری تشخیص داده‌شده / مشکوک", + "placeholder": "نوع بیماری تشخیص داده‌شده / مشکوک", + "items": [ + "آنفلوانزا", + "نیوکاسل", + "IB", + "عفونت‌های باکتریایی", + "مشکلات گوارشی", + "سایر (شرح)" + ], + "selectedValue": null, + "enabled": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "other_type_of_disease", + "label": "نوع بیماری", + "keyboard_type": "text", + "visible_condition": "type_of_disease == 'سایر (شرح)'" + } + }, + { + "type": "dropdown", + "visible": true, + "data": { + "key": "sampling_done", + "label": "نمونه‌برداری انجام‌شده", + "placeholder": "نمونه‌برداری انجام‌شده", + "items": [ + "انجام شد", + "انجام نشد" + ], + "selectedValue": null, + "enabled": true + } + }, + { + "type": "chip_selection", + "visible": true, + "data": { + "key": "sample_type", + "label": "نوع نمونه", + "selectedIndex": -1, + "visible_condition": "sampling_done == 'انجام شد'", + "options": [ + { + "index": 0, + "label": "لاشه", + "value": "لاشه" + }, + { + "index": 1, + "label": "آب", + "value": "آب" + }, + { + "index": 2, + "label": "دانه", + "value": "دانه" + } + ] + } + } + ] + } + }, + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "مسئول فنی", + "visible_condition": "activeStepperIndex == 4", + "padding_horizontal": 12.0, + "padding_vertical": 11.0 + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "technical_health_officer_name", + "label": "نام مسئول فنی بهداشتی", + "keyboard_type": "text" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "technical_engineering_officer_name", + "label": "نام مسئول فنی نظام مهندسی", + "keyboard_type": "text" + } + } + ] + } + }, + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "نهاده و خوراک", + "visible_condition": "activeStepperIndex == 5", + "padding_horizontal": 12.0, + "padding_vertical": 11.0 + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "dropdown", + "visible": true, + "data": { + "key": "input_status", + "label": "وضعیت نهاده", + "placeholder": "وضعیت نهاده", + "items": [ + "وابسته", + "مستقل" + ], + "selectedValue": null, + "enabled": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "company_name", + "label": "نام کارخانه", + "keyboard_type": "text", + "visible_condition": "input_status == 'وابسته'" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "tracking_code", + "label": "شناسه خرید یا کد پیگیری", + "keyboard_type": "text", + "visible_condition": "input_status == 'مستقل'" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "input_inventory_until_visit", + "label": "موجودی نهاده مصرفی تا روز بازدید (کیلوگرم)", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "dropdown", + "visible": true, + "data": { + "key": "type_of_grain", + "label": "نوع دان", + "placeholder": "نوع دان", + "items": [ + "آردی", + "پلت", + "کرامبل و اکسترود", + "مش", + "پوره و وال" + ], + "selectedValue": null, + "enabled": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "input_inventory_in_warehouse", + "label": "موجودی نهاده موجود در انبار (کیلوگرم)", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "chip_selection", + "visible": true, + "data": { + "key": "grain_quality", + "label": "کیفیت دانه", + "selectedIndex": -1, + "options": [ + { + "index": 0, + "label": "خوب", + "value": "خوب" + }, + { + "index": 1, + "label": "متوسط", + "value": "متوسط" + }, + { + "index": 2, + "label": "ضعیف", + "value": "ضعیف" + } + ] + } + } + ] + } + }, + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "زیرساخت و انرژی", + "visible_condition": "activeStepperIndex == 6", + "padding_horizontal": 12.0, + "padding_vertical": 11.0 + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "generator_type", + "label": "نوع ژنراتور", + "keyboard_type": "text" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "generator_model", + "label": "مدل ژنراتور", + "keyboard_type": "text" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "generator_count", + "label": "تعداد ژنراتور", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "dropdown", + "visible": true, + "data": { + "key": "fuel_type", + "label": "نوع سوخت", + "placeholder": "نوع سوخت", + "items": [ + "گازوئیل", + "نفت گاز" + ], + "selectedValue": null, + "enabled": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "generator_capacity", + "label": "ظرفیت (KVA)", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "chip_selection", + "visible": true, + "data": { + "key": "generator_operating_status", + "label": "وضعیت عملکرد ژنراتور", + "selectedIndex": -1, + "options": [ + { + "index": 0, + "label": "سالم", + "value": "سالم" + }, + { + "index": 1, + "label": "نیمه‌سالم", + "value": "نیمه‌سالم" + }, + { + "index": 2, + "label": "معیوب", + "value": "معیوب" + } + ] + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "emergency_fuel_inventory", + "label": "میزان موجودی سوخت اضطراری (لیتر)", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "dropdown", + "visible": true, + "data": { + "key": "power_cut_history", + "label": "سابقه قطعی برق دوره جاری", + "placeholder": "سابقه قطعی برق دوره جاری", + "items": [ + "ندارد", + "دارد" + ], + "selectedValue": null, + "enabled": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "power_cut_duration", + "label": "مدت قطعی", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "power_cut_hour", + "label": "ساعت قطعی", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "additional_notes", + "label": "توضیحات تکمیلی", + "keyboard_type": "text", + "max_line": 5, + "min_line": 5 + } + } + ] + } + }, + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "نیروی انسانی", + "visible_condition": "activeStepperIndex == 7", + "padding_horizontal": 12.0, + "padding_vertical": 11.0 + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "employed_workers_count", + "label": "تعداد افراد شاغل", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "native_workers_count", + "label": "تعداد افراد بومی", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "non_native_workers_count", + "label": "تعداد افراد غیر بومی", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "chip_selection", + "visible": true, + "data": { + "key": "worker_contract_status", + "label": "وضعیت قرارداد کارگران", + "selectedIndex": -1, + "options": [ + { + "index": 0, + "label": "دائم", + "value": "دائم" + }, + { + "index": 1, + "label": "موقت", + "value": "موقت" + }, + { + "index": 2, + "label": "روزمزدی", + "value": "روزمزدی" + } + ] + } + }, + { + "type": "dropdown", + "visible": true, + "data": { + "key": "training_status", + "label": "آموزش‌دیده در حوزه بهداشت و امنیت زیستی", + "placeholder": "آموزش‌دیده در حوزه بهداشت و امنیت زیستی", + "items": [ + "بله", + "خیر" + ], + "selectedValue": null, + "enabled": true + } + } + ] + } + }, + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "تسهیلات و حمایت‌ها", + "visible_condition": "activeStepperIndex == 8", + "padding_horizontal": 12.0, + "padding_vertical": 11.0 + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "dropdown", + "visible": true, + "data": { + "key": "has_facilities", + "label": "تسهیلات دریافتی فعال", + "placeholder": "تسهیلات دریافتی فعال", + "items": [ + "دارد", + "ندارد" + ], + "selectedValue": null, + "enabled": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "facility_type", + "label": "نوع تسهیلات", + "keyboard_type": "text" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "facility_amount", + "label": "مبلغ", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "payment_year", + "label": "سال دریافت", + "keyboard_type": "text", + "readonly": true, + "type": "date_picker" + } + }, + { + "type": "dropdown", + "visible": true, + "data": { + "key": "overdue_status", + "label": "وضعیت بازپرداخت", + "placeholder": "وضعیت بازپرداخت", + "items": [ + "دارای معوقه", + "منظم" + ], + "selectedValue": null, + "enabled": true + } + }, + { + "type": "dropdown", + "visible": true, + "data": { + "key": "new_beneficiary_request", + "label": "درخواست جدید بهره بردار", + "placeholder": "درخواست جدید بهره بردار", + "items": [ + "نهاده", + "تسهیلات", + "واکسن", + "تجهیزات" + ], + "selectedValue": null, + "enabled": true + } + } + ] + } + }, + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "مستندات", + "visible_condition": "activeStepperIndex == 9", + "padding_horizontal": 12.0, + "padding_vertical": 11.0 + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "image_picker", + "visible": true, + "data": { + "key": "hall_images", + "label": "ثبت عکس سالن (حداقل ۳ زاویه)", + "required": true + } + }, + { + "type": "image_picker", + "visible": true, + "data": { + "key": "input_warehouse_images", + "label": "ثبت عکس انبار نهاده‌ها" + } + }, + { + "type": "image_picker", + "visible": true, + "data": { + "key": "losses_images", + "label": "ثبت عکس تلفات" + } + } + ] + } + }, + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "جمع‌بندی بازرس", + "visible_condition": "activeStepperIndex == 10", + "padding_horizontal": 12.0, + "padding_vertical": 11.0 + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "chip_selection", + "visible": true, + "data": { + "key": "inspector_conclusion", + "label": "وضعیت کلی واحد", + "selectedIndex": -1, + "options": [ + { + "index": 0, + "label": "تایید شده", + "value": "تایید شده" + }, + { + "index": 1, + "label": "نیازمند اصلاح", + "value": "نیازمند اصلاح" + }, + { + "index": 2, + "label": "پرریسک", + "value": "پرریسک" + } + ] + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "inspector_conclusion_description", + "label": "توصیه‌ها / اخطارها / اقدامات اصلاحی ...", + "hint_text": "توصیه‌ها / اخطارها / اقدامات اصلاحی ...", + "keyboard_type": "text", + "max_line": 5, + "min_line": 5 + } + } + ] + } + } + ] + } +} \ No newline at end of file diff --git a/packages/chicken/lib/presentation/widget/sdui/form/ts_with_stepper.json b/packages/chicken/lib/presentation/widget/sdui/form/ts_with_stepper.json new file mode 100644 index 0000000..2f4202f --- /dev/null +++ b/packages/chicken/lib/presentation/widget/sdui/form/ts_with_stepper.json @@ -0,0 +1,1108 @@ +{ + "info": { + "type": "column", + "visible": true, + "data": { + "spacing": 30.0 + }, + "children": [ + { + "type": "stepper", + "visible": true, + "data": { + "key": "activeStepperIndex", + "total_steps": 7, + "active_step": 0 + } + }, + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "اطلاعات پایه واحد", + "padding_horizontal": 12.0, + "padding_vertical": 11.0, + "visible_condition": "activeStepperIndex == 0" + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "unit_name", + "label": "نام واحد مرغداری", + "keyboard_type": "text", + "readonly": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "breeding_unique_id", + "label": "کد یکتا / شناسه واحد", + "keyboard_type": "text", + "readonly": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "health_license", + "label": "پروانه بهداشتی", + "keyboard_type": "text" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "tenant_status", + "label": "وضعیت مستاجر", + "keyboard_type": "text" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "tenant_name", + "label": "نام مستاجر", + "keyboard_type": "text", + "visible_condition": "tenant_status == 'دارد'" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "tenant_national_id", + "label": "کد ملی مستاجر", + "keyboard_type": "text", + "visible_condition": "tenant_status == 'دارد'" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "tenant_phone_number", + "label": "شماره تماس مستاجر", + "keyboard_type": "text", + "visible_condition": "tenant_status == 'دارد'" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "owner_national_code", + "label": "کد ملی بهره‌بردار", + "keyboard_type": "text", + "readonly": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "owner_phone_number", + "label": "شماره تماس بهره‌بردار", + "keyboard_type": "text", + "readonly": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "total_capacity", + "label": "ظرفیت اسمی سالن‌ها", + "keyboard_type": "number", + "comma_separator": true + } + } + ] + } + }, + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "اطلاعات جوجه ریزی", + "visible_condition": "activeStepperIndex == 1", + "padding_horizontal": 12.0, + "padding_vertical": 11.0 + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "hatching_date", + "label": "تاریخ جوجه ریزی", + "keyboard_type": "text", + "readonly": true, + "type": "date_picker" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "visit_date", + "label": "تاریخ بازدید", + "keyboard_type": "text", + "readonly": true, + "type": "date_picker" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "hatching_count", + "label": "تعداد جوجه‌ریزی اولیه", + "keyboard_type": "number", + "readonly": true, + "comma_separator": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "hatching_breed", + "label": "نوع نژاد", + "keyboard_type": "text" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "hatching_average_weight", + "label": "میانگین وزن جوجه", + "keyboard_type": "number", + "comma_separator": true + } + } + ] + } + }, + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "وضعیت عمومی سالن", + "visible_condition": "activeStepperIndex == 2", + "padding_horizontal": 12.0, + "padding_vertical": 11.0 + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "image_picker", + "visible": true, + "data": { + "key": "pultry_images", + "label": "تعداد موجود فعلی" + } + }, + { + "type": "chip_selection", + "visible": true, + "data": { + "key": "sanitary_condition_of_the_hall", + "label": "وضعیت بهداشتی سالن", + "selectedIndex": -1, + "options": [ + { + "index": 0, + "label": "عالی", + "value": "عالی" + }, + { + "index": 1, + "label": "خوب", + "value": "خوب" + }, + { + "index": 2, + "label": "متوسط", + "value": "متوسط" + }, + { + "index": 3, + "label": "ضعیف", + "value": "ضعیف" + } + ] + } + }, + { + "type": "chip_selection", + "visible": true, + "data": { + "key": "ventilation_status", + "label": "وضعیت تهویه", + "selectedIndex": -1, + "options": [ + { + "index": 0, + "label": "عالی", + "value": "عالی" + }, + { + "index": 1, + "label": "خوب", + "value": "خوب" + }, + { + "index": 2, + "label": "متوسط", + "value": "متوسط" + }, + { + "index": 3, + "label": "ضعیف", + "value": "ضعیف" + } + ] + } + }, + { + "type": "chip_selection", + "visible": true, + "data": { + "key": "bedding_status", + "label": "وضعیت بستر", + "selectedIndex": -1, + "options": [ + { + "index": 0, + "label": "خشک", + "value": "خشک" + }, + { + "index": 1, + "label": "نیمه‌مرطوب", + "value": "نیمه‌مرطوب" + }, + { + "index": 2, + "label": "مرطوب", + "value": "مرطوب" + } + ] + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "hatching_temperature", + "label": "دمای سالن", + "keyboard_type": "number" + } + }, + { + "type": "chip_selection", + "visible": true, + "data": { + "key": "water_quality", + "label": "آب مصرفی", + "selectedIndex": -1, + "options": [ + { + "index": 0, + "label": "چاه", + "value": "چاه" + }, + { + "index": 1, + "label": "شهری", + "value": "شهری" + }, + { + "index": 2, + "label": "تصفیه‌شده", + "value": "تصفیه‌شده" + }, + { + "index": 3, + "label": "حمل تانکر", + "value": "حمل تانکر" + } + ] + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "water_hardness", + "label": "درصد سختی آب (PPM)", + "keyboard_type": "number", + "decimal": true + } + } + ] + } + }, + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "تلفات", + "visible_condition": "activeStepperIndex == 3", + "padding_horizontal": 12.0, + "padding_vertical": 11.0 + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "normal_losses", + "label": "تعداد تلفات عادی دوره", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "abnormal_losses", + "label": "تلفات غیرعادی", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "dropdown", + "visible": true, + "data": { + "key": "cause_of_unusual_casualties", + "label": "علت تلفات غیرعادی", + "placeholder": "علت تلفات غیرعادی", + "items": [ + "بیماری", + "قطعی برق", + "استرس گرمایی", + "مشکلات دان", + "کیفیت جوجه", + "سایر (شرح…)" + ], + "selectedValue": null, + "enabled": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "other_cause_of_unusual_casualties", + "label": "علت تلفات غیرعادی", + "keyboard_type": "text", + "visible_condition": "cause_of_unusual_casualties == 'سایر (شرح…)'" + } + }, + { + "type": "dropdown", + "visible": true, + "data": { + "key": "type_of_disease", + "label": "نوع بیماری تشخیص داده‌شده / مشکوک", + "placeholder": "نوع بیماری تشخیص داده‌شده / مشکوک", + "items": [ + "آنفلوانزا", + "نیوکاسل", + "IB", + "عفونت‌های باکتریایی", + "مشکلات گوارشی", + "سایر (شرح)" + ], + "selectedValue": null, + "enabled": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "other_type_of_disease", + "label": "نوع بیماری", + "keyboard_type": "text", + "visible_condition": "type_of_disease == 'سایر (شرح)'" + } + }, + { + "type": "dropdown", + "visible": true, + "data": { + "key": "sampling_done", + "label": "نمونه‌برداری انجام‌شده", + "placeholder": "نمونه‌برداری انجام‌شده", + "items": [ + "انجام شد", + "انجام نشد" + ], + "selectedValue": null, + "enabled": true + } + }, + { + "type": "chip_selection", + "visible": true, + "data": { + "key": "sample_type", + "label": "نوع نمونه", + "selectedIndex": -1, + "visible_condition": "sampling_done == 'انجام شد'", + "options": [ + { + "index": 0, + "label": "لاشه", + "value": "لاشه" + }, + { + "index": 1, + "label": "آب", + "value": "آب" + }, + { + "index": 2, + "label": "دانه", + "value": "دانه" + } + ] + } + } + ] + } + }, + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "مسئول فنی", + "visible_condition": "activeStepperIndex == 4", + "padding_horizontal": 12.0, + "padding_vertical": 11.0 + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "technical_health_officer_name", + "label": "نام مسئول فنی بهداشتی", + "keyboard_type": "text" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "technical_engineering_officer_name", + "label": "نام مسئول فنی نظام مهندسی", + "keyboard_type": "text" + } + } + ] + } + }, + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "نهاده و خوراک", + "visible_condition": "activeStepperIndex == 5", + "padding_horizontal": 12.0, + "padding_vertical": 11.0 + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "dropdown", + "visible": true, + "data": { + "key": "input_status", + "label": "وضعیت نهاده", + "placeholder": "وضعیت نهاده", + "items": [ + "وابسته", + "مستقل" + ], + "selectedValue": null, + "enabled": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "company_name", + "label": "نام کارخانه", + "keyboard_type": "text", + "visible_condition": "input_status == 'وابسته'" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "tracking_code", + "label": "شناسه خرید یا کد پیگیری", + "keyboard_type": "text", + "visible_condition": "input_status == 'مستقل'" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "input_inventory_until_visit", + "label": "موجودی نهاده مصرفی تا روز بازدید (کیلوگرم)", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "dropdown", + "visible": true, + "data": { + "key": "type_of_grain", + "label": "نوع دان", + "placeholder": "نوع دان", + "items": [ + "آردی", + "پلت", + "کرامبل و اکسترود", + "مش", + "پوره و وال" + ], + "selectedValue": null, + "enabled": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "input_inventory_in_warehouse", + "label": "موجودی نهاده موجود در انبار (کیلوگرم)", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "chip_selection", + "visible": true, + "data": { + "key": "grain_quality", + "label": "کیفیت دانه", + "selectedIndex": -1, + "options": [ + { + "index": 0, + "label": "خوب", + "value": "خوب" + }, + { + "index": 1, + "label": "متوسط", + "value": "متوسط" + }, + { + "index": 2, + "label": "ضعیف", + "value": "ضعیف" + } + ] + } + } + ] + } + }, + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "زیرساخت و انرژی", + "visible_condition": "activeStepperIndex == 6", + "padding_horizontal": 12.0, + "padding_vertical": 11.0 + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "generator_type", + "label": "نوع ژنراتور", + "keyboard_type": "text" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "generator_model", + "label": "مدل ژنراتور", + "keyboard_type": "text" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "generator_count", + "label": "تعداد ژنراتور", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "dropdown", + "visible": true, + "data": { + "key": "fuel_type", + "label": "نوع سوخت", + "placeholder": "نوع سوخت", + "items": [ + "گازوئیل", + "نفت گاز" + ], + "selectedValue": null, + "enabled": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "generator_capacity", + "label": "ظرفیت (KVA)", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "chip_selection", + "visible": true, + "data": { + "key": "generator_operating_status", + "label": "وضعیت عملکرد ژنراتور", + "selectedIndex": -1, + "options": [ + { + "index": 0, + "label": "سالم", + "value": "سالم" + }, + { + "index": 1, + "label": "نیمه‌سالم", + "value": "نیمه‌سالم" + }, + { + "index": 2, + "label": "معیوب", + "value": "معیوب" + } + ] + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "emergency_fuel_inventory", + "label": "میزان موجودی سوخت اضطراری (لیتر)", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "dropdown", + "visible": true, + "data": { + "key": "power_cut_history", + "label": "سابقه قطعی برق دوره جاری", + "placeholder": "سابقه قطعی برق دوره جاری", + "items": [ + "ندارد", + "دارد" + ], + "selectedValue": null, + "enabled": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "power_cut_duration", + "label": "مدت قطعی", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "power_cut_hour", + "label": "ساعت قطعی", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "additional_notes", + "label": "توضیحات تکمیلی", + "keyboard_type": "text", + "max_line": 5, + "min_line": 5 + } + } + ] + } + }, + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "نیروی انسانی", + "visible_condition": "activeStepperIndex == 7", + "padding_horizontal": 12.0, + "padding_vertical": 11.0 + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "employed_workers_count", + "label": "تعداد افراد شاغل", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "native_workers_count", + "label": "تعداد افراد بومی", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "non_native_workers_count", + "label": "تعداد افراد غیر بومی", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "chip_selection", + "visible": true, + "data": { + "key": "worker_contract_status", + "label": "وضعیت قرارداد کارگران", + "selectedIndex": -1, + "options": [ + { + "index": 0, + "label": "دائم", + "value": "دائم" + }, + { + "index": 1, + "label": "موقت", + "value": "موقت" + }, + { + "index": 2, + "label": "روزمزدی", + "value": "روزمزدی" + } + ] + } + }, + { + "type": "dropdown", + "visible": true, + "data": { + "key": "training_status", + "label": "آموزش‌دیده در حوزه بهداشت و امنیت زیستی", + "placeholder": "آموزش‌دیده در حوزه بهداشت و امنیت زیستی", + "items": [ + "بله", + "خیر" + ], + "selectedValue": null, + "enabled": true + } + } + ] + } + }, + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "تسهیلات و حمایت‌ها", + "visible_condition": "activeStepperIndex == 8", + "padding_horizontal": 12.0, + "padding_vertical": 11.0 + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "dropdown", + "visible": true, + "data": { + "key": "has_facilities", + "label": "تسهیلات دریافتی فعال", + "placeholder": "تسهیلات دریافتی فعال", + "items": [ + "دارد", + "ندارد" + ], + "selectedValue": null, + "enabled": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "facility_type", + "label": "نوع تسهیلات", + "keyboard_type": "text" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "facility_amount", + "label": "مبلغ", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "payment_year", + "label": "سال دریافت", + "keyboard_type": "text", + "readonly": true, + "type": "date_picker" + } + }, + { + "type": "dropdown", + "visible": true, + "data": { + "key": "overdue_status", + "label": "وضعیت بازپرداخت", + "placeholder": "وضعیت بازپرداخت", + "items": [ + "دارای معوقه", + "منظم" + ], + "selectedValue": null, + "enabled": true + } + }, + { + "type": "dropdown", + "visible": true, + "data": { + "key": "new_beneficiary_request", + "label": "درخواست جدید بهره بردار", + "placeholder": "درخواست جدید بهره بردار", + "items": [ + "نهاده", + "تسهیلات", + "واکسن", + "تجهیزات" + ], + "selectedValue": null, + "enabled": true + } + } + ] + } + }, + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "مستندات", + "visible_condition": "activeStepperIndex == 9", + "padding_horizontal": 12.0, + "padding_vertical": 11.0 + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "image_picker", + "visible": true, + "data": { + "key": "hall_images", + "label": "ثبت عکس سالن (حداقل ۳ زاویه)", + "required": true + } + }, + { + "type": "image_picker", + "visible": true, + "data": { + "key": "input_warehouse_images", + "label": "ثبت عکس انبار نهاده‌ها" + } + }, + { + "type": "image_picker", + "visible": true, + "data": { + "key": "losses_images", + "label": "ثبت عکس تلفات" + } + } + ] + } + }, + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "جمع‌بندی بازرس", + "visible_condition": "activeStepperIndex == 10", + "padding_horizontal": 12.0, + "padding_vertical": 11.0 + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "chip_selection", + "visible": true, + "data": { + "key": "inspector_conclusion", + "label": "وضعیت کلی واحد", + "selectedIndex": -1, + "options": [ + { + "index": 0, + "label": "تایید شده", + "value": "تایید شده" + }, + { + "index": 1, + "label": "نیازمند اصلاح", + "value": "نیازمند اصلاح" + }, + { + "index": 2, + "label": "پرریسک", + "value": "پرریسک" + } + ] + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "inspector_conclusion_description", + "label": "توصیه‌ها / اخطارها / اقدامات اصلاحی ...", + "hint_text": "توصیه‌ها / اخطارها / اقدامات اصلاحی ...", + "keyboard_type": "text", + "max_line": 5, + "min_line": 5 + } + } + ] + } + } + ] + } +} \ No newline at end of file diff --git a/packages/chicken/lib/presentation/widget/sdui/model/sdui_widget.dart b/packages/chicken/lib/presentation/widget/sdui/model/sdui_widget.dart new file mode 100644 index 0000000..5f3a486 --- /dev/null +++ b/packages/chicken/lib/presentation/widget/sdui/model/sdui_widget.dart @@ -0,0 +1,150 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:rasadyar_chicken/presentation/widget/sdui/widgets/text_form_filed/model/text_form_field_sdui_model.dart'; +import 'package:rasadyar_chicken/presentation/widget/sdui/widgets/card_label_item/model/card_label_item_sdui_model.dart'; +import 'package:rasadyar_chicken/presentation/widget/sdui/widgets/chip_selection/model/chip_selection_sdui_model.dart'; +import 'package:rasadyar_chicken/presentation/widget/sdui/widgets/dropdown/model/dropdown_sdui_model.dart'; +import 'package:rasadyar_chicken/presentation/widget/sdui/widgets/image_picker/model/image_picker_sdui_model.dart'; +import 'package:rasadyar_chicken/presentation/widget/sdui/widgets/stepper/model/stepper_sdui_model.dart'; +import 'package:rasadyar_chicken/presentation/widget/sdui/widgets/page_view/model/page_view_sdui_model.dart'; + +part 'sdui_widget.freezed.dart'; +part 'sdui_widget.g.dart'; + +@Freezed(unionKey: 'type', unionValueCase: FreezedUnionCase.snake) +sealed class SDUIWidgetModel with _$SDUIWidgetModel { + const factory SDUIWidgetModel.textFormField({ + required TextFormFieldSDUIModel data, + @Default(true) bool visible, + }) = _TextFormField; + + const factory SDUIWidgetModel.cardLabelItem({ + required CardLabelItemData data, + SDUIWidgetModel? child, + List? children, + @Default(true) bool visible, + String? visibleCondition, + }) = _CardLabelItem; + + const factory SDUIWidgetModel.chipSelection({ + required ChipSelectionSDUIModel data, + @Default(true) bool visible, + }) = _ChipSelection; + + const factory SDUIWidgetModel.dropdown({ + required DropdownSDUIModel data, + @Default(true) bool visible, + }) = _Dropdown; + + const factory SDUIWidgetModel.imagePicker({ + required ImagePickerSDUIModel data, + @Default(true) bool visible, + }) = _ImagePicker; + + const factory SDUIWidgetModel.column({ + required List children, + @Default(0.0) double spacing, + @Default('max') String mainAxisSize, + @Default(0.0) double paddingHorizontal, + @Default(0.0) double paddingVertical, + @Default('center') String crossAxisAlignment, + @Default(true) bool visible, + }) = _Column; + + const factory SDUIWidgetModel.row({ + required List children, + @Default(0.0) double spacing, + @Default('start') String mainAxisAlignment, + @Default(true) bool visible, + }) = _Row; + + const factory SDUIWidgetModel.sizedBox({ + double? width, + double? height, + @Default(true) bool visible, + }) = _SizedBox; + + const factory SDUIWidgetModel.stepper({ + required StepperSDUIModel data, + List? children, + @Default(true) bool visible, + int? index, + }) = _Stepper; + + const factory SDUIWidgetModel.pageView({ + required PageViewSDUIModel data, + required List children, + @Default(true) bool visible, + }) = _PageView; + + factory SDUIWidgetModel.fromJson(Map json) => + _$SDUIWidgetModelFromJson(json); + + factory SDUIWidgetModel.fromRawJson(Map json) { + final type = json['type'] as String?; + if (type == null) return const SDUIWidgetModel.sizedBox(visible: false); + + final preparedJson = Map.from(json); + + _prepareData(type, preparedJson); + + return SDUIWidgetModel.fromJson(preparedJson); + } + + static void _prepareData(String type, Map json) { + final rawData = json['data']; + + // Handle stepper with List data (children) + if (type == 'stepper' && rawData is List) { + // Convert List data to children + json['children'] = rawData; + // Create default stepper data + json['data'] = {'key': 'stepper_key', 'activeStep': 0}; + // Recursively prepare children + for (var i = 0; i < rawData.length; i++) { + if (rawData[i] is Map) { + final childJson = rawData[i] as Map; + final childType = childJson['type'] as String?; + if (childType != null) { + _prepareData(childType, childJson); + } + } + } + } + + // Handle column, row, sized_box with Map data + if (['column', 'row', 'sized_box'].contains(type) && rawData is Map) { + json.addAll(Map.from(rawData)); + } + + // Handle visible_condition for card_label_item + if (type == 'card_label_item' && rawData is Map) { + final dataMap = Map.from(rawData); + if (dataMap.containsKey('visible_condition')) { + json['visible_condition'] = dataMap['visible_condition']; + } + } + + // Recursively prepare children for all widget types + if (json['children'] is List) { + final children = json['children'] as List; + for (var i = 0; i < children.length; i++) { + if (children[i] is Map) { + final childJson = children[i] as Map; + final childType = childJson['type'] as String?; + if (childType != null) { + _prepareData(childType, childJson); + } + } + } + } + + // Recursively prepare child (singular) for card_label_item + if (json['child'] is Map) { + final childJson = json['child'] as Map; + final childType = childJson['type'] as String?; + if (childType != null) { + _prepareData(childType, childJson); + } + } + } +} diff --git a/packages/chicken/lib/presentation/widget/sdui/model/sdui_widget.freezed.dart b/packages/chicken/lib/presentation/widget/sdui/model/sdui_widget.freezed.dart new file mode 100644 index 0000000..d7d044c --- /dev/null +++ b/packages/chicken/lib/presentation/widget/sdui/model/sdui_widget.freezed.dart @@ -0,0 +1,1198 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'sdui_widget.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// dart format off +T _$identity(T value) => value; +SDUIWidgetModel _$SDUIWidgetModelFromJson( + Map json +) { + switch (json['type']) { + case 'text_form_field': + return _TextFormField.fromJson( + json + ); + case 'card_label_item': + return _CardLabelItem.fromJson( + json + ); + case 'chip_selection': + return _ChipSelection.fromJson( + json + ); + case 'dropdown': + return _Dropdown.fromJson( + json + ); + case 'image_picker': + return _ImagePicker.fromJson( + json + ); + case 'column': + return _Column.fromJson( + json + ); + case 'row': + return _Row.fromJson( + json + ); + case 'sized_box': + return _SizedBox.fromJson( + json + ); + case 'stepper': + return _Stepper.fromJson( + json + ); + case 'page_view': + return _PageView.fromJson( + json + ); + + default: + throw CheckedFromJsonException( + json, + 'type', + 'SDUIWidgetModel', + 'Invalid union type "${json['type']}"!' +); + } + +} + +/// @nodoc +mixin _$SDUIWidgetModel { + + bool get visible; +/// Create a copy of SDUIWidgetModel +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$SDUIWidgetModelCopyWith get copyWith => _$SDUIWidgetModelCopyWithImpl(this as SDUIWidgetModel, _$identity); + + /// Serializes this SDUIWidgetModel to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is SDUIWidgetModel&&(identical(other.visible, visible) || other.visible == visible)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,visible); + +@override +String toString() { + return 'SDUIWidgetModel(visible: $visible)'; +} + + +} + +/// @nodoc +abstract mixin class $SDUIWidgetModelCopyWith<$Res> { + factory $SDUIWidgetModelCopyWith(SDUIWidgetModel value, $Res Function(SDUIWidgetModel) _then) = _$SDUIWidgetModelCopyWithImpl; +@useResult +$Res call({ + bool visible +}); + + + + +} +/// @nodoc +class _$SDUIWidgetModelCopyWithImpl<$Res> + implements $SDUIWidgetModelCopyWith<$Res> { + _$SDUIWidgetModelCopyWithImpl(this._self, this._then); + + final SDUIWidgetModel _self; + final $Res Function(SDUIWidgetModel) _then; + +/// Create a copy of SDUIWidgetModel +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? visible = null,}) { + return _then(_self.copyWith( +visible: null == visible ? _self.visible : visible // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + +} + + +/// Adds pattern-matching-related methods to [SDUIWidgetModel]. +extension SDUIWidgetModelPatterns on SDUIWidgetModel { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap({TResult Function( _TextFormField value)? textFormField,TResult Function( _CardLabelItem value)? cardLabelItem,TResult Function( _ChipSelection value)? chipSelection,TResult Function( _Dropdown value)? dropdown,TResult Function( _ImagePicker value)? imagePicker,TResult Function( _Column value)? column,TResult Function( _Row value)? row,TResult Function( _SizedBox value)? sizedBox,TResult Function( _Stepper value)? stepper,TResult Function( _PageView value)? pageView,required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _TextFormField() when textFormField != null: +return textFormField(_that);case _CardLabelItem() when cardLabelItem != null: +return cardLabelItem(_that);case _ChipSelection() when chipSelection != null: +return chipSelection(_that);case _Dropdown() when dropdown != null: +return dropdown(_that);case _ImagePicker() when imagePicker != null: +return imagePicker(_that);case _Column() when column != null: +return column(_that);case _Row() when row != null: +return row(_that);case _SizedBox() when sizedBox != null: +return sizedBox(_that);case _Stepper() when stepper != null: +return stepper(_that);case _PageView() when pageView != null: +return pageView(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map({required TResult Function( _TextFormField value) textFormField,required TResult Function( _CardLabelItem value) cardLabelItem,required TResult Function( _ChipSelection value) chipSelection,required TResult Function( _Dropdown value) dropdown,required TResult Function( _ImagePicker value) imagePicker,required TResult Function( _Column value) column,required TResult Function( _Row value) row,required TResult Function( _SizedBox value) sizedBox,required TResult Function( _Stepper value) stepper,required TResult Function( _PageView value) pageView,}){ +final _that = this; +switch (_that) { +case _TextFormField(): +return textFormField(_that);case _CardLabelItem(): +return cardLabelItem(_that);case _ChipSelection(): +return chipSelection(_that);case _Dropdown(): +return dropdown(_that);case _ImagePicker(): +return imagePicker(_that);case _Column(): +return column(_that);case _Row(): +return row(_that);case _SizedBox(): +return sizedBox(_that);case _Stepper(): +return stepper(_that);case _PageView(): +return pageView(_that);} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull({TResult? Function( _TextFormField value)? textFormField,TResult? Function( _CardLabelItem value)? cardLabelItem,TResult? Function( _ChipSelection value)? chipSelection,TResult? Function( _Dropdown value)? dropdown,TResult? Function( _ImagePicker value)? imagePicker,TResult? Function( _Column value)? column,TResult? Function( _Row value)? row,TResult? Function( _SizedBox value)? sizedBox,TResult? Function( _Stepper value)? stepper,TResult? Function( _PageView value)? pageView,}){ +final _that = this; +switch (_that) { +case _TextFormField() when textFormField != null: +return textFormField(_that);case _CardLabelItem() when cardLabelItem != null: +return cardLabelItem(_that);case _ChipSelection() when chipSelection != null: +return chipSelection(_that);case _Dropdown() when dropdown != null: +return dropdown(_that);case _ImagePicker() when imagePicker != null: +return imagePicker(_that);case _Column() when column != null: +return column(_that);case _Row() when row != null: +return row(_that);case _SizedBox() when sizedBox != null: +return sizedBox(_that);case _Stepper() when stepper != null: +return stepper(_that);case _PageView() when pageView != null: +return pageView(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen({TResult Function( TextFormFieldSDUIModel data, bool visible)? textFormField,TResult Function( CardLabelItemData data, SDUIWidgetModel? child, List? children, bool visible, String? visibleCondition)? cardLabelItem,TResult Function( ChipSelectionSDUIModel data, bool visible)? chipSelection,TResult Function( DropdownSDUIModel data, bool visible)? dropdown,TResult Function( ImagePickerSDUIModel data, bool visible)? imagePicker,TResult Function( List children, double spacing, String mainAxisSize, double paddingHorizontal, double paddingVertical, String crossAxisAlignment, bool visible)? column,TResult Function( List children, double spacing, String mainAxisAlignment, bool visible)? row,TResult Function( double? width, double? height, bool visible)? sizedBox,TResult Function( StepperSDUIModel data, List? children, bool visible, int? index)? stepper,TResult Function( PageViewSDUIModel data, List children, bool visible)? pageView,required TResult orElse(),}) {final _that = this; +switch (_that) { +case _TextFormField() when textFormField != null: +return textFormField(_that.data,_that.visible);case _CardLabelItem() when cardLabelItem != null: +return cardLabelItem(_that.data,_that.child,_that.children,_that.visible,_that.visibleCondition);case _ChipSelection() when chipSelection != null: +return chipSelection(_that.data,_that.visible);case _Dropdown() when dropdown != null: +return dropdown(_that.data,_that.visible);case _ImagePicker() when imagePicker != null: +return imagePicker(_that.data,_that.visible);case _Column() when column != null: +return column(_that.children,_that.spacing,_that.mainAxisSize,_that.paddingHorizontal,_that.paddingVertical,_that.crossAxisAlignment,_that.visible);case _Row() when row != null: +return row(_that.children,_that.spacing,_that.mainAxisAlignment,_that.visible);case _SizedBox() when sizedBox != null: +return sizedBox(_that.width,_that.height,_that.visible);case _Stepper() when stepper != null: +return stepper(_that.data,_that.children,_that.visible,_that.index);case _PageView() when pageView != null: +return pageView(_that.data,_that.children,_that.visible);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when({required TResult Function( TextFormFieldSDUIModel data, bool visible) textFormField,required TResult Function( CardLabelItemData data, SDUIWidgetModel? child, List? children, bool visible, String? visibleCondition) cardLabelItem,required TResult Function( ChipSelectionSDUIModel data, bool visible) chipSelection,required TResult Function( DropdownSDUIModel data, bool visible) dropdown,required TResult Function( ImagePickerSDUIModel data, bool visible) imagePicker,required TResult Function( List children, double spacing, String mainAxisSize, double paddingHorizontal, double paddingVertical, String crossAxisAlignment, bool visible) column,required TResult Function( List children, double spacing, String mainAxisAlignment, bool visible) row,required TResult Function( double? width, double? height, bool visible) sizedBox,required TResult Function( StepperSDUIModel data, List? children, bool visible, int? index) stepper,required TResult Function( PageViewSDUIModel data, List children, bool visible) pageView,}) {final _that = this; +switch (_that) { +case _TextFormField(): +return textFormField(_that.data,_that.visible);case _CardLabelItem(): +return cardLabelItem(_that.data,_that.child,_that.children,_that.visible,_that.visibleCondition);case _ChipSelection(): +return chipSelection(_that.data,_that.visible);case _Dropdown(): +return dropdown(_that.data,_that.visible);case _ImagePicker(): +return imagePicker(_that.data,_that.visible);case _Column(): +return column(_that.children,_that.spacing,_that.mainAxisSize,_that.paddingHorizontal,_that.paddingVertical,_that.crossAxisAlignment,_that.visible);case _Row(): +return row(_that.children,_that.spacing,_that.mainAxisAlignment,_that.visible);case _SizedBox(): +return sizedBox(_that.width,_that.height,_that.visible);case _Stepper(): +return stepper(_that.data,_that.children,_that.visible,_that.index);case _PageView(): +return pageView(_that.data,_that.children,_that.visible);} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull({TResult? Function( TextFormFieldSDUIModel data, bool visible)? textFormField,TResult? Function( CardLabelItemData data, SDUIWidgetModel? child, List? children, bool visible, String? visibleCondition)? cardLabelItem,TResult? Function( ChipSelectionSDUIModel data, bool visible)? chipSelection,TResult? Function( DropdownSDUIModel data, bool visible)? dropdown,TResult? Function( ImagePickerSDUIModel data, bool visible)? imagePicker,TResult? Function( List children, double spacing, String mainAxisSize, double paddingHorizontal, double paddingVertical, String crossAxisAlignment, bool visible)? column,TResult? Function( List children, double spacing, String mainAxisAlignment, bool visible)? row,TResult? Function( double? width, double? height, bool visible)? sizedBox,TResult? Function( StepperSDUIModel data, List? children, bool visible, int? index)? stepper,TResult? Function( PageViewSDUIModel data, List children, bool visible)? pageView,}) {final _that = this; +switch (_that) { +case _TextFormField() when textFormField != null: +return textFormField(_that.data,_that.visible);case _CardLabelItem() when cardLabelItem != null: +return cardLabelItem(_that.data,_that.child,_that.children,_that.visible,_that.visibleCondition);case _ChipSelection() when chipSelection != null: +return chipSelection(_that.data,_that.visible);case _Dropdown() when dropdown != null: +return dropdown(_that.data,_that.visible);case _ImagePicker() when imagePicker != null: +return imagePicker(_that.data,_that.visible);case _Column() when column != null: +return column(_that.children,_that.spacing,_that.mainAxisSize,_that.paddingHorizontal,_that.paddingVertical,_that.crossAxisAlignment,_that.visible);case _Row() when row != null: +return row(_that.children,_that.spacing,_that.mainAxisAlignment,_that.visible);case _SizedBox() when sizedBox != null: +return sizedBox(_that.width,_that.height,_that.visible);case _Stepper() when stepper != null: +return stepper(_that.data,_that.children,_that.visible,_that.index);case _PageView() when pageView != null: +return pageView(_that.data,_that.children,_that.visible);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _TextFormField implements SDUIWidgetModel { + const _TextFormField({required this.data, this.visible = true, final String? $type}): $type = $type ?? 'text_form_field'; + factory _TextFormField.fromJson(Map json) => _$TextFormFieldFromJson(json); + + final TextFormFieldSDUIModel data; +@override@JsonKey() final bool visible; + +@JsonKey(name: 'type') +final String $type; + + +/// Create a copy of SDUIWidgetModel +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$TextFormFieldCopyWith<_TextFormField> get copyWith => __$TextFormFieldCopyWithImpl<_TextFormField>(this, _$identity); + +@override +Map toJson() { + return _$TextFormFieldToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _TextFormField&&(identical(other.data, data) || other.data == data)&&(identical(other.visible, visible) || other.visible == visible)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,data,visible); + +@override +String toString() { + return 'SDUIWidgetModel.textFormField(data: $data, visible: $visible)'; +} + + +} + +/// @nodoc +abstract mixin class _$TextFormFieldCopyWith<$Res> implements $SDUIWidgetModelCopyWith<$Res> { + factory _$TextFormFieldCopyWith(_TextFormField value, $Res Function(_TextFormField) _then) = __$TextFormFieldCopyWithImpl; +@override @useResult +$Res call({ + TextFormFieldSDUIModel data, bool visible +}); + + +$TextFormFieldSDUIModelCopyWith<$Res> get data; + +} +/// @nodoc +class __$TextFormFieldCopyWithImpl<$Res> + implements _$TextFormFieldCopyWith<$Res> { + __$TextFormFieldCopyWithImpl(this._self, this._then); + + final _TextFormField _self; + final $Res Function(_TextFormField) _then; + +/// Create a copy of SDUIWidgetModel +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? data = null,Object? visible = null,}) { + return _then(_TextFormField( +data: null == data ? _self.data : data // ignore: cast_nullable_to_non_nullable +as TextFormFieldSDUIModel,visible: null == visible ? _self.visible : visible // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + +/// Create a copy of SDUIWidgetModel +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$TextFormFieldSDUIModelCopyWith<$Res> get data { + + return $TextFormFieldSDUIModelCopyWith<$Res>(_self.data, (value) { + return _then(_self.copyWith(data: value)); + }); +} +} + +/// @nodoc +@JsonSerializable() + +class _CardLabelItem implements SDUIWidgetModel { + const _CardLabelItem({required this.data, this.child, final List? children, this.visible = true, this.visibleCondition, final String? $type}): _children = children,$type = $type ?? 'card_label_item'; + factory _CardLabelItem.fromJson(Map json) => _$CardLabelItemFromJson(json); + + final CardLabelItemData data; + final SDUIWidgetModel? child; + final List? _children; + List? get children { + final value = _children; + if (value == null) return null; + if (_children is EqualUnmodifiableListView) return _children; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); +} + +@override@JsonKey() final bool visible; + final String? visibleCondition; + +@JsonKey(name: 'type') +final String $type; + + +/// Create a copy of SDUIWidgetModel +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$CardLabelItemCopyWith<_CardLabelItem> get copyWith => __$CardLabelItemCopyWithImpl<_CardLabelItem>(this, _$identity); + +@override +Map toJson() { + return _$CardLabelItemToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _CardLabelItem&&(identical(other.data, data) || other.data == data)&&(identical(other.child, child) || other.child == child)&&const DeepCollectionEquality().equals(other._children, _children)&&(identical(other.visible, visible) || other.visible == visible)&&(identical(other.visibleCondition, visibleCondition) || other.visibleCondition == visibleCondition)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,data,child,const DeepCollectionEquality().hash(_children),visible,visibleCondition); + +@override +String toString() { + return 'SDUIWidgetModel.cardLabelItem(data: $data, child: $child, children: $children, visible: $visible, visibleCondition: $visibleCondition)'; +} + + +} + +/// @nodoc +abstract mixin class _$CardLabelItemCopyWith<$Res> implements $SDUIWidgetModelCopyWith<$Res> { + factory _$CardLabelItemCopyWith(_CardLabelItem value, $Res Function(_CardLabelItem) _then) = __$CardLabelItemCopyWithImpl; +@override @useResult +$Res call({ + CardLabelItemData data, SDUIWidgetModel? child, List? children, bool visible, String? visibleCondition +}); + + +$CardLabelItemDataCopyWith<$Res> get data;$SDUIWidgetModelCopyWith<$Res>? get child; + +} +/// @nodoc +class __$CardLabelItemCopyWithImpl<$Res> + implements _$CardLabelItemCopyWith<$Res> { + __$CardLabelItemCopyWithImpl(this._self, this._then); + + final _CardLabelItem _self; + final $Res Function(_CardLabelItem) _then; + +/// Create a copy of SDUIWidgetModel +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? data = null,Object? child = freezed,Object? children = freezed,Object? visible = null,Object? visibleCondition = freezed,}) { + return _then(_CardLabelItem( +data: null == data ? _self.data : data // ignore: cast_nullable_to_non_nullable +as CardLabelItemData,child: freezed == child ? _self.child : child // ignore: cast_nullable_to_non_nullable +as SDUIWidgetModel?,children: freezed == children ? _self._children : children // ignore: cast_nullable_to_non_nullable +as List?,visible: null == visible ? _self.visible : visible // ignore: cast_nullable_to_non_nullable +as bool,visibleCondition: freezed == visibleCondition ? _self.visibleCondition : visibleCondition // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + +/// Create a copy of SDUIWidgetModel +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$CardLabelItemDataCopyWith<$Res> get data { + + return $CardLabelItemDataCopyWith<$Res>(_self.data, (value) { + return _then(_self.copyWith(data: value)); + }); +}/// Create a copy of SDUIWidgetModel +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$SDUIWidgetModelCopyWith<$Res>? get child { + if (_self.child == null) { + return null; + } + + return $SDUIWidgetModelCopyWith<$Res>(_self.child!, (value) { + return _then(_self.copyWith(child: value)); + }); +} +} + +/// @nodoc +@JsonSerializable() + +class _ChipSelection implements SDUIWidgetModel { + const _ChipSelection({required this.data, this.visible = true, final String? $type}): $type = $type ?? 'chip_selection'; + factory _ChipSelection.fromJson(Map json) => _$ChipSelectionFromJson(json); + + final ChipSelectionSDUIModel data; +@override@JsonKey() final bool visible; + +@JsonKey(name: 'type') +final String $type; + + +/// Create a copy of SDUIWidgetModel +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$ChipSelectionCopyWith<_ChipSelection> get copyWith => __$ChipSelectionCopyWithImpl<_ChipSelection>(this, _$identity); + +@override +Map toJson() { + return _$ChipSelectionToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ChipSelection&&(identical(other.data, data) || other.data == data)&&(identical(other.visible, visible) || other.visible == visible)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,data,visible); + +@override +String toString() { + return 'SDUIWidgetModel.chipSelection(data: $data, visible: $visible)'; +} + + +} + +/// @nodoc +abstract mixin class _$ChipSelectionCopyWith<$Res> implements $SDUIWidgetModelCopyWith<$Res> { + factory _$ChipSelectionCopyWith(_ChipSelection value, $Res Function(_ChipSelection) _then) = __$ChipSelectionCopyWithImpl; +@override @useResult +$Res call({ + ChipSelectionSDUIModel data, bool visible +}); + + +$ChipSelectionSDUIModelCopyWith<$Res> get data; + +} +/// @nodoc +class __$ChipSelectionCopyWithImpl<$Res> + implements _$ChipSelectionCopyWith<$Res> { + __$ChipSelectionCopyWithImpl(this._self, this._then); + + final _ChipSelection _self; + final $Res Function(_ChipSelection) _then; + +/// Create a copy of SDUIWidgetModel +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? data = null,Object? visible = null,}) { + return _then(_ChipSelection( +data: null == data ? _self.data : data // ignore: cast_nullable_to_non_nullable +as ChipSelectionSDUIModel,visible: null == visible ? _self.visible : visible // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + +/// Create a copy of SDUIWidgetModel +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ChipSelectionSDUIModelCopyWith<$Res> get data { + + return $ChipSelectionSDUIModelCopyWith<$Res>(_self.data, (value) { + return _then(_self.copyWith(data: value)); + }); +} +} + +/// @nodoc +@JsonSerializable() + +class _Dropdown implements SDUIWidgetModel { + const _Dropdown({required this.data, this.visible = true, final String? $type}): $type = $type ?? 'dropdown'; + factory _Dropdown.fromJson(Map json) => _$DropdownFromJson(json); + + final DropdownSDUIModel data; +@override@JsonKey() final bool visible; + +@JsonKey(name: 'type') +final String $type; + + +/// Create a copy of SDUIWidgetModel +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$DropdownCopyWith<_Dropdown> get copyWith => __$DropdownCopyWithImpl<_Dropdown>(this, _$identity); + +@override +Map toJson() { + return _$DropdownToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Dropdown&&(identical(other.data, data) || other.data == data)&&(identical(other.visible, visible) || other.visible == visible)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,data,visible); + +@override +String toString() { + return 'SDUIWidgetModel.dropdown(data: $data, visible: $visible)'; +} + + +} + +/// @nodoc +abstract mixin class _$DropdownCopyWith<$Res> implements $SDUIWidgetModelCopyWith<$Res> { + factory _$DropdownCopyWith(_Dropdown value, $Res Function(_Dropdown) _then) = __$DropdownCopyWithImpl; +@override @useResult +$Res call({ + DropdownSDUIModel data, bool visible +}); + + +$DropdownSDUIModelCopyWith<$Res> get data; + +} +/// @nodoc +class __$DropdownCopyWithImpl<$Res> + implements _$DropdownCopyWith<$Res> { + __$DropdownCopyWithImpl(this._self, this._then); + + final _Dropdown _self; + final $Res Function(_Dropdown) _then; + +/// Create a copy of SDUIWidgetModel +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? data = null,Object? visible = null,}) { + return _then(_Dropdown( +data: null == data ? _self.data : data // ignore: cast_nullable_to_non_nullable +as DropdownSDUIModel,visible: null == visible ? _self.visible : visible // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + +/// Create a copy of SDUIWidgetModel +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$DropdownSDUIModelCopyWith<$Res> get data { + + return $DropdownSDUIModelCopyWith<$Res>(_self.data, (value) { + return _then(_self.copyWith(data: value)); + }); +} +} + +/// @nodoc +@JsonSerializable() + +class _ImagePicker implements SDUIWidgetModel { + const _ImagePicker({required this.data, this.visible = true, final String? $type}): $type = $type ?? 'image_picker'; + factory _ImagePicker.fromJson(Map json) => _$ImagePickerFromJson(json); + + final ImagePickerSDUIModel data; +@override@JsonKey() final bool visible; + +@JsonKey(name: 'type') +final String $type; + + +/// Create a copy of SDUIWidgetModel +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$ImagePickerCopyWith<_ImagePicker> get copyWith => __$ImagePickerCopyWithImpl<_ImagePicker>(this, _$identity); + +@override +Map toJson() { + return _$ImagePickerToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ImagePicker&&(identical(other.data, data) || other.data == data)&&(identical(other.visible, visible) || other.visible == visible)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,data,visible); + +@override +String toString() { + return 'SDUIWidgetModel.imagePicker(data: $data, visible: $visible)'; +} + + +} + +/// @nodoc +abstract mixin class _$ImagePickerCopyWith<$Res> implements $SDUIWidgetModelCopyWith<$Res> { + factory _$ImagePickerCopyWith(_ImagePicker value, $Res Function(_ImagePicker) _then) = __$ImagePickerCopyWithImpl; +@override @useResult +$Res call({ + ImagePickerSDUIModel data, bool visible +}); + + +$ImagePickerSDUIModelCopyWith<$Res> get data; + +} +/// @nodoc +class __$ImagePickerCopyWithImpl<$Res> + implements _$ImagePickerCopyWith<$Res> { + __$ImagePickerCopyWithImpl(this._self, this._then); + + final _ImagePicker _self; + final $Res Function(_ImagePicker) _then; + +/// Create a copy of SDUIWidgetModel +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? data = null,Object? visible = null,}) { + return _then(_ImagePicker( +data: null == data ? _self.data : data // ignore: cast_nullable_to_non_nullable +as ImagePickerSDUIModel,visible: null == visible ? _self.visible : visible // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + +/// Create a copy of SDUIWidgetModel +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ImagePickerSDUIModelCopyWith<$Res> get data { + + return $ImagePickerSDUIModelCopyWith<$Res>(_self.data, (value) { + return _then(_self.copyWith(data: value)); + }); +} +} + +/// @nodoc +@JsonSerializable() + +class _Column implements SDUIWidgetModel { + const _Column({required final List children, this.spacing = 0.0, this.mainAxisSize = 'max', this.paddingHorizontal = 0.0, this.paddingVertical = 0.0, this.crossAxisAlignment = 'center', this.visible = true, final String? $type}): _children = children,$type = $type ?? 'column'; + factory _Column.fromJson(Map json) => _$ColumnFromJson(json); + + final List _children; + List get children { + if (_children is EqualUnmodifiableListView) return _children; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_children); +} + +@JsonKey() final double spacing; +@JsonKey() final String mainAxisSize; +@JsonKey() final double paddingHorizontal; +@JsonKey() final double paddingVertical; +@JsonKey() final String crossAxisAlignment; +@override@JsonKey() final bool visible; + +@JsonKey(name: 'type') +final String $type; + + +/// Create a copy of SDUIWidgetModel +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$ColumnCopyWith<_Column> get copyWith => __$ColumnCopyWithImpl<_Column>(this, _$identity); + +@override +Map toJson() { + return _$ColumnToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Column&&const DeepCollectionEquality().equals(other._children, _children)&&(identical(other.spacing, spacing) || other.spacing == spacing)&&(identical(other.mainAxisSize, mainAxisSize) || other.mainAxisSize == mainAxisSize)&&(identical(other.paddingHorizontal, paddingHorizontal) || other.paddingHorizontal == paddingHorizontal)&&(identical(other.paddingVertical, paddingVertical) || other.paddingVertical == paddingVertical)&&(identical(other.crossAxisAlignment, crossAxisAlignment) || other.crossAxisAlignment == crossAxisAlignment)&&(identical(other.visible, visible) || other.visible == visible)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_children),spacing,mainAxisSize,paddingHorizontal,paddingVertical,crossAxisAlignment,visible); + +@override +String toString() { + return 'SDUIWidgetModel.column(children: $children, spacing: $spacing, mainAxisSize: $mainAxisSize, paddingHorizontal: $paddingHorizontal, paddingVertical: $paddingVertical, crossAxisAlignment: $crossAxisAlignment, visible: $visible)'; +} + + +} + +/// @nodoc +abstract mixin class _$ColumnCopyWith<$Res> implements $SDUIWidgetModelCopyWith<$Res> { + factory _$ColumnCopyWith(_Column value, $Res Function(_Column) _then) = __$ColumnCopyWithImpl; +@override @useResult +$Res call({ + List children, double spacing, String mainAxisSize, double paddingHorizontal, double paddingVertical, String crossAxisAlignment, bool visible +}); + + + + +} +/// @nodoc +class __$ColumnCopyWithImpl<$Res> + implements _$ColumnCopyWith<$Res> { + __$ColumnCopyWithImpl(this._self, this._then); + + final _Column _self; + final $Res Function(_Column) _then; + +/// Create a copy of SDUIWidgetModel +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? children = null,Object? spacing = null,Object? mainAxisSize = null,Object? paddingHorizontal = null,Object? paddingVertical = null,Object? crossAxisAlignment = null,Object? visible = null,}) { + return _then(_Column( +children: null == children ? _self._children : children // ignore: cast_nullable_to_non_nullable +as List,spacing: null == spacing ? _self.spacing : spacing // ignore: cast_nullable_to_non_nullable +as double,mainAxisSize: null == mainAxisSize ? _self.mainAxisSize : mainAxisSize // ignore: cast_nullable_to_non_nullable +as String,paddingHorizontal: null == paddingHorizontal ? _self.paddingHorizontal : paddingHorizontal // ignore: cast_nullable_to_non_nullable +as double,paddingVertical: null == paddingVertical ? _self.paddingVertical : paddingVertical // ignore: cast_nullable_to_non_nullable +as double,crossAxisAlignment: null == crossAxisAlignment ? _self.crossAxisAlignment : crossAxisAlignment // ignore: cast_nullable_to_non_nullable +as String,visible: null == visible ? _self.visible : visible // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + + +} + +/// @nodoc +@JsonSerializable() + +class _Row implements SDUIWidgetModel { + const _Row({required final List children, this.spacing = 0.0, this.mainAxisAlignment = 'start', this.visible = true, final String? $type}): _children = children,$type = $type ?? 'row'; + factory _Row.fromJson(Map json) => _$RowFromJson(json); + + final List _children; + List get children { + if (_children is EqualUnmodifiableListView) return _children; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_children); +} + +@JsonKey() final double spacing; +@JsonKey() final String mainAxisAlignment; +@override@JsonKey() final bool visible; + +@JsonKey(name: 'type') +final String $type; + + +/// Create a copy of SDUIWidgetModel +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$RowCopyWith<_Row> get copyWith => __$RowCopyWithImpl<_Row>(this, _$identity); + +@override +Map toJson() { + return _$RowToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Row&&const DeepCollectionEquality().equals(other._children, _children)&&(identical(other.spacing, spacing) || other.spacing == spacing)&&(identical(other.mainAxisAlignment, mainAxisAlignment) || other.mainAxisAlignment == mainAxisAlignment)&&(identical(other.visible, visible) || other.visible == visible)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_children),spacing,mainAxisAlignment,visible); + +@override +String toString() { + return 'SDUIWidgetModel.row(children: $children, spacing: $spacing, mainAxisAlignment: $mainAxisAlignment, visible: $visible)'; +} + + +} + +/// @nodoc +abstract mixin class _$RowCopyWith<$Res> implements $SDUIWidgetModelCopyWith<$Res> { + factory _$RowCopyWith(_Row value, $Res Function(_Row) _then) = __$RowCopyWithImpl; +@override @useResult +$Res call({ + List children, double spacing, String mainAxisAlignment, bool visible +}); + + + + +} +/// @nodoc +class __$RowCopyWithImpl<$Res> + implements _$RowCopyWith<$Res> { + __$RowCopyWithImpl(this._self, this._then); + + final _Row _self; + final $Res Function(_Row) _then; + +/// Create a copy of SDUIWidgetModel +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? children = null,Object? spacing = null,Object? mainAxisAlignment = null,Object? visible = null,}) { + return _then(_Row( +children: null == children ? _self._children : children // ignore: cast_nullable_to_non_nullable +as List,spacing: null == spacing ? _self.spacing : spacing // ignore: cast_nullable_to_non_nullable +as double,mainAxisAlignment: null == mainAxisAlignment ? _self.mainAxisAlignment : mainAxisAlignment // ignore: cast_nullable_to_non_nullable +as String,visible: null == visible ? _self.visible : visible // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + + +} + +/// @nodoc +@JsonSerializable() + +class _SizedBox implements SDUIWidgetModel { + const _SizedBox({this.width, this.height, this.visible = true, final String? $type}): $type = $type ?? 'sized_box'; + factory _SizedBox.fromJson(Map json) => _$SizedBoxFromJson(json); + + final double? width; + final double? height; +@override@JsonKey() final bool visible; + +@JsonKey(name: 'type') +final String $type; + + +/// Create a copy of SDUIWidgetModel +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$SizedBoxCopyWith<_SizedBox> get copyWith => __$SizedBoxCopyWithImpl<_SizedBox>(this, _$identity); + +@override +Map toJson() { + return _$SizedBoxToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _SizedBox&&(identical(other.width, width) || other.width == width)&&(identical(other.height, height) || other.height == height)&&(identical(other.visible, visible) || other.visible == visible)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,width,height,visible); + +@override +String toString() { + return 'SDUIWidgetModel.sizedBox(width: $width, height: $height, visible: $visible)'; +} + + +} + +/// @nodoc +abstract mixin class _$SizedBoxCopyWith<$Res> implements $SDUIWidgetModelCopyWith<$Res> { + factory _$SizedBoxCopyWith(_SizedBox value, $Res Function(_SizedBox) _then) = __$SizedBoxCopyWithImpl; +@override @useResult +$Res call({ + double? width, double? height, bool visible +}); + + + + +} +/// @nodoc +class __$SizedBoxCopyWithImpl<$Res> + implements _$SizedBoxCopyWith<$Res> { + __$SizedBoxCopyWithImpl(this._self, this._then); + + final _SizedBox _self; + final $Res Function(_SizedBox) _then; + +/// Create a copy of SDUIWidgetModel +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? width = freezed,Object? height = freezed,Object? visible = null,}) { + return _then(_SizedBox( +width: freezed == width ? _self.width : width // ignore: cast_nullable_to_non_nullable +as double?,height: freezed == height ? _self.height : height // ignore: cast_nullable_to_non_nullable +as double?,visible: null == visible ? _self.visible : visible // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + + +} + +/// @nodoc +@JsonSerializable() + +class _Stepper implements SDUIWidgetModel { + const _Stepper({required this.data, final List? children, this.visible = true, this.index, final String? $type}): _children = children,$type = $type ?? 'stepper'; + factory _Stepper.fromJson(Map json) => _$StepperFromJson(json); + + final StepperSDUIModel data; + final List? _children; + List? get children { + final value = _children; + if (value == null) return null; + if (_children is EqualUnmodifiableListView) return _children; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); +} + +@override@JsonKey() final bool visible; + final int? index; + +@JsonKey(name: 'type') +final String $type; + + +/// Create a copy of SDUIWidgetModel +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$StepperCopyWith<_Stepper> get copyWith => __$StepperCopyWithImpl<_Stepper>(this, _$identity); + +@override +Map toJson() { + return _$StepperToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Stepper&&(identical(other.data, data) || other.data == data)&&const DeepCollectionEquality().equals(other._children, _children)&&(identical(other.visible, visible) || other.visible == visible)&&(identical(other.index, index) || other.index == index)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,data,const DeepCollectionEquality().hash(_children),visible,index); + +@override +String toString() { + return 'SDUIWidgetModel.stepper(data: $data, children: $children, visible: $visible, index: $index)'; +} + + +} + +/// @nodoc +abstract mixin class _$StepperCopyWith<$Res> implements $SDUIWidgetModelCopyWith<$Res> { + factory _$StepperCopyWith(_Stepper value, $Res Function(_Stepper) _then) = __$StepperCopyWithImpl; +@override @useResult +$Res call({ + StepperSDUIModel data, List? children, bool visible, int? index +}); + + +$StepperSDUIModelCopyWith<$Res> get data; + +} +/// @nodoc +class __$StepperCopyWithImpl<$Res> + implements _$StepperCopyWith<$Res> { + __$StepperCopyWithImpl(this._self, this._then); + + final _Stepper _self; + final $Res Function(_Stepper) _then; + +/// Create a copy of SDUIWidgetModel +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? data = null,Object? children = freezed,Object? visible = null,Object? index = freezed,}) { + return _then(_Stepper( +data: null == data ? _self.data : data // ignore: cast_nullable_to_non_nullable +as StepperSDUIModel,children: freezed == children ? _self._children : children // ignore: cast_nullable_to_non_nullable +as List?,visible: null == visible ? _self.visible : visible // ignore: cast_nullable_to_non_nullable +as bool,index: freezed == index ? _self.index : index // ignore: cast_nullable_to_non_nullable +as int?, + )); +} + +/// Create a copy of SDUIWidgetModel +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$StepperSDUIModelCopyWith<$Res> get data { + + return $StepperSDUIModelCopyWith<$Res>(_self.data, (value) { + return _then(_self.copyWith(data: value)); + }); +} +} + +/// @nodoc +@JsonSerializable() + +class _PageView implements SDUIWidgetModel { + const _PageView({required this.data, required final List children, this.visible = true, final String? $type}): _children = children,$type = $type ?? 'page_view'; + factory _PageView.fromJson(Map json) => _$PageViewFromJson(json); + + final PageViewSDUIModel data; + final List _children; + List get children { + if (_children is EqualUnmodifiableListView) return _children; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_children); +} + +@override@JsonKey() final bool visible; + +@JsonKey(name: 'type') +final String $type; + + +/// Create a copy of SDUIWidgetModel +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$PageViewCopyWith<_PageView> get copyWith => __$PageViewCopyWithImpl<_PageView>(this, _$identity); + +@override +Map toJson() { + return _$PageViewToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _PageView&&(identical(other.data, data) || other.data == data)&&const DeepCollectionEquality().equals(other._children, _children)&&(identical(other.visible, visible) || other.visible == visible)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,data,const DeepCollectionEquality().hash(_children),visible); + +@override +String toString() { + return 'SDUIWidgetModel.pageView(data: $data, children: $children, visible: $visible)'; +} + + +} + +/// @nodoc +abstract mixin class _$PageViewCopyWith<$Res> implements $SDUIWidgetModelCopyWith<$Res> { + factory _$PageViewCopyWith(_PageView value, $Res Function(_PageView) _then) = __$PageViewCopyWithImpl; +@override @useResult +$Res call({ + PageViewSDUIModel data, List children, bool visible +}); + + +$PageViewSDUIModelCopyWith<$Res> get data; + +} +/// @nodoc +class __$PageViewCopyWithImpl<$Res> + implements _$PageViewCopyWith<$Res> { + __$PageViewCopyWithImpl(this._self, this._then); + + final _PageView _self; + final $Res Function(_PageView) _then; + +/// Create a copy of SDUIWidgetModel +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? data = null,Object? children = null,Object? visible = null,}) { + return _then(_PageView( +data: null == data ? _self.data : data // ignore: cast_nullable_to_non_nullable +as PageViewSDUIModel,children: null == children ? _self._children : children // ignore: cast_nullable_to_non_nullable +as List,visible: null == visible ? _self.visible : visible // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + +/// Create a copy of SDUIWidgetModel +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$PageViewSDUIModelCopyWith<$Res> get data { + + return $PageViewSDUIModelCopyWith<$Res>(_self.data, (value) { + return _then(_self.copyWith(data: value)); + }); +} +} + +// dart format on diff --git a/packages/chicken/lib/presentation/widget/sdui/model/sdui_widget.g.dart b/packages/chicken/lib/presentation/widget/sdui/model/sdui_widget.g.dart new file mode 100644 index 0000000..a342029 --- /dev/null +++ b/packages/chicken/lib/presentation/widget/sdui/model/sdui_widget.g.dart @@ -0,0 +1,178 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'sdui_widget.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_TextFormField _$TextFormFieldFromJson(Map json) => + _TextFormField( + data: TextFormFieldSDUIModel.fromJson( + json['data'] as Map, + ), + visible: json['visible'] as bool? ?? true, + $type: json['type'] as String?, + ); + +Map _$TextFormFieldToJson(_TextFormField instance) => + { + 'data': instance.data, + 'visible': instance.visible, + 'type': instance.$type, + }; + +_CardLabelItem _$CardLabelItemFromJson(Map json) => + _CardLabelItem( + data: CardLabelItemData.fromJson(json['data'] as Map), + child: json['child'] == null + ? null + : SDUIWidgetModel.fromJson(json['child'] as Map), + children: (json['children'] as List?) + ?.map((e) => SDUIWidgetModel.fromJson(e as Map)) + .toList(), + visible: json['visible'] as bool? ?? true, + visibleCondition: json['visible_condition'] as String?, + $type: json['type'] as String?, + ); + +Map _$CardLabelItemToJson(_CardLabelItem instance) => + { + 'data': instance.data, + 'child': instance.child, + 'children': instance.children, + 'visible': instance.visible, + 'visible_condition': instance.visibleCondition, + 'type': instance.$type, + }; + +_ChipSelection _$ChipSelectionFromJson(Map json) => + _ChipSelection( + data: ChipSelectionSDUIModel.fromJson( + json['data'] as Map, + ), + visible: json['visible'] as bool? ?? true, + $type: json['type'] as String?, + ); + +Map _$ChipSelectionToJson(_ChipSelection instance) => + { + 'data': instance.data, + 'visible': instance.visible, + 'type': instance.$type, + }; + +_Dropdown _$DropdownFromJson(Map json) => _Dropdown( + data: DropdownSDUIModel.fromJson(json['data'] as Map), + visible: json['visible'] as bool? ?? true, + $type: json['type'] as String?, +); + +Map _$DropdownToJson(_Dropdown instance) => { + 'data': instance.data, + 'visible': instance.visible, + 'type': instance.$type, +}; + +_ImagePicker _$ImagePickerFromJson(Map json) => _ImagePicker( + data: ImagePickerSDUIModel.fromJson(json['data'] as Map), + visible: json['visible'] as bool? ?? true, + $type: json['type'] as String?, +); + +Map _$ImagePickerToJson(_ImagePicker instance) => + { + 'data': instance.data, + 'visible': instance.visible, + 'type': instance.$type, + }; + +_Column _$ColumnFromJson(Map json) => _Column( + children: (json['children'] as List) + .map((e) => SDUIWidgetModel.fromJson(e as Map)) + .toList(), + spacing: (json['spacing'] as num?)?.toDouble() ?? 0.0, + mainAxisSize: json['main_axis_size'] as String? ?? 'max', + paddingHorizontal: (json['padding_horizontal'] as num?)?.toDouble() ?? 0.0, + paddingVertical: (json['padding_vertical'] as num?)?.toDouble() ?? 0.0, + crossAxisAlignment: json['cross_axis_alignment'] as String? ?? 'center', + visible: json['visible'] as bool? ?? true, + $type: json['type'] as String?, +); + +Map _$ColumnToJson(_Column instance) => { + 'children': instance.children, + 'spacing': instance.spacing, + 'main_axis_size': instance.mainAxisSize, + 'padding_horizontal': instance.paddingHorizontal, + 'padding_vertical': instance.paddingVertical, + 'cross_axis_alignment': instance.crossAxisAlignment, + 'visible': instance.visible, + 'type': instance.$type, +}; + +_Row _$RowFromJson(Map json) => _Row( + children: (json['children'] as List) + .map((e) => SDUIWidgetModel.fromJson(e as Map)) + .toList(), + spacing: (json['spacing'] as num?)?.toDouble() ?? 0.0, + mainAxisAlignment: json['main_axis_alignment'] as String? ?? 'start', + visible: json['visible'] as bool? ?? true, + $type: json['type'] as String?, +); + +Map _$RowToJson(_Row instance) => { + 'children': instance.children, + 'spacing': instance.spacing, + 'main_axis_alignment': instance.mainAxisAlignment, + 'visible': instance.visible, + 'type': instance.$type, +}; + +_SizedBox _$SizedBoxFromJson(Map json) => _SizedBox( + width: (json['width'] as num?)?.toDouble(), + height: (json['height'] as num?)?.toDouble(), + visible: json['visible'] as bool? ?? true, + $type: json['type'] as String?, +); + +Map _$SizedBoxToJson(_SizedBox instance) => { + 'width': instance.width, + 'height': instance.height, + 'visible': instance.visible, + 'type': instance.$type, +}; + +_Stepper _$StepperFromJson(Map json) => _Stepper( + data: StepperSDUIModel.fromJson(json['data'] as Map), + children: (json['children'] as List?) + ?.map((e) => SDUIWidgetModel.fromJson(e as Map)) + .toList(), + visible: json['visible'] as bool? ?? true, + index: (json['index'] as num?)?.toInt(), + $type: json['type'] as String?, +); + +Map _$StepperToJson(_Stepper instance) => { + 'data': instance.data, + 'children': instance.children, + 'visible': instance.visible, + 'index': instance.index, + 'type': instance.$type, +}; + +_PageView _$PageViewFromJson(Map json) => _PageView( + data: PageViewSDUIModel.fromJson(json['data'] as Map), + children: (json['children'] as List) + .map((e) => SDUIWidgetModel.fromJson(e as Map)) + .toList(), + visible: json['visible'] as bool? ?? true, + $type: json['type'] as String?, +); + +Map _$PageViewToJson(_PageView instance) => { + 'data': instance.data, + 'children': instance.children, + 'visible': instance.visible, + 'type': instance.$type, +}; diff --git a/packages/chicken/lib/presentation/widget/sdui/model/sdui_widget_model.dart b/packages/chicken/lib/presentation/widget/sdui/model/sdui_widget_model.dart deleted file mode 100644 index 53be8d8..0000000 --- a/packages/chicken/lib/presentation/widget/sdui/model/sdui_widget_model.dart +++ /dev/null @@ -1,18 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'sdui_widget_model.freezed.dart'; -part 'sdui_widget_model.g.dart'; - -@freezed -abstract class SDUIWidgetModel with _$SDUIWidgetModel { - const factory SDUIWidgetModel({ - String? type, - bool? visible, - Map? data, - Map? child, - List>? children, - }) = _SDUIWidgetModel; - - factory SDUIWidgetModel.fromJson(Map json) => - _$SDUIWidgetModelFromJson(json); -} diff --git a/packages/chicken/lib/presentation/widget/sdui/model/sdui_widget_model.freezed.dart b/packages/chicken/lib/presentation/widget/sdui/model/sdui_widget_model.freezed.dart deleted file mode 100644 index e4a3905..0000000 --- a/packages/chicken/lib/presentation/widget/sdui/model/sdui_widget_model.freezed.dart +++ /dev/null @@ -1,313 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND -// coverage:ignore-file -// ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark - -part of 'sdui_widget_model.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -// dart format off -T _$identity(T value) => value; - -/// @nodoc -mixin _$SDUIWidgetModel { - - String? get type; bool? get visible; Map? get data; Map? get child; List>? get children; -/// Create a copy of SDUIWidgetModel -/// with the given fields replaced by the non-null parameter values. -@JsonKey(includeFromJson: false, includeToJson: false) -@pragma('vm:prefer-inline') -$SDUIWidgetModelCopyWith get copyWith => _$SDUIWidgetModelCopyWithImpl(this as SDUIWidgetModel, _$identity); - - /// Serializes this SDUIWidgetModel to a JSON map. - Map toJson(); - - -@override -bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is SDUIWidgetModel&&(identical(other.type, type) || other.type == type)&&(identical(other.visible, visible) || other.visible == visible)&&const DeepCollectionEquality().equals(other.data, data)&&const DeepCollectionEquality().equals(other.child, child)&&const DeepCollectionEquality().equals(other.children, children)); -} - -@JsonKey(includeFromJson: false, includeToJson: false) -@override -int get hashCode => Object.hash(runtimeType,type,visible,const DeepCollectionEquality().hash(data),const DeepCollectionEquality().hash(child),const DeepCollectionEquality().hash(children)); - -@override -String toString() { - return 'SDUIWidgetModel(type: $type, visible: $visible, data: $data, child: $child, children: $children)'; -} - - -} - -/// @nodoc -abstract mixin class $SDUIWidgetModelCopyWith<$Res> { - factory $SDUIWidgetModelCopyWith(SDUIWidgetModel value, $Res Function(SDUIWidgetModel) _then) = _$SDUIWidgetModelCopyWithImpl; -@useResult -$Res call({ - String? type, bool? visible, Map? data, Map? child, List>? children -}); - - - - -} -/// @nodoc -class _$SDUIWidgetModelCopyWithImpl<$Res> - implements $SDUIWidgetModelCopyWith<$Res> { - _$SDUIWidgetModelCopyWithImpl(this._self, this._then); - - final SDUIWidgetModel _self; - final $Res Function(SDUIWidgetModel) _then; - -/// Create a copy of SDUIWidgetModel -/// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? type = freezed,Object? visible = freezed,Object? data = freezed,Object? child = freezed,Object? children = freezed,}) { - return _then(_self.copyWith( -type: freezed == type ? _self.type : type // ignore: cast_nullable_to_non_nullable -as String?,visible: freezed == visible ? _self.visible : visible // ignore: cast_nullable_to_non_nullable -as bool?,data: freezed == data ? _self.data : data // ignore: cast_nullable_to_non_nullable -as Map?,child: freezed == child ? _self.child : child // ignore: cast_nullable_to_non_nullable -as Map?,children: freezed == children ? _self.children : children // ignore: cast_nullable_to_non_nullable -as List>?, - )); -} - -} - - -/// Adds pattern-matching-related methods to [SDUIWidgetModel]. -extension SDUIWidgetModelPatterns on SDUIWidgetModel { -/// A variant of `map` that fallback to returning `orElse`. -/// -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case final Subclass value: -/// return ...; -/// case _: -/// return orElse(); -/// } -/// ``` - -@optionalTypeArgs TResult maybeMap(TResult Function( _SDUIWidgetModel value)? $default,{required TResult orElse(),}){ -final _that = this; -switch (_that) { -case _SDUIWidgetModel() when $default != null: -return $default(_that);case _: - return orElse(); - -} -} -/// A `switch`-like method, using callbacks. -/// -/// Callbacks receives the raw object, upcasted. -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case final Subclass value: -/// return ...; -/// case final Subclass2 value: -/// return ...; -/// } -/// ``` - -@optionalTypeArgs TResult map(TResult Function( _SDUIWidgetModel value) $default,){ -final _that = this; -switch (_that) { -case _SDUIWidgetModel(): -return $default(_that);case _: - throw StateError('Unexpected subclass'); - -} -} -/// A variant of `map` that fallback to returning `null`. -/// -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case final Subclass value: -/// return ...; -/// case _: -/// return null; -/// } -/// ``` - -@optionalTypeArgs TResult? mapOrNull(TResult? Function( _SDUIWidgetModel value)? $default,){ -final _that = this; -switch (_that) { -case _SDUIWidgetModel() when $default != null: -return $default(_that);case _: - return null; - -} -} -/// A variant of `when` that fallback to an `orElse` callback. -/// -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case Subclass(:final field): -/// return ...; -/// case _: -/// return orElse(); -/// } -/// ``` - -@optionalTypeArgs TResult maybeWhen(TResult Function( String? type, bool? visible, Map? data, Map? child, List>? children)? $default,{required TResult orElse(),}) {final _that = this; -switch (_that) { -case _SDUIWidgetModel() when $default != null: -return $default(_that.type,_that.visible,_that.data,_that.child,_that.children);case _: - return orElse(); - -} -} -/// A `switch`-like method, using callbacks. -/// -/// As opposed to `map`, this offers destructuring. -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case Subclass(:final field): -/// return ...; -/// case Subclass2(:final field2): -/// return ...; -/// } -/// ``` - -@optionalTypeArgs TResult when(TResult Function( String? type, bool? visible, Map? data, Map? child, List>? children) $default,) {final _that = this; -switch (_that) { -case _SDUIWidgetModel(): -return $default(_that.type,_that.visible,_that.data,_that.child,_that.children);case _: - throw StateError('Unexpected subclass'); - -} -} -/// A variant of `when` that fallback to returning `null` -/// -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case Subclass(:final field): -/// return ...; -/// case _: -/// return null; -/// } -/// ``` - -@optionalTypeArgs TResult? whenOrNull(TResult? Function( String? type, bool? visible, Map? data, Map? child, List>? children)? $default,) {final _that = this; -switch (_that) { -case _SDUIWidgetModel() when $default != null: -return $default(_that.type,_that.visible,_that.data,_that.child,_that.children);case _: - return null; - -} -} - -} - -/// @nodoc -@JsonSerializable() - -class _SDUIWidgetModel implements SDUIWidgetModel { - const _SDUIWidgetModel({this.type, this.visible, final Map? data, final Map? child, final List>? children}): _data = data,_child = child,_children = children; - factory _SDUIWidgetModel.fromJson(Map json) => _$SDUIWidgetModelFromJson(json); - -@override final String? type; -@override final bool? visible; - final Map? _data; -@override Map? get data { - final value = _data; - if (value == null) return null; - if (_data is EqualUnmodifiableMapView) return _data; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); -} - - final Map? _child; -@override Map? get child { - final value = _child; - if (value == null) return null; - if (_child is EqualUnmodifiableMapView) return _child; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); -} - - final List>? _children; -@override List>? get children { - final value = _children; - if (value == null) return null; - if (_children is EqualUnmodifiableListView) return _children; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(value); -} - - -/// Create a copy of SDUIWidgetModel -/// with the given fields replaced by the non-null parameter values. -@override @JsonKey(includeFromJson: false, includeToJson: false) -@pragma('vm:prefer-inline') -_$SDUIWidgetModelCopyWith<_SDUIWidgetModel> get copyWith => __$SDUIWidgetModelCopyWithImpl<_SDUIWidgetModel>(this, _$identity); - -@override -Map toJson() { - return _$SDUIWidgetModelToJson(this, ); -} - -@override -bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _SDUIWidgetModel&&(identical(other.type, type) || other.type == type)&&(identical(other.visible, visible) || other.visible == visible)&&const DeepCollectionEquality().equals(other._data, _data)&&const DeepCollectionEquality().equals(other._child, _child)&&const DeepCollectionEquality().equals(other._children, _children)); -} - -@JsonKey(includeFromJson: false, includeToJson: false) -@override -int get hashCode => Object.hash(runtimeType,type,visible,const DeepCollectionEquality().hash(_data),const DeepCollectionEquality().hash(_child),const DeepCollectionEquality().hash(_children)); - -@override -String toString() { - return 'SDUIWidgetModel(type: $type, visible: $visible, data: $data, child: $child, children: $children)'; -} - - -} - -/// @nodoc -abstract mixin class _$SDUIWidgetModelCopyWith<$Res> implements $SDUIWidgetModelCopyWith<$Res> { - factory _$SDUIWidgetModelCopyWith(_SDUIWidgetModel value, $Res Function(_SDUIWidgetModel) _then) = __$SDUIWidgetModelCopyWithImpl; -@override @useResult -$Res call({ - String? type, bool? visible, Map? data, Map? child, List>? children -}); - - - - -} -/// @nodoc -class __$SDUIWidgetModelCopyWithImpl<$Res> - implements _$SDUIWidgetModelCopyWith<$Res> { - __$SDUIWidgetModelCopyWithImpl(this._self, this._then); - - final _SDUIWidgetModel _self; - final $Res Function(_SDUIWidgetModel) _then; - -/// Create a copy of SDUIWidgetModel -/// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? type = freezed,Object? visible = freezed,Object? data = freezed,Object? child = freezed,Object? children = freezed,}) { - return _then(_SDUIWidgetModel( -type: freezed == type ? _self.type : type // ignore: cast_nullable_to_non_nullable -as String?,visible: freezed == visible ? _self.visible : visible // ignore: cast_nullable_to_non_nullable -as bool?,data: freezed == data ? _self._data : data // ignore: cast_nullable_to_non_nullable -as Map?,child: freezed == child ? _self._child : child // ignore: cast_nullable_to_non_nullable -as Map?,children: freezed == children ? _self._children : children // ignore: cast_nullable_to_non_nullable -as List>?, - )); -} - - -} - -// dart format on diff --git a/packages/chicken/lib/presentation/widget/sdui/model/sdui_widget_model.g.dart b/packages/chicken/lib/presentation/widget/sdui/model/sdui_widget_model.g.dart deleted file mode 100644 index d565ab4..0000000 --- a/packages/chicken/lib/presentation/widget/sdui/model/sdui_widget_model.g.dart +++ /dev/null @@ -1,27 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'sdui_widget_model.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_SDUIWidgetModel _$SDUIWidgetModelFromJson(Map json) => - _SDUIWidgetModel( - type: json['type'] as String?, - visible: json['visible'] as bool?, - data: json['data'] as Map?, - child: json['child'] as Map?, - children: (json['children'] as List?) - ?.map((e) => e as Map) - .toList(), - ); - -Map _$SDUIWidgetModelToJson(_SDUIWidgetModel instance) => - { - 'type': instance.type, - 'visible': instance.visible, - 'data': instance.data, - 'child': instance.child, - 'children': instance.children, - }; diff --git a/packages/chicken/lib/presentation/widget/sdui/sdui.dart b/packages/chicken/lib/presentation/widget/sdui/sdui.dart index fafa24c..f048c0f 100644 --- a/packages/chicken/lib/presentation/widget/sdui/sdui.dart +++ b/packages/chicken/lib/presentation/widget/sdui/sdui.dart @@ -1,8 +1,7 @@ // SDUI Export file export 'form/sdui_form_widget.dart'; -export 'model/sdui_widget_model.dart'; +export 'model/sdui_widget.dart'; // Sealed class برای type-safe widget handling export 'widgets/card_label_item/card_label_item_sdui.dart'; export 'widgets/card_label_item/model/card_label_item_sdui_model.dart'; export 'widgets/text_form_filed/text_form_filed_sdui.dart'; export 'widgets/text_form_filed/model/text_form_field_sdui_model.dart'; - diff --git a/packages/chicken/lib/presentation/widget/sdui/widgets/stepper/stepper_sdui.dart b/packages/chicken/lib/presentation/widget/sdui/widgets/stepper/stepper_sdui.dart index 8060ba1..a807d77 100644 --- a/packages/chicken/lib/presentation/widget/sdui/widgets/stepper/stepper_sdui.dart +++ b/packages/chicken/lib/presentation/widget/sdui/widgets/stepper/stepper_sdui.dart @@ -15,14 +15,14 @@ class StepperSDUI extends StatelessWidget { return Obx(() { final activeStep = state?[model.key] as int? ?? model.activeStep ?? 0; - return Directionality( - textDirection: TextDirection.ltr, - child: SizedBox( - height: 24, - width: Get.width, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: _buildSteps(totalSteps, activeStep), + return SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Directionality( + textDirection: TextDirection.ltr, + child: SizedBox( + height: 30.h, + width: Get.width, + child: Row(children: _buildSteps(totalSteps, activeStep)), ), ), ); @@ -58,7 +58,8 @@ class StepperSDUI extends StatelessWidget { // Add divider between steps (except after last step) if (i < totalSteps - 1) { widgets.add( - Expanded( + SizedBox( + width: 40.w, child: Divider( color: activeStep >= i + 1 ? AppColor.greenNormalHover