Merge branch 'master_mohemm_flutter' into development_haroon

# Conflicts:
#	ios/Runner.xcodeproj/project.pbxproj
development_haroon
haroon amjad 2 years ago
commit 165485965a

@ -0,0 +1,6 @@
-----BEGIN PRIVATE KEY-----
MIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQg+oBl9YdOiMRXfQZe
nIe6tR1tojoOvvcohNJmJtH+SsagCgYIKoZIzj0DAQehRANCAATDY9E82MAgMI/g
bKF1t4zLHJ1Yt9uoOnedNYsfyZLhh3l3ZyXRj02uDXz04AsNbNFjkLJXPc4xY9ad
+A4rY70x
-----END PRIVATE KEY-----

@ -91,5 +91,7 @@
<array> <array>
<string>TAG</string> <string>TAG</string>
</array> </array>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict> </dict>
</plist> </plist>

@ -60,7 +60,7 @@ class MyRequestsApiClient {
}, url, postParams); }, url, postParams);
} }
Future<SubmitCcpTransactionList?> getSubmitNewRequest(List<Map<String, dynamic>> list) async Future<GenericResponseModel> getSubmitNewRequest(List<Map<String, dynamic>> list) async
{ {
String url = "${ApiConsts.erpRest}SUBMIT_CCP_TRANSACTION"; String url = "${ApiConsts.erpRest}SUBMIT_CCP_TRANSACTION";
Map<String, dynamic> postParams = { Map<String, dynamic> postParams = {
@ -73,7 +73,7 @@ class MyRequestsApiClient {
postParams["EITTransactionTBL"] = list; postParams["EITTransactionTBL"] = list;
return await ApiClient().postJsonForObject((json) { return await ApiClient().postJsonForObject((json) {
GenericResponseModel? responseData = GenericResponseModel.fromJson(json); GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
return responseData.submitCcpTransactionList; return responseData;
}, url, postParams); }, url, postParams);
} }

@ -3,12 +3,16 @@ import 'dart:io';
import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart';
// import 'package:huawei_hmsavailability/huawei_hmsavailability.dart'; // import 'package:huawei_hmsavailability/huawei_hmsavailability.dart';
import 'package:huawei_push/huawei_push.dart' as huawei_push; import 'package:huawei_push/huawei_push.dart' as huawei_push;
import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart';
import 'package:mohem_flutter_app/classes/date_uitl.dart';
import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/classes/utils.dart';
import 'package:mohem_flutter_app/models/get_notifications_response_model.dart';
import 'package:mohem_flutter_app/ui/notifications/notification_details_page.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin(); final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
@ -24,6 +28,8 @@ class AppNotifications {
String _huaweiToken = ''; String _huaweiToken = '';
late BuildContext context;
Future<void> requestPermissions() async { Future<void> requestPermissions() async {
if (Platform.isIOS) { if (Platform.isIOS) {
await flutterLocalNotificationsPlugin.resolvePlatformSpecificImplementation<IOSFlutterLocalNotificationsPlugin>()?.requestPermissions(alert: true, badge: true, sound: true); await flutterLocalNotificationsPlugin.resolvePlatformSpecificImplementation<IOSFlutterLocalNotificationsPlugin>()?.requestPermissions(alert: true, badge: true, sound: true);
@ -40,11 +46,13 @@ class AppNotifications {
} }
} }
void init(String? firebaseToken) async { void init(String? firebaseToken, BuildContext context) async {
// if (Platform.isAndroid) { // if (Platform.isAndroid) {
// hmsApiAvailability = HmsApiAvailability(); // hmsApiAvailability = HmsApiAvailability();
// } // }
this.context = context;
await requestPermissions(); await requestPermissions();
AppState().setDeviceToken = firebaseToken; AppState().setDeviceToken = firebaseToken;
await Permission.notification.isDenied.then((bool value) { await Permission.notification.isDenied.then((bool value) {
@ -116,12 +124,51 @@ class AppNotifications {
void _handleMessage(RemoteMessage message) { void _handleMessage(RemoteMessage message) {
Utils.saveStringFromPrefs("isAppOpendByChat", "false"); Utils.saveStringFromPrefs("isAppOpendByChat", "false");
GetNotificationsResponseModel notification = GetNotificationsResponseModel();
notification.createdOn = DateUtil.getMonthDayYearDateFormatted(DateTime.now());
notification.messageTypeData = message.data['picture'];
notification.message = message.data['message'];
notification.notificationType = message.data["NotificationType"].toString();
if (message.data["NotificationType"] == "2") {
notification.videoURL = message.data["VideoUrl"];
}
Future.delayed(Duration(seconds: 5), () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context) => NotificationsDetailsPage(
notification: notification,
),
),
);
});
} }
void _handleOpenApp(RemoteMessage message) { void _handleOpenApp(RemoteMessage message) {
if (message.data.isNotEmpty && message.data["type"] == 'chat') { if (message.data.isNotEmpty && message.data["type"] == 'chat') {
Utils.saveStringFromPrefs("isAppOpendByChat", "true"); Utils.saveStringFromPrefs("isAppOpendByChat", "true");
Utils.saveStringFromPrefs("notificationData", message.data["user_chat_history_response"].toString()); Utils.saveStringFromPrefs("notificationData", message.data["user_chat_history_response"].toString());
} else {
GetNotificationsResponseModel notification = GetNotificationsResponseModel();
notification.createdOn = DateUtil.getMonthDayYearDateFormatted(DateTime.now());
notification.messageTypeData = message.data['picture'];
notification.message = message.data['message'];
notification.notificationType = message.data["NotificationType"].toString();
if (message.data["NotificationType"] == "2") {
notification.videoURL = message.data["VideoUrl"];
}
Future.delayed(Duration(seconds: 5), () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context) => NotificationsDetailsPage(
notification: notification,
),
),
);
});
} }
} }
} }

@ -401,4 +401,15 @@ class Utils {
} }
return false; return false;
} }
static bool isDate(String input, String format) {
try {
DateTime d = DateFormat(format).parseStrict(input);
//print(d);
return true;
} catch (e) {
//print(e);
return false;
}
}
} }

