mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-13 11:38: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;
|
var items = Provider.of<Inputs>(context).inputItems;
|
||||||
List<Widget> listWidgets = [];
|
List<Widget> listWidgets = [];
|
||||||
formItems = items;
|
formItems = items;
|
||||||
|
print("itemmmm : ${formItems[1]}");
|
||||||
for (var count = 0; count < formItems.length; count++) {
|
for (var count = 0; count < formItems.length; count++) {
|
||||||
Map item = formItems[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());
|
// print(item['require_scanner'].toString());
|
||||||
TextEditingController idCTRL = new TextEditingController();
|
TextEditingController idCTRL = new TextEditingController();
|
||||||
final _media = MediaQuery.of(context);
|
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" ||
|
if (item['type'] == "Range" ||
|
||||||
item['type'] == "Temperature" ||
|
item['type'] == "Temperature" ||
|
||||||
item['type'] == "Pressure") {
|
item['type'] == "Pressure") {
|
||||||
@@ -558,7 +678,8 @@ class _FormCreatorState extends State<FormCreator> {
|
|||||||
cameraIcon: Icon(
|
cameraIcon: Icon(
|
||||||
Icons.camera_alt,
|
Icons.camera_alt,
|
||||||
color: Colors.red,
|
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(
|
cameraText: Text(
|
||||||
"From Camera",
|
"From Camera",
|
||||||
style: TextStyle(color: Colors.red),
|
style: TextStyle(color: Colors.red),
|
||||||
@@ -571,28 +692,30 @@ class _FormCreatorState extends State<FormCreator> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> loadAssetsFromFilePicker(BuildContext context) async {
|
Future<void> loadAssetsFromFilePicker(BuildContext context) async {
|
||||||
var providerObject = Provider.of<TestResultsProvider>(context, listen: false);
|
var providerObject =
|
||||||
List<PlatformFile> files = providerObject.catchImages;
|
Provider.of<TestResultsProvider>(context, listen: false);
|
||||||
var image = await ImagePicker.platform.pickImage(
|
List<PlatformFile> files = providerObject.catchImages;
|
||||||
source: ImageSource.gallery,
|
var image = await ImagePicker.platform.pickImage(
|
||||||
imageQuality: 25,
|
source: ImageSource.gallery,
|
||||||
);
|
imageQuality: 25,
|
||||||
if (image != null) {
|
);
|
||||||
files.add(
|
if (image != null) {
|
||||||
PlatformFile(
|
files.add(
|
||||||
path: image.path,
|
PlatformFile(
|
||||||
name: "item_image",
|
path: image.path,
|
||||||
bytes: File(image.path).readAsBytesSync(),
|
name: "item_image",
|
||||||
size: File(image.path).lengthSync(),
|
bytes: File(image.path).readAsBytesSync(),
|
||||||
),
|
size: File(image.path).lengthSync(),
|
||||||
);
|
),
|
||||||
|
);
|
||||||
providerObject.setCatchImages(files);
|
providerObject.setCatchImages(files);
|
||||||
providerObject.setImages();
|
providerObject.setImages();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> loadAssetsFromCamera(BuildContext context) async {
|
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;
|
List<PlatformFile> _catchImages = providerObject.catchImages;
|
||||||
var image = await ImagePicker.platform.pickImage(
|
var image = await ImagePicker.platform.pickImage(
|
||||||
source: ImageSource.camera,
|
source: ImageSource.camera,
|
||||||
|
|||||||
Reference in New Issue
Block a user