fix issues in feedback

merge-requests/34/merge
Mohammad Aljammal 6 years ago
parent 5619b8c06f
commit 8495260c5a

@ -55,6 +55,7 @@ class BaseAppClient {
'Accept': 'application/json' 'Accept': 'application/json'
}); });
final int statusCode = response.statusCode; final int statusCode = response.statusCode;
print("statusCode :$statusCode");
if (statusCode < 200 || statusCode >= 400 || json == null) { if (statusCode < 200 || statusCode >= 400 || json == null) {
onFailure('Error While Fetching data', statusCode); onFailure('Error While Fetching data', statusCode);
} else { } else {

@ -59,7 +59,7 @@ class FeedbackService extends BaseService {
onFailure: (String error, int statusCode) { onFailure: (String error, int statusCode) {
hasError = true; hasError = true;
super.error = error; super.error = error;
}, body: _requestInsertCOCItem.toJson()); }, body: body);
} }
Future getStatusCOC() async { Future getStatusCOC() async {

@ -6,6 +6,9 @@ class MedicalService extends BaseService {
List<AppoitmentAllHistoryResultList> appoitmentAllHistoryResultList = List(); List<AppoitmentAllHistoryResultList> appoitmentAllHistoryResultList = List();
getAppointmentHistory() async { getAppointmentHistory() async {
hasError = false;
super.error = "";
await baseAppClient.post(GET_PATIENT_APPOINTMENT_HISTORY, await baseAppClient.post(GET_PATIENT_APPOINTMENT_HISTORY,
onSuccess: (response, statusCode) async { onSuccess: (response, statusCode) async {
appoitmentAllHistoryResultList.clear(); appoitmentAllHistoryResultList.clear();

@ -6,10 +6,52 @@ import 'package:diplomaticquarterapp/pages/feedback/appointment_history.dart';
import '../../../locator.dart'; import '../../../locator.dart';
enum MessageType {
ComplaintOnAnAppointment,
ComplaintWithoutAppointment,
Question,
Compliment,
Suggestion,
NON
}
class FeedbackViewModel extends BaseViewModel { class FeedbackViewModel extends BaseViewModel {
FeedbackService _feedbackService = locator<FeedbackService>(); FeedbackService _feedbackService = locator<FeedbackService>();
List<COCItem> get cOCItemList => _feedbackService.cOCItemList; List<COCItem> 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<AppointmentHistory> get appointHistoryList => List<AppointmentHistory> get appointHistoryList =>
_feedbackService.appointHistoryList; _feedbackService.appointHistoryList;
@ -30,9 +72,11 @@ class FeedbackViewModel extends BaseViewModel {
if (_feedbackService.hasError) { if (_feedbackService.hasError) {
error = _feedbackService.error; error = _feedbackService.error;
setState(ViewState.ErrorLocal); setState(ViewState.ErrorLocal);
setMessageType(MessageType.NON);
return false; return false;
} else { } else {
setState(ViewState.Idle); setState(ViewState.Idle);
setMessageType(MessageType.NON);
return true; return true;
} }
} }
@ -48,7 +92,7 @@ class FeedbackViewModel extends BaseViewModel {
} }
} }
getPatentAppointmentHistory() async { Future getPatentAppointmentHistory() async {
setState(ViewState.Busy); setState(ViewState.Busy);
await _feedbackService.getPatentAppointmentHistory(); await _feedbackService.getPatentAppointmentHistory();
if (_feedbackService.hasError) { if (_feedbackService.hasError) {

@ -10,22 +10,12 @@ import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/input/text_field.dart'; import 'package:diplomaticquarterapp/widgets/input/text_field.dart';
import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.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/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'appointment_history.dart'; import 'appointment_history.dart';
enum MessageType {
ComplaintOnAnAppointment,
ComplaintWithoutAppointment,
Question,
Compliment,
Suggestion,
NON
}
class SendFeedbackPage extends StatefulWidget { class SendFeedbackPage extends StatefulWidget {
@override @override
_SendFeedbackPageState createState() => _SendFeedbackPageState(); _SendFeedbackPageState createState() => _SendFeedbackPageState();
@ -34,8 +24,6 @@ class SendFeedbackPage extends StatefulWidget {
class _SendFeedbackPageState extends State<SendFeedbackPage> { class _SendFeedbackPageState extends State<SendFeedbackPage> {
TextEditingController titleController = TextEditingController(); TextEditingController titleController = TextEditingController();
TextEditingController messageController = TextEditingController(); TextEditingController messageController = TextEditingController();
MessageType messageType = MessageType.NON;
String _selected = "not selected";
List<String> images = []; List<String> images = [];
String title; String title;
AppointmentHistory appointHistory; AppointmentHistory appointHistory;
@ -86,7 +74,7 @@ class _SendFeedbackPageState extends State<SendFeedbackPage> {
children: <Widget>[ children: <Widget>[
Container( Container(
child: Texts( child: Texts(
_selected, model.selected,
variant: 'bodyText', variant: 'bodyText',
), ),
margin: EdgeInsets.only(left: 10), margin: EdgeInsets.only(left: 10),
@ -100,7 +88,8 @@ class _SendFeedbackPageState extends State<SendFeedbackPage> {
), ),
), ),
), ),
if (appointHistory != null) if (appointHistory != null && model.messageType ==
MessageType.ComplaintOnAnAppointment)
InkWell( InkWell(
onTap: () { onTap: () {
setState(() { setState(() {
@ -175,7 +164,8 @@ class _SendFeedbackPageState extends State<SendFeedbackPage> {
), ),
), ),
), ),
if (messageType == MessageType.ComplaintOnAnAppointment && if (model.messageType ==
MessageType.ComplaintOnAnAppointment &&
model.appointHistoryList.length != 0 && model.appointHistoryList.length != 0 &&
isShowListAppointHistory) isShowListAppointHistory)
Container( Container(
@ -403,14 +393,14 @@ class _SendFeedbackPageState extends State<SendFeedbackPage> {
loading: model.state == ViewState.BusyLocal, loading: model.state == ViewState.BusyLocal,
onTap: () { onTap: () {
final form = formKey.currentState; final form = formKey.currentState;
if (form.validate()) if (messageType != MessageType.NON) if (form.validate()) if (model.messageType != MessageType.NON)
model model
.sendCOCItem( .sendCOCItem(
title: titleController.text, title: titleController.text,
attachment: images.length > 0 ? images[0] : "", attachment: images.length > 0 ? images[0] : "",
details: messageController.text, details: messageController.text,
cOCTypeName: getCOCName(), cOCTypeName: getCOCName(model),
appointHistory: messageType == appointHistory: model.messageType ==
MessageType.ComplaintOnAnAppointment MessageType.ComplaintOnAnAppointment
? appointHistory ? appointHistory
: null) : null)
@ -420,8 +410,8 @@ class _SendFeedbackPageState extends State<SendFeedbackPage> {
titleController.text = ""; titleController.text = "";
messageController.text = ""; messageController.text = "";
images = []; images = [];
messageType = MessageType.NON;
}); });
model.setMessageType(MessageType.NON);
AppToast.showSuccessToast( AppToast.showSuccessToast(
message: "Your feedback was send"); message: "Your feedback was send");
} else { } else {
@ -440,8 +430,8 @@ class _SendFeedbackPageState extends State<SendFeedbackPage> {
); );
} }
String getCOCName() { String getCOCName(FeedbackViewModel model) {
switch (messageType) { switch (model.messageType) {
case MessageType.ComplaintOnAnAppointment: case MessageType.ComplaintOnAnAppointment:
return "1"; return "1";
break; break;
@ -469,292 +459,223 @@ class _SendFeedbackPageState extends State<SendFeedbackPage> {
showDialog( showDialog(
context: context, context: context,
child: FeedbackTypeDialog( child: FeedbackTypeDialog(
onValueChange: (MessageType value) { onValueSelected: (MessageType value) {
if (value == MessageType.ComplaintOnAnAppointment) { if (value == MessageType.ComplaintOnAnAppointment) {
model.getPatentAppointmentHistory(); model.getPatentAppointmentHistory().then((value) {
setState(() { setState(() {
appointHistory = null; appointHistory = null;
});
}); });
} }
setState(() { model.setMessageType(value);
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);
}, },
)); ));
} }
} }
class FeedbackTypeDialog extends StatefulWidget { class FeedbackTypeDialog extends StatefulWidget {
const FeedbackTypeDialog( final Function(MessageType) onValueSelected;
{this.onValueChange, this.initialValue, this.onValueSelected});
final MessageType initialValue; const FeedbackTypeDialog({Key key, this.onValueSelected}) : super(key: key);
final void Function(MessageType) onValueChange;
final GestureTapCallback onValueSelected;
@override @override
State createState() => new FeedbackTypeDialogState(); State createState() => new FeedbackTypeDialogState();
} }
class FeedbackTypeDialogState extends State<FeedbackTypeDialog> { class FeedbackTypeDialogState extends State<FeedbackTypeDialog> {
MessageType _messageType;
@override
void initState() {
super.initState();
_messageType = widget.initialValue;
}
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new SimpleDialog( return BaseView<FeedbackViewModel>(
title: Text( builder: (_, model, widge) => SimpleDialog(
"Message Type", title: Text(
textAlign: TextAlign.center, "Message Type",
), textAlign: TextAlign.center,
children: <Widget>[ ),
Container( children: <Widget>[
Container(
// padding: const EdgeInsets.all(10.0), // padding: const EdgeInsets.all(10.0),
child: Column( child: Column(
children: <Widget>[
Divider(
height: 2.5,
color: Colors.grey[500],
),
Row(
children: <Widget>[ children: <Widget>[
Expanded( Divider(
flex: 1, height: 2.5,
child: InkWell( color: Colors.grey[500],
onTap: () { ),
setState(() { Row(
_messageType = MessageType.ComplaintOnAnAppointment; children: <Widget>[
widget.onValueChange(_messageType); Expanded(
}); flex: 1,
}, child: InkWell(
child: ListTile( onTap: () => model.setMessageDialogType(
title: const Text('Complaint on an appointment'), MessageType.ComplaintOnAnAppointment),
leading: Radio( child: ListTile(
value: MessageType.ComplaintOnAnAppointment, title: const Text('Complaint on an appointment'),
groupValue: _messageType, leading: Radio(
activeColor: Colors.red[800], value: MessageType.ComplaintOnAnAppointment,
onChanged: (MessageType value) { groupValue: model.messageTypeDialog,
setState(() { activeColor: Colors.red[800],
_messageType = MessageType.ComplaintOnAnAppointment; onChanged: (MessageType value) =>
widget.onValueChange(_messageType); model.setMessageDialogType(value),
}); ),
}, ),
), ),
), )
), ],
) ),
], SizedBox(
), height: 5.0,
SizedBox( ),
height: 5.0, Row(
), children: <Widget>[
Row( Expanded(
children: <Widget>[ flex: 1,
Expanded( child: InkWell(
flex: 1, onTap: () => model.setMessageDialogType(
child: InkWell( MessageType.ComplaintWithoutAppointment),
onTap: () { child: ListTile(
setState(() { title: const Text('Complaint without appointment'),
_messageType = MessageType.ComplaintWithoutAppointment; leading: Radio(
widget.onValueChange(_messageType); value: MessageType.ComplaintWithoutAppointment,
}); groupValue: model.messageTypeDialog,
}, activeColor: Colors.red[800],
child: ListTile( onChanged: (MessageType value) =>
title: const Text('Complaint without appointment'), model.setMessageDialogType(value),
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,
SizedBox( ),
height: 5.0, Row(
), children: <Widget>[
Row( Expanded(
children: <Widget>[ flex: 1,
Expanded( child: InkWell(
flex: 1, onTap: () =>
child: InkWell( model.setMessageDialogType(MessageType.Question),
onTap: () { child: ListTile(
setState(() { title: const Text('Question'),
_messageType = MessageType.Question; leading: Radio(
widget.onValueChange(_messageType); value: MessageType.Question,
}); groupValue: model.messageTypeDialog,
}, activeColor: Colors.red[800],
child: ListTile( onChanged: (MessageType value) =>
title: const Text('Question'), model.setMessageDialogType(value),
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,
SizedBox( ),
height: 5.0, Row(
), children: <Widget>[
Row( Expanded(
children: <Widget>[ flex: 1,
Expanded( child: InkWell(
flex: 1, onTap: () =>
child: InkWell( model.setMessageDialogType(MessageType.Compliment),
onTap: () { child: ListTile(
setState(() { title: const Text('compliment'),
_messageType = MessageType.Compliment; leading: Radio(
widget.onValueChange(_messageType); value: MessageType.Compliment,
}); groupValue: model.messageTypeDialog,
}, activeColor: Colors.red[800],
child: ListTile( onChanged: (MessageType value) =>
title: const Text('compliment'), model.setMessageDialogType(value),
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,
SizedBox( ),
height: 5.0, Row(
), children: <Widget>[
Row( Expanded(
children: <Widget>[ flex: 1,
Expanded( child: InkWell(
flex: 1, onTap: () =>
child: InkWell( model.setMessageDialogType(MessageType.Suggestion),
onTap: () { child: ListTile(
setState(() { title: const Text('Suggestion'),
_messageType = MessageType.Suggestion; leading: Radio(
widget.onValueChange(_messageType); value: MessageType.Suggestion,
}); groupValue: model.messageTypeDialog,
}, activeColor: Colors.red[800],
child: ListTile( onChanged: (MessageType value) =>
title: const Text('Suggestion'), model.setMessageDialogType(value),
leading: Radio( ),
value: MessageType.Suggestion, ),
groupValue: _messageType, ),
activeColor: Colors.red[800], )
onChanged: (MessageType value) { ],
setState(() { ),
_messageType = MessageType.Suggestion; SizedBox(
widget.onValueChange(_messageType); height: 5.0,
}); ),
Divider(
height: 2.5,
color: Colors.grey[500],
),
SizedBox(
height: 5,
),
Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
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,
),
),
),
),
), ),
), ),
), Container(
) width: 1,
], height: 30,
), color: Colors.grey[500],
SizedBox( ),
height: 5.0, Expanded(
), flex: 1,
Divider( child: InkWell(
height: 2.5, onTap: () {
color: Colors.grey[500], widget.onValueSelected(model.messageTypeDialog);
), Navigator.pop(context);
SizedBox( },
height: 5, child: Padding(
), padding: const EdgeInsets.all(8.0),
Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Expanded(
flex: 1,
child: InkWell(
onTap: () {
Navigator.pop(context);
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
child: Center( child: Center(
child: Texts( child: Texts(
'cancel', 'ok',
color: Colors.red, fontWeight: FontWeight.w400,
))), )),
), ),
)),
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,
)), )),
), ],
)), )
], ],
) ),
], ),
)), ],
], ),
); );
} }
} }

@ -43,27 +43,31 @@ class _StatusFeedbackPageState extends State<StatusFeedbackPage> {
mainAxisAlignment: mainAxisAlignment:
MainAxisAlignment.spaceBetween, MainAxisAlignment.spaceBetween,
children: <Widget>[ children: <Widget>[
Column( Expanded(
crossAxisAlignment: child: Column(
CrossAxisAlignment.start, crossAxisAlignment:
children: <Widget>[ CrossAxisAlignment.start,
Texts('${model.cOCItemList[index].cOCTitle}'), children: <Widget>[
Texts( Texts('${model.cOCItemList[index].cOCTitle}'),
'Number :${model.cOCItemList[index].itemID}', Texts(
variant: 'overline', 'Number :${model.cOCItemList[index].itemID}',
), variant: 'overline',
], ),
],
),
), ),
Column( Expanded(
crossAxisAlignment: child: Column(
CrossAxisAlignment.start, crossAxisAlignment:
children: <Widget>[ CrossAxisAlignment.start,
Texts('${model.cOCItemList[index].status}'), children: <Widget>[
Texts( Texts('${model.cOCItemList[index].status}'),
'${model.cOCItemList[index].date}', Texts(
variant: 'overline', '${model.cOCItemList[index].date}',
), variant: 'overline',
], ),
],
),
), ),
], ],
), ),

@ -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<TimeLineWidget> {
@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
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()
],
);
}
}
Loading…
Cancel
Save