83 lines
2.5 KiB
Dart
83 lines
2.5 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:sefer_driver/controller/auth/captin/login_captin_controller.dart';
|
|
import 'package:sefer_driver/views/home/on_boarding_page.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:package_info_plus/package_info_plus.dart';
|
|
|
|
import '../../constant/box_name.dart';
|
|
import '../../main.dart';
|
|
import '../../views/auth/captin/login_captin.dart';
|
|
|
|
class SplashScreenController extends GetxController
|
|
with SingleGetTickerProviderMixin {
|
|
late AnimationController animationController;
|
|
late Animation<double> zoomInAnimation;
|
|
late Animation<double> zoomOutAnimation;
|
|
|
|
String packageInfo = '';
|
|
|
|
Future<void> checkForUpdate() async {
|
|
final packageInfo = await PackageInfo.fromPlatform();
|
|
final currentVersion = packageInfo.buildNumber;
|
|
final version1 = packageInfo.version;
|
|
print('currentVersion is : $currentVersion');
|
|
// Fetch the latest version from your server
|
|
|
|
update();
|
|
}
|
|
|
|
@override
|
|
void onInit() {
|
|
super.onInit();
|
|
checkForUpdate();
|
|
animationController = AnimationController(
|
|
vsync: this,
|
|
duration: const Duration(seconds: 4),
|
|
);
|
|
|
|
zoomInAnimation = Tween<double>(begin: 1.0, end: 1.5).animate(
|
|
CurvedAnimation(
|
|
parent: animationController,
|
|
curve: Curves.easeInOut,
|
|
),
|
|
);
|
|
|
|
zoomOutAnimation = Tween<double>(begin: 1.5, end: 1.0).animate(
|
|
CurvedAnimation(
|
|
parent: animationController,
|
|
curve: Curves.easeInOut,
|
|
),
|
|
);
|
|
|
|
animationController.repeat(reverse: true);
|
|
startTimer();
|
|
}
|
|
|
|
void startTimer() async {
|
|
debugPrint('onBoarding: ${box.read(BoxName.onBoarding)}');
|
|
debugPrint('emailDriver: ${box.read(BoxName.emailDriver)}');
|
|
debugPrint('phoneDriver: ${box.read(BoxName.phoneDriver)}');
|
|
debugPrint('phoneVerified: ${box.read(BoxName.phoneVerified)}');
|
|
Timer(const Duration(seconds: 5), () async {
|
|
box.read(BoxName.onBoarding) == null
|
|
? Get.off(() => OnBoardingPage())
|
|
: box.read(BoxName.emailDriver) != null &&
|
|
box.read(BoxName.phoneDriver) != null &&
|
|
box.read(BoxName.phoneVerified) == '1'
|
|
? await Get.put(LoginDriverController())
|
|
.loginWithGoogleCredential(
|
|
box.read(BoxName.driverID).toString(),
|
|
box.read(BoxName.emailDriver))
|
|
: Get.off(() => LoginCaptin());
|
|
});
|
|
}
|
|
|
|
@override
|
|
void onClose() {
|
|
animationController.dispose();
|
|
super.onClose();
|
|
}
|
|
}
|