@ -0,0 +1,96 @@
class GetNotificationsResponseModel {
int? id;
int? recordId;
int? patientID;
bool? projectOutSA;
String? deviceType;
String? deviceToken;
String? message;
String? messageType;
String? messageTypeData;
dynamic videoURL;
bool? isQueue;
String? isQueueOn;
String? createdOn;
String? createdBy;
String? notificationType;
bool? isSent;
String? isSentOn;
bool? isRead;
String? isReadOn;
int? channelID;
int? projectID;
GetNotificationsResponseModel(
{this.id,
this.recordId,
this.patientID,
this.projectOutSA,
this.deviceType,
this.deviceToken,
this.message,
this.messageType,
this.messageTypeData,
this.videoURL,
this.isQueue,
this.isQueueOn,
this.createdOn,
this.createdBy,
this.notificationType,
this.isSent,
this.isSentOn,
this.isRead,
this.isReadOn,
this.channelID,
this.projectID});
GetNotificationsResponseModel.fromJson(Map<String, dynamic> json) {
id = json['Id'];
recordId = json['RecordId'];
patientID = json['PatientID'];
projectOutSA = json['ProjectOutSA'];
deviceType = json['DeviceType'];
deviceToken = json['DeviceToken'];
message = json['Message'];
messageType = json['MessageType'];
messageTypeData = json['MessageTypeData'];
videoURL = json['VideoURL'];
isQueue = json['IsQueue'];
isQueueOn = json['IsQueueOn'];
createdOn = json['CreatedOn'];
createdBy = json['CreatedBy'];
notificationType = json['NotificationType'];
isSent = json['IsSent'];
isSentOn = json['IsSentOn'];
isRead = json['IsRead'];
isReadOn = json['IsReadOn'];
channelID = json['ChannelID'];
projectID = json['ProjectID'];
}
Map<String, dynamic> toJson() {
Map<String, dynamic> data = new Map<String, dynamic>();
data['Id'] = this.id;
data['RecordId'] = this.recordId;
data['PatientID'] = this.patientID;
data['ProjectOutSA'] = this.projectOutSA;
data['DeviceType'] = this.deviceType;
data['DeviceToken'] = this.deviceToken;
data['Message'] = this.message;
data['MessageType'] = this.messageType;
data['MessageTypeData'] = this.messageTypeData;
data['VideoURL'] = this.videoURL;
data['IsQueue'] = this.isQueue;
data['IsQueueOn'] = this.isQueueOn;
data['CreatedOn'] = this.createdOn;
data['CreatedBy'] = this.createdBy;
data['NotificationType'] = this.notificationType;
data['IsSent'] = this.isSent;
data['IsSentOn'] = this.isSentOn;
data['IsRead'] = this.isRead;
data['IsReadOn'] = this.isReadOn;
data['ChannelID'] = this.channelID;
data['ProjectID'] = this.projectID;
return data;
}
}

