From 26f94345f6f66100331b4ebe4f605e07666cc6ae Mon Sep 17 00:00:00 2001 From: "mr.mojtaba" Date: Wed, 31 Dec 2025 15:28:17 +0330 Subject: [PATCH] feat: enhance SDUI widget model with dynamic visibility conditions, refactor NewPageLogic for improved form handling, and update UI components to support new visibility features --- .../presentation/pages/new_page/logic.dart | 77 +++- .../presentation/pages/new_page/view.dart | 4 +- .../widget/sdui/form/sdui_form_widget.dart | 399 +++++++++++------- .../widget/sdui/form/ts1 copy.json | 94 ++--- .../widget/sdui/form/ts_with_stepper.json | 184 +++++--- .../widget/sdui/model/sdui_widget.dart | 104 ++--- .../sdui/model/sdui_widget.freezed.dart | 395 ++++++++--------- .../widget/sdui/model/sdui_widget.g.dart | 48 ++- 8 files changed, 711 insertions(+), 594 deletions(-) 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 c22fbec..e085028 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 @@ -57,18 +57,21 @@ class NewPageLogic extends GetxController { if (sduiData != null) { iLog('SDUI data to parse: $sduiData'); - sduiModel.value = SDUIWidgetModel.fromRawJson(sduiData); + sduiModel.value = SDUIWidgetModel.fromJson(sduiData); // Log model info using pattern matching final modelType = sduiModel.value?.maybeWhen( - textFormField: (data, visible) => 'text_form_field', + textFormField: (data, visible, visibleCondition) => + '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', + chipSelection: (data, visible, visibleCondition) => + 'chip_selection', + dropdown: (data, visible, visibleCondition) => 'dropdown', + imagePicker: (data, visible, visibleCondition) => + 'image_picker', column: ( children, @@ -78,12 +81,22 @@ class NewPageLogic extends GetxController { visible, paddingHorizontal, paddingVertical, + visibleCondition, ) => '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', + row: + ( + children, + spacing, + mainAxisAlignment, + visible, + visibleCondition, + ) => 'row', + sizedBox: (width, height, visible, visibleCondition) => + 'sized_box', + stepper: (data, children, visible, visibleCondition) => + 'stepper', + pageView: (data, children, visible, visibleCondition) => + 'page_view', orElse: () => 'unknown', ) ?? 'null'; @@ -99,15 +112,23 @@ class NewPageLogic extends GetxController { visible, paddingHorizontal, paddingVertical, + visibleCondition, + ) => children.length, + row: + ( + children, + spacing, + mainAxisAlignment, + visible, + visibleCondition, ) => 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) => + stepper: (data, children, visible, visibleCondition) => children?.length ?? 0, - pageView: (data, children, visible) => children.length, + pageView: (data, children, visible, visibleCondition) => + children.length, orElse: () => 0, ) ?? 0; @@ -143,7 +164,7 @@ class NewPageLogic extends GetxController { void _extractTextFields(SDUIWidgetModel model) { // Extract text form field using pattern matching model.maybeWhen( - textFormField: (data, visible) { + textFormField: (data, visible, visibleCondition) { final key = data.key; final value = data.value; if (key != null && !controllers.containsKey(key)) { @@ -155,12 +176,22 @@ class NewPageLogic extends GetxController { // 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) { + column: + ( + children, + spacing, + mainAxisSize, + crossAxisAlignment, + visible, + paddingHorizontal, + paddingVertical, + visibleCondition, + ) { + for (var child in children) { + _extractTextFields(child); + } + }, + row: (children, spacing, mainAxisAlignment, visible, visibleCondition) { for (var child in children) { _extractTextFields(child); } @@ -175,14 +206,14 @@ class NewPageLogic extends GetxController { } } }, - stepper: (data, children, visible, index) { + stepper: (data, children, visible, visibleCondition) { if (children != null) { for (var child in children) { _extractTextFields(child); } } }, - pageView: (data, children, visible) { + pageView: (data, children, visible, visibleCondition) { for (var child in children) { _extractTextFields(child); } 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 1aa6088..ab26a5d 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 @@ -29,7 +29,9 @@ class NewPage extends GetView { SizedBox(height: 24.h), RElevated( text: 'دکمه نمونه', - onPressed: () { + onPressed: () async { + await controller.getSDUIForm(); + Get.bottomSheet( isScrollControlled: true, enableDrag: true, 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 fa7aeff..f2d55a0 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 @@ -67,14 +67,16 @@ class SDUIFormWidget extends StatelessWidget { paddingHorizontal, paddingVertical, visible, + visibleCondition, ) => children.isNotEmpty, - row: (children, spacing, mainAxisAlignment, visible) => + row: (children, spacing, mainAxisAlignment, visible, visibleCondition) => children.isNotEmpty, cardLabelItem: (data, child, children, visible, visibleCondition) => child != null || (children != null && children.isNotEmpty), - stepper: (data, children, visible, index) => + stepper: (data, children, visible, visibleCondition) => children != null && children.isNotEmpty, - pageView: (data, children, visible) => children.isNotEmpty, + pageView: (data, children, visible, visibleCondition) => + children.isNotEmpty, orElse: () => false, ); @@ -114,36 +116,89 @@ class SDUIFormWidget extends StatelessWidget { return widget.map( // ویجت‌های فرم - textFormField: (value) => _buildTextFormField(value.data), + textFormField: (value) => _buildWithVisibleCondition( + value.visibleCondition, + () => _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), + chipSelection: (value) => _buildWithVisibleCondition( + value.visibleCondition, + () => _buildChipSelection(value.data), + ), + dropdown: (value) => _buildWithVisibleCondition( + value.visibleCondition, + () => _buildDropdown(value.data), + ), + imagePicker: (value) => _buildWithVisibleCondition( + value.visibleCondition, + () => _buildImagePicker(value.data), + ), // ویجت‌های layout - column: (value) => _buildColumn( - value.children, - value.spacing, - value.mainAxisSize, - value.crossAxisAlignment, - value.paddingHorizontal, - value.paddingVertical, + column: (value) => _buildWithVisibleCondition( + value.visibleCondition, + () => _buildColumn( + value.children, + value.spacing, + value.mainAxisSize, + value.crossAxisAlignment, + value.paddingHorizontal, + value.paddingVertical, + ), + ), + row: (value) => _buildWithVisibleCondition( + value.visibleCondition, + () => _buildRow(value.children, value.spacing, value.mainAxisAlignment), + ), + sizedBox: (value) => _buildWithVisibleCondition( + value.visibleCondition, + () => _buildSizedBox(value.width, value.height), ), - 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), + stepper: (value) => _buildWithVisibleCondition( + value.visibleCondition, + () => _buildStepper(value.data, value.children), + ), + pageView: (value) => _buildWithVisibleCondition( + value.visibleCondition, + () => _buildPageView(value.data, value.children), + ), ); } + /// Helper method to handle visible_condition for widgets + Widget _buildWithVisibleCondition( + String? visibleCondition, + Widget Function() builder, + ) { + // If no condition or condition is null/empty, always show + if (visibleCondition == null || visibleCondition.isEmpty) { + return builder(); + } + + // If state is null, only show first step (0) by default + if (state == null) { + if (visibleCondition.contains('activeStepperIndex == 0')) { + return builder(); + } + return const SizedBox.shrink(); + } + + // Use Obx for reactive updates + return Obx(() { + if (!_evaluateVisibleCondition(visibleCondition)) { + return const SizedBox.shrink(); + } + return builder(); + }); + } + Widget _buildTextFormField(TextFormFieldSDUIModel data) { try { // Use provided controller or create a new one @@ -591,7 +646,7 @@ class SDUIFormWidget extends StatelessWidget { _StepperInfo? _findStepperInTree(SDUIWidgetModel widgetModel) { // Check if current widget is a stepper return widgetModel.maybeWhen( - stepper: (data, children, visible, index) { + stepper: (data, children, visible, visibleCondition) { try { return _StepperInfo( stepperModel: widgetModel, @@ -616,6 +671,27 @@ class SDUIFormWidget extends StatelessWidget { visible, paddingHorizontal, paddingVertical, + visibleCondition, + ) { + 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, + visibleCondition, ) { for (var child in children) { final stepperInfo = _findStepperInTree(child); @@ -629,19 +705,6 @@ class SDUIFormWidget extends StatelessWidget { } 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); @@ -667,7 +730,7 @@ class SDUIFormWidget extends StatelessWidget { } return null; }, - stepper: (data, children, visible, index) { + stepper: (data, children, visible, visibleCondition) { if (children != null) { for (var child in children) { final stepperInfo = _findStepperInTree(child); @@ -682,7 +745,7 @@ class SDUIFormWidget extends StatelessWidget { } return null; }, - pageView: (data, children, visible) { + pageView: (data, children, visible, visibleCondition) { for (var child in children) { final stepperInfo = _findStepperInTree(child); if (stepperInfo != null) { @@ -706,7 +769,7 @@ class SDUIFormWidget extends StatelessWidget { // Check if current widget is a stepper count += widgetModel.maybeWhen( - stepper: (data, children, visible, index) => 1, + stepper: (data, children, visible, visibleCondition) => 1, orElse: () => 0, ) ?? 0; @@ -723,6 +786,21 @@ class SDUIFormWidget extends StatelessWidget { visible, paddingHorizontal, paddingVertical, + visibleCondition, + ) { + int childCount = 0; + for (var child in children) { + childCount += _countSteppersInTree(child); + } + return childCount; + }, + row: + ( + children, + spacing, + mainAxisAlignment, + visible, + visibleCondition, ) { int childCount = 0; for (var child in children) { @@ -730,13 +808,6 @@ class SDUIFormWidget extends StatelessWidget { } 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) { @@ -749,7 +820,7 @@ class SDUIFormWidget extends StatelessWidget { } return childCount; }, - stepper: (data, children, visible, index) { + stepper: (data, children, visible, visibleCondition) { int childCount = 0; if (children != null) { for (var child in children) { @@ -758,7 +829,7 @@ class SDUIFormWidget extends StatelessWidget { } return childCount; }, - pageView: (data, children, visible) { + pageView: (data, children, visible, visibleCondition) { int childCount = 0; for (var child in children) { childCount += _countSteppersInTree(child); @@ -906,6 +977,7 @@ class SDUIFormWidget extends StatelessWidget { visible, paddingHorizontal, paddingVertical, + visibleCondition, ) { for (var child in children) { stepIndices.addAll( @@ -913,7 +985,7 @@ class SDUIFormWidget extends StatelessWidget { ); } }, - row: (children, spacing, mainAxisAlignment, visible) { + row: (children, spacing, mainAxisAlignment, visible, visibleCondition) { for (var child in children) { stepIndices.addAll(_collectStepIndicesFromVisibleConditions(child)); } @@ -928,14 +1000,14 @@ class SDUIFormWidget extends StatelessWidget { } } }, - stepper: (data, children, visible, index) { + stepper: (data, children, visible, visibleCondition) { if (children != null) { for (var child in children) { stepIndices.addAll(_collectStepIndicesFromVisibleConditions(child)); } } }, - pageView: (data, children, visible) { + pageView: (data, children, visible, visibleCondition) { for (var child in children) { stepIndices.addAll(_collectStepIndicesFromVisibleConditions(child)); } @@ -968,7 +1040,7 @@ class SDUIFormWidget extends StatelessWidget { // 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) { + stepper: (data, children, visible, visibleCondition) { return data.key == stepperKey; }, orElse: () => false, @@ -1007,12 +1079,13 @@ class SDUIFormWidget extends StatelessWidget { visible, paddingHorizontal, paddingVertical, + visibleCondition, ) { for (var child in children) { if (isStepperToExclude(child)) { // If stepper has children, build those children child.maybeWhen( - stepper: (data, stepperChildren, visible, index) { + stepper: (data, stepperChildren, visible, visibleCondition) { if (stepperChildren != null) { int childIndex = 0; for (var stepperChild in stepperChildren) { @@ -1028,7 +1101,7 @@ class SDUIFormWidget extends StatelessWidget { ) { return extractStepIndex(visibleCondition); }, - orElse: () => index != null ? index : childIndex, + orElse: () => childIndex, ); widgets.add( @@ -1067,71 +1140,85 @@ class SDUIFormWidget extends StatelessWidget { } 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; - }, + row: + ( + children, + spacing, + mainAxisAlignment, + visible, + visibleCondition, + ) { + for (var child in children) { + if (isStepperToExclude(child)) { + child.maybeWhen( + stepper: + (data, stepperChildren, visible, visibleCondition) { + 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, - ), - ); - } - } - }, + stepper: + ( + stepperData, + stepperChildren, + visible, + visibleCondition, + ) { + 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 { @@ -1155,26 +1242,32 @@ class SDUIFormWidget extends StatelessWidget { 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, - ), - ); - } - } - }, + stepper: + ( + stepperData, + stepperChildren, + visible, + visibleCondition, + ) { + 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; @@ -1197,7 +1290,7 @@ class SDUIFormWidget extends StatelessWidget { } return widgets; }, - stepper: (data, children, visible, index) { + stepper: (data, children, visible, visibleCondition) { if (children != null) { for (var child in children) { widgets.add( @@ -1215,27 +1308,33 @@ class SDUIFormWidget extends StatelessWidget { } return widgets; }, - pageView: (data, children, visible) { + pageView: (data, children, visible, visibleCondition) { 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, - ), - ); - } - } - }, + stepper: + ( + stepperData, + stepperChildren, + visible, + visibleCondition, + ) { + 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; @@ -1280,7 +1379,7 @@ class SDUIFormWidget extends StatelessWidget { color: Colors.white, boxShadow: [ BoxShadow( - color: Colors.black.withOpacity(0.05), + color: Colors.black.withAlpha(5), blurRadius: 10, offset: Offset(0, -2), ), diff --git a/packages/chicken/lib/presentation/widget/sdui/form/ts1 copy.json b/packages/chicken/lib/presentation/widget/sdui/form/ts1 copy.json index 3c5af55..8347751 100644 --- a/packages/chicken/lib/presentation/widget/sdui/form/ts1 copy.json +++ b/packages/chicken/lib/presentation/widget/sdui/form/ts1 copy.json @@ -2,9 +2,7 @@ "info": { "type": "column", "visible": true, - "data": { - "spacing": 30.0 - }, + "spacing": 30.0, "children": [ { "type": "card_label_item", @@ -12,15 +10,12 @@ "data": { "title": "اطلاعات پایه واحد", "padding_horizontal": 12.0, - "padding_vertical": 11.0, - "visible_condition": "activeStepperIndex == 0" + "padding_vertical": 11.0 }, "child": { "type": "column", "visible": true, - "data": { - "spacing": 10.0 - }, + "spacing": 10.0, "children": [ { "type": "text_form_field", @@ -66,8 +61,7 @@ "data": { "key": "tenant_name", "label": "نام مستاجر", - "keyboard_type": "text", - "visible_condition": "tenant_status == 'دارد'" + "keyboard_type": "text" } }, { @@ -76,8 +70,7 @@ "data": { "key": "tenant_national_id", "label": "کد ملی مستاجر", - "keyboard_type": "text", - "visible_condition": "tenant_status == 'دارد'" + "keyboard_type": "text" } }, { @@ -86,8 +79,7 @@ "data": { "key": "tenant_phone_number", "label": "شماره تماس مستاجر", - "keyboard_type": "text", - "visible_condition": "tenant_status == 'دارد'" + "keyboard_type": "text" } }, { @@ -128,16 +120,13 @@ "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 - }, + "spacing": 10.0, "children": [ { "type": "text_form_field", @@ -146,8 +135,7 @@ "key": "hatching_date", "label": "تاریخ جوجه ریزی", "keyboard_type": "text", - "readonly": true, - "type": "date_picker" + "readonly": true } }, { @@ -157,8 +145,7 @@ "key": "visit_date", "label": "تاریخ بازدید", "keyboard_type": "text", - "readonly": true, - "type": "date_picker" + "readonly": true } }, { @@ -199,16 +186,13 @@ "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 - }, + "spacing": 10.0, "children": [ { "type": "image_picker", @@ -364,16 +348,13 @@ "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 - }, + "spacing": 10.0, "children": [ { "type": "text_form_field", @@ -420,8 +401,7 @@ "data": { "key": "other_cause_of_unusual_casualties", "label": "علت تلفات غیرعادی", - "keyboard_type": "text", - "visible_condition": "cause_of_unusual_casualties == 'سایر (شرح…)'" + "keyboard_type": "text" } }, { @@ -449,8 +429,7 @@ "data": { "key": "other_type_of_disease", "label": "نوع بیماری", - "keyboard_type": "text", - "visible_condition": "type_of_disease == 'سایر (شرح)'" + "keyboard_type": "text" } }, { @@ -475,7 +454,6 @@ "key": "sample_type", "label": "نوع نمونه", "selectedIndex": -1, - "visible_condition": "sampling_done == 'انجام شد'", "options": [ { "index": 0, @@ -503,16 +481,13 @@ "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 - }, + "spacing": 10.0, "children": [ { "type": "text_form_field", @@ -540,16 +515,13 @@ "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 - }, + "spacing": 10.0, "children": [ { "type": "dropdown", @@ -569,11 +541,11 @@ { "type": "text_form_field", "visible": true, + "visible_condition": "input_status == 'وابسته'", "data": { "key": "company_name", "label": "نام کارخانه", - "keyboard_type": "text", - "visible_condition": "input_status == 'وابسته'" + "keyboard_type": "text" } }, { @@ -582,13 +554,13 @@ "data": { "key": "tracking_code", "label": "شناسه خرید یا کد پیگیری", - "keyboard_type": "text", - "visible_condition": "input_status == 'مستقل'" + "keyboard_type": "text" } }, { "type": "text_form_field", "visible": true, + "visible_condition": "input_status == 'مستقل'", "data": { "key": "input_inventory_until_visit", "label": "موجودی نهاده مصرفی تا روز بازدید (کیلوگرم)", @@ -658,16 +630,13 @@ "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 - }, + "spacing": 10.0, "children": [ { "type": "text_form_field", @@ -812,16 +781,13 @@ "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 - }, + "spacing": 10.0, "children": [ { "type": "text_form_field", @@ -902,16 +868,13 @@ "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 - }, + "spacing": 10.0, "children": [ { "type": "dropdown", @@ -954,8 +917,7 @@ "key": "payment_year", "label": "سال دریافت", "keyboard_type": "text", - "readonly": true, - "type": "date_picker" + "readonly": true } }, { @@ -998,16 +960,13 @@ "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 - }, + "spacing": 10.0, "children": [ { "type": "image_picker", @@ -1042,16 +1001,13 @@ "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 - }, + "spacing": 10.0, "children": [ { "type": "chip_selection", 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 index 2f4202f..2242158 100644 --- a/packages/chicken/lib/presentation/widget/sdui/form/ts_with_stepper.json +++ b/packages/chicken/lib/presentation/widget/sdui/form/ts_with_stepper.json @@ -2,38 +2,38 @@ "info": { "type": "column", "visible": true, - "data": { - "spacing": 30.0 - }, + "visible_condition": null, + "spacing": 30.0, "children": [ { "type": "stepper", "visible": true, + "visible_condition": null, "data": { "key": "activeStepperIndex", - "total_steps": 7, + "total_steps": 11, "active_step": 0 } }, { "type": "card_label_item", "visible": true, + "visible_condition": "activeStepperIndex == 0", "data": { "title": "اطلاعات پایه واحد", "padding_horizontal": 12.0, - "padding_vertical": 11.0, - "visible_condition": "activeStepperIndex == 0" + "padding_vertical": 11.0 }, "child": { "type": "column", "visible": true, - "data": { - "spacing": 10.0 - }, + "visible_condition": null, + "spacing": 10.0, "children": [ { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "unit_name", "label": "نام واحد مرغداری", @@ -44,6 +44,7 @@ { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "breeding_unique_id", "label": "کد یکتا / شناسه واحد", @@ -54,6 +55,7 @@ { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "health_license", "label": "پروانه بهداشتی", @@ -63,6 +65,7 @@ { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "tenant_status", "label": "وضعیت مستاجر", @@ -72,36 +75,37 @@ { "type": "text_form_field", "visible": true, + "visible_condition": "tenant_status == 'دارد'", "data": { "key": "tenant_name", "label": "نام مستاجر", - "keyboard_type": "text", - "visible_condition": "tenant_status == 'دارد'" + "keyboard_type": "text" } }, { "type": "text_form_field", "visible": true, + "visible_condition": "tenant_status == 'دارد'", "data": { "key": "tenant_national_id", "label": "کد ملی مستاجر", - "keyboard_type": "text", - "visible_condition": "tenant_status == 'دارد'" + "keyboard_type": "text" } }, { "type": "text_form_field", "visible": true, + "visible_condition": "tenant_status == 'دارد'", "data": { "key": "tenant_phone_number", "label": "شماره تماس مستاجر", - "keyboard_type": "text", - "visible_condition": "tenant_status == 'دارد'" + "keyboard_type": "text" } }, { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "owner_national_code", "label": "کد ملی بهره‌بردار", @@ -112,6 +116,7 @@ { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "owner_phone_number", "label": "شماره تماس بهره‌بردار", @@ -122,6 +127,7 @@ { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "total_capacity", "label": "ظرفیت اسمی سالن‌ها", @@ -135,44 +141,44 @@ { "type": "card_label_item", "visible": true, + "visible_condition": "activeStepperIndex == 1", "data": { "title": "اطلاعات جوجه ریزی", - "visible_condition": "activeStepperIndex == 1", "padding_horizontal": 12.0, "padding_vertical": 11.0 }, "child": { "type": "column", "visible": true, - "data": { - "spacing": 10.0 - }, + "visible_condition": null, + "spacing": 10.0, "children": [ { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "hatching_date", "label": "تاریخ جوجه ریزی", "keyboard_type": "text", - "readonly": true, - "type": "date_picker" + "readonly": true } }, { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "visit_date", "label": "تاریخ بازدید", "keyboard_type": "text", - "readonly": true, - "type": "date_picker" + "readonly": true } }, { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "hatching_count", "label": "تعداد جوجه‌ریزی اولیه", @@ -184,6 +190,7 @@ { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "hatching_breed", "label": "نوع نژاد", @@ -193,6 +200,7 @@ { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "hatching_average_weight", "label": "میانگین وزن جوجه", @@ -206,22 +214,22 @@ { "type": "card_label_item", "visible": true, + "visible_condition": "activeStepperIndex == 2", "data": { "title": "وضعیت عمومی سالن", - "visible_condition": "activeStepperIndex == 2", "padding_horizontal": 12.0, "padding_vertical": 11.0 }, "child": { "type": "column", "visible": true, - "data": { - "spacing": 10.0 - }, + "visible_condition": null, + "spacing": 10.0, "children": [ { "type": "image_picker", "visible": true, + "visible_condition": null, "data": { "key": "pultry_images", "label": "تعداد موجود فعلی" @@ -230,6 +238,7 @@ { "type": "chip_selection", "visible": true, + "visible_condition": null, "data": { "key": "sanitary_condition_of_the_hall", "label": "وضعیت بهداشتی سالن", @@ -261,6 +270,7 @@ { "type": "chip_selection", "visible": true, + "visible_condition": null, "data": { "key": "ventilation_status", "label": "وضعیت تهویه", @@ -292,6 +302,7 @@ { "type": "chip_selection", "visible": true, + "visible_condition": null, "data": { "key": "bedding_status", "label": "وضعیت بستر", @@ -318,6 +329,7 @@ { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "hatching_temperature", "label": "دمای سالن", @@ -327,6 +339,7 @@ { "type": "chip_selection", "visible": true, + "visible_condition": null, "data": { "key": "water_quality", "label": "آب مصرفی", @@ -358,6 +371,7 @@ { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "water_hardness", "label": "درصد سختی آب (PPM)", @@ -371,22 +385,22 @@ { "type": "card_label_item", "visible": true, + "visible_condition": "activeStepperIndex == 3", "data": { "title": "تلفات", - "visible_condition": "activeStepperIndex == 3", "padding_horizontal": 12.0, "padding_vertical": 11.0 }, "child": { "type": "column", "visible": true, - "data": { - "spacing": 10.0 - }, + "visible_condition": null, + "spacing": 10.0, "children": [ { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "normal_losses", "label": "تعداد تلفات عادی دوره", @@ -397,6 +411,7 @@ { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "abnormal_losses", "label": "تلفات غیرعادی", @@ -407,6 +422,7 @@ { "type": "dropdown", "visible": true, + "visible_condition": null, "data": { "key": "cause_of_unusual_casualties", "label": "علت تلفات غیرعادی", @@ -426,16 +442,17 @@ { "type": "text_form_field", "visible": true, + "visible_condition": "cause_of_unusual_casualties == 'سایر (شرح…)'", "data": { "key": "other_cause_of_unusual_casualties", "label": "علت تلفات غیرعادی", - "keyboard_type": "text", - "visible_condition": "cause_of_unusual_casualties == 'سایر (شرح…)'" + "keyboard_type": "text" } }, { "type": "dropdown", "visible": true, + "visible_condition": null, "data": { "key": "type_of_disease", "label": "نوع بیماری تشخیص داده‌شده / مشکوک", @@ -455,16 +472,17 @@ { "type": "text_form_field", "visible": true, + "visible_condition": "type_of_disease == 'سایر (شرح)'", "data": { "key": "other_type_of_disease", "label": "نوع بیماری", - "keyboard_type": "text", - "visible_condition": "type_of_disease == 'سایر (شرح)'" + "keyboard_type": "text" } }, { "type": "dropdown", "visible": true, + "visible_condition": null, "data": { "key": "sampling_done", "label": "نمونه‌برداری انجام‌شده", @@ -480,11 +498,11 @@ { "type": "chip_selection", "visible": true, + "visible_condition": "sampling_done == 'انجام شد'", "data": { "key": "sample_type", "label": "نوع نمونه", "selectedIndex": -1, - "visible_condition": "sampling_done == 'انجام شد'", "options": [ { "index": 0, @@ -510,22 +528,22 @@ { "type": "card_label_item", "visible": true, + "visible_condition": "activeStepperIndex == 4", "data": { "title": "مسئول فنی", - "visible_condition": "activeStepperIndex == 4", "padding_horizontal": 12.0, "padding_vertical": 11.0 }, "child": { "type": "column", "visible": true, - "data": { - "spacing": 10.0 - }, + "visible_condition": null, + "spacing": 10.0, "children": [ { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "technical_health_officer_name", "label": "نام مسئول فنی بهداشتی", @@ -535,6 +553,7 @@ { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "technical_engineering_officer_name", "label": "نام مسئول فنی نظام مهندسی", @@ -547,22 +566,22 @@ { "type": "card_label_item", "visible": true, + "visible_condition": "activeStepperIndex == 5", "data": { "title": "نهاده و خوراک", - "visible_condition": "activeStepperIndex == 5", "padding_horizontal": 12.0, "padding_vertical": 11.0 }, "child": { "type": "column", "visible": true, - "data": { - "spacing": 10.0 - }, + "visible_condition": null, + "spacing": 10.0, "children": [ { "type": "dropdown", "visible": true, + "visible_condition": null, "data": { "key": "input_status", "label": "وضعیت نهاده", @@ -578,26 +597,27 @@ { "type": "text_form_field", "visible": true, + "visible_condition": "input_status == 'وابسته'", "data": { "key": "company_name", "label": "نام کارخانه", - "keyboard_type": "text", - "visible_condition": "input_status == 'وابسته'" + "keyboard_type": "text" } }, { "type": "text_form_field", "visible": true, + "visible_condition": "input_status == 'مستقل'", "data": { "key": "tracking_code", "label": "شناسه خرید یا کد پیگیری", - "keyboard_type": "text", - "visible_condition": "input_status == 'مستقل'" + "keyboard_type": "text" } }, { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "input_inventory_until_visit", "label": "موجودی نهاده مصرفی تا روز بازدید (کیلوگرم)", @@ -608,6 +628,7 @@ { "type": "dropdown", "visible": true, + "visible_condition": null, "data": { "key": "type_of_grain", "label": "نوع دان", @@ -626,6 +647,7 @@ { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "input_inventory_in_warehouse", "label": "موجودی نهاده موجود در انبار (کیلوگرم)", @@ -636,6 +658,7 @@ { "type": "chip_selection", "visible": true, + "visible_condition": null, "data": { "key": "grain_quality", "label": "کیفیت دانه", @@ -665,22 +688,22 @@ { "type": "card_label_item", "visible": true, + "visible_condition": "activeStepperIndex == 6", "data": { "title": "زیرساخت و انرژی", - "visible_condition": "activeStepperIndex == 6", "padding_horizontal": 12.0, "padding_vertical": 11.0 }, "child": { "type": "column", "visible": true, - "data": { - "spacing": 10.0 - }, + "visible_condition": null, + "spacing": 10.0, "children": [ { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "generator_type", "label": "نوع ژنراتور", @@ -690,6 +713,7 @@ { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "generator_model", "label": "مدل ژنراتور", @@ -699,6 +723,7 @@ { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "generator_count", "label": "تعداد ژنراتور", @@ -709,6 +734,7 @@ { "type": "dropdown", "visible": true, + "visible_condition": null, "data": { "key": "fuel_type", "label": "نوع سوخت", @@ -724,6 +750,7 @@ { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "generator_capacity", "label": "ظرفیت (KVA)", @@ -734,6 +761,7 @@ { "type": "chip_selection", "visible": true, + "visible_condition": null, "data": { "key": "generator_operating_status", "label": "وضعیت عملکرد ژنراتور", @@ -760,6 +788,7 @@ { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "emergency_fuel_inventory", "label": "میزان موجودی سوخت اضطراری (لیتر)", @@ -770,6 +799,7 @@ { "type": "dropdown", "visible": true, + "visible_condition": null, "data": { "key": "power_cut_history", "label": "سابقه قطعی برق دوره جاری", @@ -785,6 +815,7 @@ { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "power_cut_duration", "label": "مدت قطعی", @@ -795,6 +826,7 @@ { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "power_cut_hour", "label": "ساعت قطعی", @@ -805,6 +837,7 @@ { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "additional_notes", "label": "توضیحات تکمیلی", @@ -819,22 +852,22 @@ { "type": "card_label_item", "visible": true, + "visible_condition": "activeStepperIndex == 7", "data": { "title": "نیروی انسانی", - "visible_condition": "activeStepperIndex == 7", "padding_horizontal": 12.0, "padding_vertical": 11.0 }, "child": { "type": "column", "visible": true, - "data": { - "spacing": 10.0 - }, + "visible_condition": null, + "spacing": 10.0, "children": [ { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "employed_workers_count", "label": "تعداد افراد شاغل", @@ -845,6 +878,7 @@ { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "native_workers_count", "label": "تعداد افراد بومی", @@ -855,6 +889,7 @@ { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "non_native_workers_count", "label": "تعداد افراد غیر بومی", @@ -865,6 +900,7 @@ { "type": "chip_selection", "visible": true, + "visible_condition": null, "data": { "key": "worker_contract_status", "label": "وضعیت قرارداد کارگران", @@ -891,6 +927,7 @@ { "type": "dropdown", "visible": true, + "visible_condition": null, "data": { "key": "training_status", "label": "آموزش‌دیده در حوزه بهداشت و امنیت زیستی", @@ -909,22 +946,22 @@ { "type": "card_label_item", "visible": true, + "visible_condition": "activeStepperIndex == 8", "data": { "title": "تسهیلات و حمایت‌ها", - "visible_condition": "activeStepperIndex == 8", "padding_horizontal": 12.0, "padding_vertical": 11.0 }, "child": { "type": "column", "visible": true, - "data": { - "spacing": 10.0 - }, + "visible_condition": null, + "spacing": 10.0, "children": [ { "type": "dropdown", "visible": true, + "visible_condition": null, "data": { "key": "has_facilities", "label": "تسهیلات دریافتی فعال", @@ -940,6 +977,7 @@ { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "facility_type", "label": "نوع تسهیلات", @@ -949,6 +987,7 @@ { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "facility_amount", "label": "مبلغ", @@ -959,17 +998,18 @@ { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "payment_year", "label": "سال دریافت", "keyboard_type": "text", - "readonly": true, - "type": "date_picker" + "readonly": true } }, { "type": "dropdown", "visible": true, + "visible_condition": null, "data": { "key": "overdue_status", "label": "وضعیت بازپرداخت", @@ -985,6 +1025,7 @@ { "type": "dropdown", "visible": true, + "visible_condition": null, "data": { "key": "new_beneficiary_request", "label": "درخواست جدید بهره بردار", @@ -1005,22 +1046,22 @@ { "type": "card_label_item", "visible": true, + "visible_condition": "activeStepperIndex == 9", "data": { "title": "مستندات", - "visible_condition": "activeStepperIndex == 9", "padding_horizontal": 12.0, "padding_vertical": 11.0 }, "child": { "type": "column", "visible": true, - "data": { - "spacing": 10.0 - }, + "visible_condition": null, + "spacing": 10.0, "children": [ { "type": "image_picker", "visible": true, + "visible_condition": null, "data": { "key": "hall_images", "label": "ثبت عکس سالن (حداقل ۳ زاویه)", @@ -1030,6 +1071,7 @@ { "type": "image_picker", "visible": true, + "visible_condition": null, "data": { "key": "input_warehouse_images", "label": "ثبت عکس انبار نهاده‌ها" @@ -1038,6 +1080,7 @@ { "type": "image_picker", "visible": true, + "visible_condition": null, "data": { "key": "losses_images", "label": "ثبت عکس تلفات" @@ -1049,22 +1092,22 @@ { "type": "card_label_item", "visible": true, + "visible_condition": "activeStepperIndex == 10", "data": { "title": "جمع‌بندی بازرس", - "visible_condition": "activeStepperIndex == 10", "padding_horizontal": 12.0, "padding_vertical": 11.0 }, "child": { "type": "column", "visible": true, - "data": { - "spacing": 10.0 - }, + "visible_condition": null, + "spacing": 10.0, "children": [ { "type": "chip_selection", "visible": true, + "visible_condition": null, "data": { "key": "inspector_conclusion", "label": "وضعیت کلی واحد", @@ -1091,6 +1134,7 @@ { "type": "text_form_field", "visible": true, + "visible_condition": null, "data": { "key": "inspector_conclusion_description", "label": "توصیه‌ها / اخطارها / اقدامات اصلاحی ...", diff --git a/packages/chicken/lib/presentation/widget/sdui/model/sdui_widget.dart b/packages/chicken/lib/presentation/widget/sdui/model/sdui_widget.dart index 5f3a486..032cc14 100644 --- a/packages/chicken/lib/presentation/widget/sdui/model/sdui_widget.dart +++ b/packages/chicken/lib/presentation/widget/sdui/model/sdui_widget.dart @@ -10,36 +10,47 @@ import 'package:rasadyar_chicken/presentation/widget/sdui/widgets/page_view/mode part 'sdui_widget.freezed.dart'; part 'sdui_widget.g.dart'; +// استفاده از snake_case برای تبدیل خودکار نام‌ها (مثلاً text_form_field به textFormField) @Freezed(unionKey: 'type', unionValueCase: FreezedUnionCase.snake) sealed class SDUIWidgetModel with _$SDUIWidgetModel { + // ۱. فیلد متنی const factory SDUIWidgetModel.textFormField({ required TextFormFieldSDUIModel data, @Default(true) bool visible, + String? visibleCondition, }) = _TextFormField; + // ۲. کارت لیبل‌دار const factory SDUIWidgetModel.cardLabelItem({ required CardLabelItemData data, SDUIWidgetModel? child, List? children, @Default(true) bool visible, - String? visibleCondition, + String? visibleCondition, }) = _CardLabelItem; + // ۳. انتخاب گزینه‌ای const factory SDUIWidgetModel.chipSelection({ required ChipSelectionSDUIModel data, @Default(true) bool visible, + String? visibleCondition, }) = _ChipSelection; + // ۴. لیست کشویی const factory SDUIWidgetModel.dropdown({ required DropdownSDUIModel data, @Default(true) bool visible, + String? visibleCondition, }) = _Dropdown; + // ۵. انتخاب عکس const factory SDUIWidgetModel.imagePicker({ required ImagePickerSDUIModel data, @Default(true) bool visible, + String? visibleCondition, }) = _ImagePicker; + // ۶. ستون (Container ویجت - فاقد شیء data در JSON جدید) const factory SDUIWidgetModel.column({ required List children, @Default(0.0) double spacing, @@ -48,103 +59,44 @@ sealed class SDUIWidgetModel with _$SDUIWidgetModel { @Default(0.0) double paddingVertical, @Default('center') String crossAxisAlignment, @Default(true) bool visible, + String? visibleCondition, }) = _Column; + // ۷. ردیف (Container ویجت - فاقد شیء data در JSON جدید) const factory SDUIWidgetModel.row({ required List children, @Default(0.0) double spacing, @Default('start') String mainAxisAlignment, @Default(true) bool visible, + String? visibleCondition, }) = _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, + String? visibleCondition, }) = _Stepper; + // ۹. پیج ویو const factory SDUIWidgetModel.pageView({ required PageViewSDUIModel data, required List children, @Default(true) bool visible, + String? visibleCondition, }) = _PageView; + // ۱۰. جعبه با اندازه ثابت + const factory SDUIWidgetModel.sizedBox({ + double? width, + double? height, + @Default(true) bool visible, + String? visibleCondition, + }) = _SizedBox; + + // تبدیل مستقیم JSON به مدل بدون هیچ واسطه‌ای 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 index d7d044c..a2c1992 100644 --- a/packages/chicken/lib/presentation/widget/sdui/model/sdui_widget.freezed.dart +++ b/packages/chicken/lib/presentation/widget/sdui/model/sdui_widget.freezed.dart @@ -42,10 +42,6 @@ SDUIWidgetModel _$SDUIWidgetModelFromJson( case 'row': return _Row.fromJson( json - ); - case 'sized_box': - return _SizedBox.fromJson( - json ); case 'stepper': return _Stepper.fromJson( @@ -55,6 +51,10 @@ SDUIWidgetModel _$SDUIWidgetModelFromJson( return _PageView.fromJson( json ); + case 'sized_box': + return _SizedBox.fromJson( + json + ); default: throw CheckedFromJsonException( @@ -70,7 +70,7 @@ SDUIWidgetModel _$SDUIWidgetModelFromJson( /// @nodoc mixin _$SDUIWidgetModel { - bool get visible; + bool get visible; String? get visibleCondition; /// Create a copy of SDUIWidgetModel /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -83,16 +83,16 @@ $SDUIWidgetModelCopyWith get copyWith => _$SDUIWidgetModelCopyW @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is SDUIWidgetModel&&(identical(other.visible, visible) || other.visible == visible)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is SDUIWidgetModel&&(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,visible); +int get hashCode => Object.hash(runtimeType,visible,visibleCondition); @override String toString() { - return 'SDUIWidgetModel(visible: $visible)'; + return 'SDUIWidgetModel(visible: $visible, visibleCondition: $visibleCondition)'; } @@ -103,7 +103,7 @@ abstract mixin class $SDUIWidgetModelCopyWith<$Res> { factory $SDUIWidgetModelCopyWith(SDUIWidgetModel value, $Res Function(SDUIWidgetModel) _then) = _$SDUIWidgetModelCopyWithImpl; @useResult $Res call({ - bool visible + bool visible, String? visibleCondition }); @@ -120,10 +120,11 @@ class _$SDUIWidgetModelCopyWithImpl<$Res> /// 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,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? visible = null,Object? visibleCondition = freezed,}) { return _then(_self.copyWith( visible: null == visible ? _self.visible : visible // ignore: cast_nullable_to_non_nullable -as bool, +as bool,visibleCondition: freezed == visibleCondition ? _self.visibleCondition : visibleCondition // ignore: cast_nullable_to_non_nullable +as String?, )); } @@ -144,7 +145,7 @@ extension SDUIWidgetModelPatterns on SDUIWidgetModel { /// } /// ``` -@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(),}){ +@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( _Stepper value)? stepper,TResult Function( _PageView value)? pageView,TResult Function( _SizedBox value)? sizedBox,required TResult orElse(),}){ final _that = this; switch (_that) { case _TextFormField() when textFormField != null: @@ -154,10 +155,10 @@ 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 row(_that);case _Stepper() when stepper != null: return stepper(_that);case _PageView() when pageView != null: -return pageView(_that);case _: +return pageView(_that);case _SizedBox() when sizedBox != null: +return sizedBox(_that);case _: return orElse(); } @@ -175,7 +176,7 @@ return pageView(_that);case _: /// } /// ``` -@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,}){ +@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( _Stepper value) stepper,required TResult Function( _PageView value) pageView,required TResult Function( _SizedBox value) sizedBox,}){ final _that = this; switch (_that) { case _TextFormField(): @@ -185,10 +186,10 @@ 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 row(_that);case _Stepper(): return stepper(_that);case _PageView(): -return pageView(_that);} +return pageView(_that);case _SizedBox(): +return sizedBox(_that);} } /// A variant of `map` that fallback to returning `null`. /// @@ -202,7 +203,7 @@ return pageView(_that);} /// } /// ``` -@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,}){ +@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( _Stepper value)? stepper,TResult? Function( _PageView value)? pageView,TResult? Function( _SizedBox value)? sizedBox,}){ final _that = this; switch (_that) { case _TextFormField() when textFormField != null: @@ -212,10 +213,10 @@ 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 row(_that);case _Stepper() when stepper != null: return stepper(_that);case _PageView() when pageView != null: -return pageView(_that);case _: +return pageView(_that);case _SizedBox() when sizedBox != null: +return sizedBox(_that);case _: return null; } @@ -232,19 +233,19 @@ return pageView(_that);case _: /// } /// ``` -@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; +@optionalTypeArgs TResult maybeWhen({TResult Function( TextFormFieldSDUIModel data, bool visible, String? visibleCondition)? textFormField,TResult Function( CardLabelItemData data, SDUIWidgetModel? child, List? children, bool visible, String? visibleCondition)? cardLabelItem,TResult Function( ChipSelectionSDUIModel data, bool visible, String? visibleCondition)? chipSelection,TResult Function( DropdownSDUIModel data, bool visible, String? visibleCondition)? dropdown,TResult Function( ImagePickerSDUIModel data, bool visible, String? visibleCondition)? imagePicker,TResult Function( List children, double spacing, String mainAxisSize, double paddingHorizontal, double paddingVertical, String crossAxisAlignment, bool visible, String? visibleCondition)? column,TResult Function( List children, double spacing, String mainAxisAlignment, bool visible, String? visibleCondition)? row,TResult Function( StepperSDUIModel data, List? children, bool visible, String? visibleCondition)? stepper,TResult Function( PageViewSDUIModel data, List children, bool visible, String? visibleCondition)? pageView,TResult Function( double? width, double? height, bool visible, String? visibleCondition)? sizedBox,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 textFormField(_that.data,_that.visible,_that.visibleCondition);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 chipSelection(_that.data,_that.visible,_that.visibleCondition);case _Dropdown() when dropdown != null: +return dropdown(_that.data,_that.visible,_that.visibleCondition);case _ImagePicker() when imagePicker != null: +return imagePicker(_that.data,_that.visible,_that.visibleCondition);case _Column() when column != null: +return column(_that.children,_that.spacing,_that.mainAxisSize,_that.paddingHorizontal,_that.paddingVertical,_that.crossAxisAlignment,_that.visible,_that.visibleCondition);case _Row() when row != null: +return row(_that.children,_that.spacing,_that.mainAxisAlignment,_that.visible,_that.visibleCondition);case _Stepper() when stepper != null: +return stepper(_that.data,_that.children,_that.visible,_that.visibleCondition);case _PageView() when pageView != null: +return pageView(_that.data,_that.children,_that.visible,_that.visibleCondition);case _SizedBox() when sizedBox != null: +return sizedBox(_that.width,_that.height,_that.visible,_that.visibleCondition);case _: return orElse(); } @@ -262,19 +263,19 @@ return pageView(_that.data,_that.children,_that.visible);case _: /// } /// ``` -@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; +@optionalTypeArgs TResult when({required TResult Function( TextFormFieldSDUIModel data, bool visible, String? visibleCondition) textFormField,required TResult Function( CardLabelItemData data, SDUIWidgetModel? child, List? children, bool visible, String? visibleCondition) cardLabelItem,required TResult Function( ChipSelectionSDUIModel data, bool visible, String? visibleCondition) chipSelection,required TResult Function( DropdownSDUIModel data, bool visible, String? visibleCondition) dropdown,required TResult Function( ImagePickerSDUIModel data, bool visible, String? visibleCondition) imagePicker,required TResult Function( List children, double spacing, String mainAxisSize, double paddingHorizontal, double paddingVertical, String crossAxisAlignment, bool visible, String? visibleCondition) column,required TResult Function( List children, double spacing, String mainAxisAlignment, bool visible, String? visibleCondition) row,required TResult Function( StepperSDUIModel data, List? children, bool visible, String? visibleCondition) stepper,required TResult Function( PageViewSDUIModel data, List children, bool visible, String? visibleCondition) pageView,required TResult Function( double? width, double? height, bool visible, String? visibleCondition) sizedBox,}) {final _that = this; switch (_that) { case _TextFormField(): -return textFormField(_that.data,_that.visible);case _CardLabelItem(): +return textFormField(_that.data,_that.visible,_that.visibleCondition);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);} +return chipSelection(_that.data,_that.visible,_that.visibleCondition);case _Dropdown(): +return dropdown(_that.data,_that.visible,_that.visibleCondition);case _ImagePicker(): +return imagePicker(_that.data,_that.visible,_that.visibleCondition);case _Column(): +return column(_that.children,_that.spacing,_that.mainAxisSize,_that.paddingHorizontal,_that.paddingVertical,_that.crossAxisAlignment,_that.visible,_that.visibleCondition);case _Row(): +return row(_that.children,_that.spacing,_that.mainAxisAlignment,_that.visible,_that.visibleCondition);case _Stepper(): +return stepper(_that.data,_that.children,_that.visible,_that.visibleCondition);case _PageView(): +return pageView(_that.data,_that.children,_that.visible,_that.visibleCondition);case _SizedBox(): +return sizedBox(_that.width,_that.height,_that.visible,_that.visibleCondition);} } /// A variant of `when` that fallback to returning `null` /// @@ -288,19 +289,19 @@ return pageView(_that.data,_that.children,_that.visible);} /// } /// ``` -@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; +@optionalTypeArgs TResult? whenOrNull({TResult? Function( TextFormFieldSDUIModel data, bool visible, String? visibleCondition)? textFormField,TResult? Function( CardLabelItemData data, SDUIWidgetModel? child, List? children, bool visible, String? visibleCondition)? cardLabelItem,TResult? Function( ChipSelectionSDUIModel data, bool visible, String? visibleCondition)? chipSelection,TResult? Function( DropdownSDUIModel data, bool visible, String? visibleCondition)? dropdown,TResult? Function( ImagePickerSDUIModel data, bool visible, String? visibleCondition)? imagePicker,TResult? Function( List children, double spacing, String mainAxisSize, double paddingHorizontal, double paddingVertical, String crossAxisAlignment, bool visible, String? visibleCondition)? column,TResult? Function( List children, double spacing, String mainAxisAlignment, bool visible, String? visibleCondition)? row,TResult? Function( StepperSDUIModel data, List? children, bool visible, String? visibleCondition)? stepper,TResult? Function( PageViewSDUIModel data, List children, bool visible, String? visibleCondition)? pageView,TResult? Function( double? width, double? height, bool visible, String? visibleCondition)? sizedBox,}) {final _that = this; switch (_that) { case _TextFormField() when textFormField != null: -return textFormField(_that.data,_that.visible);case _CardLabelItem() when cardLabelItem != null: +return textFormField(_that.data,_that.visible,_that.visibleCondition);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 chipSelection(_that.data,_that.visible,_that.visibleCondition);case _Dropdown() when dropdown != null: +return dropdown(_that.data,_that.visible,_that.visibleCondition);case _ImagePicker() when imagePicker != null: +return imagePicker(_that.data,_that.visible,_that.visibleCondition);case _Column() when column != null: +return column(_that.children,_that.spacing,_that.mainAxisSize,_that.paddingHorizontal,_that.paddingVertical,_that.crossAxisAlignment,_that.visible,_that.visibleCondition);case _Row() when row != null: +return row(_that.children,_that.spacing,_that.mainAxisAlignment,_that.visible,_that.visibleCondition);case _Stepper() when stepper != null: +return stepper(_that.data,_that.children,_that.visible,_that.visibleCondition);case _PageView() when pageView != null: +return pageView(_that.data,_that.children,_that.visible,_that.visibleCondition);case _SizedBox() when sizedBox != null: +return sizedBox(_that.width,_that.height,_that.visible,_that.visibleCondition);case _: return null; } @@ -312,11 +313,12 @@ return pageView(_that.data,_that.children,_that.visible);case _: @JsonSerializable() class _TextFormField implements SDUIWidgetModel { - const _TextFormField({required this.data, this.visible = true, final String? $type}): $type = $type ?? 'text_form_field'; + const _TextFormField({required this.data, this.visible = true, this.visibleCondition, final String? $type}): $type = $type ?? 'text_form_field'; factory _TextFormField.fromJson(Map json) => _$TextFormFieldFromJson(json); final TextFormFieldSDUIModel data; @override@JsonKey() final bool visible; +@override final String? visibleCondition; @JsonKey(name: 'type') final String $type; @@ -335,16 +337,16 @@ Map toJson() { @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)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _TextFormField&&(identical(other.data, data) || other.data == data)&&(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,visible); +int get hashCode => Object.hash(runtimeType,data,visible,visibleCondition); @override String toString() { - return 'SDUIWidgetModel.textFormField(data: $data, visible: $visible)'; + return 'SDUIWidgetModel.textFormField(data: $data, visible: $visible, visibleCondition: $visibleCondition)'; } @@ -355,7 +357,7 @@ abstract mixin class _$TextFormFieldCopyWith<$Res> implements $SDUIWidgetModelCo factory _$TextFormFieldCopyWith(_TextFormField value, $Res Function(_TextFormField) _then) = __$TextFormFieldCopyWithImpl; @override @useResult $Res call({ - TextFormFieldSDUIModel data, bool visible + TextFormFieldSDUIModel data, bool visible, String? visibleCondition }); @@ -372,11 +374,12 @@ class __$TextFormFieldCopyWithImpl<$Res> /// 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,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? data = null,Object? visible = null,Object? visibleCondition = freezed,}) { 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, +as bool,visibleCondition: freezed == visibleCondition ? _self.visibleCondition : visibleCondition // ignore: cast_nullable_to_non_nullable +as String?, )); } @@ -411,7 +414,7 @@ class _CardLabelItem implements SDUIWidgetModel { } @override@JsonKey() final bool visible; - final String? visibleCondition; +@override final String? visibleCondition; @JsonKey(name: 'type') final String $type; @@ -506,11 +509,12 @@ $SDUIWidgetModelCopyWith<$Res>? get child { @JsonSerializable() class _ChipSelection implements SDUIWidgetModel { - const _ChipSelection({required this.data, this.visible = true, final String? $type}): $type = $type ?? 'chip_selection'; + const _ChipSelection({required this.data, this.visible = true, this.visibleCondition, final String? $type}): $type = $type ?? 'chip_selection'; factory _ChipSelection.fromJson(Map json) => _$ChipSelectionFromJson(json); final ChipSelectionSDUIModel data; @override@JsonKey() final bool visible; +@override final String? visibleCondition; @JsonKey(name: 'type') final String $type; @@ -529,16 +533,16 @@ Map toJson() { @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)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ChipSelection&&(identical(other.data, data) || other.data == data)&&(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,visible); +int get hashCode => Object.hash(runtimeType,data,visible,visibleCondition); @override String toString() { - return 'SDUIWidgetModel.chipSelection(data: $data, visible: $visible)'; + return 'SDUIWidgetModel.chipSelection(data: $data, visible: $visible, visibleCondition: $visibleCondition)'; } @@ -549,7 +553,7 @@ abstract mixin class _$ChipSelectionCopyWith<$Res> implements $SDUIWidgetModelCo factory _$ChipSelectionCopyWith(_ChipSelection value, $Res Function(_ChipSelection) _then) = __$ChipSelectionCopyWithImpl; @override @useResult $Res call({ - ChipSelectionSDUIModel data, bool visible + ChipSelectionSDUIModel data, bool visible, String? visibleCondition }); @@ -566,11 +570,12 @@ class __$ChipSelectionCopyWithImpl<$Res> /// 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,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? data = null,Object? visible = null,Object? visibleCondition = freezed,}) { 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, +as bool,visibleCondition: freezed == visibleCondition ? _self.visibleCondition : visibleCondition // ignore: cast_nullable_to_non_nullable +as String?, )); } @@ -590,11 +595,12 @@ $ChipSelectionSDUIModelCopyWith<$Res> get data { @JsonSerializable() class _Dropdown implements SDUIWidgetModel { - const _Dropdown({required this.data, this.visible = true, final String? $type}): $type = $type ?? 'dropdown'; + const _Dropdown({required this.data, this.visible = true, this.visibleCondition, final String? $type}): $type = $type ?? 'dropdown'; factory _Dropdown.fromJson(Map json) => _$DropdownFromJson(json); final DropdownSDUIModel data; @override@JsonKey() final bool visible; +@override final String? visibleCondition; @JsonKey(name: 'type') final String $type; @@ -613,16 +619,16 @@ Map toJson() { @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)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Dropdown&&(identical(other.data, data) || other.data == data)&&(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,visible); +int get hashCode => Object.hash(runtimeType,data,visible,visibleCondition); @override String toString() { - return 'SDUIWidgetModel.dropdown(data: $data, visible: $visible)'; + return 'SDUIWidgetModel.dropdown(data: $data, visible: $visible, visibleCondition: $visibleCondition)'; } @@ -633,7 +639,7 @@ abstract mixin class _$DropdownCopyWith<$Res> implements $SDUIWidgetModelCopyWit factory _$DropdownCopyWith(_Dropdown value, $Res Function(_Dropdown) _then) = __$DropdownCopyWithImpl; @override @useResult $Res call({ - DropdownSDUIModel data, bool visible + DropdownSDUIModel data, bool visible, String? visibleCondition }); @@ -650,11 +656,12 @@ class __$DropdownCopyWithImpl<$Res> /// 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,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? data = null,Object? visible = null,Object? visibleCondition = freezed,}) { 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, +as bool,visibleCondition: freezed == visibleCondition ? _self.visibleCondition : visibleCondition // ignore: cast_nullable_to_non_nullable +as String?, )); } @@ -674,11 +681,12 @@ $DropdownSDUIModelCopyWith<$Res> get data { @JsonSerializable() class _ImagePicker implements SDUIWidgetModel { - const _ImagePicker({required this.data, this.visible = true, final String? $type}): $type = $type ?? 'image_picker'; + const _ImagePicker({required this.data, this.visible = true, this.visibleCondition, final String? $type}): $type = $type ?? 'image_picker'; factory _ImagePicker.fromJson(Map json) => _$ImagePickerFromJson(json); final ImagePickerSDUIModel data; @override@JsonKey() final bool visible; +@override final String? visibleCondition; @JsonKey(name: 'type') final String $type; @@ -697,16 +705,16 @@ Map toJson() { @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)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ImagePicker&&(identical(other.data, data) || other.data == data)&&(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,visible); +int get hashCode => Object.hash(runtimeType,data,visible,visibleCondition); @override String toString() { - return 'SDUIWidgetModel.imagePicker(data: $data, visible: $visible)'; + return 'SDUIWidgetModel.imagePicker(data: $data, visible: $visible, visibleCondition: $visibleCondition)'; } @@ -717,7 +725,7 @@ abstract mixin class _$ImagePickerCopyWith<$Res> implements $SDUIWidgetModelCopy factory _$ImagePickerCopyWith(_ImagePicker value, $Res Function(_ImagePicker) _then) = __$ImagePickerCopyWithImpl; @override @useResult $Res call({ - ImagePickerSDUIModel data, bool visible + ImagePickerSDUIModel data, bool visible, String? visibleCondition }); @@ -734,11 +742,12 @@ class __$ImagePickerCopyWithImpl<$Res> /// 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,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? data = null,Object? visible = null,Object? visibleCondition = freezed,}) { 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, +as bool,visibleCondition: freezed == visibleCondition ? _self.visibleCondition : visibleCondition // ignore: cast_nullable_to_non_nullable +as String?, )); } @@ -758,7 +767,7 @@ $ImagePickerSDUIModelCopyWith<$Res> get data { @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'; + 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, this.visibleCondition, final String? $type}): _children = children,$type = $type ?? 'column'; factory _Column.fromJson(Map json) => _$ColumnFromJson(json); final List _children; @@ -774,6 +783,7 @@ class _Column implements SDUIWidgetModel { @JsonKey() final double paddingVertical; @JsonKey() final String crossAxisAlignment; @override@JsonKey() final bool visible; +@override final String? visibleCondition; @JsonKey(name: 'type') final String $type; @@ -792,16 +802,16 @@ Map toJson() { @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)); + 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)&&(identical(other.visibleCondition, visibleCondition) || other.visibleCondition == visibleCondition)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_children),spacing,mainAxisSize,paddingHorizontal,paddingVertical,crossAxisAlignment,visible); +int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_children),spacing,mainAxisSize,paddingHorizontal,paddingVertical,crossAxisAlignment,visible,visibleCondition); @override String toString() { - return 'SDUIWidgetModel.column(children: $children, spacing: $spacing, mainAxisSize: $mainAxisSize, paddingHorizontal: $paddingHorizontal, paddingVertical: $paddingVertical, crossAxisAlignment: $crossAxisAlignment, visible: $visible)'; + return 'SDUIWidgetModel.column(children: $children, spacing: $spacing, mainAxisSize: $mainAxisSize, paddingHorizontal: $paddingHorizontal, paddingVertical: $paddingVertical, crossAxisAlignment: $crossAxisAlignment, visible: $visible, visibleCondition: $visibleCondition)'; } @@ -812,7 +822,7 @@ abstract mixin class _$ColumnCopyWith<$Res> implements $SDUIWidgetModelCopyWith< 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 + List children, double spacing, String mainAxisSize, double paddingHorizontal, double paddingVertical, String crossAxisAlignment, bool visible, String? visibleCondition }); @@ -829,7 +839,7 @@ class __$ColumnCopyWithImpl<$Res> /// 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,}) { +@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,Object? visibleCondition = freezed,}) { 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 @@ -838,7 +848,8 @@ as String,paddingHorizontal: null == paddingHorizontal ? _self.paddingHorizontal 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, +as bool,visibleCondition: freezed == visibleCondition ? _self.visibleCondition : visibleCondition // ignore: cast_nullable_to_non_nullable +as String?, )); } @@ -849,7 +860,7 @@ as bool, @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'; + const _Row({required final List children, this.spacing = 0.0, this.mainAxisAlignment = 'start', this.visible = true, this.visibleCondition, final String? $type}): _children = children,$type = $type ?? 'row'; factory _Row.fromJson(Map json) => _$RowFromJson(json); final List _children; @@ -862,6 +873,7 @@ class _Row implements SDUIWidgetModel { @JsonKey() final double spacing; @JsonKey() final String mainAxisAlignment; @override@JsonKey() final bool visible; +@override final String? visibleCondition; @JsonKey(name: 'type') final String $type; @@ -880,16 +892,16 @@ Map toJson() { @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)); + 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)&&(identical(other.visibleCondition, visibleCondition) || other.visibleCondition == visibleCondition)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_children),spacing,mainAxisAlignment,visible); +int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_children),spacing,mainAxisAlignment,visible,visibleCondition); @override String toString() { - return 'SDUIWidgetModel.row(children: $children, spacing: $spacing, mainAxisAlignment: $mainAxisAlignment, visible: $visible)'; + return 'SDUIWidgetModel.row(children: $children, spacing: $spacing, mainAxisAlignment: $mainAxisAlignment, visible: $visible, visibleCondition: $visibleCondition)'; } @@ -900,7 +912,7 @@ abstract mixin class _$RowCopyWith<$Res> implements $SDUIWidgetModelCopyWith<$Re factory _$RowCopyWith(_Row value, $Res Function(_Row) _then) = __$RowCopyWithImpl; @override @useResult $Res call({ - List children, double spacing, String mainAxisAlignment, bool visible + List children, double spacing, String mainAxisAlignment, bool visible, String? visibleCondition }); @@ -917,90 +929,14 @@ class __$RowCopyWithImpl<$Res> /// 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,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? children = null,Object? spacing = null,Object? mainAxisAlignment = null,Object? visible = null,Object? visibleCondition = freezed,}) { 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, +as bool,visibleCondition: freezed == visibleCondition ? _self.visibleCondition : visibleCondition // ignore: cast_nullable_to_non_nullable +as String?, )); } @@ -1011,7 +947,7 @@ as bool, @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'; + const _Stepper({required this.data, final List? children, this.visible = true, this.visibleCondition, final String? $type}): _children = children,$type = $type ?? 'stepper'; factory _Stepper.fromJson(Map json) => _$StepperFromJson(json); final StepperSDUIModel data; @@ -1025,7 +961,7 @@ class _Stepper implements SDUIWidgetModel { } @override@JsonKey() final bool visible; - final int? index; +@override final String? visibleCondition; @JsonKey(name: 'type') final String $type; @@ -1044,16 +980,16 @@ Map toJson() { @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)); + 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.visibleCondition, visibleCondition) || other.visibleCondition == visibleCondition)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,data,const DeepCollectionEquality().hash(_children),visible,index); +int get hashCode => Object.hash(runtimeType,data,const DeepCollectionEquality().hash(_children),visible,visibleCondition); @override String toString() { - return 'SDUIWidgetModel.stepper(data: $data, children: $children, visible: $visible, index: $index)'; + return 'SDUIWidgetModel.stepper(data: $data, children: $children, visible: $visible, visibleCondition: $visibleCondition)'; } @@ -1064,7 +1000,7 @@ abstract mixin class _$StepperCopyWith<$Res> implements $SDUIWidgetModelCopyWith factory _$StepperCopyWith(_Stepper value, $Res Function(_Stepper) _then) = __$StepperCopyWithImpl; @override @useResult $Res call({ - StepperSDUIModel data, List? children, bool visible, int? index + StepperSDUIModel data, List? children, bool visible, String? visibleCondition }); @@ -1081,13 +1017,13 @@ class __$StepperCopyWithImpl<$Res> /// 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,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? data = null,Object? children = freezed,Object? visible = null,Object? visibleCondition = 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?, +as bool,visibleCondition: freezed == visibleCondition ? _self.visibleCondition : visibleCondition // ignore: cast_nullable_to_non_nullable +as String?, )); } @@ -1107,7 +1043,7 @@ $StepperSDUIModelCopyWith<$Res> get data { @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'; + const _PageView({required this.data, required final List children, this.visible = true, this.visibleCondition, final String? $type}): _children = children,$type = $type ?? 'page_view'; factory _PageView.fromJson(Map json) => _$PageViewFromJson(json); final PageViewSDUIModel data; @@ -1119,6 +1055,7 @@ class _PageView implements SDUIWidgetModel { } @override@JsonKey() final bool visible; +@override final String? visibleCondition; @JsonKey(name: 'type') final String $type; @@ -1137,16 +1074,16 @@ Map toJson() { @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)); + 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)&&(identical(other.visibleCondition, visibleCondition) || other.visibleCondition == visibleCondition)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,data,const DeepCollectionEquality().hash(_children),visible); +int get hashCode => Object.hash(runtimeType,data,const DeepCollectionEquality().hash(_children),visible,visibleCondition); @override String toString() { - return 'SDUIWidgetModel.pageView(data: $data, children: $children, visible: $visible)'; + return 'SDUIWidgetModel.pageView(data: $data, children: $children, visible: $visible, visibleCondition: $visibleCondition)'; } @@ -1157,7 +1094,7 @@ abstract mixin class _$PageViewCopyWith<$Res> implements $SDUIWidgetModelCopyWit factory _$PageViewCopyWith(_PageView value, $Res Function(_PageView) _then) = __$PageViewCopyWithImpl; @override @useResult $Res call({ - PageViewSDUIModel data, List children, bool visible + PageViewSDUIModel data, List children, bool visible, String? visibleCondition }); @@ -1174,12 +1111,13 @@ class __$PageViewCopyWithImpl<$Res> /// 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,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? data = null,Object? children = null,Object? visible = null,Object? visibleCondition = freezed,}) { 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, +as bool,visibleCondition: freezed == visibleCondition ? _self.visibleCondition : visibleCondition // ignore: cast_nullable_to_non_nullable +as String?, )); } @@ -1195,4 +1133,83 @@ $PageViewSDUIModelCopyWith<$Res> get data { } } +/// @nodoc +@JsonSerializable() + +class _SizedBox implements SDUIWidgetModel { + const _SizedBox({this.width, this.height, this.visible = true, this.visibleCondition, 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; +@override 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') +_$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)&&(identical(other.visibleCondition, visibleCondition) || other.visibleCondition == visibleCondition)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,width,height,visible,visibleCondition); + +@override +String toString() { + return 'SDUIWidgetModel.sizedBox(width: $width, height: $height, visible: $visible, visibleCondition: $visibleCondition)'; +} + + +} + +/// @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, String? visibleCondition +}); + + + + +} +/// @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,Object? visibleCondition = freezed,}) { + 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,visibleCondition: freezed == visibleCondition ? _self.visibleCondition : visibleCondition // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + + +} + // 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 index a342029..1096e3d 100644 --- a/packages/chicken/lib/presentation/widget/sdui/model/sdui_widget.g.dart +++ b/packages/chicken/lib/presentation/widget/sdui/model/sdui_widget.g.dart @@ -12,6 +12,7 @@ _TextFormField _$TextFormFieldFromJson(Map json) => json['data'] as Map, ), visible: json['visible'] as bool? ?? true, + visibleCondition: json['visible_condition'] as String?, $type: json['type'] as String?, ); @@ -19,6 +20,7 @@ Map _$TextFormFieldToJson(_TextFormField instance) => { 'data': instance.data, 'visible': instance.visible, + 'visible_condition': instance.visibleCondition, 'type': instance.$type, }; @@ -52,6 +54,7 @@ _ChipSelection _$ChipSelectionFromJson(Map json) => json['data'] as Map, ), visible: json['visible'] as bool? ?? true, + visibleCondition: json['visible_condition'] as String?, $type: json['type'] as String?, ); @@ -59,24 +62,28 @@ Map _$ChipSelectionToJson(_ChipSelection instance) => { 'data': instance.data, 'visible': instance.visible, + 'visible_condition': instance.visibleCondition, 'type': instance.$type, }; _Dropdown _$DropdownFromJson(Map json) => _Dropdown( data: DropdownSDUIModel.fromJson(json['data'] as Map), visible: json['visible'] as bool? ?? true, + visibleCondition: json['visible_condition'] as String?, $type: json['type'] as String?, ); Map _$DropdownToJson(_Dropdown instance) => { 'data': instance.data, 'visible': instance.visible, + 'visible_condition': instance.visibleCondition, 'type': instance.$type, }; _ImagePicker _$ImagePickerFromJson(Map json) => _ImagePicker( data: ImagePickerSDUIModel.fromJson(json['data'] as Map), visible: json['visible'] as bool? ?? true, + visibleCondition: json['visible_condition'] as String?, $type: json['type'] as String?, ); @@ -84,6 +91,7 @@ Map _$ImagePickerToJson(_ImagePicker instance) => { 'data': instance.data, 'visible': instance.visible, + 'visible_condition': instance.visibleCondition, 'type': instance.$type, }; @@ -97,6 +105,7 @@ _Column _$ColumnFromJson(Map json) => _Column( paddingVertical: (json['padding_vertical'] as num?)?.toDouble() ?? 0.0, crossAxisAlignment: json['cross_axis_alignment'] as String? ?? 'center', visible: json['visible'] as bool? ?? true, + visibleCondition: json['visible_condition'] as String?, $type: json['type'] as String?, ); @@ -108,6 +117,7 @@ Map _$ColumnToJson(_Column instance) => { 'padding_vertical': instance.paddingVertical, 'cross_axis_alignment': instance.crossAxisAlignment, 'visible': instance.visible, + 'visible_condition': instance.visibleCondition, 'type': instance.$type, }; @@ -118,6 +128,7 @@ _Row _$RowFromJson(Map json) => _Row( spacing: (json['spacing'] as num?)?.toDouble() ?? 0.0, mainAxisAlignment: json['main_axis_alignment'] as String? ?? 'start', visible: json['visible'] as bool? ?? true, + visibleCondition: json['visible_condition'] as String?, $type: json['type'] as String?, ); @@ -126,20 +137,7 @@ Map _$RowToJson(_Row instance) => { '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, + 'visible_condition': instance.visibleCondition, 'type': instance.$type, }; @@ -149,7 +147,7 @@ _Stepper _$StepperFromJson(Map json) => _Stepper( ?.map((e) => SDUIWidgetModel.fromJson(e as Map)) .toList(), visible: json['visible'] as bool? ?? true, - index: (json['index'] as num?)?.toInt(), + visibleCondition: json['visible_condition'] as String?, $type: json['type'] as String?, ); @@ -157,7 +155,7 @@ Map _$StepperToJson(_Stepper instance) => { 'data': instance.data, 'children': instance.children, 'visible': instance.visible, - 'index': instance.index, + 'visible_condition': instance.visibleCondition, 'type': instance.$type, }; @@ -167,6 +165,7 @@ _PageView _$PageViewFromJson(Map json) => _PageView( .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?, ); @@ -174,5 +173,22 @@ Map _$PageViewToJson(_PageView instance) => { 'data': instance.data, 'children': instance.children, 'visible': instance.visible, + 'visible_condition': instance.visibleCondition, + '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, + visibleCondition: json['visible_condition'] as String?, + $type: json['type'] as String?, +); + +Map _$SizedBoxToJson(_SizedBox instance) => { + 'width': instance.width, + 'height': instance.height, + 'visible': instance.visible, + 'visible_condition': instance.visibleCondition, 'type': instance.$type, };