Skip to content

Commit

Permalink
Merge pull request #171 from codeforpakistan/lagging
Browse files Browse the repository at this point in the history
  • Loading branch information
mubassirhayat authored Oct 31, 2023
2 parents c35ff80 + a79ecf1 commit 098b677
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 26 deletions.
64 changes: 40 additions & 24 deletions lib/hcai_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class _HcaiFormPageState extends State<HcaiFormPage> {
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(
Expand All @@ -118,8 +118,13 @@ class _HcaiFormPageState extends State<HcaiFormPage> {
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),
)),
Expand Down Expand Up @@ -328,6 +333,7 @@ class _HcaiFormPageState extends State<HcaiFormPage> {
key: field['key'].toString(),
options: field['options'],
truncate: field['truncate'] ?? false,
readOnly: field['readOnly'] ?? false,
helpLabelText: field['hasHelpLabel']
? field['helpLabelText']
: '',
Expand Down Expand Up @@ -475,8 +481,8 @@ class _HcaiFormPageState extends State<HcaiFormPage> {
? IconButton(
icon: Icon(Icons.info_outline),
onPressed: () {
_showDialog(
context, "Information", helpLabelText, false, false);
_showDialog(context, "Information", helpLabelText, false,
false, false);
},
)
: null),
Expand Down Expand Up @@ -515,7 +521,7 @@ class _HcaiFormPageState extends State<HcaiFormPage> {
childs.children.add(TextFormField(
validator: validator,
keyboardType: Helper.getMaskType(maskType),
inputFormatters: Helper.getMask(maskType),
// inputFormatters: Helper.getMask(maskType),
decoration: InputDecoration(
filled: true,
fillColor: readOnly
Expand All @@ -532,8 +538,8 @@ class _HcaiFormPageState extends State<HcaiFormPage> {
? IconButton(
icon: Icon(Icons.info_outline),
onPressed: () {
_showDialog(
context, "Information", helpLabelText, false, false);
_showDialog(context, "Information", helpLabelText, false,
false, false);
},
)
: null),
Expand Down Expand Up @@ -699,7 +705,7 @@ class _HcaiFormPageState extends State<HcaiFormPage> {
icon: Icon(Icons.info_outline),
onPressed: () {
_showDialog(context, "Information", helpLabelText,
false, false);
false, false, false);
},
)
: null),
Expand Down Expand Up @@ -763,8 +769,8 @@ class _HcaiFormPageState extends State<HcaiFormPage> {
? IconButton(
icon: Icon(Icons.info_outline),
onPressed: () {
_showDialog(
context, "Information", helpLabelText, false, false);
_showDialog(context, "Information", helpLabelText, false,
false, false);
},
)
: null),
Expand Down Expand Up @@ -804,6 +810,7 @@ class _HcaiFormPageState extends State<HcaiFormPage> {
required String key,
required List<dynamic> options,
required bool truncate,
required bool readOnly,
required String helpLabelText,
required List<dynamic> hiddenFeilds,
List<dynamic> conditions = const []}) {
Expand Down Expand Up @@ -853,6 +860,7 @@ class _HcaiFormPageState extends State<HcaiFormPage> {
groupValue: _groupValue,
selected: options[0]['name'],
truncate: truncate,
readOnly: readOnly,
helpLabelText: helpLabelText,
hiddenFeilds: hiddenFeilds,
conditions: conditions))
Expand All @@ -871,6 +879,7 @@ class _HcaiFormPageState extends State<HcaiFormPage> {
required int groupValue,
String? selected,
required bool truncate,
required bool readOnly,
required String helpLabelText,
required List<dynamic> hiddenFeilds,
List<dynamic> conditions = const []}) {
Expand All @@ -879,13 +888,17 @@ class _HcaiFormPageState extends State<HcaiFormPage> {
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;
Expand Down Expand Up @@ -1121,10 +1134,11 @@ class _HcaiFormPageState extends State<HcaiFormPage> {
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');
Expand Down Expand Up @@ -1265,18 +1279,20 @@ class _HcaiFormPageState extends State<HcaiFormPage> {
}
}

_showDialog(context, String alertTitle, String alertMsg, bool showCancel,
bool shouldSave) {
_showDialog(context, String alertTitle, String alertMsg, bool showOnlyCancel,
bool shouldSave, bool showOnlyClose) {
List<Widget> 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);
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
7 changes: 6 additions & 1 deletion lib/utils/validation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
Expand Down

0 comments on commit 098b677

Please sign in to comment.