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 4e2a3ca..3f9f9a0 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 @@ -25,30 +25,39 @@ class NewPage extends GetView { child: Column( children: [ SizedBox(height: 24.h), - ObxValue((data) { - if (data.value == null) { - return Center(child: CircularProgressIndicator()); - } - return Obx( - () => SDUIFormWidget( - model: data.value!, - controllers: controller.controllers, - state: controller.formState, - onStateChanged: (key, value) { - controller.formState[key] = value; - }, - images: controller.images, - onImagesChanged: (key, imageList) { - controller.images[key] = imageList; - }, - ), - ); - }, controller.sduiModel), + Row(children: []), SizedBox(height: 24.h), RElevated( text: 'دکمه نمونه', onPressed: () { - controller.onButtonPressed(); + Get.bottomSheet( + isScrollControlled: true, + enableDrag: true, + + + BaseBottomSheet( + height: Get.height * 0.8, + child: ObxValue((data) { + if (data.value == null) { + return Center(child: CircularProgressIndicator()); + } + return Obx( + () => SDUIFormWidget( + model: data.value!, + controllers: controller.controllers, + state: controller.formState, + onStateChanged: (key, value) { + controller.formState[key] = value; + }, + images: controller.images, + onImagesChanged: (key, imageList) { + controller.images[key] = imageList; + }, + ), + ); + }, controller.sduiModel), + ), + ); }, ), SizedBox(height: 24.h), diff --git a/packages/chicken/lib/presentation/widget/sdui/sdui.json b/packages/chicken/lib/presentation/widget/sdui/sdui.json index a053d9d..923ddfb 100644 --- a/packages/chicken/lib/presentation/widget/sdui/sdui.json +++ b/packages/chicken/lib/presentation/widget/sdui/sdui.json @@ -1,13 +1,149 @@ { - "type": "card_label_item", - "visible": true, - "data": { - "title": "اطلاعات مزرعه", - "padding_horizontal": 12.0, - "padding_vertical": 11.0 - }, - "child": { - + "info": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0, + "crossAxisAlignment": "start" + }, + "children": [ + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "اطلاعات پایه واحد", + "padding_horizontal": 12.0, + "padding_vertical": 11.0 + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "unit_name", + "label": "نام واحد مرغداری", + "keyboard_type": "text" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "breeding_unique_id", + "label": "(عدد معمولی)کد یکتا / شناسه واحد", + "keyboard_type": "number" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "health", + "label": "پروانه بهداشتی", + "keyboard_type": "number" + + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "health_license", + "label": "عدد اعشاری ", + "keyboard_type": "number", + "decimal": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "health_q", + "label": "عدد اعشاری با 2 رقم اعشار", + "keyboard_type": "number", + "decimal": true, + "decimal_places": 2 + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "unit_date", + "label": "نام تاریییییییییییخ", + "keyboard_type": "text", + "type": "date_picker" + } + }, + { + "type": "chip_selection", + "visible": true, + "data": { + "key": "grain_quality", + "label": "کیفیت دانه", + "selectedIndex": -1, + "options": [ + { + "index": 0, + "label": "خوب", + "value": "خوب" + }, + { + "index": 1, + "label": "متوسط", + "value": "متوسط" + }, + { + "index": 2, + "label": "ضعیف", + "value": "ضعیف" + } + ] + } + }, + { + "type": "dropdown", + "visible": true, + "data": { + "key": "training_status", + "label": "آموزش‌دیده در حوزه بهداشت و امنیت زیستی", + "placeholder": "آموزش‌دیده در حوزه بهداشت و امنیت زیستی", + "items": [ + "بله", + "خیر" + ], + "selectedValue": null, + "enabled": true + } + }, + { + "type": "image_picker", + "visible": true, + "data": { + "key": "hall_images", + "label": "ثبت عکس سالن (حداقل ۳ زاویه)", + "required": true + } + }, + { + "type": "image_picker", + "visible": true, + "data": { + "key": "hall_images_klllll", + "label": "ثبت عکس", + "required": true, + "max_images": 3 + } + } + ] + } + } + ] } -} - +} \ No newline at end of file diff --git a/packages/chicken/lib/presentation/widget/sdui/widgets/card_label_item/sdui.json b/packages/chicken/lib/presentation/widget/sdui/widgets/card_label_item/sdui.json index a053d9d..a81d9c2 100644 --- a/packages/chicken/lib/presentation/widget/sdui/widgets/card_label_item/sdui.json +++ b/packages/chicken/lib/presentation/widget/sdui/widgets/card_label_item/sdui.json @@ -1,13 +1,1086 @@ { - "type": "card_label_item", + "type": "column", "visible": true, "data": { - "title": "اطلاعات مزرعه", - "padding_horizontal": 12.0, - "padding_vertical": 11.0 + "spacing": 30.0 }, - "child": { - - } -} - + "children": [ + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "اطلاعات پایه واحد", + "padding_horizontal": 12.0, + "padding_vertical": 11.0 + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "unit_name", + "label": "نام واحد مرغداری", + "keyboard_type": "text", + "readonly": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "breeding_unique_id", + "label": "کد یکتا / شناسه واحد", + "keyboard_type": "text", + "readonly": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "health_license", + "label": "پروانه بهداشتی", + "keyboard_type": "text" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "tenant_status", + "label": "وضعیت مستاجر", + "keyboard_type": "text" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "tenant_name", + "label": "نام مستاجر", + "keyboard_type": "text", + "visible_condition": "tenant_status == 'دارد'" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "tenant_national_id", + "label": "کد ملی مستاجر", + "keyboard_type": "text", + "visible_condition": "tenant_status == 'دارد'" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "tenant_phone_number", + "label": "شماره تماس مستاجر", + "keyboard_type": "text", + "visible_condition": "tenant_status == 'دارد'" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "owner_national_code", + "label": "کد ملی بهره‌بردار", + "keyboard_type": "text", + "readonly": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "owner_phone_number", + "label": "شماره تماس بهره‌بردار", + "keyboard_type": "text", + "readonly": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "total_capacity", + "label": "ظرفیت اسمی سالن‌ها", + "keyboard_type": "number", + "comma_separator": true + } + } + ] + } + }, + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "اطلاعات جوجه ریزی", + "padding_horizontal": 12.0, + "padding_vertical": 11.0 + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "hatching_date", + "label": "تاریخ جوجه ریزی", + "keyboard_type": "text", + "readonly": true, + "type": "date_picker" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "visit_date", + "label": "تاریخ بازدید", + "keyboard_type": "text", + "readonly": true, + "type": "date_picker" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "hatching_count", + "label": "تعداد جوجه‌ریزی اولیه", + "keyboard_type": "number", + "readonly": true, + "comma_separator": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "hatching_breed", + "label": "نوع نژاد", + "keyboard_type": "text" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "hatching_average_weight", + "label": "میانگین وزن جوجه", + "keyboard_type": "number", + "comma_separator": true + } + } + ] + } + }, + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "وضعیت عمومی سالن", + "padding_horizontal": 12.0, + "padding_vertical": 11.0 + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "image_picker", + "visible": true, + "data": { + "key": "pultry_images", + "label": "تعداد موجود فعلی" + } + }, + { + "type": "chip_selection", + "visible": true, + "data": { + "key": "sanitary_condition_of_the_hall", + "label": "وضعیت بهداشتی سالن", + "selectedIndex": -1, + "options": [ + { + "index": 0, + "label": "عالی", + "value": "عالی" + }, + { + "index": 1, + "label": "خوب", + "value": "خوب" + }, + { + "index": 2, + "label": "متوسط", + "value": "متوسط" + }, + { + "index": 3, + "label": "ضعیف", + "value": "ضعیف" + } + ] + } + }, + { + "type": "chip_selection", + "visible": true, + "data": { + "key": "ventilation_status", + "label": "وضعیت تهویه", + "selectedIndex": -1, + "options": [ + { + "index": 0, + "label": "عالی", + "value": "عالی" + }, + { + "index": 1, + "label": "خوب", + "value": "خوب" + }, + { + "index": 2, + "label": "متوسط", + "value": "متوسط" + }, + { + "index": 3, + "label": "ضعیف", + "value": "ضعیف" + } + ] + } + }, + { + "type": "chip_selection", + "visible": true, + "data": { + "key": "bedding_status", + "label": "وضعیت بستر", + "selectedIndex": -1, + "options": [ + { + "index": 0, + "label": "خشک", + "value": "خشک" + }, + { + "index": 1, + "label": "نیمه‌مرطوب", + "value": "نیمه‌مرطوب" + }, + { + "index": 2, + "label": "مرطوب", + "value": "مرطوب" + } + ] + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "hatching_temperature", + "label": "دمای سالن", + "keyboard_type": "number" + } + }, + { + "type": "chip_selection", + "visible": true, + "data": { + "key": "water_quality", + "label": "آب مصرفی", + "selectedIndex": -1, + "options": [ + { + "index": 0, + "label": "چاه", + "value": "چاه" + }, + { + "index": 1, + "label": "شهری", + "value": "شهری" + }, + { + "index": 2, + "label": "تصفیه‌شده", + "value": "تصفیه‌شده" + }, + { + "index": 3, + "label": "حمل تانکر", + "value": "حمل تانکر" + } + ] + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "water_hardness", + "label": "درصد سختی آب (PPM)", + "keyboard_type": "number", + "decimal": true + } + } + ] + } + }, + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "تلفات", + "padding_horizontal": 12.0, + "padding_vertical": 11.0 + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "normal_losses", + "label": "تعداد تلفات عادی دوره", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "abnormal_losses", + "label": "تلفات غیرعادی", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "dropdown", + "visible": true, + "data": { + "key": "cause_of_unusual_casualties", + "label": "علت تلفات غیرعادی", + "placeholder": "علت تلفات غیرعادی", + "items": [ + "بیماری", + "قطعی برق", + "استرس گرمایی", + "مشکلات دان", + "کیفیت جوجه", + "سایر (شرح…)" + ], + "selectedValue": null, + "enabled": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "other_cause_of_unusual_casualties", + "label": "علت تلفات غیرعادی", + "keyboard_type": "text", + "visible_condition": "cause_of_unusual_casualties == 'سایر (شرح…)'" + } + }, + { + "type": "dropdown", + "visible": true, + "data": { + "key": "type_of_disease", + "label": "نوع بیماری تشخیص داده‌شده / مشکوک", + "placeholder": "نوع بیماری تشخیص داده‌شده / مشکوک", + "items": [ + "آنفلوانزا", + "نیوکاسل", + "IB", + "عفونت‌های باکتریایی", + "مشکلات گوارشی", + "سایر (شرح)" + ], + "selectedValue": null, + "enabled": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "other_type_of_disease", + "label": "نوع بیماری", + "keyboard_type": "text", + "visible_condition": "type_of_disease == 'سایر (شرح)'" + } + }, + { + "type": "dropdown", + "visible": true, + "data": { + "key": "sampling_done", + "label": "نمونه‌برداری انجام‌شده", + "placeholder": "نمونه‌برداری انجام‌شده", + "items": [ + "انجام شد", + "انجام نشد" + ], + "selectedValue": null, + "enabled": true + } + }, + { + "type": "chip_selection", + "visible": true, + "data": { + "key": "sample_type", + "label": "نوع نمونه", + "selectedIndex": -1, + "visible_condition": "sampling_done == 'انجام شد'", + "options": [ + { + "index": 0, + "label": "لاشه", + "value": "لاشه" + }, + { + "index": 1, + "label": "آب", + "value": "آب" + }, + { + "index": 2, + "label": "دانه", + "value": "دانه" + } + ] + } + } + ] + } + }, + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "مسئول فنی", + "padding_horizontal": 12.0, + "padding_vertical": 11.0 + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "technical_health_officer_name", + "label": "نام مسئول فنی بهداشتی", + "keyboard_type": "text" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "technical_engineering_officer_name", + "label": "نام مسئول فنی نظام مهندسی", + "keyboard_type": "text" + } + } + ] + } + }, + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "نهاده و خوراک", + "padding_horizontal": 12.0, + "padding_vertical": 11.0 + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "dropdown", + "visible": true, + "data": { + "key": "input_status", + "label": "وضعیت نهاده", + "placeholder": "وضعیت نهاده", + "items": [ + "وابسته", + "مستقل" + ], + "selectedValue": null, + "enabled": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "company_name", + "label": "نام کارخانه", + "keyboard_type": "text", + "visible_condition": "input_status == 'وابسته'" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "tracking_code", + "label": "شناسه خرید یا کد پیگیری", + "keyboard_type": "text", + "visible_condition": "input_status == 'مستقل'" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "input_inventory_until_visit", + "label": "موجودی نهاده مصرفی تا روز بازدید (کیلوگرم)", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "dropdown", + "visible": true, + "data": { + "key": "type_of_grain", + "label": "نوع دان", + "placeholder": "نوع دان", + "items": [ + "آردی", + "پلت", + "کرامبل و اکسترود", + "مش", + "پوره و وال" + ], + "selectedValue": null, + "enabled": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "input_inventory_in_warehouse", + "label": "موجودی نهاده موجود در انبار (کیلوگرم)", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "chip_selection", + "visible": true, + "data": { + "key": "grain_quality", + "label": "کیفیت دانه", + "selectedIndex": -1, + "options": [ + { + "index": 0, + "label": "خوب", + "value": "خوب" + }, + { + "index": 1, + "label": "متوسط", + "value": "متوسط" + }, + { + "index": 2, + "label": "ضعیف", + "value": "ضعیف" + } + ] + } + } + ] + } + }, + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "زیرساخت و انرژی", + "padding_horizontal": 12.0, + "padding_vertical": 11.0 + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "generator_type", + "label": "نوع ژنراتور", + "keyboard_type": "text" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "generator_model", + "label": "مدل ژنراتور", + "keyboard_type": "text" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "generator_count", + "label": "تعداد ژنراتور", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "dropdown", + "visible": true, + "data": { + "key": "fuel_type", + "label": "نوع سوخت", + "placeholder": "نوع سوخت", + "items": [ + "گازوئیل", + "نفت گاز" + ], + "selectedValue": null, + "enabled": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "generator_capacity", + "label": "ظرفیت (KVA)", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "chip_selection", + "visible": true, + "data": { + "key": "generator_operating_status", + "label": "وضعیت عملکرد ژنراتور", + "selectedIndex": -1, + "options": [ + { + "index": 0, + "label": "سالم", + "value": "سالم" + }, + { + "index": 1, + "label": "نیمه‌سالم", + "value": "نیمه‌سالم" + }, + { + "index": 2, + "label": "معیوب", + "value": "معیوب" + } + ] + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "emergency_fuel_inventory", + "label": "میزان موجودی سوخت اضطراری (لیتر)", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "dropdown", + "visible": true, + "data": { + "key": "power_cut_history", + "label": "سابقه قطعی برق دوره جاری", + "placeholder": "سابقه قطعی برق دوره جاری", + "items": [ + "ندارد", + "دارد" + ], + "selectedValue": null, + "enabled": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "power_cut_duration", + "label": "مدت قطعی", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "power_cut_hour", + "label": "ساعت قطعی", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "additional_notes", + "label": "توضیحات تکمیلی", + "keyboard_type": "text", + "max_line": 5, + "min_line": 5 + } + } + ] + } + }, + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "نیروی انسانی", + "padding_horizontal": 12.0, + "padding_vertical": 11.0 + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "employed_workers_count", + "label": "تعداد افراد شاغل", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "native_workers_count", + "label": "تعداد افراد بومی", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "non_native_workers_count", + "label": "تعداد افراد غیر بومی", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "chip_selection", + "visible": true, + "data": { + "key": "worker_contract_status", + "label": "وضعیت قرارداد کارگران", + "selectedIndex": -1, + "options": [ + { + "index": 0, + "label": "دائم", + "value": "دائم" + }, + { + "index": 1, + "label": "موقت", + "value": "موقت" + }, + { + "index": 2, + "label": "روزمزدی", + "value": "روزمزدی" + } + ] + } + }, + { + "type": "dropdown", + "visible": true, + "data": { + "key": "training_status", + "label": "آموزش‌دیده در حوزه بهداشت و امنیت زیستی", + "placeholder": "آموزش‌دیده در حوزه بهداشت و امنیت زیستی", + "items": [ + "بله", + "خیر" + ], + "selectedValue": null, + "enabled": true + } + } + ] + } + }, + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "تسهیلات و حمایت‌ها", + "padding_horizontal": 12.0, + "padding_vertical": 11.0 + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "dropdown", + "visible": true, + "data": { + "key": "has_facilities", + "label": "تسهیلات دریافتی فعال", + "placeholder": "تسهیلات دریافتی فعال", + "items": [ + "دارد", + "ندارد" + ], + "selectedValue": null, + "enabled": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "facility_type", + "label": "نوع تسهیلات", + "keyboard_type": "text" + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "facility_amount", + "label": "مبلغ", + "keyboard_type": "number", + "comma_separator": true + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "payment_year", + "label": "سال دریافت", + "keyboard_type": "text", + "readonly": true, + "type": "date_picker" + } + }, + { + "type": "dropdown", + "visible": true, + "data": { + "key": "overdue_status", + "label": "وضعیت بازپرداخت", + "placeholder": "وضعیت بازپرداخت", + "items": [ + "دارای معوقه", + "منظم" + ], + "selectedValue": null, + "enabled": true + } + }, + { + "type": "dropdown", + "visible": true, + "data": { + "key": "new_beneficiary_request", + "label": "درخواست جدید بهره بردار", + "placeholder": "درخواست جدید بهره بردار", + "items": [ + "نهاده", + "تسهیلات", + "واکسن", + "تجهیزات" + ], + "selectedValue": null, + "enabled": true + } + } + ] + } + }, + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "مستندات", + "padding_horizontal": 12.0, + "padding_vertical": 11.0 + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "image_picker", + "visible": true, + "data": { + "key": "hall_images", + "label": "ثبت عکس سالن (حداقل ۳ زاویه)", + "required": true + } + }, + { + "type": "image_picker", + "visible": true, + "data": { + "key": "input_warehouse_images", + "label": "ثبت عکس انبار نهاده‌ها" + } + }, + { + "type": "image_picker", + "visible": true, + "data": { + "key": "losses_images", + "label": "ثبت عکس تلفات" + } + } + ] + } + }, + { + "type": "card_label_item", + "visible": true, + "data": { + "title": "جمع‌بندی بازرس", + "padding_horizontal": 12.0, + "padding_vertical": 11.0 + }, + "child": { + "type": "column", + "visible": true, + "data": { + "spacing": 10.0 + }, + "children": [ + { + "type": "chip_selection", + "visible": true, + "data": { + "key": "inspector_conclusion", + "label": "وضعیت کلی واحد", + "selectedIndex": -1, + "options": [ + { + "index": 0, + "label": "تایید شده", + "value": "تایید شده" + }, + { + "index": 1, + "label": "نیازمند اصلاح", + "value": "نیازمند اصلاح" + }, + { + "index": 2, + "label": "پرریسک", + "value": "پرریسک" + } + ] + } + }, + { + "type": "text_form_field", + "visible": true, + "data": { + "key": "inspector_conclusion_description", + "label": "توصیه‌ها / اخطارها / اقدامات اصلاحی ...", + "hint_text": "توصیه‌ها / اخطارها / اقدامات اصلاحی ...", + "keyboard_type": "text", + "max_line": 5, + "min_line": 5 + } + } + ] + } + } + ] +} \ No newline at end of file diff --git a/packages/core/lib/presentation/widget/inputs/r_input.dart b/packages/core/lib/presentation/widget/inputs/r_input.dart index 1aa6a81..b994254 100644 --- a/packages/core/lib/presentation/widget/inputs/r_input.dart +++ b/packages/core/lib/presentation/widget/inputs/r_input.dart @@ -213,86 +213,98 @@ class _RTextFieldState extends State { return widget.height; } + bool get _isMultiLine { + return (widget.maxLines != null && widget.maxLines! > 1) || + (widget.minLines != null && widget.minLines! > 1); + } + @override Widget build(BuildContext context) { - return SizedBox( - height: _calculateHeight().h, - child: Padding( - padding: widget.padding ?? EdgeInsets.zero, - child: TextFormField( - key: _formFieldKey, - textAlignVertical: TextAlignVertical.center, - controller: widget.controller, - focusNode: widget.focusNode, - textAlign: widget.textAlign ?? TextAlign.start, - readOnly: widget.readonly, - minLines: widget.minLines, - maxLines: widget.maxLines, - onChanged: (value) { - widget.onChanged?.call(value); - }, - validator: (value) { - final error = widget.validator?.call(value); + final Widget textField = Padding( + padding: widget.padding ?? EdgeInsets.zero, + child: TextFormField( + key: _formFieldKey, + textAlignVertical: _isMultiLine + ? TextAlignVertical.top + : TextAlignVertical.center, + controller: widget.controller, + focusNode: widget.focusNode, + textAlign: widget.textAlign ?? TextAlign.start, + readOnly: widget.readonly, + minLines: widget.minLines, + maxLines: widget.maxLines, + onChanged: (value) { + widget.onChanged?.call(value); + }, + validator: (value) { + final error = widget.validator?.call(value); - if (widget.isFullHeight) { - WidgetsBinding.instance.addPostFrameCallback((_) { - if (mounted) { - setState(() {}); - } - }); - } - return error; - }, - inputFormatters: widget.inputFormatters, - enabled: widget.enabled, - obscureText: obscure, - onTap: widget.onTap, - onTapOutside: (_) => FocusScope.of(context).unfocus(), - onFieldSubmitted: widget.onSubmitted, - maxLength: widget.maxLength, - textDirection: textDirection, - style: widget.style, - keyboardType: widget.keyboardType, - autovalidateMode: - widget.autoValidateMode ?? AutovalidateMode.disabled, - cursorColor: widget.cursorColor, - textCapitalization: widget.textCapitalization, - autocorrect: widget.autocorrect ?? true, - enableSuggestions: widget.enableSuggestions ?? true, - textInputAction: widget.textInputAction, - autofillHints: widget.autofillHints, - decoration: InputDecoration( - contentPadding: EdgeInsets.symmetric( - horizontal: 16, - vertical: widget.isFullHeight ? widget.height / 3 : 0, - ), - - errorStyle: widget.errorStyle, - errorMaxLines: 1, - isDense: widget.isDense, - suffix: widget.suffix, - suffixIcon: _buildSuffixIcon(), - suffixIconConstraints: widget.boxConstraints, - prefixIcon: widget.prefixIcon, - prefixIconConstraints: widget.boxConstraints, - hintText: widget.hintText, - labelText: widget.label, - alignLabelWithHint: true, - labelStyle: AppFonts.yekan14 - .copyWith(color: AppColor.lightGreyDarkActive) - .merge(widget.labelStyle), - filled: - widget.filled || widget._noBorder || widget._passwordNoBorder, - fillColor: widget.filledColor, - counter: widget.showCounter ? null : const SizedBox(), - hintStyle: widget.hintStyle, - enabledBorder: widget._inputBorder, - focusedBorder: widget.focusedBorder ?? widget._inputBorder, - border: widget._inputBorder, + if (widget.isFullHeight) { + WidgetsBinding.instance.addPostFrameCallback((_) { + if (mounted) { + setState(() {}); + } + }); + } + return error; + }, + inputFormatters: widget.inputFormatters, + enabled: widget.enabled, + obscureText: obscure, + onTap: widget.onTap, + onTapOutside: (_) => FocusScope.of(context).unfocus(), + onFieldSubmitted: widget.onSubmitted, + maxLength: widget.maxLength, + textDirection: textDirection, + style: widget.style, + keyboardType: widget.keyboardType, + autovalidateMode: widget.autoValidateMode ?? AutovalidateMode.disabled, + cursorColor: widget.cursorColor, + textCapitalization: widget.textCapitalization, + autocorrect: widget.autocorrect ?? true, + enableSuggestions: widget.enableSuggestions ?? true, + textInputAction: widget.textInputAction, + autofillHints: widget.autofillHints, + decoration: InputDecoration( + contentPadding: EdgeInsets.symmetric( + horizontal: 16, + vertical: _isMultiLine + ? 12 + : (widget.isFullHeight ? widget.height / 3 : 0), ), + + errorStyle: widget.errorStyle, + errorMaxLines: 1, + isDense: widget.isDense, + suffix: widget.suffix, + suffixIcon: _buildSuffixIcon(), + suffixIconConstraints: widget.boxConstraints, + prefixIcon: widget.prefixIcon, + prefixIconConstraints: widget.boxConstraints, + hintText: widget.hintText, + labelText: widget.label, + alignLabelWithHint: true, + labelStyle: AppFonts.yekan14 + .copyWith(color: AppColor.lightGreyDarkActive) + .merge(widget.labelStyle), + filled: widget.filled || widget._noBorder || widget._passwordNoBorder, + fillColor: widget.filledColor, + counter: widget.showCounter ? null : const SizedBox(), + hintStyle: widget.hintStyle, + enabledBorder: widget._inputBorder, + focusedBorder: widget.focusedBorder ?? widget._inputBorder, + border: widget._inputBorder, ), ), ); + + // برای فیلدهای تک خطی، ارتفاع ثابت اعمال می‌کنیم + // برای فیلدهای چند خطی، اجازه می‌دهیم ارتفاع به صورت خودکار تنظیم شود + if (_isMultiLine) { + return textField; + } + + return SizedBox(height: _calculateHeight().h, child: textField); } @override