mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-10 19:48:56 +03:30
Fix lable and subForms in test forms
This commit is contained in:
@@ -55,7 +55,7 @@ class _FormCreatorState extends State<FormCreator> {
|
||||
var items = Provider.of<Inputs>(context).inputItems;
|
||||
List<Widget> listWidgets = [];
|
||||
formItems = items;
|
||||
|
||||
print("itemmmm : ${formItems[1]}");
|
||||
for (var count = 0; count < formItems.length; count++) {
|
||||
Map item = formItems[count];
|
||||
|
||||
@@ -172,7 +172,7 @@ class _FormCreatorState extends State<FormCreator> {
|
||||
);
|
||||
}
|
||||
|
||||
if (item['type'] == "Text") {
|
||||
if (item['type'] == "Text" && item['name'] != null) {
|
||||
// print(item['require_scanner'].toString());
|
||||
TextEditingController idCTRL = new TextEditingController();
|
||||
final _media = MediaQuery.of(context);
|
||||
@@ -261,6 +261,126 @@ class _FormCreatorState extends State<FormCreator> {
|
||||
);
|
||||
}
|
||||
|
||||
if (item['type'] == "Form") {
|
||||
List<Widget> formWidget = [];
|
||||
formWidget.add(Text(
|
||||
item['name'],
|
||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0),
|
||||
));
|
||||
var children = item['children'] as List<dynamic>;
|
||||
for (var index = 0; index < children.length; index++) {
|
||||
Map child = children[index];
|
||||
if (child['type'] == "Time") {
|
||||
formWidget.add(
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: TextFormField(
|
||||
inputFormatters: <TextInputFormatter>[
|
||||
LengthLimitingTextInputFormatter(5),
|
||||
FilteringTextInputFormatter.digitsOnly,
|
||||
// BlacklistingTextInputFormatter.singleLineFormatter,
|
||||
TextInputFormatter.withFunction(
|
||||
(TextEditingValue oldValue, TextEditingValue newValue) {
|
||||
final int newTextLength = newValue.text.length;
|
||||
int selectionIndex = newValue.selection.end;
|
||||
int usedSubstringIndex = 0;
|
||||
final StringBuffer newText = StringBuffer();
|
||||
if (newTextLength >= 2) {
|
||||
newText.write(
|
||||
newValue.text.substring(0, usedSubstringIndex = 2) +
|
||||
':');
|
||||
if (newValue.selection.end >= 2) selectionIndex++;
|
||||
}
|
||||
// Dump the rest.
|
||||
if (newTextLength >= usedSubstringIndex)
|
||||
newText
|
||||
.write(newValue.text.substring(usedSubstringIndex));
|
||||
return TextEditingValue(
|
||||
text: newText.toString(),
|
||||
selection:
|
||||
TextSelection.collapsed(offset: selectionIndex),
|
||||
);
|
||||
})
|
||||
],
|
||||
keyboardType: TextInputType.datetime,
|
||||
decoration: InputDecoration(
|
||||
labelText: child['name'] ?? "",
|
||||
border: UnderlineInputBorder(),
|
||||
contentPadding: EdgeInsets.all(0),
|
||||
),
|
||||
// initialValue: item['value'] ?? '',
|
||||
onChanged: (String value) {
|
||||
children[index]['value'] = value;
|
||||
_handleChanged();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
if (child['type'] == "Range" ||
|
||||
child['type'] == "Temperature" ||
|
||||
child['type'] == "Pressure") {
|
||||
double startValue, endValue;
|
||||
if (child['type'] == "Range") {
|
||||
startValue = double.parse(child['options'][0]['title']);
|
||||
endValue = double.parse(child['options'][1]['title']);
|
||||
} else {
|
||||
startValue = child['type'] == "Temperature" ? 0.0 : -1.0;
|
||||
endValue = child['type'] == "Temperature" ? 200.0 : 3.0;
|
||||
}
|
||||
|
||||
children[index]['value'] = children[index]['value'] ?? startValue;
|
||||
// int divisions = (endValue - startValue).round();
|
||||
formWidget.add(
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 35, left: 10, right: 10),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
Text(child['type']),
|
||||
Text(children[index]['value'].toString()),
|
||||
],
|
||||
),
|
||||
Slider(
|
||||
min: startValue,
|
||||
max: endValue,
|
||||
value: children[index]['value'],
|
||||
// label: '${formItems[count]['value'].round()}',
|
||||
// divisions: divisions,
|
||||
onChanged: (double value) {
|
||||
setState(() {
|
||||
children[index]['value'] =
|
||||
double.parse(value.toStringAsFixed(2));
|
||||
});
|
||||
// print(formItems[count]['value']);
|
||||
},
|
||||
// semanticFormatterCallback: (double newValue) {
|
||||
// return '${newValue.round()}';
|
||||
// },
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
listWidgets.add(Container(
|
||||
margin: EdgeInsets.only(top: 10),
|
||||
decoration: BoxDecoration(border: Border.all(color: Colors.grey)),
|
||||
child: ListView.builder(
|
||||
padding: EdgeInsets.all(widget.padding ?? 6.0),
|
||||
itemCount: formWidget.length,
|
||||
itemBuilder: (context, index) {
|
||||
return formWidget[index];
|
||||
},
|
||||
shrinkWrap: true,
|
||||
controller: ScrollController(keepScrollOffset: false),
|
||||
),
|
||||
));
|
||||
}
|
||||
if (item['type'] == "Range" ||
|
||||
item['type'] == "Temperature" ||
|
||||
item['type'] == "Pressure") {
|
||||
@@ -558,7 +678,8 @@ class _FormCreatorState extends State<FormCreator> {
|
||||
cameraIcon: Icon(
|
||||
Icons.camera_alt,
|
||||
color: Colors.red,
|
||||
), //cameraIcon and galleryIcon can change. If no icon provided default icon will be present
|
||||
),
|
||||
//cameraIcon and galleryIcon can change. If no icon provided default icon will be present
|
||||
cameraText: Text(
|
||||
"From Camera",
|
||||
style: TextStyle(color: Colors.red),
|
||||
@@ -571,28 +692,30 @@ class _FormCreatorState extends State<FormCreator> {
|
||||
}
|
||||
|
||||
Future<void> loadAssetsFromFilePicker(BuildContext context) async {
|
||||
var providerObject = Provider.of<TestResultsProvider>(context, listen: false);
|
||||
List<PlatformFile> files = providerObject.catchImages;
|
||||
var image = await ImagePicker.platform.pickImage(
|
||||
source: ImageSource.gallery,
|
||||
imageQuality: 25,
|
||||
);
|
||||
if (image != null) {
|
||||
files.add(
|
||||
PlatformFile(
|
||||
path: image.path,
|
||||
name: "item_image",
|
||||
bytes: File(image.path).readAsBytesSync(),
|
||||
size: File(image.path).lengthSync(),
|
||||
),
|
||||
);
|
||||
var providerObject =
|
||||
Provider.of<TestResultsProvider>(context, listen: false);
|
||||
List<PlatformFile> files = providerObject.catchImages;
|
||||
var image = await ImagePicker.platform.pickImage(
|
||||
source: ImageSource.gallery,
|
||||
imageQuality: 25,
|
||||
);
|
||||
if (image != null) {
|
||||
files.add(
|
||||
PlatformFile(
|
||||
path: image.path,
|
||||
name: "item_image",
|
||||
bytes: File(image.path).readAsBytesSync(),
|
||||
size: File(image.path).lengthSync(),
|
||||
),
|
||||
);
|
||||
providerObject.setCatchImages(files);
|
||||
providerObject.setImages();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> loadAssetsFromCamera(BuildContext context) async {
|
||||
var providerObject = Provider.of<TestResultsProvider>(context, listen: false);
|
||||
var providerObject =
|
||||
Provider.of<TestResultsProvider>(context, listen: false);
|
||||
List<PlatformFile> _catchImages = providerObject.catchImages;
|
||||
var image = await ImagePicker.platform.pickImage(
|
||||
source: ImageSource.camera,
|
||||
|
||||
Reference in New Issue
Block a user