refactor: update text form field model to use dynamic value type, enhance condition evaluator for step index extraction, and improve SDK path formatting
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import 'package:rasadyar_chicken/features/poultry_science/data/model/response/poultry_science_report/poultry_science_report.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/data/model/request/submit_inspection/submit_inspection_response.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/data/model/response/poultry_science_report/poultry_science_report.dart';
|
||||
import 'package:rasadyar_chicken/features/vet_farm/data/datasources/remote/vet_farm_remote_data_source.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
@@ -38,11 +38,9 @@ class VetFarmRemoteDataSourceImpl implements VetFarmRemoteDataSource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<DioResponse<Map<String, dynamic>>> getSDUIForm({
|
||||
required String token,
|
||||
}) async {
|
||||
Future<DioResponse<Map<String, dynamic>>> getSDUIForm({required String token}) async {
|
||||
var res = await _httpClient.get(
|
||||
'/inspection_form_sd_ui/?name=b1',
|
||||
'/form-information/?hatching=232&form=b1',
|
||||
headers: {'Authorization': 'Bearer $token'},
|
||||
fromJson: (json) {
|
||||
return json;
|
||||
|
||||
@@ -41,9 +41,7 @@ class NewPageLogic extends GetxController {
|
||||
// Check if info has type field (meaning it's the SDUI structure itself)
|
||||
if (infoMap.containsKey('type')) {
|
||||
sduiData = infoMap;
|
||||
iLog(
|
||||
'SDUI data extracted from info (info contains type field)',
|
||||
);
|
||||
iLog('SDUI data extracted from info (info contains type field)');
|
||||
} else if (infoMap['data'] != null) {
|
||||
// Fallback: if info.data exists, use it
|
||||
sduiData = infoMap['data'] as Map<String, dynamic>;
|
||||
@@ -64,16 +62,12 @@ class NewPageLogic extends GetxController {
|
||||
// Log model info using pattern matching
|
||||
final modelType =
|
||||
sduiModel.value?.maybeWhen(
|
||||
textFormField: (data, visible, visibleCondition) =>
|
||||
'text_form_field',
|
||||
cardLabelItem:
|
||||
(data, child, children, visible, visibleCondition) =>
|
||||
'card_label_item',
|
||||
chipSelection: (data, visible, visibleCondition) =>
|
||||
'chip_selection',
|
||||
textFormField: (data, visible, visibleCondition) => 'text_form_field',
|
||||
cardLabelItem: (data, child, children, visible, visibleCondition) =>
|
||||
'card_label_item',
|
||||
chipSelection: (data, visible, visibleCondition) => 'chip_selection',
|
||||
dropdown: (data, visible, visibleCondition) => 'dropdown',
|
||||
imagePicker: (data, visible, visibleCondition) =>
|
||||
'image_picker',
|
||||
imagePicker: (data, visible, visibleCondition) => 'image_picker',
|
||||
column:
|
||||
(
|
||||
children,
|
||||
@@ -85,20 +79,10 @@ class NewPageLogic extends GetxController {
|
||||
paddingVertical,
|
||||
visibleCondition,
|
||||
) => 'column',
|
||||
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',
|
||||
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';
|
||||
@@ -116,21 +100,12 @@ class NewPageLogic extends GetxController {
|
||||
paddingVertical,
|
||||
visibleCondition,
|
||||
) => children.length,
|
||||
row:
|
||||
(
|
||||
children,
|
||||
spacing,
|
||||
mainAxisAlignment,
|
||||
visible,
|
||||
visibleCondition,
|
||||
) => children.length,
|
||||
cardLabelItem:
|
||||
(data, child, children, visible, visibleCondition) =>
|
||||
(child != null ? 1 : 0) + (children?.length ?? 0),
|
||||
stepper: (data, children, visible, visibleCondition) =>
|
||||
children?.length ?? 0,
|
||||
pageView: (data, children, visible, visibleCondition) =>
|
||||
row: (children, spacing, mainAxisAlignment, visible, visibleCondition) =>
|
||||
children.length,
|
||||
cardLabelItem: (data, child, children, visible, visibleCondition) =>
|
||||
(child != null ? 1 : 0) + (children?.length ?? 0),
|
||||
stepper: (data, children, visible, visibleCondition) => children?.length ?? 0,
|
||||
pageView: (data, children, visible, visibleCondition) => children.length,
|
||||
orElse: () => 0,
|
||||
) ??
|
||||
0;
|
||||
@@ -170,7 +145,7 @@ class NewPageLogic extends GetxController {
|
||||
final key = data.key;
|
||||
final value = data.value;
|
||||
if (key != null && !controllers.containsKey(key)) {
|
||||
controllers[key] = TextEditingController(text: value ?? '');
|
||||
controllers[key] = TextEditingController(text: value.toString() ?? '');
|
||||
}
|
||||
},
|
||||
orElse: () {},
|
||||
|
||||
Reference in New Issue
Block a user