ITG ADs update

mohemm_HMG_flutter_upgrade
haroon amjad 2 years ago
parent 5098aa7f90
commit a48d703642

@ -201,7 +201,7 @@ class DashboardApiClient {
}, url, postParams); }, url, postParams);
} }
Future setAdvertisementViewed(String masterID, int advertisementId, String ackValue) async { Future setAdvertisementViewed(String masterID, int advertisementId, String? ackValue) async {
String url = "${ApiConsts.cocRest}Mohemm_ITG_UpdateAdvertisementAsViewed"; String url = "${ApiConsts.cocRest}Mohemm_ITG_UpdateAdvertisementAsViewed";
Map<String, dynamic> postParams = { Map<String, dynamic> postParams = {

@ -3,8 +3,8 @@ import 'package:mohem_flutter_app/ui/marathon/widgets/question_card.dart';
class ApiConsts { class ApiConsts {
//static String baseUrl = "http://10.200.204.20:2801/"; // Local server //static String baseUrl = "http://10.200.204.20:2801/"; // Local server
// static String baseUrl = "https://erptstapp.srca.org.sa"; // SRCA server // static String baseUrl = "https://erptstapp.srca.org.sa"; // SRCA server
// static String baseUrl = "https://uat.hmgwebservices.com"; // UAT server static String baseUrl = "https://uat.hmgwebservices.com"; // UAT server
static String baseUrl = "https://hmgwebservices.com"; // Live server // static String baseUrl = "https://hmgwebservices.com"; // Live server
static String baseUrlServices = baseUrl + "/Services/"; // server static String baseUrlServices = baseUrl + "/Services/"; // server
// static String baseUrlServices = "https://api.cssynapses.com/tangheem/"; // Live server // static String baseUrlServices = "https://api.cssynapses.com/tangheem/"; // Live server
static String utilitiesRest = baseUrlServices + "Utilities.svc/REST/"; static String utilitiesRest = baseUrlServices + "Utilities.svc/REST/";

@ -1,108 +1,156 @@
class Advertisement { class Advertisement {
int? advertisementId;
String? advertisementTitle;
int? durationInSeconds;
bool? showDelete;
dynamic acknowledgment;
late bool isOptional;
List<ViewAttachFileColl>? viewAttachFileColl;
int? skipButtonId;
List<ActionButtonsColl>? actionButtonsColl;
bool? isActive;
num? pageSize;
num? pageNo;
num? languageId;
Advertisement({ Advertisement({
this.advertisementId, this.advertisementId,
this.advertisementTitle, this.advertisementTitle,
this.durationInSeconds, this.durationInSeconds,
this.showDelete, this.showDelete,
this.acknowledgment, this.acknowledgment,
required this.isOptional,
// this.skipBtnTextEn,
// this.skipBtnTextAr,
this.viewAttachFileColl, this.viewAttachFileColl,
this.skipButtonId,
this.actionButtonsColl,
this.isActive, this.isActive,
this.pageSize, this.pageSize,
this.pageNo, this.pageNo,
this.languageId, this.languageId,
this.isOptional,
this.skipButtonTextEn,
this.skipButtonTextAr,
}); });
final int? advertisementId; Advertisement.fromJson(Map<String, dynamic> json) {
final String? advertisementTitle; advertisementId = json['advertisementId'];
final int? durationInSeconds; advertisementTitle = json['advertisementTitle'];
final bool? showDelete; durationInSeconds = json['durationInSeconds'];
final dynamic acknowledgment; showDelete = json['showDelete'];
final List<ViewAttachFileColl>? viewAttachFileColl; acknowledgment = json['acknowledgment'];
final bool? isActive; isOptional = json['isOptional'];
final dynamic pageSize; // skipBtnTextEn = json['skipBtnTextEn'];
final dynamic pageNo; // skipBtnTextAr = json['skipBtnTextAr'];
final dynamic languageId; if (json['viewAttachFileColl'] != null) {
final bool? isOptional; viewAttachFileColl = <ViewAttachFileColl>[];
final String? skipButtonTextEn; json['viewAttachFileColl'].forEach((v) {
final String? skipButtonTextAr; viewAttachFileColl!.add(ViewAttachFileColl.fromJson(v));
});
factory Advertisement.fromJson(Map<String, dynamic> json) => Advertisement( }
advertisementId: json["advertisementId"] == null ? null : json["advertisementId"], skipButtonId = json['skipButtonId'];
advertisementTitle: json["advertisementTitle"] == null ? null : json["advertisementTitle"], if (json['actionButtonsColl'] != null) {
durationInSeconds: json["durationInSeconds"] == null ? null : json["durationInSeconds"], actionButtonsColl = <ActionButtonsColl>[];
showDelete: json["showDelete"] == null ? null : json["showDelete"], json['actionButtonsColl'].forEach((v) {
acknowledgment: json["acknowledgment"], actionButtonsColl!.add(ActionButtonsColl.fromJson(v));
viewAttachFileColl: json["viewAttachFileColl"] == null ? null : List<ViewAttachFileColl>.from(json["viewAttachFileColl"].map((x) => ViewAttachFileColl.fromJson(x))), });
isActive: json["isActive"] == null ? null : json["isActive"], }
pageSize: json["pageSize"], isActive = json['isActive'];
pageNo: json["pageNo"], pageSize = json['pageSize'];
languageId: json["languageId"], pageNo = json['pageNo'];
isOptional: json["isOptional"] == null ? null : json["isOptional"], languageId = json['languageId'];
skipButtonTextEn: json["skipBtnTextEn"] == null ? null : json["skipBtnTextEn"], }
skipButtonTextAr: json["skipBtnTextAr"] == null ? null : json["skipBtnTextAr"],
);
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() {
"advertisementId": advertisementId == null ? null : advertisementId, Map<String, dynamic> data = Map<String, dynamic>();
"advertisementTitle": advertisementTitle == null ? null : advertisementTitle, data['advertisementId'] = this.advertisementId;
"durationInSeconds": durationInSeconds == null ? null : durationInSeconds, data['advertisementTitle'] = this.advertisementTitle;
"showDelete": showDelete == null ? null : showDelete, data['durationInSeconds'] = this.durationInSeconds;
"acknowledgment": acknowledgment, data['showDelete'] = this.showDelete;
"viewAttachFileColl": viewAttachFileColl == null ? null : List<dynamic>.from(viewAttachFileColl!.map((x) => x.toJson())), data['acknowledgment'] = this.acknowledgment;
"isActive": isActive == null ? null : isActive, data['isOptional'] = this.isOptional;
"pageSize": pageSize, // data['skipBtnTextEn'] = this.skipBtnTextEn;
"pageNo": pageNo, // data['skipBtnTextAr'] = this.skipBtnTextAr;
"languageId": languageId, if (this.viewAttachFileColl != null) {
}; data['viewAttachFileColl'] = this.viewAttachFileColl!.map((v) => v.toJson()).toList();
}
data['skipButtonId'] = this.skipButtonId;
if (this.actionButtonsColl != null) {
data['actionButtonsColl'] = this.actionButtonsColl!.map((v) => v.toJson()).toList();
}
data['isActive'] = this.isActive;
data['pageSize'] = this.pageSize;
data['pageNo'] = this.pageNo;
data['languageId'] = this.languageId;
return data;
}
} }
class ViewAttachFileColl { class ViewAttachFileColl {
ViewAttachFileColl({ dynamic attachmentId;
this.attachmentId, String? fileName;
this.fileName, String? contentType;
this.contentType, dynamic attachFileStream;
this.attachFileStream, String? base64String;
this.base64String, dynamic isActive;
this.isActive, dynamic referenceItemId;
this.referenceItemId, dynamic content;
this.content, dynamic filePath;
this.filePath,
}); ViewAttachFileColl({this.attachmentId, this.fileName, this.contentType, this.attachFileStream, this.base64String, this.isActive, this.referenceItemId, this.content, this.filePath});
ViewAttachFileColl.fromJson(Map<String, dynamic> json) {
attachmentId = json['attachmentId'];
fileName = json['fileName'];
contentType = json['contentType'];
attachFileStream = json['attachFileStream'];
base64String = json['base64String'];
isActive = json['isActive'];
referenceItemId = json['referenceItemId'];
content = json['content'];
filePath = json['filePath'];
}
Map<String, dynamic> toJson() {
Map<String, dynamic> data = new Map<String, dynamic>();
data['attachmentId'] = this.attachmentId;
data['fileName'] = this.fileName;
data['contentType'] = this.contentType;
data['attachFileStream'] = this.attachFileStream;
data['base64String'] = this.base64String;
data['isActive'] = this.isActive;
data['referenceItemId'] = this.referenceItemId;
data['content'] = this.content;
data['filePath'] = this.filePath;
return data;
}
}
class ActionButtonsColl {
late int actionButtonId;
late String btnTextEn;
late String btnTextAr;
late String actionValue;
late dynamic iconOrImage;
late int orderNo;
final dynamic attachmentId; ActionButtonsColl({required this.actionButtonId, required this.btnTextEn, required this.btnTextAr, required this.actionValue, required this.iconOrImage, required this.orderNo});
final String? fileName;
final String? contentType;
final dynamic attachFileStream;
final String? base64String;
final dynamic isActive;
final dynamic referenceItemId;
final dynamic content;
final dynamic filePath;
factory ViewAttachFileColl.fromJson(Map<String, dynamic> json) => ViewAttachFileColl( ActionButtonsColl.fromJson(Map<String, dynamic> json) {
attachmentId: json["attachmentId"], actionButtonId = json['actionButtonId'];
fileName: json["fileName"] == null ? null : json["fileName"], btnTextEn = json['btnTextEn'];
contentType: json["contentType"] == null ? null : json["contentType"], btnTextAr = json['btnTextAr'];
attachFileStream: json["attachFileStream"], actionValue = json['actionValue'];
base64String: json["base64String"] == null ? null : json["base64String"], iconOrImage = json['iconOrImage'];
isActive: json["isActive"], orderNo = json['orderNo'];
referenceItemId: json["referenceItemId"], }
content: json["content"],
filePath: json["filePath"],
);
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() {
"attachmentId": attachmentId, Map<String, dynamic> data = new Map<String, dynamic>();
"fileName": fileName == null ? null : fileName, data['actionButtonId'] = this.actionButtonId;
"contentType": contentType == null ? null : contentType, data['btnTextEn'] = this.btnTextEn;
"attachFileStream": attachFileStream, data['btnTextAr'] = this.btnTextAr;
"base64String": base64String == null ? null : base64String, data['actionValue'] = this.actionValue;
"isActive": isActive, data['iconOrImage'] = this.iconOrImage;
"referenceItemId": referenceItemId, data['orderNo'] = this.orderNo;
"content": content, return data;
"filePath": filePath, }
};
} }

@ -5,9 +5,9 @@ class SurveyModel {
String? description; String? description;
List<Questions>? questions; List<Questions>? questions;
bool? isActive; bool? isActive;
Null? pageSize; dynamic pageSize;
Null? pageNo; dynamic pageNo;
Null? languageId; dynamic languageId;
SurveyModel({this.surveyId, this.referenceNo, this.title, this.description, this.questions, this.isActive, this.pageSize, this.pageNo, this.languageId}); SurveyModel({this.surveyId, this.referenceNo, this.title, this.description, this.questions, this.isActive, this.pageSize, this.pageNo, this.languageId});
@ -51,13 +51,13 @@ class Questions {
bool? isRequired; bool? isRequired;
String? type; String? type;
int? sequenceNo; int? sequenceNo;
Null? surveyId; dynamic surveyId;
List<Options>? options; List<Options>? options;
Null? rspPercentage; dynamic rspPercentage;
Null? isActive; dynamic isActive;
Null? pageSize; dynamic pageSize;
Null? pageNo; dynamic pageNo;
Null? languageId; 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.isRequired, this.type, this.sequenceNo, this.surveyId, this.options, this.rspPercentage, this.isActive, this.pageSize, this.pageNo, this.languageId});
@ -107,12 +107,12 @@ class Options {
bool? isCommentsRequired; bool? isCommentsRequired;
int? sequenceNo; int? sequenceNo;
int? questionId; int? questionId;
Null? rspPercentage; dynamic rspPercentage;
Null? count; dynamic count;
Null? isActive; dynamic isActive;
Null? pageSize; dynamic pageSize;
Null? pageNo; dynamic pageNo;
Null? languageId; 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.isCommentsRequired, this.sequenceNo, this.questionId, this.rspPercentage, this.count, this.isActive, this.pageSize, this.pageNo, this.languageId});

@ -6,7 +6,7 @@ class ITGRequest {
List<AllowedActions>? allowedActions; List<AllowedActions>? allowedActions;
List<dynamic>? attachments; List<dynamic>? attachments;
List<FieldGoups>? fieldGoups; List<FieldGoups>? fieldGoups;
Null? grantFields; dynamic grantFields;
List<WFHistory>? wFHistory; List<WFHistory>? wFHistory;
ITGRequest({this.allowedActions, this.attachments, this.fieldGoups, this.grantFields, this.wFHistory}); ITGRequest({this.allowedActions, this.attachments, this.fieldGoups, this.grantFields, this.wFHistory});

@ -163,7 +163,7 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
print("-------------------- Survey ----------------------------"); print("-------------------- Survey ----------------------------");
if (val.result!.data!.notificationType == "Survey") { if (val.result!.data!.notificationType == "Survey") {
DashboardApiClient().getAdvertisementDetail(val.result!.data!.notificationMasterId ?? "").then( DashboardApiClient().getAdvertisementDetail(val.result!.data!.notificationMasterId ?? "").then(
(value) { (value) {
if (value!.mohemmItgResponseItem!.statusCode == 200) { if (value!.mohemmItgResponseItem!.statusCode == 200) {
if (value.mohemmItgResponseItem!.result!.data != null) { if (value.mohemmItgResponseItem!.result!.data != null) {
// Navigator.pushNamed(context, AppRoutes.survey, arguments: val.result!.data); // Navigator.pushNamed(context, AppRoutes.survey, arguments: val.result!.data);

@ -61,6 +61,11 @@ class _ITGAdsScreenState extends State<ITGAdsScreen> {
isVideo = true; isVideo = true;
_futureController = createVideoPlayer(rFile!); _futureController = createVideoPlayer(rFile!);
} }
advertisementData?.actionButtonsColl!.forEach((element) {
advertisementData?.actionButtonsColl!.removeWhere((element1) => element1.actionButtonId == advertisementData?.skipButtonId);
});
setState(() {}); setState(() {});
} }
@ -152,55 +157,101 @@ class _ITGAdsScreenState extends State<ITGAdsScreen> {
textStyle: const TextStyle(color: Colors.white, fontSize: 16, letterSpacing: -0.48, fontWeight: FontWeight.bold), textStyle: const TextStyle(color: Colors.white, fontSize: 16, letterSpacing: -0.48, fontWeight: FontWeight.bold),
), ),
50.height, 50.height,
if (advertisementData?.isOptional ?? false)
DefaultButton(AppState().isArabic(context) ? "يتخطى" : "Skip", () async {
Navigator.pop(context);
DashboardApiClient().setAdvertisementViewed(masterID!, advertisementData!.advertisementId!, "Skip").then((value) {
logger.d(value);
});
}).paddingOnly(left: 60.0, right: 60.0, top: 8, bottom: 8),
ValueListenableBuilder<bool>( ValueListenableBuilder<bool>(
valueListenable: hasTimerEnded, valueListenable: hasTimerEnded,
builder: (context, val, child) { builder: (context, val, child) {
if (hasTimerEndedBool) { if (hasTimerEndedBool) {
return Row( return GridView.builder(
mainAxisAlignment: MainAxisAlignment.center, padding: EdgeInsets.zero,
children: [ itemCount: advertisementData?.actionButtonsColl!.length,
Container( shrinkWrap: true,
padding: const EdgeInsets.all(16), decoration: Utils.containerRadius(MyColors.white, 10), child: const Icon(Icons.thumb_up, color: MyColors.gradiantEndColor)) physics: const NeverScrollableScrollPhysics(),
.onPress(() { itemBuilder: (context, index) {
try { String? btnText = AppState().isArabic(context) ? advertisementData?.actionButtonsColl![index].btnTextAr : advertisementData?.actionButtonsColl![index].btnTextEn;
Navigator.pop(context); return DefaultButton(btnText!, () async {
DashboardApiClient().setAdvertisementViewed(masterID!, advertisementData!.advertisementId!, "Like").then((value) { Navigator.pop(context);
logger.d(value); DashboardApiClient()
}); .setAdvertisementViewed(masterID!, advertisementData!.advertisementId!, advertisementData?.actionButtonsColl![index].actionValue)
} catch (ex) { .then((value) {
logger.wtf(ex); logger.d(value);
Utils.handleException(ex, context, null); });
} }).paddingOnly(left: 60.0, right: 60.0, top: 8, bottom: 8);
}), },
20.width, gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
Container( crossAxisCount: 1,
padding: const EdgeInsets.all(16), decoration: Utils.containerRadius(MyColors.white, 10), child: const Icon(Icons.thumb_down, color: MyColors.gradiantEndColor)) childAspectRatio: (7.0),
.onPress(() { ),
try {
Navigator.pop(context);
DashboardApiClient().setAdvertisementViewed(masterID!, advertisementData!.advertisementId!, "Dislike").then((value) {
logger.d(value);
});
} catch (ex) {
logger.wtf(ex);
Utils.handleException(ex, context, null);
}
}),
],
); );
// Row(
// mainAxisAlignment: MainAxisAlignment.center,
// children: [
// Container(padding: const EdgeInsets.all(16), decoration: Utils.containerRadius(MyColors.white, 10), child: const Icon(Icons.thumb_up, color: MyColors.gradiantEndColor))
// .onPress(() {
// try {
// Navigator.pop(context);
// DashboardApiClient().setAdvertisementViewed(masterID!, advertisementData!.advertisementId!, "Like").then((value) {
// logger.d(value);
// });
// } catch (ex) {
// logger.wtf(ex);
// Utils.handleException(ex, context, null);
// }
// }),
// 20.width,
// Container(
// padding: const EdgeInsets.all(16), decoration: Utils.containerRadius(MyColors.white, 10), child: const Icon(Icons.thumb_down, color: MyColors.gradiantEndColor))
// .onPress(() {
// try {
// Navigator.pop(context);
// DashboardApiClient().setAdvertisementViewed(masterID!, advertisementData!.advertisementId!, "Dislike").then((value) {
// logger.d(value);
// });
// } catch (ex) {
// logger.wtf(ex);
// Utils.handleException(ex, context, null);
// }
// }),
// ],
// );
} else { } else {
return Container(); return Container();
} }
}, },
), ),
20.height, 20.height,
if (advertisementData?.isOptional ?? false) // if (advertisementData?.isOptional ?? false)
DefaultButton(AppState().isArabic(context) ? advertisementData?.skipButtonTextAr ?? "Skip" : advertisementData?.skipButtonTextEn ?? "Skip", () async { // GridView.builder(
Navigator.pop(context); // padding: EdgeInsets.zero,
DashboardApiClient().setAdvertisementViewed(masterID!, advertisementData!.advertisementId!, "Skip").then((value) { // itemCount: advertisementData?.actionButtonsColl!.length,
logger.d(value); // shrinkWrap: true,
}); // physics: const NeverScrollableScrollPhysics(),
}).paddingOnly(left: 100, right: 100) // itemBuilder: (context, index) {
// String? btnText = AppState().isArabic(context) ? advertisementData?.actionButtonsColl![index].btnTextAr : advertisementData?.actionButtonsColl![index].btnTextEn;
// return DefaultButton(btnText!, () async {
// Navigator.pop(context);
// DashboardApiClient().setAdvertisementViewed(masterID!, advertisementData!.advertisementId!, advertisementData?.actionButtonsColl![index].actionValue).then((value) {
// logger.d(value);
// });
// }).paddingAll(8);
// },
// gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
// crossAxisCount: 2,
// childAspectRatio: (4.0),
// ),
// )
// DefaultButton(AppState().isArabic(context) ? advertisementData?.skipButtonTextAr ?? "Skip" : advertisementData?.skipButtonTextEn ?? "Skip", () async {
// Navigator.pop(context);
// DashboardApiClient().setAdvertisementViewed(masterID!, advertisementData!.advertisementId!, "Skip").then((value) {
// logger.d(value);
// });
// }).paddingOnly(left: 100, right: 100)
], ],
); );
} else { } else {

Loading…
Cancel
Save