@ -39,6 +39,12 @@ class _ITGAdsScreenState extends State<ITGAdsScreen> {
String? masterID; String? masterID;
int videoDuration = 0; int videoDuration = 0;
bool hasTimerEndedBool = false;
final ValueNotifier<bool> hasTimerEnded = ValueNotifier(false);
late CountdownTimerController timerController;
void checkFileType() async { void checkFileType() async {
String? rFile = advertisementData!.viewAttachFileColl!.first.base64String; String? rFile = advertisementData!.viewAttachFileColl!.first.base64String;
String? rFileExt = advertisementData!.viewAttachFileColl!.first.fileName; String? rFileExt = advertisementData!.viewAttachFileColl!.first.fileName;
@ -56,6 +62,17 @@ class _ITGAdsScreenState extends State<ITGAdsScreen> {
setState(() {}); setState(() {});
} }
void changeTimer(bool isTimerEnd) {
hasTimerEndedBool = isTimerEnd;
hasTimerEnded.value = !hasTimerEnded.value;
}
void onTimerEnd() {
changeTimer(true);
timerController.disposeTimer();
timerController.dispose();
}
Future processImage(String encodedBytes) async { Future processImage(String encodedBytes) async {
try { try {
Uint8List decodedBytes = base64Decode(encodedBytes.split("base64,").last); Uint8List decodedBytes = base64Decode(encodedBytes.split("base64,").last);
@ -69,18 +86,20 @@ class _ITGAdsScreenState extends State<ITGAdsScreen> {
Future<VideoPlayerController> createVideoPlayer(String encodedBytes) async { Future<VideoPlayerController> createVideoPlayer(String encodedBytes) async {
try { try {
Uint8List decodedBytes = base64Decode(encodedBytes.split("base64,").last); // Uint8List decodedBytes = base64Decode(encodedBytes.split("base64,").last);
Directory appDocumentsDirectory = await getApplicationDocumentsDirectory(); // 1 // Directory appDocumentsDirectory = await getApplicationDocumentsDirectory(); // 1
File file = Io.File("${appDocumentsDirectory.path}/myAdsVideo.mp4"); // File file = Io.File("${appDocumentsDirectory.path}/myAdsVideo.mp4");
file.writeAsBytesSync(decodedBytes); // file.writeAsBytesSync(decodedBytes);
VideoPlayerController controller = VideoPlayerController.file(file); // VideoPlayerController controller = VideoPlayerController.file(file);
VideoPlayerController controller = VideoPlayerController.network(advertisementData!.viewAttachFileColl!.first.base64String!);
await controller.initialize(); await controller.initialize();
await controller.play(); await controller.play();
await controller.setVolume(1.0); await controller.setVolume(1.0);
await controller.setLooping(false); await controller.setLooping(false);
return controller; return controller;
} catch (e) { } catch (e) {
return VideoPlayerController.asset("dataSource"); print(e);
return VideoPlayerController.network("https://apimohemmweb.cloudsolutions.com.sa/ErmAttachment/compressedvideo.mp4");
} }
} }
@ -107,6 +126,7 @@ class _ITGAdsScreenState extends State<ITGAdsScreen> {
if (advertisementData != null) { if (advertisementData != null) {
checkFileType(); checkFileType();
videoDuration = advertisementData?.durationInSeconds ?? 0; videoDuration = advertisementData?.durationInSeconds ?? 0;
timerController = CountdownTimerController(endTime: DateTime.now().millisecondsSinceEpoch + 1000 * videoDuration, onEnd: onTimerEnd);
} }
return Scaffold( return Scaffold(
backgroundColor: Colors.black, backgroundColor: Colors.black,
@ -131,24 +151,34 @@ class _ITGAdsScreenState extends State<ITGAdsScreen> {
), ),
30.height, 30.height,
CountdownTimer( CountdownTimer(
controller: timerController,
endTime: DateTime.now().millisecondsSinceEpoch + 1000 * videoDuration, endTime: DateTime.now().millisecondsSinceEpoch + 1000 * videoDuration,
onEnd: null, endWidget: "00:00:00".toText16(color: Colors.white, isBold: true),
endWidget: "00:00:00".toText14(color: Colors.white, isBold: true),
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,
Container(padding: const EdgeInsets.all(16), decoration: Utils.containerRadius(MyColors.white, 10), child: const Icon(Icons.thumb_up, color: MyColors.gradiantEndColor)) ValueListenableBuilder<bool>(
.onPress(() { valueListenable: hasTimerEnded,
try { builder: (context, val, child) {
DashboardApiClient().setAdvertisementViewed(masterID!, advertisementData!.advertisementId!).then((value) { if (hasTimerEndedBool) {
logger.d(value); return Container(
Navigator.pop(context); padding: const EdgeInsets.all(16), decoration: Utils.containerRadius(MyColors.white, 10), child: const Icon(Icons.thumb_up, color: MyColors.gradiantEndColor))
}); .onPress(() {
} catch (ex) { try {
logger.wtf(ex); DashboardApiClient().setAdvertisementViewed(masterID!, advertisementData!.advertisementId!).then((value) {
Utils.handleException(ex, context, null); logger.d(value);
} Navigator.pop(context);
}), });
} catch (ex) {
logger.wtf(ex);
Utils.handleException(ex, context, null);
}
});
} else {
return Container();
}
}),
// DefaultButton(LocaleKeys.home.tr(), () async { // DefaultButton(LocaleKeys.home.tr(), () async {
// DashboardApiClient().setAdvertisementViewed(masterID!, advertisementData!.advertisementId!).then((value) { // DashboardApiClient().setAdvertisementViewed(masterID!, advertisementData!.advertisementId!).then((value) {
// logger.d(value); // logger.d(value);

@ -27,7 +27,6 @@ import 'package:mohem_flutter_app/models/member_information_list_model.dart';
import 'package:mohem_flutter_app/models/member_login_list_model.dart'; import 'package:mohem_flutter_app/models/member_login_list_model.dart';
import 'package:mohem_flutter_app/models/privilege_list_model.dart'; import 'package:mohem_flutter_app/models/privilege_list_model.dart';
import 'package:mohem_flutter_app/widgets/button/default_button.dart'; import 'package:mohem_flutter_app/widgets/button/default_button.dart';
import 'package:mohem_flutter_app/widgets/button/hmg_connectivity_button.dart';
import 'package:mohem_flutter_app/widgets/input_widget.dart'; import 'package:mohem_flutter_app/widgets/input_widget.dart';
// import 'package:safe_device/safe_device.dart'; // import 'package:safe_device/safe_device.dart';
@ -98,6 +97,7 @@ class _LoginScreenState extends State<LoginScreen> {
Future<void> checkFirebaseToken() async { Future<void> checkFirebaseToken() async {
try { try {
await checkPrefs();
Utils.showLoading(context); Utils.showLoading(context);
if (Platform.isAndroid) { if (Platform.isAndroid) {
try { try {
@ -110,7 +110,8 @@ class _LoginScreenState extends State<LoginScreen> {
await Firebase.initializeApp(); await Firebase.initializeApp();
_firebaseMessaging = FirebaseMessaging.instance; _firebaseMessaging = FirebaseMessaging.instance;
firebaseToken = await _firebaseMessaging.getToken(); firebaseToken = await _firebaseMessaging.getToken();
AppNotifications().init(firebaseToken); print(firebaseToken);
AppNotifications().init(firebaseToken, context);
checkLoginInfo(); checkLoginInfo();
await FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(true); await FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(true);
} }
@ -120,7 +121,10 @@ class _LoginScreenState extends State<LoginScreen> {
await Firebase.initializeApp(); await Firebase.initializeApp();
_firebaseMessaging = FirebaseMessaging.instance; _firebaseMessaging = FirebaseMessaging.instance;
firebaseToken = await _firebaseMessaging.getToken(); firebaseToken = await _firebaseMessaging.getToken();
AppNotifications().init(firebaseToken); String? firebaseAPNSToken = await _firebaseMessaging.getAPNSToken();
print("Firebase Token: $firebaseToken");
print("Firebase APNS Token: $firebaseAPNSToken");
AppNotifications().init(firebaseToken, context);
checkLoginInfo(); checkLoginInfo();
await FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(true); await FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(true);
} }
@ -132,17 +136,21 @@ class _LoginScreenState extends State<LoginScreen> {
} }
void checkLoginInfo() async { void checkLoginInfo() async {
loginInfo = await LoginApiClient().getMobileLoginInfoNEW(AppState().getIsHuawei ? AppState().getHuaweiPushToken : firebaseToken ?? "", Platform.isAndroid ? "android" : "ios"); try {
if (loginInfo == null) { loginInfo = await LoginApiClient().getMobileLoginInfoNEW(AppState().getIsHuawei ? AppState().getHuaweiPushToken : firebaseToken ?? "", Platform.isAndroid ? "android" : "ios");
await checkPrefs(); if (loginInfo == null) {
_autoLogin = false; await checkPrefs();
Utils.hideLoading(context); _autoLogin = false;
return; Utils.hideLoading(context);
} else { return;
loginInfo!.deviceToken = firebaseToken; } else {
await checkPrefs(); loginInfo!.deviceToken = firebaseToken;
await checkPrefs();
Utils.hideLoading(context);
performLogin();
}
} catch (ex) {
Utils.hideLoading(context); Utils.hideLoading(context);
performLogin();
} }
} }

@ -340,10 +340,15 @@ class _DynamicInputScreenState extends State<DynamicInputScreen> {
idColName = val; idColName = val;
if (getEitDffStructureList![j].fORMATTYPE == "X") { if (getEitDffStructureList![j].fORMATTYPE == "X") {
idColName = Utils.formatDateDefault(idColName!); idColName = Utils.reverseFormatDate(idColName!);
// commenting to test if (Utils.isDate(Utils.reverseFormatDate(Utils.formatDateNew(idColName)), "yyyy-MM-dd")) {
// DateTime date = DateFormat('yyyy-MM-dd').parse(idColName!); idColName = Utils.formatStandardDate(Utils.formatStandardDate(Utils.formatDateNew(idColName)));
// idColName = DateFormat('yyyy-MM-dd HH:mm:ss').format(date); // idColName = DateFormat('yyyy/MM/dd HH:mm:ss').format(date);
} else if (Utils.isDate(Utils.reverseFormatDate(idColName), "dd-MM-yyyy")) {
// // change date format on 31/05/2023
DateTime date = DateFormat('dd-MM-yyyy').parse(idColName);
idColName = DateFormat('yyyy-MM-dd HH:mm:ss').format(date);
}
} }
} }

@ -0,0 +1,74 @@
import 'package:flutter/material.dart';
import 'package:lottie/lottie.dart';
import 'package:mohem_flutter_app/models/get_notifications_response_model.dart';
import 'package:mohem_flutter_app/widgets/app_bar_widget.dart';
class NotificationsDetailsPage extends StatefulWidget {
final GetNotificationsResponseModel notification;
NotificationsDetailsPage({required this.notification});
@override
State<NotificationsDetailsPage> createState() => _NotificationsDetailsPageState();
}
class _NotificationsDetailsPageState extends State<NotificationsDetailsPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBarWidget(
context,
title: "Notification Details",
),
body: ListView(
physics: BouncingScrollPhysics(),
padding: EdgeInsets.all(21),
children: [
Text(
widget.notification.createdOn!,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Color(0xff2E303A),
letterSpacing: -0.64,
),
),
if (widget.notification.messageTypeData != null)
if (widget.notification.messageTypeData!.isNotEmpty && widget.notification.notificationType != "2")
Padding(
padding: const EdgeInsets.only(top: 18),
child: Image.network(widget.notification.messageTypeData!, loadingBuilder: (BuildContext context, Widget child, ImageChunkEvent? loadingProgress) {
if (loadingProgress == null) return child;
return Center(
child: SizedBox(
width: 40.0,
height: 40.0,
child: showLoadingAnimation(),
),
);
}, fit: BoxFit.fill),
),
SizedBox(height: 18),
Text(
widget.notification.message!.trim(),
style: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
color: Color(0xff575757),
letterSpacing: -0.48,
),
),
],
),
);
}
Widget showLoadingAnimation() {
return Lottie.asset(
'assets/lottie/loading.json',
repeat: true,
reverse: false,
);
}
}

@ -76,70 +76,72 @@ class _MyRequestsState extends State<MyRequests> {
}), }),
), ),
12.height, 12.height,
getCCPTransactionsList.isNotEmpty ? Expanded( getCCPTransactionsList.isNotEmpty
child: ListView.separated( ? Expanded(
physics: const BouncingScrollPhysics(), child: ListView.separated(
shrinkWrap: true, physics: const BouncingScrollPhysics(),
itemBuilder: (BuildContext context, int index) { shrinkWrap: true,
return Container( itemBuilder: (BuildContext context, int index) {
width: double.infinity, return Container(
padding: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 12), width: double.infinity,
margin: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 0), padding: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 12),
decoration: BoxDecoration( margin: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 0),
color: Colors.white, decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10), color: Colors.white,
boxShadow: [ borderRadius: BorderRadius.circular(10),
BoxShadow( boxShadow: [
color: const Color(0xff000000).withOpacity(.05), BoxShadow(
blurRadius: 26, color: const Color(0xff000000).withOpacity(.05),
offset: const Offset(0, -3), blurRadius: 26,
), offset: const Offset(0, -3),
], ),
), ],
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
("Request ID: " + getCCPTransactionsList[index].rEQUESTID.toString()).toText12(color: MyColors.grey57Color),
DateUtil.formatDateToDate(DateUtil.convertStringToDate(getCCPTransactionsList[index].rEQUESTDATE!), false).toText12(color: MyColors.grey70Color),
],
),
Container(
padding: const EdgeInsets.only(top: 10.0),
child: ("Phase: " + getCCPTransactionsList[index].cCPPHASE!).toText12(color: MyColors.grey57Color, isBold: true),
),
Container(
padding: const EdgeInsets.only(top: 10.0),
child: "Program Name: ".toText12(color: MyColors.grey57Color, isBold: true),
),
getCCPTransactionsList[index].cONCURRENTPROGRAMNAME!.toText12(color: MyColors.gradiantEndColor),
Container(
padding: const EdgeInsets.only(top: 10.0),
child: InkWell(
onTap: () {
getCCPOutput(getCCPTransactionsList[index].rEQUESTID.toString());
},
child: Row(
children: [
"Output: ".toText12(color: MyColors.grey57Color),
8.width,
"Open PDF".toText12(color: MyColors.grey57Color),
6.width,
const Icon(Icons.launch, size: 16.0),
],
),
), ),
), child: Column(
], crossAxisAlignment: CrossAxisAlignment.start,
), children: [
); Row(
}, crossAxisAlignment: CrossAxisAlignment.start,
separatorBuilder: (BuildContext context, int index) => 12.height, mainAxisAlignment: MainAxisAlignment.spaceBetween,
itemCount: getCCPTransactionsList.length), children: [
) : Container(), ("Request ID: " + getCCPTransactionsList[index].rEQUESTID.toString()).toText12(color: MyColors.grey57Color),
DateUtil.formatDateToDate(DateUtil.convertStringToDate(getCCPTransactionsList[index].rEQUESTDATE!), false).toText12(color: MyColors.grey70Color),
],
),
Container(
padding: const EdgeInsets.only(top: 10.0),
child: ("Phase: " + getCCPTransactionsList[index].cCPPHASE!).toText12(color: MyColors.grey57Color, isBold: true),
),
Container(
padding: const EdgeInsets.only(top: 10.0),
child: "Program Name: ".toText12(color: MyColors.grey57Color, isBold: true),
),
getCCPTransactionsList[index].cONCURRENTPROGRAMNAME!.toText12(color: MyColors.gradiantEndColor),
Container(
padding: const EdgeInsets.only(top: 10.0),
child: InkWell(
onTap: () {
getCCPOutput(getCCPTransactionsList[index].rEQUESTID.toString());
},
child: Row(
children: [
"Output: ".toText12(color: MyColors.grey57Color),
8.width,
"Open PDF".toText12(color: MyColors.grey57Color),
6.width,
const Icon(Icons.launch, size: 16.0),
],
),
),
),
],
),
);
},
separatorBuilder: (BuildContext context, int index) => 12.height,
itemCount: getCCPTransactionsList.length),
)
: Container(),
], ],
).expanded, ).expanded,
1.divider, 1.divider,
@ -153,7 +155,9 @@ class _MyRequestsState extends State<MyRequests> {
void openNewRequest() async { void openNewRequest() async {
await Navigator.pushNamed(context, AppRoutes.newRequest).then((value) { await Navigator.pushNamed(context, AppRoutes.newRequest).then((value) {
// getOpenTickets(); if (value != null && value == "refresh") {
getCCPTransactions(selectedConcurrentProgramList?.cONCURRENTPROGRAMNAME);
}
}); });
} }

