You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
760 lines
29 KiB
Dart
760 lines
29 KiB
Dart
import 'dart:async';
|
|
import 'dart:io';
|
|
|
|
import 'package:diplomaticquarterapp/config/config.dart';
|
|
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
|
|
import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart';
|
|
import 'package:diplomaticquarterapp/core/model/geofencing/requests/GeoZonesRequestModel.dart';
|
|
import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart';
|
|
import 'package:diplomaticquarterapp/core/service/geofencing/GeofencingServices.dart';
|
|
import 'package:diplomaticquarterapp/core/viewModels/appointment_rate_view_model.dart';
|
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
|
import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart';
|
|
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
|
|
import 'package:diplomaticquarterapp/models/Authentication/select_device_imei_res.dart';
|
|
import 'package:diplomaticquarterapp/models/LiveCare/IncomingCallData.dart';
|
|
import 'package:diplomaticquarterapp/pages/BookAppointment/Search.dart';
|
|
import 'package:diplomaticquarterapp/pages/DrawerPages/family/my-family.dart';
|
|
import 'package:diplomaticquarterapp/pages/ToDoList/ToDo.dart';
|
|
import 'package:diplomaticquarterapp/pages/landing/home_page_2.dart';
|
|
import 'package:diplomaticquarterapp/pages/medical/medical_profile_page_new.dart';
|
|
import 'package:diplomaticquarterapp/pages/rateAppointment/rate_appointment_doctor.dart';
|
|
import 'package:diplomaticquarterapp/pages/videocall-webrtc-rnd/webrtc/start_video_call.dart';
|
|
import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart';
|
|
import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart';
|
|
import 'package:diplomaticquarterapp/services/family_files/family_files_provider.dart'
|
|
as family;
|
|
import 'package:diplomaticquarterapp/services/livecare_services/livecare_provider.dart';
|
|
import 'package:diplomaticquarterapp/services/payfort_services/payfort_view_model.dart';
|
|
import 'package:diplomaticquarterapp/services/robo_search/event_provider.dart';
|
|
import 'package:diplomaticquarterapp/theme/colors.dart';
|
|
import 'package:diplomaticquarterapp/uitl/LocalNotification.dart';
|
|
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
|
|
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
|
|
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
|
|
import 'package:diplomaticquarterapp/uitl/location_util.dart';
|
|
import 'package:diplomaticquarterapp/uitl/push-notification-handler.dart';
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
import 'package:diplomaticquarterapp/widgets/bottom_navigation/bottom_nav_bar.dart';
|
|
import 'package:diplomaticquarterapp/widgets/buttons/floatingActionButton.dart';
|
|
import 'package:diplomaticquarterapp/widgets/drawer/app_drawer_widget.dart';
|
|
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
|
import 'package:diplomaticquarterapp/widgets/others/not_auh_page.dart';
|
|
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
|
|
import 'package:firebase_messaging/firebase_messaging.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_app_icon_badge/flutter_app_icon_badge.dart';
|
|
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
import 'package:flutter_zoom_videosdk/native/zoom_videosdk.dart';
|
|
import 'package:permission_handler/permission_handler.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../../locator.dart';
|
|
import '../../routes.dart';
|
|
|
|
class LandingPage extends StatefulWidget {
|
|
static late LandingPage shared;
|
|
late _LandingPageState state;
|
|
|
|
LandingPage() {
|
|
LandingPage.shared = this;
|
|
}
|
|
|
|
static bool isOpenCallPage = false;
|
|
|
|
static IncomingCallData incomingCallData = new IncomingCallData();
|
|
|
|
@override
|
|
_LandingPageState createState() => state = _LandingPageState();
|
|
|
|
switchToDoFromHMGServices() {
|
|
state.changeCurrentTab(4);
|
|
}
|
|
}
|
|
|
|
class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
|
|
var authProvider = new AuthProvider();
|
|
AppointmentRateViewModel appointmentRateViewModel =
|
|
locator<AppointmentRateViewModel>();
|
|
|
|
int currentTab = 0;
|
|
late PageController pageController;
|
|
late ProjectViewModel projectViewModel;
|
|
late ToDoCountProviderModel model;
|
|
var notificationCount = '';
|
|
var themeNotifier;
|
|
DateTime? currentBackPressTime;
|
|
|
|
// SignalRUtil signalRUtil;
|
|
|
|
late ToDoCountProviderModel toDoProvider;
|
|
|
|
bool _showBottomNavigationBar = true;
|
|
|
|
///inject the user data
|
|
AuthenticatedUserObject authenticatedUserObject =
|
|
locator<AuthenticatedUserObject>();
|
|
|
|
final FirebaseMessaging _firebaseMessaging = FirebaseMessaging.instance;
|
|
final authService = new AuthProvider();
|
|
|
|
var event = RobotProvider();
|
|
var familyFileProvider = family.FamilyFilesProvider();
|
|
|
|
// VoIPKit
|
|
var dummyCallId = '123456';
|
|
var dummyCallerName = 'Dummy Tester';
|
|
late Timer timeOutTimer;
|
|
bool isTalking = false;
|
|
|
|
var sharedPref = new AppSharedPreferences();
|
|
|
|
var data = {
|
|
"AppointmentNo": "2016059247",
|
|
"ProjectID": "15",
|
|
"NotificationType": "10",
|
|
"background": "0",
|
|
"doctorname": "Call from postman",
|
|
"clinicname": "LIVECARE FAMILY MEDICINE AND GP",
|
|
"speciality": "General Practioner",
|
|
"appointmentdate": "2022-01-19",
|
|
"appointmenttime": "12:10",
|
|
"PatientName": "Testing",
|
|
"session_id":
|
|
"1_MX40NjIwOTk2Mn5-MTY0NzI1NjYxNDI2OX5ySXhlVjZjam13RFdMVmdleWVsSDhzQkx-fg",
|
|
"token":
|
|
"T1==cGFydG5lcl9pZD00NjIwOTk2MiZzaWc9OGMyY2IyYWFiZmZmMzI4ZmEwMjgxNDdmMGFhZGI0N2JiZjdmZWY4MjpzZXNzaW9uX2lkPTFfTVg0ME5qSXdPVGsyTW41LU1UWTBOekkxTmpZeE5ESTJPWDV5U1hobFZqWmphbTEzUkZkTVZtZGxlV1ZzU0RoelFreC1mZyZjcmVhdGVfdGltZT0xNjQ3MjU2NjE0Jm5vbmNlPTAuMjgzNDgyNjM1NDczNjQ2OCZyb2xlPW1vZGVyYXRvciZleHBpcmVfdGltZT0xNjQ3MjU4NDE0JmluaXRpYWxfbGF5b3V0X2NsYXNzX2xpc3Q9",
|
|
"DoctorImageURL":
|
|
"https://image.shutterstock.com/image-vector/sample-stamp-square-grunge-sign-260nw-1474408826.jpg",
|
|
"callerID": "9920",
|
|
"PatientID": "1231755",
|
|
"is_call": "true"
|
|
};
|
|
|
|
void _requestIOSPermissions() {
|
|
flutterLocalNotificationsPlugin
|
|
.resolvePlatformSpecificImplementation<
|
|
IOSFlutterLocalNotificationsPlugin>()
|
|
?.requestPermissions(
|
|
alert: true,
|
|
badge: true,
|
|
sound: true,
|
|
);
|
|
}
|
|
|
|
bool isPageNavigated = false;
|
|
late LocationUtils locationUtils;
|
|
|
|
Future<bool> onWillPop() {
|
|
if (currentTab != 0) {
|
|
changeCurrentTab(0);
|
|
return Future.value(false);
|
|
} else {
|
|
DateTime now = DateTime.now();
|
|
if (currentBackPressTime == null ||
|
|
now.difference(currentBackPressTime!) > Duration(seconds: 2)) {
|
|
currentBackPressTime = now;
|
|
AppToast.showToast(message: TranslationBase.of(context).pressAgain);
|
|
return Future.value(false);
|
|
}
|
|
return Future.value(true);
|
|
}
|
|
}
|
|
|
|
changeCurrentTab(int tab) {
|
|
if (!projectViewModel.isLogin) {
|
|
if (tab == 3) {
|
|
List<ImagesInfo> imagesInfo = [];
|
|
imagesInfo.add(
|
|
ImagesInfo(
|
|
imageEn:
|
|
'https://hmgwebservices.com/Images/MobileApp/images-info-home/family-file/en/0.png',
|
|
imageAr:
|
|
'https://hmgwebservices.com/Images/MobileApp/images-info-home/family-file/ar/0.png'),
|
|
);
|
|
|
|
imagesInfo.add(
|
|
ImagesInfo(
|
|
imageEn:
|
|
'https://hmgwebservices.com/Images/MobileApp/images-info-home/family-file/en/1.png',
|
|
imageAr:
|
|
'https://hmgwebservices.com/Images/MobileApp/images-info-home/family-file/ar/1.png'),
|
|
);
|
|
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (cxt) => NotAutPage(
|
|
title: TranslationBase.of(context).myFamilyFiles,
|
|
description: TranslationBase.of(context).familyInfo,
|
|
infoList: [],
|
|
imagesInfo: imagesInfo,
|
|
icon: "assets/images/new/bottom_nav/family_files.svg",
|
|
),
|
|
),
|
|
);
|
|
return;
|
|
}
|
|
if (tab == 4) {
|
|
List<ImagesInfo> imagesInfo = [];
|
|
imagesInfo.add(ImagesInfo(
|
|
imageEn:
|
|
'https://hmgwebservices.com/Images/MobileApp/images-info-home/todo/en/0.png',
|
|
imageAr:
|
|
'https://hmgwebservices.com/Images/MobileApp/images-info-home/todo/ar/0.png'));
|
|
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (cxt) => NotAutPage(
|
|
title: TranslationBase.of(context).todoList,
|
|
description: TranslationBase.of(context).infoTodo,
|
|
infoList: [],
|
|
imagesInfo: imagesInfo,
|
|
icon: "assets/images/new/bottom_nav/todo.svg",
|
|
),
|
|
),
|
|
);
|
|
return;
|
|
}
|
|
}
|
|
Future.delayed(Duration(seconds: 0), () {
|
|
setState(() {
|
|
if (tab == 5) {
|
|
IS_VOICE_COMMAND_CLOSED = false;
|
|
triggerRobot();
|
|
|
|
// pageController.jumpToPage(tab);
|
|
} else {
|
|
if (currentTab > 0 && tab == 2) {
|
|
pageController.jumpToPage(0);
|
|
currentTab = tab;
|
|
} else if (tab != 0) {
|
|
// if (tab == 4 && projectViewModel.isLogin && model.count == 0) {
|
|
// AppToast.showErrorToast(message: TranslationBase.of(context).noBookedAppo);
|
|
// } else {
|
|
pageController.jumpToPage(tab);
|
|
currentTab = tab;
|
|
// }
|
|
} else {
|
|
pageController.jumpToPage(tab);
|
|
currentTab = tab;
|
|
}
|
|
|
|
// currentTab = tab;
|
|
}
|
|
});
|
|
});
|
|
|
|
projectViewModel.analytics.bottomTabNavigation
|
|
.log(tabIndex: tab, isLoggedIn: projectViewModel.isLogin);
|
|
}
|
|
|
|
getToDoCount() {
|
|
toDoProvider.setState(0, 0, true, toDoProvider.notificationsCount);
|
|
ClinicListService service = new ClinicListService();
|
|
service.getActiveAppointmentNo(context).then((res) {
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
print(res['AppointmentActiveNumber']);
|
|
if (res['MessageStatus'] == 1) {
|
|
// toDoProvider.setState(res['AppointmentActiveNumber'], true, toDoProvider.notificationsCount);
|
|
toDoProvider.setState(
|
|
res['AppointmentActiveNumber'],
|
|
res['AncillaryOrderListCount'],
|
|
true,
|
|
toDoProvider.notificationsCount);
|
|
} else {}
|
|
}).catchError((err) {
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
print(err);
|
|
});
|
|
}
|
|
|
|
@override
|
|
void didChangeAppLifecycleState(AppLifecycleState state) {
|
|
super.didChangeAppLifecycleState(state);
|
|
|
|
AppGlobal.context = context;
|
|
if (state == AppLifecycleState.resumed) {
|
|
PushNotificationHandler.getInstance().onResume();
|
|
sharedPref.remove(APPOINTMENT_HISTORY_MEDICAL);
|
|
}
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
WidgetsBinding.instance.removeObserver(this);
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
PushNotificationHandler.getInstance().onResume();
|
|
|
|
WidgetsBinding.instance.addObserver(this);
|
|
|
|
AppGlobal.context = context;
|
|
pageController = PageController(keepPage: true);
|
|
|
|
_firebaseMessaging.setAutoInitEnabled(true);
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
if (projectViewModel.isLogin && !projectViewModel.isLoginChild) {
|
|
int languageID =
|
|
Provider.of<ProjectViewModel>(context, listen: false).isArabic
|
|
? 1
|
|
: 2;
|
|
familyFileProvider.getSharedRecordByStatus(languageID);
|
|
}
|
|
// Future.delayed(Duration(seconds: 3)).then((result) async {
|
|
// LocalNotification.getInstance().showNow(title: "Payload Update", subtitle: "Payload Update", payload: "Payload Update");
|
|
// });
|
|
});
|
|
|
|
PayfortViewModel payfortViewModel = context.read<PayfortViewModel>();
|
|
payfortViewModel.initPayfort();
|
|
|
|
// HMG (Guest/Internet) Wifi Access [Zohaib Kambrani]
|
|
// for now commented to reduce this call will enable it when needed
|
|
// HMGNetworkConnectivity(context).start();
|
|
|
|
_firebaseMessaging.getToken().then((String? token) {
|
|
print("Firebase Token: " + token!);
|
|
sharedPref.setString(PUSH_TOKEN, token!);
|
|
if (Platform.isIOS) {
|
|
FirebaseMessaging.instance.getAPNSToken().then((value) {
|
|
print("Push APNS getToken: " + value!);
|
|
AppSharedPreferences().setString(APNS_TOKEN, value);
|
|
AppSharedPreferences().setString(ONESIGNAL_APNS_TOKEN, value);
|
|
});
|
|
// voIPKit.getVoIPToken().then((value) {
|
|
// print('🎈 example: getVoIPToken: $value');
|
|
// AppSharedPreferences().setString(APNS_TOKEN, value!);
|
|
// // getOneSignalVOIPToken(value);
|
|
// });
|
|
}
|
|
if (token != null) {
|
|
DEVICE_TOKEN = token;
|
|
if (!projectViewModel.isLoginChild) {
|
|
checkUserStatus(token);
|
|
}
|
|
}
|
|
});
|
|
startZoom();
|
|
// HMG_Geofencing(context).loadZones().then((instance) => instance.init());
|
|
}
|
|
void startZoom(){
|
|
var zoom = ZoomVideoSdk();
|
|
InitConfig initConfig = InitConfig(
|
|
domain: "zoom.us",
|
|
enableLog: true,
|
|
);
|
|
zoom.initSdk(initConfig);
|
|
}
|
|
|
|
void setUserValues(value) async {
|
|
if (value != null) sharedPref.setObject(IMEI_USER_DATA, value);
|
|
}
|
|
|
|
Future<dynamic> getUserInformation() async {
|
|
var userInfoJson = sharedPref.getObject(IMEI_USER_DATA);
|
|
return userInfoJson;
|
|
}
|
|
|
|
checkValue(projectProvider) {
|
|
if (projectProvider.searchValue != null) {
|
|
changeCurrentTab(2);
|
|
}
|
|
}
|
|
|
|
// registerGeofences() async {
|
|
// await locator<GeofencingServices>().getAllGeoZones(GeoZonesRequestModel());
|
|
//
|
|
// // void doIt() {
|
|
// // // getUserInformation().then((value) {
|
|
// // // if (value != null)
|
|
// // projectViewModel.platformBridge().registerHmgGeofences();
|
|
// // // });
|
|
// // }
|
|
// //
|
|
// // if (await Permission.location.isGranted) {
|
|
// // doIt();
|
|
// // } else {
|
|
// // [Permission.location].request().then((value) async {
|
|
// // if (await Permission.location.isGranted) {
|
|
// // doIt();
|
|
// // }
|
|
// // });
|
|
// // }
|
|
// }
|
|
|
|
login() async {
|
|
var data = await sharedPref.getObject(IMEI_USER_DATA);
|
|
sharedPref.remove(REGISTER_DATA_FOR_LOGIIN);
|
|
if (data != null) {
|
|
Navigator.of(context).pushNamed(CONFIRM_LOGIN);
|
|
} else {
|
|
// AppGlobal.context = context;
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
authService.selectDeviceImei(DEVICE_TOKEN).then((value) async {
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
var data = await sharedPref.getObject(IMEI_USER_DATA);
|
|
if (value != null) {
|
|
setUserValues(value);
|
|
Navigator.of(context).pushNamed(CONFIRM_LOGIN);
|
|
} else {
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
Navigator.of(context).pushNamed(
|
|
WELCOME_LOGIN,
|
|
);
|
|
}
|
|
}).catchError((err) {
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
Navigator.of(context).pushNamed(WELCOME_LOGIN);
|
|
});
|
|
}
|
|
}
|
|
|
|
dummyCall() async {
|
|
// final server = await SelectionDialog(
|
|
// context,
|
|
// title: "Select Server",
|
|
// items: ["https://livecareturn.hmg.com:8086", "https://104.197.179.1:8086"]
|
|
// ).show();
|
|
//
|
|
// final json = {
|
|
// "callerID": "s1",
|
|
// "PatientID": "s2",
|
|
// "msgID": "123",
|
|
// "notfID": "123",
|
|
// "notification_foreground": "true",
|
|
// "count": "1",
|
|
// "message": "Doctor is calling ",
|
|
// "AppointmentNo": "123",
|
|
// "title": "Rayyan Hospital",
|
|
// "ProjectID": "123",
|
|
// "NotificationType": "10",
|
|
// "background": "1",
|
|
// "doctorname": "Dr Sulaiman Al Habib",
|
|
// "clinicname": "ENT Clinic",
|
|
// "speciality": "Speciality",
|
|
// "appointmentdate": "Sun, 15th Dec, 2019",
|
|
// "appointmenttime": "09:00",
|
|
// "type": "video",
|
|
// "session_id":
|
|
// "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImN0eSI6InR3aWxpby1mcGE7dj0xIn0.eyJqdGkiOiJTS2I2NjYyOWMzN2ZhOTM3YjFjNDI2Zjg1MTgyNWFmN2M0LTE1OTg3NzQ1MDYiLCJpc3MiOiJTS2I2NjYyOWMzN2ZhOTM3YjFjNDI2Zjg1MTgyNWFmN2M0Iiwic3ViIjoiQUNhYWQ1YTNmOGM2NGZhNjczNTY3NTYxNTc0N2YyNmMyYiIsImV4cCI6MTU5ODc3ODEwNiwiZ3JhbnRzIjp7ImlkZW50aXR5IjoiSGFyb29uMSIsInZpZGVvIjp7InJvb20iOiJTbWFsbERhaWx5U3RhbmR1cCJ9fX0.7XUS5uMQQJfkrBZu9EjQ6STL6R7iXkso6BtO1HmrQKk",
|
|
// "identity": "Haroon1",
|
|
// "name": "SmallDailyStandup",
|
|
// "videoUrl": "video",
|
|
// "picture": "video",
|
|
// "is_call": "true",
|
|
// "server": server,
|
|
// };
|
|
|
|
// IncomingCallData incomingCallData = IncomingCallData.fromJson(json);
|
|
// final result = await Navigator.push(context, MaterialPageRoute(builder: (context) => IncomingCall(incomingCallData: incomingCallData)));
|
|
|
|
String callerId =
|
|
"2_MX40NjIwOTk2Mn5-MTY1NjU3NTQ4MzQ0NX5aSGczeVlObGNVMGJXWEFWRnc0akZRcm1-fg*T1==cGFydG5lcl9pZD00NjIwOTk2MiZzaWc9MzY5MTBmZmUyMDRiNjE3NTRiYzlmNjVjMTEyZTE1MWFjN2YxYjAxZTpzZXNzaW9uX2lkPTJfTVg0ME5qSXdPVGsyTW41LU1UWTFOalUzTlRRNE16UTBOWDVhU0djemVWbE9iR05WTUdKWFdFRldSbmMwYWtaUmNtMS1mZyZjcmVhdGVfdGltZT0xNjU2NTc1NDgzJm5vbmNlPTAuNzM3OTQyOTY4Mzg5OTU1MiZyb2xlPW1vZGVyYXRvciZleHBpcmVfdGltZT0xNjU2NjYxODgzJmluaXRpYWxfbGF5b3V0X2NsYXNzX2xpc3Q9*true*s1*s2*https://livecareturn.hmg.com:8086";
|
|
|
|
String sessionID = callerId.split("*")[0];
|
|
String token = callerId.split("*")[1];
|
|
String isWebRTC = callerId.split("*")[2];
|
|
|
|
print("🎈 SessionID: $sessionID");
|
|
print("🎈 Token: $token");
|
|
print("🎈 isWebRTC: $isWebRTC");
|
|
|
|
String caller = callerId.split("*")[3];
|
|
String receiver = callerId.split("*")[4];
|
|
String host = callerId.split("*")[5];
|
|
// await Navigator.push(context, MaterialPageRoute(builder: (context) => StartVideoCall(caller: caller, receiver: receiver, iAmCaller: false, host: host)));
|
|
}
|
|
|
|
getNotificationCount(token) async {
|
|
if (await sharedPref.getObject(USER_PROFILE) != null) {
|
|
var data =
|
|
AuthenticatedUser.fromJson(await sharedPref.getObject(USER_PROFILE));
|
|
if (data != null) {
|
|
authService.getDashboard().then((value) => {
|
|
if (value != null)
|
|
{
|
|
setState(() {
|
|
notificationCount = value['List_PatientDashboard'][0]
|
|
['UnreadPatientNotificationCount'] >
|
|
99
|
|
? '99+'
|
|
: value['List_PatientDashboard'][0]
|
|
['UnreadPatientNotificationCount']
|
|
.toString();
|
|
model.setState(model.count, 0, true, notificationCount);
|
|
sharedPref.setString(NOTIFICATION_COUNT, notificationCount);
|
|
})
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
projectViewModel = Provider.of(context);
|
|
model = Provider.of<ToDoCountProviderModel>(context);
|
|
// currentTab == 0 ? 45 : 0.0
|
|
return Scaffold(
|
|
appBar: currentTab == 0
|
|
? PreferredSize(
|
|
preferredSize: Size.fromHeight(currentTab == 0 ? 45 : 0.0),
|
|
child: AppBar(
|
|
elevation: 0,
|
|
backgroundColor: CustomColors.backgroudGreyColor,
|
|
//Changed By Aamir
|
|
// textTheme: TextTheme(
|
|
// headline6: TextStyle(color: Theme.of(context).textTheme.headline1!.color, fontWeight: FontWeight.bold),
|
|
// ),
|
|
title: Text(
|
|
getText(currentTab).toUpperCase(),
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.bold,
|
|
color: currentTab == 0
|
|
? CustomColors.backgroudGreyColor
|
|
: Theme.of(context).textTheme.headline1!.color,
|
|
fontFamily:
|
|
projectViewModel.isArabic ? 'Cairo' : 'Poppins'),
|
|
// bold: true,
|
|
),
|
|
leading: Builder(
|
|
builder: (BuildContext context) {
|
|
return new Stack(
|
|
children: <Widget>[
|
|
currentTab == 0
|
|
? IconButton(
|
|
icon: SvgPicture.asset(
|
|
"assets/images/new/menu.svg"),
|
|
color: Theme.of(context)
|
|
.textTheme
|
|
.headline1!
|
|
.color,
|
|
onPressed: () =>
|
|
Scaffold.of(context).openDrawer(),
|
|
)
|
|
: IconButton(
|
|
icon: Icon(Icons.arrow_back),
|
|
onPressed: () {
|
|
setState(() {
|
|
currentTab = 0;
|
|
});
|
|
pageController.jumpToPage(0);
|
|
},
|
|
),
|
|
projectViewModel.isLogin &&
|
|
model.notificationsCount != null &&
|
|
!projectViewModel.isLoginChild
|
|
? Positioned(
|
|
right: projectViewModel.isArabic ? 35 : 0,
|
|
top: 5,
|
|
child: new Container(
|
|
padding: EdgeInsets.all(4),
|
|
decoration: new BoxDecoration(
|
|
color: CustomColors.accentColor,
|
|
borderRadius: BorderRadius.circular(20),
|
|
),
|
|
constraints: BoxConstraints(
|
|
minWidth: 20,
|
|
minHeight: 20,
|
|
),
|
|
child: Text(
|
|
model.notificationsCount.toString(),
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize:
|
|
projectViewModel.isArabic ? 8 : 9,
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
),
|
|
)
|
|
: SizedBox()
|
|
],
|
|
);
|
|
},
|
|
),
|
|
actions: [
|
|
// IconButton(
|
|
// //iconSize: 70,
|
|
// icon: Icon(
|
|
// projectViewModel.isLogin ? Icons.settings : Icons.login,
|
|
// color: Theme.of(context).textTheme.headline1.color,
|
|
// ),
|
|
// onPressed: () {
|
|
// if (projectViewModel.isLogin)
|
|
// Navigator.of(context).pushNamed(
|
|
// SETTINGS,
|
|
// );
|
|
// else
|
|
// login();
|
|
// }, //do something,
|
|
// )
|
|
],
|
|
centerTitle: true,
|
|
),
|
|
)
|
|
: null,
|
|
drawer: SafeArea(child: AppDrawer()),
|
|
extendBody: false,
|
|
body: WillPopScope(
|
|
onWillPop: onWillPop,
|
|
child: Stack(children: [
|
|
PageView(
|
|
physics: NeverScrollableScrollPhysics(),
|
|
controller: pageController,
|
|
onPageChanged: (idx) {},
|
|
children: [
|
|
HomePage2(
|
|
goToMyProfile: () {
|
|
changeCurrentTab(1);
|
|
},
|
|
onLoginClick: () {
|
|
login();
|
|
},
|
|
onMedicalFileClick: () {
|
|
changeCurrentTab(1);
|
|
},
|
|
),
|
|
MedicalProfilePageNew(
|
|
onTap: () {
|
|
changeCurrentTab(0);
|
|
},
|
|
),
|
|
Search(
|
|
onBackClick: () {
|
|
changeCurrentTab(0);
|
|
},
|
|
),
|
|
MyFamily(
|
|
isAppbarVisible: false,
|
|
onBackClick: () {
|
|
changeCurrentTab(0);
|
|
},
|
|
),
|
|
ToDo(
|
|
isShowAppBar: true,
|
|
onBackClick: () {
|
|
changeCurrentTab(0);
|
|
},
|
|
),
|
|
], // Please do not remove the BookingOptions from this array
|
|
),
|
|
RobotIcon()
|
|
])),
|
|
bottomNavigationBar: BottomNavBar(
|
|
changeIndex: changeCurrentTab,
|
|
index: currentTab,
|
|
),
|
|
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
|
floatingActionButton:
|
|
(projectViewModel.havePrivilege(34) && currentTab == 0)
|
|
? FloatingButton(
|
|
elevation: true,
|
|
onTap: () {
|
|
changeCurrentTab(2);
|
|
projectViewModel.analytics.appointment.book_appointment();
|
|
},
|
|
)
|
|
: null);
|
|
}
|
|
|
|
triggerRobot() {
|
|
event.setValue({"isRobotVisible": 'true'});
|
|
}
|
|
|
|
getText(currentTab) {
|
|
switch (currentTab) {
|
|
case 0:
|
|
return TranslationBase.of(context).home;
|
|
case 1:
|
|
return TranslationBase.of(context).medicalProfile;
|
|
case 2:
|
|
return TranslationBase.of(context).bookAppo;
|
|
case 5:
|
|
return TranslationBase.of(context).bookAppo;
|
|
case 3:
|
|
return TranslationBase.of(context).services;
|
|
case 4:
|
|
return TranslationBase.of(context).bookAppo;
|
|
}
|
|
}
|
|
|
|
void checkUserStatus(token) async {
|
|
await PushNotificationHandler.getInstance().requestPermissions();
|
|
// authService.selectDeviceImei(token).then((SelectDeviceIMEIRES? value) => setUserValues(value));
|
|
if (authenticatedUserObject.isLogin) {
|
|
var data =
|
|
AuthenticatedUser.fromJson(await sharedPref.getObject(USER_PROFILE));
|
|
if (data != null) {
|
|
authService
|
|
.registeredAuthenticatedUser(data, token, 0, 0)
|
|
.then((res) => {});
|
|
authService.getDashboard().then((value) async {
|
|
setState(() {
|
|
if (value != null) {
|
|
notificationCount = value['List_PatientDashboard'][0]
|
|
['UnreadPatientNotificationCount'] >
|
|
99
|
|
? '99+'
|
|
: value['List_PatientDashboard'][0]
|
|
['UnreadPatientNotificationCount']
|
|
.toString();
|
|
model.setState(model.count, 0, true, notificationCount);
|
|
sharedPref.setString(NOTIFICATION_COUNT, notificationCount);
|
|
FlutterAppIconBadge.updateBadge(int.parse(notificationCount));
|
|
}
|
|
});
|
|
// if (await AppSharedPreferences().getBool(IS_LAST_APPOINTMENT_RATE_SHOWN) == null || !await AppSharedPreferences().getBool(IS_LAST_APPOINTMENT_RATE_SHOWN)) {
|
|
// int languageID = Provider.of<ProjectViewModel>(context, listen: false).isArabic ? 1 : 2;
|
|
// appointmentRateViewModel.getIsLastAppointmentRatedList(languageID).then((value) async {
|
|
// if (appointmentRateViewModel.isHaveAppointmentNotRate) {
|
|
// await AppSharedPreferences().setBool(IS_LAST_APPOINTMENT_RATE_SHOWN, true);
|
|
// Navigator.push(
|
|
// context,
|
|
// FadePage(
|
|
// page: RateAppointmentDoctor(),
|
|
// ),
|
|
// );
|
|
// }
|
|
// }).catchError((err) {
|
|
// print(err);
|
|
// });
|
|
// }
|
|
});
|
|
}
|
|
projectViewModel.analytics.setUser(data);
|
|
} else {
|
|
//changed by Aamir
|
|
projectViewModel.analytics.setUser(AuthenticatedUser());
|
|
}
|
|
if (Platform.isIOS) {
|
|
String voipToken = await sharedPref.getString(APNS_TOKEN);
|
|
// getOneSignalVOIPToken(voipToken);
|
|
}
|
|
// registerGeofences();
|
|
}
|
|
|
|
getOneSignalVOIPToken(String voipToken) {
|
|
LiveCareService service = new LiveCareService();
|
|
service.getOneSignalVOIPToken(voipToken, context).then((res) {
|
|
print("OneSignalID: $res");
|
|
AppSharedPreferences().setString(ONESIGNAL_APNS_TOKEN, res['id']);
|
|
}).catchError((err) {
|
|
print(err);
|
|
});
|
|
}
|
|
|
|
void showUserConsent() {
|
|
sharedPref.setString(IS_COVID_CONSENT_SHOWN, "true");
|
|
}
|
|
}
|