Bug Fix: 873, 878 to 881

merge-requests/320/head
Mirza.Shafique 3 years ago
parent 81ce399e85
commit 58d5734f1a

@ -27,8 +27,8 @@ class COCItem {
String statusAr; String statusAr;
dynamic statusEn; dynamic statusEn;
COCItem( COCItem({
{this.appointment, this.appointment,
this.appointmentClinicName, this.appointmentClinicName,
this.appointmentDate, this.appointmentDate,
this.appointmentProjectName, this.appointmentProjectName,
@ -54,7 +54,8 @@ class COCItem {
this.solution, this.solution,
this.status, this.status,
this.statusAr, this.statusAr,
this.statusEn}); this.statusEn,
});
COCItem.fromJson(Map<String, dynamic> json) { COCItem.fromJson(Map<String, dynamic> json) {
appointment = json['Appointment']; appointment = json['Appointment'];

@ -36,7 +36,6 @@ class ProjectViewModel extends BaseViewModel {
bool get isArabic => _isArabic; bool get isArabic => _isArabic;
bool isLoginChild = false; bool isLoginChild = false;
List<PrivilegeModel> privilegeRootUser = List(); List<PrivilegeModel> privilegeRootUser = List();
List<PrivilegeModel> privilegeChildUser = List(); List<PrivilegeModel> privilegeChildUser = List();
@ -67,7 +66,8 @@ class ProjectViewModel extends BaseViewModel {
} }
Future loadSharedPrefLanguage() async { Future loadSharedPrefLanguage() async {
currentLanguage = await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); currentLanguage =
await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar');
_appLocale = Locale(currentLanguage); _appLocale = Locale(currentLanguage);
_isArabic = currentLanguage == 'ar'; _isArabic = currentLanguage == 'ar';
notifyListeners(); notifyListeners();
@ -89,8 +89,7 @@ class ProjectViewModel extends BaseViewModel {
notifyListeners(); notifyListeners();
} }
setPrivilegeModelList( setPrivilegeModelList({List<PrivilegeModel> privilege}) {
{List<PrivilegeModel> privilege}) {
this.isLoginChild = isLoginChild; this.isLoginChild = isLoginChild;
privilegeRootUser = privilege; privilegeRootUser = privilege;
@ -113,18 +112,18 @@ class ProjectViewModel extends BaseViewModel {
notifyListeners(); notifyListeners();
} }
setIsLoginChild({@required bool isLoginChild}){ setIsLoginChild({@required bool isLoginChild}) {
this.isLoginChild = isLoginChild; this.isLoginChild = isLoginChild;
notifyListeners(); notifyListeners();
} }
bool havePrivilege(int id) { bool havePrivilege(int id) {
bool isHavePrivilege = false; bool isHavePrivilege = false;
if(isLoginChild) if (isLoginChild)
privilegeChildUser.forEach((element) { privilegeChildUser.forEach((element) {
if (element.iD == id) isHavePrivilege = element.privilege; if (element.iD == id) isHavePrivilege = element.privilege;
}); });
else{ else {
privilegeRootUser.forEach((element) { privilegeRootUser.forEach((element) {
if (element.iD == id) isHavePrivilege = element.privilege; if (element.iD == id) isHavePrivilege = element.privilege;
}); });

@ -36,7 +36,7 @@ class MyApp extends StatefulWidget {
class _MyApp extends State<MyApp> { class _MyApp extends State<MyApp> {
@override @override
void initState(){ void initState() {
// ProjectViewModel projectProvider; // ProjectViewModel projectProvider;
// projectProvider = Provider.of(context); // projectProvider = Provider.of(context);
// var font = projectProvider.isArabic ? 'Cairo' : 'WorkSans'; // var font = projectProvider.isArabic ? 'Cairo' : 'WorkSans';
@ -72,10 +72,7 @@ class _MyApp extends State<MyApp> {
value: SearchProvider(), value: SearchProvider(),
), ),
ChangeNotifierProvider<ThemeNotifier>( ChangeNotifierProvider<ThemeNotifier>(
create: (context) => ThemeNotifier( create: (context) => ThemeNotifier(defaultTheme())),
defaultTheme()
)
),
StreamProvider.value( StreamProvider.value(
value: RobotProvider().intStream(), value: RobotProvider().intStream(),
initialData: RobotProvider().setValue({}), initialData: RobotProvider().setValue({}),

@ -33,10 +33,10 @@ class _BaseViewState<T extends BaseViewModel> extends State<BaseView<T>> {
@override @override
void initState() { void initState() {
if(widget.allowAny && widget.onModelReady != null){ if (widget.allowAny && widget.onModelReady != null) {
widget.onModelReady(model); widget.onModelReady(model);
} } else if (widget.onModelReady != null &&
else if (widget.onModelReady != null && Provider.of<ProjectViewModel>(context, listen: false).isLogin) { Provider.of<ProjectViewModel>(context, listen: false).isLogin) {
widget.onModelReady(model); widget.onModelReady(model);
} }
super.initState(); super.initState();
@ -60,7 +60,6 @@ class _BaseViewState<T extends BaseViewModel> extends State<BaseView<T>> {
if (model != null) { if (model != null) {
model = null; model = null;
} }
super.dispose(); super.dispose();
} }
} }

@ -44,6 +44,7 @@ class _SendFeedbackPageState extends State<SendFeedbackPage> {
stt.SpeechToText speech = stt.SpeechToText(); stt.SpeechToText speech = stt.SpeechToText();
var reconizedWord; var reconizedWord;
var event = RobotProvider(); var event = RobotProvider();
String getSelected(BuildContext context) { String getSelected(BuildContext context) {
switch (messageType) { switch (messageType) {
case MessageType.ComplaintOnAnAppointment: case MessageType.ComplaintOnAnAppointment:
@ -325,6 +326,9 @@ class _SendFeedbackPageState extends State<SendFeedbackPage> {
fontSize: 13.5, fontSize: 13.5,
hintColor: Colors.black, hintColor: Colors.black,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
onChanged: (v){setState(() {
});},
validator: (value) { validator: (value) {
if (value.isEmpty) if (value.isEmpty)
return TranslationBase.of(context).emptySubject; return TranslationBase.of(context).emptySubject;
@ -347,6 +351,9 @@ class _SendFeedbackPageState extends State<SendFeedbackPage> {
onSuffixTap: () { onSuffixTap: () {
openSpeechReco(); openSpeechReco();
}, },
onChanged: (v){setState(() {
});},
validator: (value) { validator: (value) {
if (value.isEmpty) if (value.isEmpty)
return TranslationBase.of(context).emptyMessage; return TranslationBase.of(context).emptyMessage;
@ -440,11 +447,11 @@ class _SendFeedbackPageState extends State<SendFeedbackPage> {
label: TranslationBase.of(context).send, label: TranslationBase.of(context).send,
textColor: Colors.white, textColor: Colors.white,
disabled: (titleController.text.toString().isEmpty || disabled: (titleController.text.toString().isEmpty ||
messageController.text.toString().isEmpty || messageController.text.toString().isEmpty ),
messageType == MessageType.NON),
onTap: () { onTap: () {
final form = formKey.currentState; final form = formKey.currentState;
if (form.validate()) if (messageType != MessageType.NON) { if (form.validate()) {
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
model model
.sendCOCItem( .sendCOCItem(
@ -472,9 +479,7 @@ class _SendFeedbackPageState extends State<SendFeedbackPage> {
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
} }
}); });
} else {
AppToast.showErrorToast(
message: TranslationBase.of(context).selectPart);
} }
}, },
), ),
@ -500,10 +505,10 @@ class _SendFeedbackPageState extends State<SendFeedbackPage> {
return "4"; return "4";
break; break;
case MessageType.Suggestion: case MessageType.Suggestion:
return "5"; return "6";
break; break;
case MessageType.NON: case MessageType.NON:
return ""; return "5";
break; break;
} }
return ""; return "";
@ -583,6 +588,7 @@ class FeedbackTypeDialogState extends State<FeedbackTypeDialog> {
setMessageDialogType(MessageType messageType) { setMessageDialogType(MessageType messageType) {
setState(() { setState(() {
messageTypeDialog = messageType; messageTypeDialog = messageType;
}); });
} }

@ -156,6 +156,10 @@ class _HomePageState extends State<HomePage> {
onPressed: () { onPressed: () {
navigateToCovidDriveThru(); navigateToCovidDriveThru();
}, },
child: Center(
child: Center(
child: Center(
child: Center(
child: Texts( child: Texts(
TranslationBase.of( TranslationBase.of(
context) context)
@ -168,6 +172,10 @@ class _HomePageState extends State<HomePage> {
), ),
), ),
), ),
),
),
),
),
], ],
), ),
), ),

@ -74,7 +74,7 @@ class NewTextFields extends StatefulWidget {
this.fontWeight = FontWeight.w700, this.fontWeight = FontWeight.w700,
this.autoValidate = false, this.autoValidate = false,
this.hintColor, this.hintColor,
this.isEnabled = true}) this.isEnabled = true,this.counterText=""})
: super(key: key); : super(key: key);
final String hintText; final String hintText;
@ -112,6 +112,7 @@ class NewTextFields extends StatefulWidget {
final bool borderOnlyError; final bool borderOnlyError;
final Color hintColor; final Color hintColor;
final String initialValue; final String initialValue;
final String counterText;
@override @override
_NewTextFieldsState createState() => _NewTextFieldsState(); _NewTextFieldsState createState() => _NewTextFieldsState();
} }
@ -199,6 +200,7 @@ class _NewTextFieldsState extends State<NewTextFields> {
: widget.inputFormatters, : widget.inputFormatters,
decoration: InputDecoration( decoration: InputDecoration(
labelText: widget.hintText, labelText: widget.hintText,
counterText: widget.counterText,
labelStyle: labelStyle:
TextStyle(color: Theme.of(context).textTheme.bodyText1.color), TextStyle(color: Theme.of(context).textTheme.bodyText1.color),
errorBorder: OutlineInputBorder( errorBorder: OutlineInputBorder(

@ -51,6 +51,7 @@ class _AddWeightPageState extends State<AddWeightPage> {
]; ];
final List<String> measureUnitArList = ["كيلو جرام", "باوند"]; final List<String> measureUnitArList = ["كيلو جرام", "باوند"];
String measureTimeSelectedType; String measureTimeSelectedType;
bool isButtonDisabled = false;
@override @override
void initState() { void initState() {
@ -64,6 +65,7 @@ class _AddWeightPageState extends State<AddWeightPage> {
else if (measureUnitArList.contains(widget.measureTimeSelectedType)) else if (measureUnitArList.contains(widget.measureTimeSelectedType))
weightUnit = measureUnitArList.indexOf(widget.measureTimeSelectedType); weightUnit = measureUnitArList.indexOf(widget.measureTimeSelectedType);
_weightValueController.text = widget.weightValue; _weightValueController.text = widget.weightValue;
validateForm();
} }
} }
@ -76,7 +78,8 @@ class _AddWeightPageState extends State<AddWeightPage> {
appBarTitle: widget.isUpdate appBarTitle: widget.isUpdate
? TranslationBase.of(context).update ? TranslationBase.of(context).update
: TranslationBase.of(context).add, : TranslationBase.of(context).add,
appBarIcons:widget.isUpdate? [ appBarIcons: widget.isUpdate
? [
IconButton( IconButton(
icon: Icon(Icons.delete), icon: Icon(Icons.delete),
color: Colors.white, color: Colors.white,
@ -101,15 +104,15 @@ class _AddWeightPageState extends State<AddWeightPage> {
Navigator.pop(context); Navigator.pop(context);
}).catchError((e) { }).catchError((e) {
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
AppToast.showErrorToast( AppToast.showErrorToast(message: widget.model.error);
message: widget.model.error);
}); });
}, },
cancelFunction: () => {}); cancelFunction: () => {});
dialog.showAlertDialog(context); dialog.showAlertDialog(context);
}, },
) )
]:null, ]
: null,
body: SingleChildScrollView( body: SingleChildScrollView(
physics: BouncingScrollPhysics(), physics: BouncingScrollPhysics(),
child: Container( child: Container(
@ -123,6 +126,7 @@ class _AddWeightPageState extends State<AddWeightPage> {
hintText: TranslationBase.of(context).weightAdd, hintText: TranslationBase.of(context).weightAdd,
controller: _weightValueController, controller: _weightValueController,
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
onChanged: (value) => validateForm(),
), ),
SizedBox( SizedBox(
height: 8, height: 8,
@ -235,16 +239,19 @@ class _AddWeightPageState extends State<AddWeightPage> {
loading: widget.model.state == ViewState.BusyLocal, loading: widget.model.state == ViewState.BusyLocal,
label: TranslationBase.of(context).save.toUpperCase(), label: TranslationBase.of(context).save.toUpperCase(),
textColor: Colors.white, textColor: Colors.white,
color: isButtonDisabled ? Colors.grey[900] : Colors.grey,
onTap: () { onTap: () {
if (_weightValueController.text.isNotEmpty) { if (_weightValueController.text.isNotEmpty) {
if (widget.isUpdate) { if (widget.isUpdate) {
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
widget.model.updateWeightResult( widget.model
weightDate: '${dayWeightDate.year}-${dayWeightDate.month}-${dayWeightDate.day} ${timeWeightDate.hour}:${timeWeightDate.minute}:00', .updateWeightResult(
weightMeasured: _weightValueController.text.toString(), weightDate:
'${dayWeightDate.year}-${dayWeightDate.month}-${dayWeightDate.day} ${timeWeightDate.hour}:${timeWeightDate.minute}:00',
weightMeasured:
_weightValueController.text.toString(),
weightUnit: weightUnit, weightUnit: weightUnit,
lineItemNo: widget.lineItemNo lineItemNo: widget.lineItemNo)
)
.then((value) { .then((value) {
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
if (widget.model.state == ViewState.Error) if (widget.model.state == ViewState.Error)
@ -253,8 +260,10 @@ class _AddWeightPageState extends State<AddWeightPage> {
Navigator.pop(context); Navigator.pop(context);
}); });
} else } else
widget.model.addWeightResult( widget.model
weightDate: '${dayWeightDate.year}-${dayWeightDate.month}-${dayWeightDate.day} ${timeWeightDate.hour}:${timeWeightDate.minute}:00', .addWeightResult(
weightDate:
'${dayWeightDate.year}-${dayWeightDate.month}-${dayWeightDate.day} ${timeWeightDate.hour}:${timeWeightDate.minute}:00',
weightMeasured: _weightValueController.text.toString(), weightMeasured: _weightValueController.text.toString(),
weightUnit: weightUnit, weightUnit: weightUnit,
) )
@ -291,9 +300,23 @@ class _AddWeightPageState extends State<AddWeightPage> {
setState(() { setState(() {
measureTimeSelectedType = value; measureTimeSelectedType = value;
weightUnit = list.indexOf(value); weightUnit = list.indexOf(value);
validateForm();
}); });
}, },
), ),
); );
} }
void validateForm() {
if (_weightValueController.text.length > 0 &&
measureTimeSelectedType != null) {
setState(() {
isButtonDisabled = true;
});
} else {
setState(() {
isButtonDisabled = false;
});
}
}
} }

@ -29,7 +29,7 @@ class AddBloodPressurePage extends StatefulWidget {
{Key key, {Key key,
this.bloodSugarDate, this.bloodSugarDate,
this.measureTimeSelectedType, this.measureTimeSelectedType,
this.isUpdate=false, this.isUpdate = false,
this.lineItemNo, this.lineItemNo,
this.model, this.model,
this.bloodSystolicValue, this.bloodSystolicValue,
@ -47,6 +47,7 @@ class _AddBloodPressurePageState extends State<AddBloodPressurePage> {
DateTime bloodSugarDate = DateTime.now(); DateTime bloodSugarDate = DateTime.now();
DateTime timeSugarDate = DateTime.now(); DateTime timeSugarDate = DateTime.now();
int measuredArm = 1; int measuredArm = 1;
bool isButtonDisabled = false;
final List<String> measureTimeEnList = [ final List<String> measureTimeEnList = [
'Left', 'Left',
'Right', 'Right',
@ -70,6 +71,7 @@ class _AddBloodPressurePageState extends State<AddBloodPressurePage> {
measuredArm = measureTimeArList.indexOf(widget.measureTimeSelectedType); measuredArm = measureTimeArList.indexOf(widget.measureTimeSelectedType);
_bloodSystolicValueController.text = widget.bloodSystolicValue; _bloodSystolicValueController.text = widget.bloodSystolicValue;
_bloodDiastolicValueController.text = widget.bloodDiastolicValue; _bloodDiastolicValueController.text = widget.bloodDiastolicValue;
validateForm();
} }
} }
@ -82,7 +84,8 @@ class _AddBloodPressurePageState extends State<AddBloodPressurePage> {
appBarTitle: widget.isUpdate appBarTitle: widget.isUpdate
? TranslationBase.of(context).update ? TranslationBase.of(context).update
: TranslationBase.of(context).add, : TranslationBase.of(context).add,
appBarIcons: widget.isUpdate?[ appBarIcons: widget.isUpdate
? [
IconButton( IconButton(
icon: Icon(Icons.delete), icon: Icon(Icons.delete),
color: Colors.white, color: Colors.white,
@ -97,11 +100,13 @@ class _AddBloodPressurePageState extends State<AddBloodPressurePage> {
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
widget.model widget.model
.deactivateDiabeticStatus(lineItemNo: widget.lineItemNo) .deactivateDiabeticStatus(
lineItemNo: widget.lineItemNo)
.then((value) { .then((value) {
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
if (widget.model.state == ViewState.ErrorLocal) if (widget.model.state == ViewState.ErrorLocal)
AppToast.showErrorToast(message: widget.model.error); AppToast.showErrorToast(
message: widget.model.error);
else else
Navigator.pop(context); Navigator.pop(context);
}).catchError((e) { }).catchError((e) {
@ -113,7 +118,8 @@ class _AddBloodPressurePageState extends State<AddBloodPressurePage> {
dialog.showAlertDialog(context); dialog.showAlertDialog(context);
}, },
) )
]:null, ]
: null,
body: SingleChildScrollView( body: SingleChildScrollView(
physics: BouncingScrollPhysics(), physics: BouncingScrollPhysics(),
child: Container( child: Container(
@ -127,6 +133,8 @@ class _AddBloodPressurePageState extends State<AddBloodPressurePage> {
hintText: TranslationBase.of(context).systolicAdd, hintText: TranslationBase.of(context).systolicAdd,
controller: _bloodSystolicValueController, controller: _bloodSystolicValueController,
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
maxLength: 3,
onChanged: (value) => validateForm(),
), ),
SizedBox( SizedBox(
height: 8, height: 8,
@ -135,6 +143,8 @@ class _AddBloodPressurePageState extends State<AddBloodPressurePage> {
hintText: TranslationBase.of(context).diastolicAdd, hintText: TranslationBase.of(context).diastolicAdd,
controller: _bloodDiastolicValueController, controller: _bloodDiastolicValueController,
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
maxLength: 3,
onChanged: (value) => validateForm(),
), ),
SizedBox( SizedBox(
height: 8, height: 8,
@ -244,12 +254,16 @@ class _AddBloodPressurePageState extends State<AddBloodPressurePage> {
loading: widget.model.state == ViewState.BusyLocal, loading: widget.model.state == ViewState.BusyLocal,
label: TranslationBase.of(context).save.toUpperCase(), label: TranslationBase.of(context).save.toUpperCase(),
textColor: Colors.white, textColor: Colors.white,
color: isButtonDisabled
? Colors.grey[900]
: Colors.grey,
onTap: () async { onTap: () async {
if (_bloodSystolicValueController.text.isNotEmpty && if (_bloodSystolicValueController.text.isNotEmpty &&
_bloodDiastolicValueController.text.isNotEmpty) { _bloodDiastolicValueController.text.isNotEmpty) {
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
widget.model.addORUpdateDiabtecResult( widget.model
.addORUpdateDiabtecResult(
isUpdate: widget.isUpdate, isUpdate: widget.isUpdate,
bloodPressureDate: bloodPressureDate:
'${bloodSugarDate.year}-${bloodSugarDate.month}-${bloodSugarDate.day} ${timeSugarDate.hour}:${timeSugarDate.minute}:00', '${bloodSugarDate.year}-${bloodSugarDate.month}-${bloodSugarDate.day} ${timeSugarDate.hour}:${timeSugarDate.minute}:00',
@ -258,14 +272,15 @@ class _AddBloodPressurePageState extends State<AddBloodPressurePage> {
systolicePressure: systolicePressure:
_bloodSystolicValueController.text.toString(), _bloodSystolicValueController.text.toString(),
measuredArm: measuredArm, measuredArm: measuredArm,
).then((value) { )
.then((value) {
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
if(widget.model.state == ViewState.BusyLocal) if (widget.model.state == ViewState.BusyLocal)
AppToast.showErrorToast(message: widget.model.error); AppToast.showErrorToast(message: widget.model.error);
else else
Navigator.pop(context); Navigator.pop(context);
; ;
}).catchError((e){ }).catchError((e) {
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
AppToast.showErrorToast(message: widget.model.error); AppToast.showErrorToast(message: widget.model.error);
}); });
@ -295,9 +310,43 @@ class _AddBloodPressurePageState extends State<AddBloodPressurePage> {
setState(() { setState(() {
measureTimeSelectedType = value; measureTimeSelectedType = value;
measuredArm = list.indexOf(value); measuredArm = list.indexOf(value);
validateForm();
}); });
}, },
), ),
); );
} }
void validateForm() {
print("_bloodSystolicValueController "+_bloodSystolicValueController.text.length.toString());
if (measureTimeSelectedType != 'Left Arm' &&
_bloodSystolicValueController.text.length > 0 &&
_bloodDiastolicValueController.text.length > 0) {
setState(() {
isButtonDisabled = true;
});
} else {
setState(() {
isButtonDisabled = false;
});
}
// if(measureTimeSelectedType == 'Left Arm'){
// setState(() {
// isButtonDisabled = false;
// });
// }else if(_bloodSystolicValueController.text.length < 0){
// setState(() {
// isButtonDisabled = false;
// });
// }else if(_bloodDiastolicValueController.text.length < 0){
// setState(() {
// isButtonDisabled = false;
// });
// }else{
// setState(() {
// isButtonDisabled = true;
// });
// }
}
} }

@ -46,6 +46,7 @@ class _AddBloodSugarPageState extends State<AddBloodSugarPage> {
DateTime timeSugarDate = DateTime.now(); DateTime timeSugarDate = DateTime.now();
String measureUnitSelectedType = 'mg/dlt'; String measureUnitSelectedType = 'mg/dlt';
int measuredTime = 1; int measuredTime = 1;
bool isButtonDisabled = false;
final List<String> measureUnitList = ['mg/dlt', 'mol/L']; final List<String> measureUnitList = ['mg/dlt', 'mol/L'];
final List<String> measureTimeEnList = [ final List<String> measureTimeEnList = [
'Before Breakfast', 'Before Breakfast',
@ -85,6 +86,7 @@ class _AddBloodSugarPageState extends State<AddBloodSugarPage> {
else if (measureTimeArList.contains(widget.measuredTime)) else if (measureTimeArList.contains(widget.measuredTime))
measuredTime = measureTimeArList.indexOf(widget.measuredTime); measuredTime = measureTimeArList.indexOf(widget.measuredTime);
_bloodSugarValueController.text = widget.bloodSugarValue; _bloodSugarValueController.text = widget.bloodSugarValue;
validateForm();
} }
} }
@ -96,7 +98,8 @@ class _AddBloodSugarPageState extends State<AddBloodSugarPage> {
appBarTitle: widget.isUpdate appBarTitle: widget.isUpdate
? TranslationBase.of(context).update ? TranslationBase.of(context).update
: TranslationBase.of(context).add, : TranslationBase.of(context).add,
appBarIcons: widget.isUpdate?[ appBarIcons: widget.isUpdate
? [
IconButton( IconButton(
icon: Icon(Icons.delete), icon: Icon(Icons.delete),
color: Colors.white, color: Colors.white,
@ -111,10 +114,12 @@ class _AddBloodSugarPageState extends State<AddBloodSugarPage> {
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
widget.bloodSugarViewMode widget.bloodSugarViewMode
.deactivateDiabeticStatus(lineItemNo: widget.lineItemNo) .deactivateDiabeticStatus(
lineItemNo: widget.lineItemNo)
.then((value) { .then((value) {
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
if (widget.bloodSugarViewMode.state == ViewState.ErrorLocal) if (widget.bloodSugarViewMode.state ==
ViewState.ErrorLocal)
AppToast.showErrorToast( AppToast.showErrorToast(
message: widget.bloodSugarViewMode.error); message: widget.bloodSugarViewMode.error);
else else
@ -129,7 +134,8 @@ class _AddBloodSugarPageState extends State<AddBloodSugarPage> {
dialog.showAlertDialog(context); dialog.showAlertDialog(context);
}, },
) )
]:null, ]
: null,
body: SingleChildScrollView( body: SingleChildScrollView(
physics: BouncingScrollPhysics(), physics: BouncingScrollPhysics(),
child: Container( child: Container(
@ -143,6 +149,7 @@ class _AddBloodSugarPageState extends State<AddBloodSugarPage> {
hintText: TranslationBase.of(context).sugarAdd, hintText: TranslationBase.of(context).sugarAdd,
controller: _bloodSugarValueController, controller: _bloodSugarValueController,
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
onChanged: (value) => validateForm(),
), ),
SizedBox( SizedBox(
height: 8, height: 8,
@ -274,6 +281,7 @@ class _AddBloodSugarPageState extends State<AddBloodSugarPage> {
child: SecondaryButton( child: SecondaryButton(
label: TranslationBase.of(context).save.toUpperCase(), label: TranslationBase.of(context).save.toUpperCase(),
textColor: Colors.white, textColor: Colors.white,
color: isButtonDisabled ? Colors.grey[900] : Colors.grey,
onTap: () { onTap: () {
if (_bloodSugarValueController.text.isNotEmpty) { if (_bloodSugarValueController.text.isNotEmpty) {
if (widget.isUpdate) { if (widget.isUpdate) {
@ -289,7 +297,8 @@ class _AddBloodSugarPageState extends State<AddBloodSugarPage> {
_bloodSugarValueController.text.toString()) _bloodSugarValueController.text.toString())
.then((value) { .then((value) {
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
if (widget.bloodSugarViewMode.state == ViewState.ErrorLocal) if (widget.bloodSugarViewMode.state ==
ViewState.ErrorLocal)
AppToast.showErrorToast( AppToast.showErrorToast(
message: widget.bloodSugarViewMode.error); message: widget.bloodSugarViewMode.error);
else else
@ -360,4 +369,16 @@ class _AddBloodSugarPageState extends State<AddBloodSugarPage> {
), ),
); );
} }
void validateForm() {
if (_bloodSugarValueController.text.length > 0) {
setState(() {
isButtonDisabled = true;
});
} else {
setState(() {
isButtonDisabled = false;
});
}
}
} }

@ -393,7 +393,6 @@ class DateUtil {
break; break;
case DayOfWeek.Sunday: case DayOfWeek.Sunday:
return "Sunday"; return "Sunday";
break; break;
} }
return ""; return "";

@ -161,7 +161,9 @@ class _AnimatedButtonState extends State<AnimatedButton>
// button width is min 120.0 and max 240.0 // button width is min 120.0 and max 240.0
_width = textWidth > 120.0 && textWidth < 240.0 _width = textWidth > 120.0 && textWidth < 240.0
? textWidth ? textWidth
: textWidth >= 240.0 ? 240.0 : 120.0; : textWidth >= 240.0
? 240.0
: 120.0;
_sizeAnimation = Tween<double>(begin: 1.0, end: _height / _width) _sizeAnimation = Tween<double>(begin: 1.0, end: _height / _width)
.animate(CurvedAnimation( .animate(CurvedAnimation(
@ -191,13 +193,14 @@ class _AnimatedButtonState extends State<AnimatedButton>
animation: _colorAnimation, animation: _colorAnimation,
builder: (context, child) => Material( builder: (context, child) => Material(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(_height/2) borderRadius: BorderRadius.circular(_height / 2)),
),
color: _colorAnimation.value, color: _colorAnimation.value,
child: child, child: child,
shadowColor: _color, shadowColor: _color,
elevation: !_isLoading elevation: !_isLoading
? (_hover ? buttonTheme.highlightElevation : buttonTheme.elevation) ? (_hover
? buttonTheme.highlightElevation
: buttonTheme.elevation)
: 0, : 0,
), ),
child: InkWell( child: InkWell(
@ -287,7 +290,6 @@ class Ring extends StatelessWidget {
} }
} }
enum AnimatedTextRotation { up, down } enum AnimatedTextRotation { up, down }
/// https://medium.com/flutter-community/flutter-challenge-3d-bottom-navigation-bar-48952a5fd996 /// https://medium.com/flutter-community/flutter-challenge-3d-bottom-navigation-bar-48952a5fd996
@ -319,7 +321,6 @@ class _AnimatedTextState extends State<AnimatedText>
double get radius => _layoutHeight / 2; double get radius => _layoutHeight / 2;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
@ -452,10 +453,12 @@ class _AnimatedTextState extends State<AnimatedText>
); );
} }
// Helpers // Helpers
double toRadian(double degree) => degree * pi / 180; double toRadian(double degree) => degree * pi / 180;
double lerp(double start, double end, double percent) => (start + percent * (end - start));
double lerp(double start, double end, double percent) =>
(start + percent * (end - start));
Size getWidgetSize(GlobalKey key) { Size getWidgetSize(GlobalKey key) {
final RenderBox renderBox = key.currentContext?.findRenderObject(); final RenderBox renderBox = key.currentContext?.findRenderObject();
return renderBox?.size; return renderBox?.size;

Loading…
Cancel
Save