@ -5,12 +5,12 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:mohem_flutter_app/api/my_requests_api_client.dart'; import 'package:mohem_flutter_app/api/my_requests_api_client.dart';
import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/classes/utils.dart';
import 'package:mohem_flutter_app/config/routes.dart';
import 'package:mohem_flutter_app/extensions/int_extensions.dart'; import 'package:mohem_flutter_app/extensions/int_extensions.dart';
import 'package:mohem_flutter_app/extensions/string_extensions.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart';
import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
import 'package:mohem_flutter_app/models/dyanmic_forms/validate_eit_transaction_model.dart'; import 'package:mohem_flutter_app/models/dyanmic_forms/validate_eit_transaction_model.dart';
import 'package:mohem_flutter_app/models/generic_response_model.dart';
import 'package:mohem_flutter_app/models/get_eit_dff_structure_list_model.dart'; import 'package:mohem_flutter_app/models/get_eit_dff_structure_list_model.dart';
import 'package:mohem_flutter_app/models/my_requests/get_ccp_transactions_model.dart'; import 'package:mohem_flutter_app/models/my_requests/get_ccp_transactions_model.dart';
import 'package:mohem_flutter_app/models/my_requests/get_ccp_transations_list_model.dart'; import 'package:mohem_flutter_app/models/my_requests/get_ccp_transations_list_model.dart';
@ -118,14 +118,14 @@ class _NewRequestState extends State<NewRequest> {
return ValidateEitTransactionModel(dATEVALUE: dateVal, nAME: e.aPPLICATIONCOLUMNNAME, nUMBERVALUE: numberVal, tRANSACTIONNUMBER: 1, vARCHAR2VALUE: vatcherVal.toString()).toJson(); return ValidateEitTransactionModel(dATEVALUE: dateVal, nAME: e.aPPLICATIONCOLUMNNAME, nUMBERVALUE: numberVal, tRANSACTIONNUMBER: 1, vARCHAR2VALUE: vatcherVal.toString()).toJson();
}).toList(); }).toList();
Utils.showLoading(context); Utils.showLoading(context);
submitCcpTransactionList = await MyRequestsApiClient().getSubmitNewRequest(values); GenericResponseModel responseModel = await MyRequestsApiClient().getSubmitNewRequest(values);
getCCPTransactionsList = await MyRequestsApiClient().getCcpTransactions(values);
Utils.hideLoading(context); Utils.hideLoading(context);
Navigator.pushNamed(
context, if (responseModel.messageStatus == 1) {
AppRoutes.myRequests, Navigator.pop(context, "refresh");
); } else {
setState(() {}); Utils.showToast(responseModel.errorEndUserMessage ?? "");
}
} catch (ex) { } catch (ex) {
Utils.hideLoading(context); Utils.hideLoading(context);
Utils.handleException(ex, context, null); Utils.handleException(ex, context, null);
@ -214,13 +214,15 @@ class _NewRequestState extends State<NewRequest> {
pIDCOLUMNNAME: DateFormat('yyyy/MM/dd HH:MM:SS', "en_US").format(date1), pIDCOLUMNNAME: DateFormat('yyyy/MM/dd HH:MM:SS', "en_US").format(date1),
pRETURNMSG: "null", pRETURNMSG: "null",
pRETURNSTATUS: getCCPDFFStructureModelList![index].dEFAULTVALUE, pRETURNSTATUS: getCCPDFFStructureModelList![index].dEFAULTVALUE,
pVALUECOLUMNNAME: getCCPDFFStructureModelList![index].isDefaultTypeIsCDPS ? DateFormat('yyyy/MM/dd HH:MM:SS', "en_US").format(date) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); pVALUECOLUMNNAME:
getCCPDFFStructureModelList![index].isDefaultTypeIsCDPS ? DateFormat('yyyy/MM/dd HH:MM:SS', "en_US").format(date) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date));
} else { } else {
eservicesdv = ESERVICESDV( eservicesdv = ESERVICESDV(
pIDCOLUMNNAME: DateFormat('yyyy-MM-dd', "en_US").format(date1), pIDCOLUMNNAME: DateFormat('yyyy-MM-dd', "en_US").format(date1),
pRETURNMSG: "null", pRETURNMSG: "null",
pRETURNSTATUS: getCCPDFFStructureModelList![index].dEFAULTVALUE, pRETURNSTATUS: getCCPDFFStructureModelList![index].dEFAULTVALUE,
pVALUECOLUMNNAME: getCCPDFFStructureModelList![index].isDefaultTypeIsCDPS ? DateFormat('yyyy-MM-dd hh:mm:ss', "en_US").format(date) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date)); pVALUECOLUMNNAME:
getCCPDFFStructureModelList![index].isDefaultTypeIsCDPS ? DateFormat('yyyy-MM-dd hh:mm:ss', "en_US").format(date) : DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date));
} }
getCCPDFFStructureModelList![index].eSERVICESDV = eservicesdv; getCCPDFFStructureModelList![index].eSERVICESDV = eservicesdv;
setState(() {}); setState(() {});

