fix issues in feedback

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

@ -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 {

@ -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 {

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

@ -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<FeedbackService>();
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 =>
_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) {

@ -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<SendFeedbackPage> {
TextEditingController titleController = TextEditingController();
TextEditingController messageController = TextEditingController();
MessageType messageType = MessageType.NON;
String _selected = "not selected";
List<String> images = [];
String title;
AppointmentHistory appointHistory;
@ -86,7 +74,7 @@ class _SendFeedbackPageState extends State<SendFeedbackPage> {
children: <Widget>[
Container(
child: Texts(
_selected,
model.selected,
variant: 'bodyText',
),
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(
onTap: () {
setState(() {
@ -175,7 +164,8 @@ class _SendFeedbackPageState extends State<SendFeedbackPage> {
),
),
),
if (messageType == MessageType.ComplaintOnAnAppointment &&
if (model.messageType ==
MessageType.ComplaintOnAnAppointment &&
model.appointHistoryList.length != 0 &&
isShowListAppointHistory)
Container(
@ -403,14 +393,14 @@ class _SendFeedbackPageState extends State<SendFeedbackPage> {
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<SendFeedbackPage> {
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<SendFeedbackPage> {
);
}
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<SendFeedbackPage> {
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<FeedbackTypeDialog> {
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: <Widget>[
Container(
return BaseView<FeedbackViewModel>(
builder: (_, model, widge) => SimpleDialog(
title: Text(
"Message Type",
textAlign: TextAlign.center,
),
children: <Widget>[
Container(
// padding: const EdgeInsets.all(10.0),
child: Column(
children: <Widget>[
Divider(
height: 2.5,
color: Colors.grey[500],
),
Row(
children: <Widget>[
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: <Widget>[
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: <Widget>[
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: <Widget>[
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: <Widget>[
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: <Widget>[
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: <Widget>[
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: <Widget>[
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: <Widget>[
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: <Widget>[
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: <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,
),
),
),
),
),
),
),
)
],
),
SizedBox(
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(
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,
)),
),
)),
),
)),
],
)
],
)
],
)),
],
),
),
],
),
);
}
}

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