diff --git a/assets/images/xcellent.svg b/assets/images/excellent.svg similarity index 100% rename from assets/images/xcellent.svg rename to assets/images/excellent.svg diff --git a/assets/images/bad.svg b/assets/images/fair.svg similarity index 100% rename from assets/images/bad.svg rename to assets/images/fair.svg diff --git a/assets/images/normal.svg b/assets/images/ok.svg similarity index 100% rename from assets/images/normal.svg rename to assets/images/ok.svg diff --git a/lib/app_state/app_state.dart b/lib/app_state/app_state.dart index 2cfc751..24d8edf 100644 --- a/lib/app_state/app_state.dart +++ b/lib/app_state/app_state.dart @@ -90,7 +90,7 @@ class AppState { String get getHuaweiPushToken => _huaweiPushToken; - final PostParamsModel _postParamsInitConfig = PostParamsModel(channel: 31, versionID: 5.3, mobileType: Platform.isAndroid ? "android" : "ios"); + final PostParamsModel _postParamsInitConfig = PostParamsModel(channel: 31, versionID: 6.3, mobileType: Platform.isAndroid ? "android" : "ios"); void setPostParamsInitConfig() { isAuthenticated = false; diff --git a/lib/models/itg/itg_response_model.dart b/lib/models/itg/itg_response_model.dart index e8d8acf..6a85cb1 100644 --- a/lib/models/itg/itg_response_model.dart +++ b/lib/models/itg/itg_response_model.dart @@ -45,34 +45,57 @@ class ItgResponseResult { this.data, this.errormsg, }); - - dynamic totalItemsCount; - List? data; - dynamic errormsg; - - ItgResponseResult.fromJson(Map json) { - totalItemsCount = json['totalItemsCount']; - if (json['data'] != null) { - data = []; +// +// final dynamic totalItemsCount; +// final ItgResponseData? data; +// final dynamic errormsg; +// +// factory ItgResponseResult.fromJson(Map json) => ItgResponseResult( +// totalItemsCount: json["totalItemsCount"], +// data: json["data"] == null ? null : ItgResponseData.fromJson(json["data"]), +// errormsg: json["errormsg"], +// ); +// +// Map toJson() => { +// "totalItemsCount": totalItemsCount, +// "data": data == null ? null : data!.toJson(), +// "errormsg": errormsg, +// }; +// } + +// todo these lines, for ERM new change on UAT +dynamic totalItemsCount; +List? data; +dynamic errormsg; + +ItgResponseResult.fromJson(Map json) { + totalItemsCount = json['totalItemsCount']; + if (json['data'] != null) { + data = []; + if(json['data'] is List) { json['data'].forEach((v) { data!.add(ItgResponseData.fromJson(v)); }); + } else { + data!.add(ItgResponseData.fromJson(json['data'])); } - errormsg = json['errormsg']; - } - // - // factory ItgResponseResult.fromJson(Map json) => ItgResponseResult( - // totalItemsCount: json["totalItemsCount"], - // data: json["data"] == null ? null : ItgResponseData.fromJson(json["data"]), - // errormsg: json["errormsg"], - // ); + } + errormsg = json['errormsg']; +} - Map toJson() => { - "totalItemsCount": totalItemsCount, - "data": data == null ? null : data!.map((v) => v.toJson()).toList(), - "errormsg": errormsg, - }; +// +// factory ItgResponseResult.fromJson(Map json) => ItgResponseResult( +// totalItemsCount: json["totalItemsCount"], +// data: json["data"] == null ? null : ItgResponseData.fromJson(json["data"]), +// errormsg: json["errormsg"], +// ); + +Map toJson() => { + "totalItemsCount": totalItemsCount, + "data": data == null ? null : data!.map((v) => v.toJson()).toList(), + "errormsg": errormsg, + }; } class ItgResponseData { diff --git a/lib/models/itg/survey_model.dart b/lib/models/itg/survey_model.dart index f9ac415..501ce65 100644 --- a/lib/models/itg/survey_model.dart +++ b/lib/models/itg/survey_model.dart @@ -9,13 +9,18 @@ class SurveyModel { dynamic pageNo; dynamic languageId; - SurveyModel({this.surveyId, this.referenceNo, this.title, this.description, this.questions, this.isActive, this.pageSize, this.pageNo, this.languageId}); + String? descriptionAr; + String? titleAr; + + SurveyModel({this.surveyId, this.referenceNo, this.title,this.titleAr, this.description, this.descriptionAr, this.questions, this.isActive, this.pageSize, this.pageNo, this.languageId}); SurveyModel.fromJson(Map json) { surveyId = json['surveyId']; referenceNo = json['referenceNo']; title = json['title']; + titleAr = json['titleAr']; description = json['description']; + descriptionAr = json['descriptionAr']; if (json['questions'] != null) { questions = []; json['questions'].forEach((v) { @@ -33,7 +38,9 @@ class SurveyModel { data['surveyId'] = this.surveyId; data['referenceNo'] = this.referenceNo; data['title'] = this.title; + data['titleAr'] = this.titleAr; data['description'] = this.description; + data['descriptionAr'] = this.descriptionAr; if (this.questions != null) { data['questions'] = this.questions!.map((v) => v.toJson()).toList(); } @@ -48,6 +55,7 @@ class SurveyModel { class Questions { int? questionId; String? title; + String? titleAr; bool? isRequired; String? type; int? sequenceNo; @@ -59,11 +67,12 @@ class Questions { dynamic pageNo; dynamic languageId; - Questions({this.questionId, this.title, this.isRequired, this.type, this.sequenceNo, this.surveyId, this.options, this.rspPercentage, this.isActive, this.pageSize, this.pageNo, this.languageId}); + Questions({this.questionId, this.title, this.titleAr, this.isRequired, this.type, this.sequenceNo, this.surveyId, this.options, this.rspPercentage, this.isActive, this.pageSize, this.pageNo, this.languageId}); Questions.fromJson(Map json) { questionId = json['questionId']; title = json['title']; + titleAr = json['titleAr']; isRequired = json['isRequired']; type = json['type']; sequenceNo = json['sequenceNo']; @@ -85,6 +94,7 @@ class Questions { Map data = new Map(); data['questionId'] = this.questionId; data['title'] = this.title; + data['titleAr'] = this.titleAr; data['isRequired'] = this.isRequired; data['type'] = this.type; data['sequenceNo'] = this.sequenceNo; @@ -104,6 +114,7 @@ class Questions { class Options { int? optionId; String? title; + String? titleAr; bool? isCommentsRequired; int? sequenceNo; int? questionId; @@ -114,11 +125,12 @@ class Options { dynamic pageNo; dynamic languageId; - Options({this.optionId, this.title, this.isCommentsRequired, this.sequenceNo, this.questionId, this.rspPercentage, this.count, this.isActive, this.pageSize, this.pageNo, this.languageId}); + Options({this.optionId, this.title,this.titleAr, this.isCommentsRequired, this.sequenceNo, this.questionId, this.rspPercentage, this.count, this.isActive, this.pageSize, this.pageNo, this.languageId}); Options.fromJson(Map json) { optionId = json['optionId']; title = json['title']; + titleAr = json['titleAr']; isCommentsRequired = json['isCommentsRequired']; sequenceNo = json['sequenceNo']; questionId = json['questionId']; @@ -134,6 +146,7 @@ class Options { Map data = new Map(); data['optionId'] = this.optionId; data['title'] = this.title; + data['titleAr'] = this.titleAr; data['isCommentsRequired'] = this.isCommentsRequired; data['sequenceNo'] = this.sequenceNo; data['questionId'] = this.questionId; diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index ea3b2cb..8b03af9 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -168,7 +168,7 @@ class _DashboardScreenState extends State with WidgetsBindingOb if (value!.mohemmItgResponseItem!.statusCode == 200) { if (value.mohemmItgResponseItem!.result!.data != null) { // Navigator.pushNamed(context, AppRoutes.survey, arguments: val.result!.data); - Navigator.pushNamed(context, AppRoutes.survey, arguments: value.mohemmItgResponseItem!.result!.data); + Navigator.pushNamed(context, AppRoutes.survey, arguments: value.mohemmItgResponseItem!.result!.data!.first); // Navigator.pushNamed(context, AppRoutes.advertisement, arguments: { // "masterId": val.result!.data!.notificationMasterId, // "advertisement": value.mohemmItgResponseItem!.result!.data!.advertisement, diff --git a/lib/ui/landing/itg/survey_screen.dart b/lib/ui/landing/itg/survey_screen.dart index 59f3c14..600be6a 100644 --- a/lib/ui/landing/itg/survey_screen.dart +++ b/lib/ui/landing/itg/survey_screen.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:mohem_flutter_app/api/dashboard_api_client.dart'; +import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/extensions/int_extensions.dart'; @@ -53,9 +54,9 @@ class _SurveyScreenState extends State { child: Column( children: [ 32.height, - itgResponseData?.survey?.title?.toText24() ?? const Text(""), + (AppState().isArabic(context) ? itgResponseData?.survey?.titleAr : itgResponseData?.survey?.title)?.toText24() ?? const Text(""), 8.height, - itgResponseData?.survey?.description?.toText16() ?? const Text(""), + (AppState().isArabic(context) ? itgResponseData?.survey?.descriptionAr : itgResponseData?.survey?.description)?.toText16() ?? const Text(""), ListView.builder( padding: EdgeInsets.zero, shrinkWrap: true, @@ -105,7 +106,7 @@ class _SurveyScreenState extends State { answeredQuestions.clear(); itgResponseData?.survey?.questions?.forEach((element) { if (element.type != "Stars") { - if(element.type == "Faces") { + if (element.type == "Faces") { _selectedIndex = element.options![0].optionId!; } answeredQuestions.add(element.options![0].optionId.toString()); @@ -122,15 +123,16 @@ class _SurveyScreenState extends State { return Column( children: [ 24.height, - question?.title?.toText18() ?? const Text(""), + (AppState().isArabic(context) ? question?.titleAr : question?.title)?.toText18() ?? const Text(""), 16.height, GridView.builder( padding: EdgeInsets.zero, - itemCount: question?.options?.length, + itemCount: question?.options?.length ?? 0, shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), itemBuilder: (context, index) { - return radioOption(question?.options?[index].title ?? "", question?.options?[index].optionId.toString() ?? "", answeredQuestions[parentIndex], parentIndex); + return radioOption((AppState().isArabic(context) ? (question!.options![index].titleAr) : question!.options![index].title) ?? "", question?.options?[index].optionId.toString() ?? "", + answeredQuestions[parentIndex], parentIndex); }, gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, @@ -145,7 +147,7 @@ class _SurveyScreenState extends State { mainAxisSize: MainAxisSize.min, children: [ 24.height, - question?.title?.toText18() ?? Text(""), + (AppState().isArabic(context) ? question?.titleAr : question?.title)?.toText18() ?? Text(""), 16.height, RatingBar.builder( initialRating: 3, @@ -171,7 +173,7 @@ class _SurveyScreenState extends State { mainAxisSize: MainAxisSize.min, children: [ 24.height, - question?.title?.toText18() ?? Text("asdasdasdasd"), + (AppState().isArabic(context) ? question?.titleAr : question?.title)?.toText18() ?? Text(""), 16.height, GridView( gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 5, crossAxisSpacing: 7, mainAxisSpacing: 7), @@ -179,11 +181,13 @@ class _SurveyScreenState extends State { padding: const EdgeInsets.only(top: 0), shrinkWrap: true, children: [ - optionUI("poor.svg", question?.options?[0].optionId, parentIndex), - optionUI("bad.svg", question?.options?[1].optionId, parentIndex), - optionUI("normal.svg", question?.options?[2].optionId, parentIndex), - optionUI("good.svg", question?.options?[3].optionId, parentIndex), - optionUI("xcellent.svg", question?.options?[4].optionId, parentIndex), + for (int i = 0; i < (question?.options?.length ?? 0); i++) optionUI("${question?.options![i].title!.toLowerCase()}.svg", question?.options?[i].optionId, parentIndex), + + // optionUI("poor.svg", question?.options?[0].optionId, parentIndex), + // optionUI("fair.svg", question?.options?[1].optionId, parentIndex), + // optionUI("ok.svg", question?.options?[2].optionId, parentIndex), + // optionUI("good.svg", question?.options?[3].optionId, parentIndex), + // optionUI("excellent.svg", question?.options?[4].optionId, parentIndex), ], ), ],