@ -58,6 +58,7 @@ class _ItemHistoryScreenState extends State<ItemHistoryScreen> {
List<GetPRActionHistoryList> actionHistoryList = []; List<GetPRActionHistoryList> actionHistoryList = [];
List<GetAttachementList> getAttachmentList = []; List<GetAttachementList> getAttachmentList = [];
int tabIndex = 0; int tabIndex = 0;
PageController controller = PageController();
@override @override
void initState() { void initState() {
@ -136,7 +137,7 @@ class _ItemHistoryScreenState extends State<ItemHistoryScreen> {
backgroundColor: Colors.white, backgroundColor: Colors.white,
body: ListView( body: ListView(
padding: _screenParams!.isPRInfo ? const EdgeInsets.all(0) : const EdgeInsets.all(21), padding: _screenParams!.isPRInfo ? const EdgeInsets.all(0) : const EdgeInsets.all(21),
physics: const BouncingScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
children: [ children: [
if (_screenParams!.isPRInfo) prLinesDataView(), if (_screenParams!.isPRInfo) prLinesDataView(),
if (moItemHistoryList.isNotEmpty) loadMoItemHistoryData(), if (moItemHistoryList.isNotEmpty) loadMoItemHistoryData(),
@ -150,6 +151,7 @@ class _ItemHistoryScreenState extends State<ItemHistoryScreen> {
Widget prLinesDataView() { Widget prLinesDataView() {
return Column( return Column(
mainAxisSize: MainAxisSize.min,
children: [ children: [
Container( Container(
padding: const EdgeInsets.only(left: 21, right: 21, top: 16, bottom: 16), padding: const EdgeInsets.only(left: 21, right: 21, top: 16, bottom: 16),
@ -177,36 +179,54 @@ class _ItemHistoryScreenState extends State<ItemHistoryScreen> {
), ),
), ),
if (tabIndex == 0) _screenParams!.getPRInformationList!.pRHeader![0].dESCRIPTION!.toText14().paddingOnly(top: 20, right: 21, left: 21), if (tabIndex == 0) _screenParams!.getPRInformationList!.pRHeader![0].dESCRIPTION!.toText14().paddingOnly(top: 20, right: 21, left: 21),
if (tabIndex == 0) SizedBox(
ListView.separated( height: MediaQuery.of(context).size.height,
padding: const EdgeInsets.all(21), child: PageView(
shrinkWrap: true, controller: controller,
physics: const NeverScrollableScrollPhysics(), onPageChanged: (pageIndex) {
itemBuilder: (cxt, index) => Column( setState(() {
children: [ tabIndex = pageIndex;
ItemDetailGrid( if (pageIndex == 1) {
ItemDetailViewCol("Cost Center", _screenParams!.getPRInformationList!.pRLines![index].cOSTCENTER ?? ""), getActionsDataFromApi();
ItemDetailViewCol("Code", _screenParams!.getPRInformationList!.pRLines![index].iTEMCODE ?? ""), }
), if (pageIndex == 2) {
ItemDetailGrid( getAttachmentsDataFromApi();
ItemDetailViewCol("Unit", _screenParams!.getPRInformationList!.pRLines![index].uOM ?? ""), }
ItemDetailViewCol("Price (SAR)", _screenParams!.getPRInformationList!.pRLines![index].uNITPRICE.toString() ?? ""), });
), },
ItemDetailGrid( children: [
ItemDetailViewCol("Amount (SAR)", _screenParams!.getPRInformationList!.pRLines![index].lINEAMOUNT.toString() ?? ""), ListView.separated(
ItemDetailViewCol("Quantity", _screenParams!.getPRInformationList!.pRLines![index].qUANTITY.toString() ?? ""), padding: const EdgeInsets.all(21),
), shrinkWrap: true,
ItemDetailGrid( physics: const NeverScrollableScrollPhysics(),
ItemDetailViewCol("AMU (Last 3 months)", _screenParams!.getPRInformationList!.pRLines![index].iTEMAMU.toString() ?? ""), itemBuilder: (cxt, index) => Column(
ItemDetailViewCol("PR Number", _screenParams!.getPRInformationList!.pRHeader![0].pRNUMBER!.toString() ?? ""), children: [
isItLast: true, ItemDetailGrid(
), ItemDetailViewCol("Cost Center", _screenParams!.getPRInformationList!.pRLines![index].cOSTCENTER ?? ""),
], ItemDetailViewCol("Code", _screenParams!.getPRInformationList!.pRLines![index].iTEMCODE ?? ""),
).objectContainerView(), ),
separatorBuilder: (cxt, index) => 12.height, ItemDetailGrid(
itemCount: _screenParams!.getPRInformationList!.pRLines!.length), ItemDetailViewCol("Unit", _screenParams!.getPRInformationList!.pRLines![index].uOM ?? ""),
if (tabIndex == 1) getPRActionsHistory(), //"ACTIONS".toText14().paddingOnly(top: 20, right: 21, left: 21), ItemDetailViewCol("Price (SAR)", _screenParams!.getPRInformationList!.pRLines![index].uNITPRICE.toString() ?? ""),
if (tabIndex == 2) getPRAttachments(), ),
ItemDetailGrid(
ItemDetailViewCol("Amount (SAR)", _screenParams!.getPRInformationList!.pRLines![index].lINEAMOUNT.toString() ?? ""),
ItemDetailViewCol("Quantity", _screenParams!.getPRInformationList!.pRLines![index].qUANTITY.toString() ?? ""),
),
ItemDetailGrid(
ItemDetailViewCol("AMU (Last 3 months)", _screenParams!.getPRInformationList!.pRLines![index].iTEMAMU.toString() ?? ""),
ItemDetailViewCol("PR Number", _screenParams!.getPRInformationList!.pRHeader![0].pRNUMBER!.toString() ?? ""),
isItLast: true,
),
],
).objectContainerView(),
separatorBuilder: (cxt, index) => 12.height,
itemCount: _screenParams!.getPRInformationList!.pRLines!.length),
getPRActionsHistory(), //"ACTIONS".toText14().paddingOnly(top: 20, right: 21, left: 21),
getPRAttachments(),
],
),
),
], ],
); );
} }
@ -550,7 +570,8 @@ class _ItemHistoryScreenState extends State<ItemHistoryScreen> {
if (index == 2) { if (index == 2) {
getAttachmentsDataFromApi(); getAttachmentsDataFromApi();
} }
tabIndex = index; // tabIndex = index;
controller.jumpToPage(index);
}); });
}).expanded; }).expanded;
} }

Loading…
Cancel
Save