|
|
|
|
|
|
|
|
// |
|
|
// |
|
|
|
|
|
|
|
|
Widget generateTextField(List<ActionUIField> fields) { |
|
|
Widget generateTextField(List<ActionUIField> fields) { |
|
|
return Container( |
|
|
|
|
|
height: fields.length * 70.0, |
|
|
|
|
|
child: ListView.separated( |
|
|
|
|
|
itemCount: fields.length, |
|
|
|
|
|
separatorBuilder: (context, index) { |
|
|
|
|
|
return SizedBox( |
|
|
|
|
|
height: 8, |
|
|
|
|
|
); |
|
|
|
|
|
}, |
|
|
|
|
|
itemBuilder: (context, index) { |
|
|
|
|
|
var field = fields[index]; |
|
|
|
|
|
if (field.tbControlTypeName == 'text') { |
|
|
|
|
|
return TextFormField( |
|
|
|
|
|
keyboardType: TextInputType.text, |
|
|
|
|
|
decoration: InputDecoration(labelText: field.description), |
|
|
|
|
|
controller: textFieldControllers[field.id.toString()], |
|
|
|
|
|
onSaved: (newValue) {}, |
|
|
|
|
|
validator: field.isMandatory |
|
|
|
|
|
? (String value) { |
|
|
|
|
|
return Validators.validateNotNullOrEmpty( |
|
|
|
|
|
value, 'Vui lòng nhập ${field.description}'); |
|
|
|
|
|
} |
|
|
|
|
|
: null, |
|
|
|
|
|
|
|
|
return Wrap( |
|
|
|
|
|
children: [ |
|
|
|
|
|
ListView.separated( |
|
|
|
|
|
shrinkWrap: true, |
|
|
|
|
|
physics: NeverScrollableScrollPhysics(), |
|
|
|
|
|
itemCount: fields.length, |
|
|
|
|
|
separatorBuilder: (context, index) { |
|
|
|
|
|
return SizedBox( |
|
|
|
|
|
height: 8, |
|
|
); |
|
|
); |
|
|
} else if (field.tbControlTypeName == 'number') { |
|
|
|
|
|
return WidgetTextFormFieldNumber( |
|
|
|
|
|
hintValue: field.description, |
|
|
|
|
|
textController: textFieldControllers[field.id.toString()], |
|
|
|
|
|
onSaved: (newValue) {}, |
|
|
|
|
|
validator: field.isMandatory |
|
|
|
|
|
? (String value) { |
|
|
|
|
|
return Validators.validNumberOrEmpty( |
|
|
|
|
|
value, 'Vui lòng nhập ${field.description}'); |
|
|
|
|
|
} |
|
|
|
|
|
: null, |
|
|
|
|
|
); |
|
|
|
|
|
} else if (field.tbControlTypeName == 'textarea') { |
|
|
|
|
|
return TextFieldAreaWidget( |
|
|
|
|
|
hint: field.description, |
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
itemBuilder: (context, index) { |
|
|
|
|
|
var field = fields[index]; |
|
|
|
|
|
if (field.tbControlTypeName == 'text') { |
|
|
|
|
|
return TextFormField( |
|
|
|
|
|
keyboardType: TextInputType.text, |
|
|
|
|
|
decoration: InputDecoration(labelText: field.description), |
|
|
controller: textFieldControllers[field.id.toString()], |
|
|
controller: textFieldControllers[field.id.toString()], |
|
|
onSaved: (newValue) {}); |
|
|
|
|
|
} else if (field.tbControlTypeName == 'dropdown') { |
|
|
|
|
|
return DropdownSupplyWidget( |
|
|
|
|
|
titleName: field.description ?? '', |
|
|
|
|
|
tbSupply: field.tbActivityExtendTypeExternalTable ?? '', |
|
|
|
|
|
tag: field.name, |
|
|
|
|
|
value: field.description, |
|
|
|
|
|
hint: '${field.description} ${field.isMandatory ? '*' : ''}', |
|
|
|
|
|
condition: field.tbActivityExtendTypeCondition, |
|
|
|
|
|
invalidMessage: '', |
|
|
|
|
|
onPressed: (commonData) { |
|
|
|
|
|
print(commonData.name); |
|
|
|
|
|
}); |
|
|
|
|
|
} else if (field.tbControlTypeName == 'date') { |
|
|
|
|
|
return FieldDateWidget( |
|
|
|
|
|
value: field.description, |
|
|
|
|
|
hint: '${field.description} ${field.isMandatory ? '*' : ''}', |
|
|
|
|
|
invalidMessage: '', |
|
|
|
|
|
onPressed: () {}); |
|
|
|
|
|
} else if (field.tbControlTypeName == 'radiobutton') { |
|
|
|
|
|
return Text(field.tbControlTypeName); |
|
|
|
|
|
} else { |
|
|
|
|
|
return Text(field.tbControlTypeName); |
|
|
|
|
|
} |
|
|
|
|
|
}), |
|
|
|
|
|
|
|
|
onSaved: (newValue) {}, |
|
|
|
|
|
validator: field.isMandatory |
|
|
|
|
|
? (String value) { |
|
|
|
|
|
return Validators.validateNotNullOrEmpty( |
|
|
|
|
|
value, 'Vui lòng nhập ${field.description}'); |
|
|
|
|
|
} |
|
|
|
|
|
: null, |
|
|
|
|
|
); |
|
|
|
|
|
} else if (field.tbControlTypeName == 'number') { |
|
|
|
|
|
return WidgetTextFormFieldNumber( |
|
|
|
|
|
hintValue: field.description, |
|
|
|
|
|
textController: textFieldControllers[field.id.toString()], |
|
|
|
|
|
onSaved: (newValue) {}, |
|
|
|
|
|
validator: field.isMandatory |
|
|
|
|
|
? (String value) { |
|
|
|
|
|
return Validators.validNumberOrEmpty( |
|
|
|
|
|
value, 'Vui lòng nhập ${field.description}'); |
|
|
|
|
|
} |
|
|
|
|
|
: null, |
|
|
|
|
|
); |
|
|
|
|
|
} else if (field.tbControlTypeName == 'textarea') { |
|
|
|
|
|
return TextFieldAreaWidget( |
|
|
|
|
|
hint: field.description, |
|
|
|
|
|
controller: textFieldControllers[field.id.toString()], |
|
|
|
|
|
onSaved: (newValue) {}); |
|
|
|
|
|
} else if (field.tbControlTypeName == 'dropdown') { |
|
|
|
|
|
return DropdownSupplyWidget( |
|
|
|
|
|
titleName: field.description ?? '', |
|
|
|
|
|
tbSupply: field.tbActivityExtendTypeExternalTable ?? '', |
|
|
|
|
|
tag: field.name, |
|
|
|
|
|
value: field.description, |
|
|
|
|
|
hint: |
|
|
|
|
|
'${field.description} ${field.isMandatory ? '*' : ''}', |
|
|
|
|
|
condition: field.tbActivityExtendTypeCondition, |
|
|
|
|
|
invalidMessage: '', |
|
|
|
|
|
onPressed: (commonData) { |
|
|
|
|
|
print(commonData.name); |
|
|
|
|
|
}); |
|
|
|
|
|
} else if (field.tbControlTypeName == 'date') { |
|
|
|
|
|
return FieldDateWidget( |
|
|
|
|
|
tag: field.name, |
|
|
|
|
|
value: field.description, |
|
|
|
|
|
hint: |
|
|
|
|
|
'${field.description} ${field.isMandatory ? '*' : ''}', |
|
|
|
|
|
invalidMessage: '', |
|
|
|
|
|
onPressed: (selectedDate) { |
|
|
|
|
|
print(selectedDate.day); |
|
|
|
|
|
}); |
|
|
|
|
|
} else if (field.tbControlTypeName == 'radiobutton') { |
|
|
|
|
|
return DropdownSupplyWidget( |
|
|
|
|
|
titleName: field.description ?? '', |
|
|
|
|
|
tbSupply: field.tbActivityExtendTypeExternalTable ?? '', |
|
|
|
|
|
tag: field.name, |
|
|
|
|
|
value: field.description, |
|
|
|
|
|
hint: |
|
|
|
|
|
'${field.description} ${field.isMandatory ? '*' : ''}', |
|
|
|
|
|
condition: field.tbActivityExtendTypeCondition, |
|
|
|
|
|
invalidMessage: '', |
|
|
|
|
|
onPressed: (commonData) { |
|
|
|
|
|
print(commonData.name); |
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
return Container(); |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
], |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|