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.
139 lines
5.6 KiB
Dart
139 lines
5.6 KiB
Dart
import 'dart:async';
|
|
import 'dart:convert';
|
|
import 'dart:io';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
import 'package:flutter_zoom_videosdk/native/zoom_videosdk.dart';
|
|
import 'package:hmg_patient_app_new/presentation/onboarding/onboarding_screen.dart';
|
|
import 'package:hmg_patient_app_new/presentation/onboarding/splash_animation_screen.dart';
|
|
import 'package:hmg_patient_app_new/core/api_consts.dart';
|
|
import 'package:hmg_patient_app_new/core/app_assets.dart';
|
|
import 'package:hmg_patient_app_new/core/app_export.dart';
|
|
import 'package:hmg_patient_app_new/core/utils/utils.dart';
|
|
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
|
|
import 'package:hmg_patient_app_new/features/authentication/authentication_view_model.dart';
|
|
|
|
// import 'package:hmg_patient_app_new/presentation/authantication/login.dart';
|
|
import 'package:hmg_patient_app_new/presentation/home/landing_page.dart';
|
|
import 'package:hmg_patient_app_new/presentation/home/navigation_screen.dart';
|
|
import 'package:hmg_patient_app_new/theme/colors.dart';
|
|
import 'package:hmg_patient_app_new/widgets/transitions/fade_page.dart';
|
|
import 'package:lottie/lottie.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'core/cache_consts.dart';
|
|
import 'core/utils/local_notifications.dart';
|
|
import 'core/utils/push_notification_handler.dart';
|
|
import 'widgets/routes/custom_page_route.dart';
|
|
|
|
class SplashPage extends StatefulWidget {
|
|
@override
|
|
_SplashScreenState createState() => _SplashScreenState();
|
|
}
|
|
|
|
class _SplashScreenState extends State<SplashPage> {
|
|
late AuthenticationViewModel authVm;
|
|
|
|
bool isNewDesign = true;
|
|
|
|
Future<void> initializeStuff() async {
|
|
Timer(
|
|
Duration(milliseconds: 500),
|
|
() async {
|
|
ApiConsts.setBackendURLs();
|
|
PushNotificationHandler().init(context); // Asyncronously
|
|
},
|
|
);
|
|
await authVm.getServicePrivilege();
|
|
Timer(Duration(seconds: 2, milliseconds: 500), () async {
|
|
LocalNotification.init(onNotificationClick: (payload) {});
|
|
|
|
if (isNewDesign) {
|
|
Navigator.of(context).pushReplacement(FadePage(page: SplashAnimationScreen(routeWidget: OnboardingScreen())));
|
|
} else {
|
|
Navigator.of(context).pushReplacement(
|
|
CustomPageRoute(
|
|
page: LandingNavigation(),
|
|
// page: LoginScreen(),
|
|
),
|
|
);
|
|
}
|
|
});
|
|
var zoom = ZoomVideoSdk();
|
|
InitConfig initConfig = InitConfig(
|
|
domain: "zoom.us",
|
|
enableLog: true,
|
|
);
|
|
zoom.initSdk(initConfig);
|
|
}
|
|
|
|
/// load the Privilege from service
|
|
Future loadPrivilege() async {
|
|
// ProjectViewModel projectProvider = Provider.of<ProjectViewModel>(context, listen: false);
|
|
// projectProvider.setPrivilegeModelList(privilege: _privilegeService.privilegeModelList);
|
|
// projectProvider.setVidaPlusProjectList(_privilegeService.vidaPlusProjectListModel);
|
|
// projectProvider.setHMCProjectList(_privilegeService.hMCProjectListModel);
|
|
// projectProvider.setProjectsDetailList(_privilegeService.projectDetailListModel);
|
|
// double lat = await AppSharedPreferences().getDouble(USER_LAT) ?? 0.0;
|
|
// double long = await AppSharedPreferences().getDouble(USER_LONG) ?? 0.0;
|
|
// AppSharedPreferences().clear(); // Clearing Shared Preferences On App Launch
|
|
// await AppSharedPreferences().setDouble(USER_LAT, lat);
|
|
// await AppSharedPreferences().setDouble(USER_LONG, long);
|
|
// AppSharedPreferences().setString(APP_LANGUAGE, projectProvider.isArabic ? "ar" : "en");
|
|
// var themeNotifier = Provider.of<ThemeNotifier>(context, listen: false);
|
|
// themeNotifier.setTheme(defaultTheme(fontName: projectProvider.isArabic ? 'Cairo' : 'Poppins'));
|
|
PushNotificationHandler().init(context); // Asyncronously
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
authVm = context.read<AuthenticationViewModel>();
|
|
super.initState();
|
|
initializeStuff();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: AppColors.whiteColor,
|
|
body: isNewDesign
|
|
? Lottie.asset(AppAnimations.loadingAnimation, repeat: true, reverse: false, frameRate: FrameRate(60), width: 80.h, height: 80.h, fit: BoxFit.fill).center
|
|
: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
Padding(
|
|
padding: EdgeInsets.symmetric(horizontal: 53),
|
|
child: Image.asset(AppAssets.hmg_logo, fit: BoxFit.fitWidth, width: MediaQuery.of(context).size.width),
|
|
),
|
|
Align(
|
|
alignment: Alignment.bottomCenter,
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text(
|
|
"Powered by",
|
|
style: TextStyle(fontSize: 14, fontWeight: FontWeight.w400, color: AppColors.textColor, letterSpacing: -0.56, height: 16 / 14),
|
|
),
|
|
SizedBox(
|
|
height: 5,
|
|
),
|
|
Utils.buildSvgWithAssets(icon: AppAssets.cloud_logo, width: 40, height: 40),
|
|
SizedBox(height: 7),
|
|
// Text(
|
|
// "Version 1.1.0",
|
|
// style: TextStyle(fontSize: 10, fontWeight: FontWeight.w400, color: Color(0xff3989898), letterSpacing: 0, height: 12 / 10),
|
|
// ),
|
|
SizedBox(
|
|
height: 18,
|
|
)
|
|
],
|
|
),
|
|
)
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|