From 8495260c5af0e75975d0806310de6cbb11d8ec22 Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Sun, 23 Aug 2020 15:06:34 +0300 Subject: [PATCH 1/2] fix issues in feedback --- lib/core/service/client/base_app_client.dart | 1 + .../service/feedback/feedback_service.dart | 2 +- lib/core/service/medical/medical_service.dart | 3 + .../feedback/feedback_view_model.dart | 46 +- lib/pages/feedback/send_feedback_page.dart | 473 ++++++++---------- lib/pages/feedback/status_feedback_page.dart | 44 +- .../medical/time_line_widget.dart | 34 ++ 7 files changed, 305 insertions(+), 298 deletions(-) create mode 100644 lib/widgets/data_display/medical/time_line_widget.dart diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index 53f91de7..19bb01eb 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -55,6 +55,7 @@ class BaseAppClient { 'Accept': 'application/json' }); final int statusCode = response.statusCode; + print("statusCode :$statusCode"); if (statusCode < 200 || statusCode >= 400 || json == null) { onFailure('Error While Fetching data', statusCode); } else { diff --git a/lib/core/service/feedback/feedback_service.dart b/lib/core/service/feedback/feedback_service.dart index 575e4110..74107585 100644 --- a/lib/core/service/feedback/feedback_service.dart +++ b/lib/core/service/feedback/feedback_service.dart @@ -59,7 +59,7 @@ class FeedbackService extends BaseService { onFailure: (String error, int statusCode) { hasError = true; super.error = error; - }, body: _requestInsertCOCItem.toJson()); + }, body: body); } Future getStatusCOC() async { diff --git a/lib/core/service/medical/medical_service.dart b/lib/core/service/medical/medical_service.dart index 95d45012..90230f6d 100644 --- a/lib/core/service/medical/medical_service.dart +++ b/lib/core/service/medical/medical_service.dart @@ -6,6 +6,9 @@ class MedicalService extends BaseService { List appoitmentAllHistoryResultList = List(); getAppointmentHistory() async { + hasError = false; + super.error = ""; + await baseAppClient.post(GET_PATIENT_APPOINTMENT_HISTORY, onSuccess: (response, statusCode) async { appoitmentAllHistoryResultList.clear(); diff --git a/lib/core/viewModels/feedback/feedback_view_model.dart b/lib/core/viewModels/feedback/feedback_view_model.dart index 5f464322..d5f14e2d 100644 --- a/lib/core/viewModels/feedback/feedback_view_model.dart +++ b/lib/core/viewModels/feedback/feedback_view_model.dart @@ -6,10 +6,52 @@ import 'package:diplomaticquarterapp/pages/feedback/appointment_history.dart'; import '../../../locator.dart'; +enum MessageType { + ComplaintOnAnAppointment, + ComplaintWithoutAppointment, + Question, + Compliment, + Suggestion, + NON +} + class FeedbackViewModel extends BaseViewModel { FeedbackService _feedbackService = locator(); List get cOCItemList => _feedbackService.cOCItemList; + MessageType messageType = MessageType.NON; + MessageType messageTypeDialog = MessageType.NON; + + String selected = "not selected"; + + setMessageDialogType(MessageType messageType) { + messageTypeDialog = messageType; + notifyListeners(); + } + + setMessageType(MessageType messageType) { + this.messageType = messageType; + switch (messageType) { + case MessageType.ComplaintOnAnAppointment: + selected = "Complaint on an appointment"; + break; + case MessageType.ComplaintWithoutAppointment: + selected = "Complaint without appointment"; + break; + case MessageType.Question: + selected = "Question"; + break; + case MessageType.Compliment: + selected = "Compliment"; + break; + case MessageType.Suggestion: + selected = "Suggestion"; + break; + case MessageType.NON: + break; + } + notifyListeners(); + } List get appointHistoryList => _feedbackService.appointHistoryList; @@ -30,9 +72,11 @@ class FeedbackViewModel extends BaseViewModel { if (_feedbackService.hasError) { error = _feedbackService.error; setState(ViewState.ErrorLocal); + setMessageType(MessageType.NON); return false; } else { setState(ViewState.Idle); + setMessageType(MessageType.NON); return true; } } @@ -48,7 +92,7 @@ class FeedbackViewModel extends BaseViewModel { } } - getPatentAppointmentHistory() async { + Future getPatentAppointmentHistory() async { setState(ViewState.Busy); await _feedbackService.getPatentAppointmentHistory(); if (_feedbackService.hasError) { diff --git a/lib/pages/feedback/send_feedback_page.dart b/lib/pages/feedback/send_feedback_page.dart index 436dae62..c5ec9757 100644 --- a/lib/pages/feedback/send_feedback_page.dart +++ b/lib/pages/feedback/send_feedback_page.dart @@ -10,22 +10,12 @@ import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/input/text_field.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; -import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'appointment_history.dart'; -enum MessageType { - ComplaintOnAnAppointment, - ComplaintWithoutAppointment, - Question, - Compliment, - Suggestion, - NON -} - class SendFeedbackPage extends StatefulWidget { @override _SendFeedbackPageState createState() => _SendFeedbackPageState(); @@ -34,8 +24,6 @@ class SendFeedbackPage extends StatefulWidget { class _SendFeedbackPageState extends State { TextEditingController titleController = TextEditingController(); TextEditingController messageController = TextEditingController(); - MessageType messageType = MessageType.NON; - String _selected = "not selected"; List images = []; String title; AppointmentHistory appointHistory; @@ -86,7 +74,7 @@ class _SendFeedbackPageState extends State { children: [ Container( child: Texts( - _selected, + model.selected, variant: 'bodyText', ), margin: EdgeInsets.only(left: 10), @@ -100,7 +88,8 @@ class _SendFeedbackPageState extends State { ), ), ), - if (appointHistory != null) + if (appointHistory != null && model.messageType == + MessageType.ComplaintOnAnAppointment) InkWell( onTap: () { setState(() { @@ -175,7 +164,8 @@ class _SendFeedbackPageState extends State { ), ), ), - if (messageType == MessageType.ComplaintOnAnAppointment && + if (model.messageType == + MessageType.ComplaintOnAnAppointment && model.appointHistoryList.length != 0 && isShowListAppointHistory) Container( @@ -403,14 +393,14 @@ class _SendFeedbackPageState extends State { loading: model.state == ViewState.BusyLocal, onTap: () { final form = formKey.currentState; - if (form.validate()) if (messageType != MessageType.NON) + if (form.validate()) if (model.messageType != MessageType.NON) model .sendCOCItem( title: titleController.text, attachment: images.length > 0 ? images[0] : "", details: messageController.text, - cOCTypeName: getCOCName(), - appointHistory: messageType == + cOCTypeName: getCOCName(model), + appointHistory: model.messageType == MessageType.ComplaintOnAnAppointment ? appointHistory : null) @@ -420,8 +410,8 @@ class _SendFeedbackPageState extends State { titleController.text = ""; messageController.text = ""; images = []; - messageType = MessageType.NON; }); + model.setMessageType(MessageType.NON); AppToast.showSuccessToast( message: "Your feedback was send"); } else { @@ -440,8 +430,8 @@ class _SendFeedbackPageState extends State { ); } - String getCOCName() { - switch (messageType) { + String getCOCName(FeedbackViewModel model) { + switch (model.messageType) { case MessageType.ComplaintOnAnAppointment: return "1"; break; @@ -469,292 +459,223 @@ class _SendFeedbackPageState extends State { showDialog( context: context, child: FeedbackTypeDialog( - onValueChange: (MessageType value) { + onValueSelected: (MessageType value) { if (value == MessageType.ComplaintOnAnAppointment) { - model.getPatentAppointmentHistory(); - setState(() { - appointHistory = null; + model.getPatentAppointmentHistory().then((value) { + setState(() { + appointHistory = null; + }); }); } - setState(() { - messageType = value; - }); - }, - initialValue: messageType, - onValueSelected: () { - setState(() { - switch (messageType) { - case MessageType.ComplaintOnAnAppointment: - _selected = "Complaint on an appointment"; - break; - case MessageType.ComplaintWithoutAppointment: - _selected = "Complaint without appointment"; - break; - case MessageType.Question: - _selected = "Question"; - break; - case MessageType.Compliment: - _selected = "Compliment"; - break; - case MessageType.Suggestion: - _selected = "Suggestion"; - break; - case MessageType.NON: - break; - } - }); - Navigator.pop(context); + model.setMessageType(value); }, )); } } class FeedbackTypeDialog extends StatefulWidget { - const FeedbackTypeDialog( - {this.onValueChange, this.initialValue, this.onValueSelected}); + final Function(MessageType) onValueSelected; - final MessageType initialValue; - final void Function(MessageType) onValueChange; - final GestureTapCallback onValueSelected; + const FeedbackTypeDialog({Key key, this.onValueSelected}) : super(key: key); @override State createState() => new FeedbackTypeDialogState(); } class FeedbackTypeDialogState extends State { - MessageType _messageType; - - @override - void initState() { - super.initState(); - _messageType = widget.initialValue; - } - Widget build(BuildContext context) { - return new SimpleDialog( - title: Text( - "Message Type", - textAlign: TextAlign.center, - ), - children: [ - Container( + return BaseView( + builder: (_, model, widge) => SimpleDialog( + title: Text( + "Message Type", + textAlign: TextAlign.center, + ), + children: [ + Container( // padding: const EdgeInsets.all(10.0), child: Column( - children: [ - Divider( - height: 2.5, - color: Colors.grey[500], - ), - Row( children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - setState(() { - _messageType = MessageType.ComplaintOnAnAppointment; - widget.onValueChange(_messageType); - }); - }, - child: ListTile( - title: const Text('Complaint on an appointment'), - leading: Radio( - value: MessageType.ComplaintOnAnAppointment, - groupValue: _messageType, - activeColor: Colors.red[800], - onChanged: (MessageType value) { - setState(() { - _messageType = MessageType.ComplaintOnAnAppointment; - widget.onValueChange(_messageType); - }); - }, + Divider( + height: 2.5, + color: Colors.grey[500], + ), + Row( + children: [ + Expanded( + flex: 1, + child: InkWell( + onTap: () => model.setMessageDialogType( + MessageType.ComplaintOnAnAppointment), + child: ListTile( + title: const Text('Complaint on an appointment'), + leading: Radio( + value: MessageType.ComplaintOnAnAppointment, + groupValue: model.messageTypeDialog, + activeColor: Colors.red[800], + onChanged: (MessageType value) => + model.setMessageDialogType(value), + ), + ), ), - ), - ), - ) - ], - ), - SizedBox( - height: 5.0, - ), - Row( - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - setState(() { - _messageType = MessageType.ComplaintWithoutAppointment; - widget.onValueChange(_messageType); - }); - }, - child: ListTile( - title: const Text('Complaint without appointment'), - leading: Radio( - value: MessageType.ComplaintWithoutAppointment, - groupValue: _messageType, - activeColor: Colors.red[800], - onChanged: (MessageType value) { - setState(() { - _messageType = - MessageType.ComplaintWithoutAppointment; - widget.onValueChange(_messageType); - }); - }, + ) + ], + ), + SizedBox( + height: 5.0, + ), + Row( + children: [ + Expanded( + flex: 1, + child: InkWell( + onTap: () => model.setMessageDialogType( + MessageType.ComplaintWithoutAppointment), + child: ListTile( + title: const Text('Complaint without appointment'), + leading: Radio( + value: MessageType.ComplaintWithoutAppointment, + groupValue: model.messageTypeDialog, + activeColor: Colors.red[800], + onChanged: (MessageType value) => + model.setMessageDialogType(value), + ), + ), ), - ), - ), - ) - ], - ), - SizedBox( - height: 5.0, - ), - Row( - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - setState(() { - _messageType = MessageType.Question; - widget.onValueChange(_messageType); - }); - }, - child: ListTile( - title: const Text('Question'), - leading: Radio( - value: MessageType.Question, - groupValue: _messageType, - activeColor: Colors.red[800], - onChanged: (MessageType value) { - setState(() { - _messageType = MessageType.Question; - widget.onValueChange(_messageType); - }); - }, + ) + ], + ), + SizedBox( + height: 5.0, + ), + Row( + children: [ + Expanded( + flex: 1, + child: InkWell( + onTap: () => + model.setMessageDialogType(MessageType.Question), + child: ListTile( + title: const Text('Question'), + leading: Radio( + value: MessageType.Question, + groupValue: model.messageTypeDialog, + activeColor: Colors.red[800], + onChanged: (MessageType value) => + model.setMessageDialogType(value), + ), + ), ), - ), - ), - ) - ], - ), - SizedBox( - height: 5.0, - ), - Row( - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - setState(() { - _messageType = MessageType.Compliment; - widget.onValueChange(_messageType); - }); - }, - child: ListTile( - title: const Text('compliment'), - leading: Radio( - value: MessageType.Compliment, - groupValue: _messageType, - activeColor: Colors.red[800], - onChanged: (MessageType value) { - setState(() { - _messageType = MessageType.Compliment; - widget.onValueChange(_messageType); - }); - }, + ) + ], + ), + SizedBox( + height: 5.0, + ), + Row( + children: [ + Expanded( + flex: 1, + child: InkWell( + onTap: () => + model.setMessageDialogType(MessageType.Compliment), + child: ListTile( + title: const Text('compliment'), + leading: Radio( + value: MessageType.Compliment, + groupValue: model.messageTypeDialog, + activeColor: Colors.red[800], + onChanged: (MessageType value) => + model.setMessageDialogType(value), + ), + ), ), - ), - ), - ) - ], - ), - SizedBox( - height: 5.0, - ), - Row( - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - setState(() { - _messageType = MessageType.Suggestion; - widget.onValueChange(_messageType); - }); - }, - child: ListTile( - title: const Text('Suggestion'), - leading: Radio( - value: MessageType.Suggestion, - groupValue: _messageType, - activeColor: Colors.red[800], - onChanged: (MessageType value) { - setState(() { - _messageType = MessageType.Suggestion; - widget.onValueChange(_messageType); - }); + ) + ], + ), + SizedBox( + height: 5.0, + ), + Row( + children: [ + Expanded( + flex: 1, + child: InkWell( + onTap: () => + model.setMessageDialogType(MessageType.Suggestion), + child: ListTile( + title: const Text('Suggestion'), + leading: Radio( + value: MessageType.Suggestion, + groupValue: model.messageTypeDialog, + activeColor: Colors.red[800], + onChanged: (MessageType value) => + model.setMessageDialogType(value), + ), + ), + ), + ) + ], + ), + SizedBox( + height: 5.0, + ), + Divider( + height: 2.5, + color: Colors.grey[500], + ), + SizedBox( + height: 5, + ), + Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + flex: 1, + child: InkWell( + onTap: () { + Navigator.pop(context); }, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Center( + child: Texts( + 'cancel', + color: Colors.red, + ), + ), + ), + ), ), ), - ), - ) - ], - ), - SizedBox( - height: 5.0, - ), - Divider( - height: 2.5, - color: Colors.grey[500], - ), - SizedBox( - height: 5, - ), - Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - Navigator.pop(context); - }, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Container( + Container( + width: 1, + height: 30, + color: Colors.grey[500], + ), + Expanded( + flex: 1, + child: InkWell( + onTap: () { + widget.onValueSelected(model.messageTypeDialog); + Navigator.pop(context); + }, + child: Padding( + padding: const EdgeInsets.all(8.0), child: Center( child: Texts( - 'cancel', - color: Colors.red, - ))), - ), - )), - Container( - width: 1, - height: 30, - color: Colors.grey[500], - ), - Expanded( - flex: 1, - child: InkWell( - onTap: widget.onValueSelected, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Center( - child: Texts( - 'ok', - fontWeight: FontWeight.w400, + 'ok', + fontWeight: FontWeight.w400, + )), + ), )), - ), - )), + ], + ) ], - ) - ], - )), - ], + ), + ), + ], + ), ); } } diff --git a/lib/pages/feedback/status_feedback_page.dart b/lib/pages/feedback/status_feedback_page.dart index 20ef4bed..01a2b4c9 100644 --- a/lib/pages/feedback/status_feedback_page.dart +++ b/lib/pages/feedback/status_feedback_page.dart @@ -43,27 +43,31 @@ class _StatusFeedbackPageState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Texts('${model.cOCItemList[index].cOCTitle}'), - Texts( - 'Number :${model.cOCItemList[index].itemID}', - variant: 'overline', - ), - ], + Expanded( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Texts('${model.cOCItemList[index].cOCTitle}'), + Texts( + 'Number :${model.cOCItemList[index].itemID}', + variant: 'overline', + ), + ], + ), ), - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Texts('${model.cOCItemList[index].status}'), - Texts( - '${model.cOCItemList[index].date}', - variant: 'overline', - ), - ], + Expanded( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Texts('${model.cOCItemList[index].status}'), + Texts( + '${model.cOCItemList[index].date}', + variant: 'overline', + ), + ], + ), ), ], ), diff --git a/lib/widgets/data_display/medical/time_line_widget.dart b/lib/widgets/data_display/medical/time_line_widget.dart new file mode 100644 index 00000000..eb6f1146 --- /dev/null +++ b/lib/widgets/data_display/medical/time_line_widget.dart @@ -0,0 +1,34 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class TimeLineWidget extends StatefulWidget { + final bool isUp; + + TimeLineWidget({Key key, this.isUp}); + + _TimeLineWidgetState createState() => _TimeLineWidgetState(); +} + +class _TimeLineWidgetState extends State { + @override + Widget build(BuildContext context) { + return Stack( + children: [ + Container( + width: double.infinity, + height: 150, + color: Colors.grey[400], + child: Center( + child: Divider( + color: Colors.white, + height: 5, + thickness: 5, + ), + ), + ), + if (widget.isUp) Container() else Container(), + Container() + ], + ); + } +} From 75fdf280366ece36650e6a017d31e2dc2a82d3df Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Sun, 23 Aug 2020 15:13:03 +0300 Subject: [PATCH 2/2] fix lab Result --- lib/core/service/client/base_app_client.dart | 2 +- lib/pages/medical/medical_profile_page.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index 19bb01eb..8e139aa1 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -24,7 +24,7 @@ class BaseAppClient { try { //Map profile = await sharedPref.getObj(DOCTOR_PROFILE); String token = await sharedPref.getString(TOKEN); - var languageID = await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); + var languageID = await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'en'); var user = await sharedPref.getObject(USER_PROFILE); body['SetupID'] = body.containsKey('SetupID') ? body['SetupID']!=null? body['SetupID'] :SETUP_ID :SETUP_ID; body['VersionID'] = body.containsKey('VersionID') ? body['VersionID']!=null? body['VersionID'] :VERSION_ID :VERSION_ID; diff --git a/lib/pages/medical/medical_profile_page.dart b/lib/pages/medical/medical_profile_page.dart index 08e5ba6b..3fb0d9bf 100644 --- a/lib/pages/medical/medical_profile_page.dart +++ b/lib/pages/medical/medical_profile_page.dart @@ -86,7 +86,7 @@ class _MedicalProfilePageState extends State { Expanded( flex: 1, child: InkWell( - onTap: () {}, + onTap: () => Navigator.push(context, FadePage(page: LabsHomePage())), child: MedicalProfileItem( title: 'Lab', imagePath: 'lab_result_icon.png',