From a79ecf1200507d1ddf86c6118a8039fbfb837faf Mon Sep 17 00:00:00 2001 From: sohail0992 Date: Tue, 31 Oct 2023 12:26:33 +0500 Subject: [PATCH] lagging on number input field and added a radio button --- lib/hcai_form.dart | 64 ++++++++++++++++++++++++--------------- lib/utils/helper.dart | 2 +- lib/utils/validation.dart | 7 ++++- 3 files changed, 47 insertions(+), 26 deletions(-) diff --git a/lib/hcai_form.dart b/lib/hcai_form.dart index 205bfd3..95c7967 100644 --- a/lib/hcai_form.dart +++ b/lib/hcai_form.dart @@ -104,7 +104,7 @@ class _HcaiFormPageState extends State { return WillPopScope( onWillPop: () async { this._showDialog(context, 'Do you want to close?', - 'Your Progress will be saved as Draft.', true, false); + 'Your Progress will be saved as Draft.', true, false, false); return false; }, child: Scaffold( @@ -118,8 +118,13 @@ class _HcaiFormPageState extends State { padding: EdgeInsets.only(right: 20.0), child: GestureDetector( onTap: () { - this._showDialog(context, 'Do you want to close?', - 'Your progress will be Saved as Draft.', true, false); + this._showDialog( + context, + 'Do you want to close?', + 'Your progress will be Saved as Draft.', + true, + false, + false); }, child: Icon(Icons.cancel_sharp, color: Colors.white), )), @@ -328,6 +333,7 @@ class _HcaiFormPageState extends State { key: field['key'].toString(), options: field['options'], truncate: field['truncate'] ?? false, + readOnly: field['readOnly'] ?? false, helpLabelText: field['hasHelpLabel'] ? field['helpLabelText'] : '', @@ -475,8 +481,8 @@ class _HcaiFormPageState extends State { ? IconButton( icon: Icon(Icons.info_outline), onPressed: () { - _showDialog( - context, "Information", helpLabelText, false, false); + _showDialog(context, "Information", helpLabelText, false, + false, false); }, ) : null), @@ -515,7 +521,7 @@ class _HcaiFormPageState extends State { childs.children.add(TextFormField( validator: validator, keyboardType: Helper.getMaskType(maskType), - inputFormatters: Helper.getMask(maskType), + // inputFormatters: Helper.getMask(maskType), decoration: InputDecoration( filled: true, fillColor: readOnly @@ -532,8 +538,8 @@ class _HcaiFormPageState extends State { ? IconButton( icon: Icon(Icons.info_outline), onPressed: () { - _showDialog( - context, "Information", helpLabelText, false, false); + _showDialog(context, "Information", helpLabelText, false, + false, false); }, ) : null), @@ -699,7 +705,7 @@ class _HcaiFormPageState extends State { icon: Icon(Icons.info_outline), onPressed: () { _showDialog(context, "Information", helpLabelText, - false, false); + false, false, false); }, ) : null), @@ -763,8 +769,8 @@ class _HcaiFormPageState extends State { ? IconButton( icon: Icon(Icons.info_outline), onPressed: () { - _showDialog( - context, "Information", helpLabelText, false, false); + _showDialog(context, "Information", helpLabelText, false, + false, false); }, ) : null), @@ -804,6 +810,7 @@ class _HcaiFormPageState extends State { required String key, required List options, required bool truncate, + required bool readOnly, required String helpLabelText, required List hiddenFeilds, List conditions = const []}) { @@ -853,6 +860,7 @@ class _HcaiFormPageState extends State { groupValue: _groupValue, selected: options[0]['name'], truncate: truncate, + readOnly: readOnly, helpLabelText: helpLabelText, hiddenFeilds: hiddenFeilds, conditions: conditions)) @@ -871,6 +879,7 @@ class _HcaiFormPageState extends State { required int groupValue, String? selected, required bool truncate, + required bool readOnly, required String helpLabelText, required List hiddenFeilds, List conditions = const []}) { @@ -879,13 +888,17 @@ class _HcaiFormPageState extends State { value: value, activeColor: Color(0xFF6200EE), groupValue: _selectedRole[key], - title: Text( - title, - maxLines: 10, - softWrap: true, - ), + title: Text(title, + maxLines: 10, + softWrap: true, + style: readOnly + ? TextStyle( + color: Colors.grey[600], + fontSize: 13, + ) + : null), onChanged: (Object? value) { - if (this.mounted) { + if (this.mounted && !readOnly) { setState(() { _selectedRole[key] = value; _values[key] = title; @@ -1121,10 +1134,11 @@ class _HcaiFormPageState extends State { if (this._values['isSSI'] == 'No') { this._showDialog( context, - 'If SSI Event Criteria is No, you dont need to fill the other data', - 'Your Progress will be saved.', + 'Surgical Site Infection (SSI) event criteria has not been met. SSI does not exist.', + 'Your data will be saved.', + true, true, - true); + false); } // if (this._values['isSSI'] == 'No') { // this.updateFlagForAll(this.allSteps, true, 'SSIDetected'); @@ -1265,18 +1279,20 @@ class _HcaiFormPageState extends State { } } - _showDialog(context, String alertTitle, String alertMsg, bool showCancel, - bool shouldSave) { + _showDialog(context, String alertTitle, String alertMsg, bool showOnlyCancel, + bool shouldSave, bool showOnlyClose) { List buttons = []; - if (showCancel) { + if (showOnlyClose) { buttons.add(new MaterialButton( child: Text("No"), onPressed: () { Navigator.of(context, rootNavigator: true).pop('dialog'); }, )); + } + if (showOnlyCancel) { buttons.add(new MaterialButton( - child: Text("Close Anyway"), + child: Text("Close"), onPressed: () { if (shouldSave) { sendData(context, this._values, true); diff --git a/lib/utils/helper.dart b/lib/utils/helper.dart index 3bbcfc1..ffbd7bc 100644 --- a/lib/utils/helper.dart +++ b/lib/utils/helper.dart @@ -148,7 +148,7 @@ class Helper { } else if (maskType == 'cnic' || maskType == 'number' || maskType == 'float') { - return TextInputType.number; + return TextInputType.numberWithOptions(decimal: true); } else { return TextInputType.text; } diff --git a/lib/utils/validation.dart b/lib/utils/validation.dart index dc2404a..d28df68 100644 --- a/lib/utils/validation.dart +++ b/lib/utils/validation.dart @@ -7,7 +7,7 @@ class Validation { return isLessThan(value1, value2, comparisionType); } else if (criteria == '==') { return isEqual(value1, value2, comparisionType); - } else if (criteria == 'in' || criteria == 'and') { + } else if (criteria == 'in' || criteria == 'and' || criteria == 'nin') { //now all values of array 2 which is in value2 must be in 1 otherwise false return hasValue1ContainsValue2(value1, value2, criteria); } else { @@ -31,6 +31,11 @@ class Validation { !isNullOrEmpty(value) && value1.any( (map) => map.containsKey("index") && map["index"] == value)); + } else if (criteria == 'nin') { + return value2?.any((value) => + !isNullOrEmpty(value) && + value1.any( + (map) => map.containsKey("index") && map["index"] != value)); } } else { return false;