|
|
|
|
@ -24,7 +24,7 @@ class SurveyScreen extends StatefulWidget {
|
|
|
|
|
class _SurveyScreenState extends State<SurveyScreen> {
|
|
|
|
|
String reviewText = "";
|
|
|
|
|
double starRating = 1;
|
|
|
|
|
int _selectedIndex = 5;
|
|
|
|
|
int _selectedIndex = 0;
|
|
|
|
|
|
|
|
|
|
ItgResponseData? itgResponseData;
|
|
|
|
|
|
|
|
|
|
@ -46,80 +46,29 @@ class _SurveyScreenState extends State<SurveyScreen> {
|
|
|
|
|
body: Column(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.all(16.0),
|
|
|
|
|
child: Column(
|
|
|
|
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
32.height,
|
|
|
|
|
itgResponseData?.survey?.title?.toText24() ?? const Text(""),
|
|
|
|
|
8.height,
|
|
|
|
|
itgResponseData?.survey?.description?.toText16() ?? const Text(""),
|
|
|
|
|
|
|
|
|
|
ListView.builder(
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
|
itemCount: itgResponseData?.survey?.questions?.length,
|
|
|
|
|
itemBuilder: (cxt, index) {
|
|
|
|
|
// return itgResponseData?.survey?.questions?[index].title?.toText14() ?? const Text("");
|
|
|
|
|
return answeredQuestions.isNotEmpty ? getSurveyWidget(itgResponseData?.survey?.questions![index], index) : Container();
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
// LocaleKeys.feedbackUserExperience.tr().toText19(),
|
|
|
|
|
// 27.height,
|
|
|
|
|
// LocaleKeys.rateUI.tr().toText16(),
|
|
|
|
|
// 22.height,
|
|
|
|
|
// Row(
|
|
|
|
|
// crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
// mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
// children: [
|
|
|
|
|
// RatingBar.builder(
|
|
|
|
|
// initialRating: 3,
|
|
|
|
|
// minRating: starRating,
|
|
|
|
|
// direction: Axis.horizontal,
|
|
|
|
|
// allowHalfRating: false,
|
|
|
|
|
// itemCount: 5,
|
|
|
|
|
// itemPadding: EdgeInsets.symmetric(horizontal: 8),
|
|
|
|
|
// itemBuilder: (context, _) => Icon(
|
|
|
|
|
// Icons.star,
|
|
|
|
|
// color: Colors.amber,
|
|
|
|
|
// ),
|
|
|
|
|
// onRatingUpdate: (rating) {
|
|
|
|
|
// starRating = rating;
|
|
|
|
|
// },
|
|
|
|
|
// )
|
|
|
|
|
// ],
|
|
|
|
|
// ).paddingOnly(left: 22, right: 22, top: 12, bottom: 12).objectContainerView(disablePadding: true),
|
|
|
|
|
// 39.height,
|
|
|
|
|
// LocaleKeys.rateUI2.tr().toText16(),
|
|
|
|
|
// 10.height,
|
|
|
|
|
// GridView(
|
|
|
|
|
// gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 5, crossAxisSpacing: 7, mainAxisSpacing: 7),
|
|
|
|
|
// physics: const NeverScrollableScrollPhysics(),
|
|
|
|
|
// padding: const EdgeInsets.only(top: 0),
|
|
|
|
|
// shrinkWrap: true,
|
|
|
|
|
// children: [
|
|
|
|
|
// optionUI("poor.svg", 1),
|
|
|
|
|
// optionUI("bad.svg", 2),
|
|
|
|
|
// optionUI("normal.svg", 3),
|
|
|
|
|
// optionUI("good.svg", 4),
|
|
|
|
|
// optionUI("xcellent.svg", 5),
|
|
|
|
|
// ],
|
|
|
|
|
// ),
|
|
|
|
|
// 27.height,
|
|
|
|
|
// DynamicTextFieldWidget(
|
|
|
|
|
// LocaleKeys.description.tr(),
|
|
|
|
|
// LocaleKeys.typeHere.tr(),
|
|
|
|
|
// lines: 3,
|
|
|
|
|
// onChange: (v) {
|
|
|
|
|
// reviewText = v;
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// 150.height
|
|
|
|
|
],
|
|
|
|
|
).paddingOnly(left: 21, right: 21),
|
|
|
|
|
child: ListView(
|
|
|
|
|
children: [
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.all(16.0),
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
32.height,
|
|
|
|
|
itgResponseData?.survey?.title?.toText24() ?? const Text(""),
|
|
|
|
|
8.height,
|
|
|
|
|
itgResponseData?.survey?.description?.toText16() ?? const Text(""),
|
|
|
|
|
ListView.builder(
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
|
itemCount: itgResponseData?.survey?.questions?.length,
|
|
|
|
|
itemBuilder: (cxt, index) {
|
|
|
|
|
return answeredQuestions.isNotEmpty ? getSurveyWidget(itgResponseData?.survey?.questions![index], index) : Container();
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).paddingOnly(left: 21, right: 21),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
)),
|
|
|
|
|
DefaultButton(
|
|
|
|
|
LocaleKeys.submitSurvey.tr(),
|
|
|
|
|
@ -156,6 +105,9 @@ class _SurveyScreenState extends State<SurveyScreen> {
|
|
|
|
|
answeredQuestions.clear();
|
|
|
|
|
itgResponseData?.survey?.questions?.forEach((element) {
|
|
|
|
|
if (element.type != "Stars") {
|
|
|
|
|
if(element.type == "Faces") {
|
|
|
|
|
_selectedIndex = element.options![0].optionId!;
|
|
|
|
|
}
|
|
|
|
|
answeredQuestions.add(element.options![0].optionId.toString());
|
|
|
|
|
} else {
|
|
|
|
|
answeredQuestions.add("3");
|
|
|
|
|
@ -172,24 +124,18 @@ class _SurveyScreenState extends State<SurveyScreen> {
|
|
|
|
|
24.height,
|
|
|
|
|
question?.title?.toText18() ?? const Text(""),
|
|
|
|
|
16.height,
|
|
|
|
|
Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 50.0,
|
|
|
|
|
child: ListView.builder(
|
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
|
itemCount: question?.options?.length,
|
|
|
|
|
itemBuilder: (cxt, index) {
|
|
|
|
|
return radioOption(question?.options?[index].title ?? "", question?.options?[index].optionId.toString() ?? "", answeredQuestions[parentIndex], parentIndex);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
GridView.builder(
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
itemCount: question?.options?.length,
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
return radioOption(question?.options?[index].title ?? "", question?.options?[index].optionId.toString() ?? "", answeredQuestions[parentIndex], parentIndex);
|
|
|
|
|
},
|
|
|
|
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
|
|
crossAxisCount: 2,
|
|
|
|
|
childAspectRatio: (4.0),
|
|
|
|
|
),
|
|
|
|
|
).paddingOnly(left: 22, right: 22, top: 12, bottom: 12).objectContainerView(disablePadding: true),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
@ -207,8 +153,8 @@ class _SurveyScreenState extends State<SurveyScreen> {
|
|
|
|
|
direction: Axis.horizontal,
|
|
|
|
|
allowHalfRating: false,
|
|
|
|
|
itemCount: 5,
|
|
|
|
|
itemPadding: EdgeInsets.symmetric(horizontal: 8),
|
|
|
|
|
itemBuilder: (context, _) => Icon(
|
|
|
|
|
itemPadding: const EdgeInsets.symmetric(horizontal: 8),
|
|
|
|
|
itemBuilder: (context, _) => const Icon(
|
|
|
|
|
Icons.star,
|
|
|
|
|
color: Colors.amber,
|
|
|
|
|
),
|
|
|
|
|
@ -262,15 +208,8 @@ class _SurveyScreenState extends State<SurveyScreen> {
|
|
|
|
|
index++;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ItgMainRes? res = await DashboardApiClient().submitItgForm(
|
|
|
|
|
comment: reviewText,
|
|
|
|
|
masterId: itgResponseData!.notificationMasterId ?? "",
|
|
|
|
|
// itgList: [
|
|
|
|
|
// {"questionId": "1", "optionId": null, "starRating": starRating},
|
|
|
|
|
// {"questionId": "2", "optionId": "4", "starRating": _selectedIndex}
|
|
|
|
|
// ],
|
|
|
|
|
itgList: itgAnswersList,
|
|
|
|
|
serviceId: itgResponseData!.survey!.surveyId ?? 0);
|
|
|
|
|
ItgMainRes? res = await DashboardApiClient()
|
|
|
|
|
.submitItgForm(comment: reviewText, masterId: itgResponseData!.notificationMasterId ?? "", itgList: itgAnswersList, serviceId: itgResponseData!.survey!.surveyId ?? 0);
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
|
|
|
|
|
if (res!.mohemmItgResponseItem!.statusCode == 200) {
|
|
|
|
|
@ -289,6 +228,8 @@ class _SurveyScreenState extends State<SurveyScreen> {
|
|
|
|
|
|
|
|
|
|
Widget radioOption(String title, String value, String groupValue, int answerIndex) {
|
|
|
|
|
return Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
width: 24,
|
|
|
|
|
|