hom
This commit is contained in:
@@ -10,73 +10,140 @@ import '../../constant/box_name.dart';
|
||||
import '../../main.dart';
|
||||
import '../../views/auth/captin/login_captin.dart';
|
||||
|
||||
// class SplashScreenController extends GetxController
|
||||
// with GetTickerProviderStateMixin {
|
||||
// late AnimationController _animationController;
|
||||
// late Animation<double> animation;
|
||||
|
||||
// String packageInfo = '';
|
||||
|
||||
// Future<void> _getPackageInfo() async {
|
||||
// final info = await PackageInfo.fromPlatform();
|
||||
// packageInfo = info.version;
|
||||
// box.write(BoxName.packagInfo, packageInfo);
|
||||
// update();
|
||||
// }
|
||||
|
||||
// @override
|
||||
// void onInit() {
|
||||
// super.onInit();
|
||||
// _getPackageInfo();
|
||||
// _animationController = AnimationController(
|
||||
// vsync: this,
|
||||
// duration: const Duration(milliseconds: 1500), // Reduced duration
|
||||
// )..forward();
|
||||
|
||||
// animation =
|
||||
// CurvedAnimation(parent: _animationController, curve: Curves.easeOut);
|
||||
|
||||
// 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 {
|
||||
// // Reduced timer duration
|
||||
// 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();
|
||||
// }
|
||||
// }
|
||||
class SplashScreenController extends GetxController
|
||||
with SingleGetTickerProviderMixin {
|
||||
late AnimationController animationController;
|
||||
late Animation<double> zoomInAnimation;
|
||||
late Animation<double> zoomOutAnimation;
|
||||
with GetTickerProviderStateMixin {
|
||||
late AnimationController _animationController;
|
||||
late Animation<double> animation;
|
||||
final progress = 0.0.obs;
|
||||
Timer? _progressTimer;
|
||||
|
||||
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
|
||||
|
||||
Future<void> _getPackageInfo() async {
|
||||
final info = await PackageInfo.fromPlatform();
|
||||
packageInfo = info.version;
|
||||
box.write(BoxName.packagInfo, packageInfo);
|
||||
update();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
checkForUpdate();
|
||||
animationController = AnimationController(
|
||||
_getPackageInfo();
|
||||
_animationController = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(seconds: 4),
|
||||
);
|
||||
duration: const Duration(milliseconds: 1500), // Reduced duration
|
||||
)..forward();
|
||||
|
||||
zoomInAnimation = Tween<double>(begin: 1.0, end: 1.5).animate(
|
||||
CurvedAnimation(
|
||||
parent: animationController,
|
||||
curve: Curves.easeInOut,
|
||||
),
|
||||
);
|
||||
animation =
|
||||
CurvedAnimation(parent: _animationController, curve: Curves.easeOut);
|
||||
|
||||
zoomOutAnimation = Tween<double>(begin: 1.5, end: 1.0).animate(
|
||||
CurvedAnimation(
|
||||
parent: animationController,
|
||||
curve: Curves.easeInOut,
|
||||
),
|
||||
);
|
||||
|
||||
animationController.repeat(reverse: true);
|
||||
startTimer();
|
||||
_startProgressTimer();
|
||||
}
|
||||
|
||||
void _startProgressTimer() {
|
||||
const totalTime = 3000; // 5 seconds in milliseconds
|
||||
const interval = 50; // Update every 50ms
|
||||
int elapsed = 0;
|
||||
|
||||
_progressTimer =
|
||||
Timer.periodic(const Duration(milliseconds: interval), (timer) async {
|
||||
elapsed += interval;
|
||||
progress.value = (elapsed / totalTime).clamp(0.0, 1.0);
|
||||
|
||||
if (elapsed >= totalTime) {
|
||||
timer.cancel();
|
||||
|
||||
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());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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());
|
||||
// box.read(BoxName.onBoarding) == null
|
||||
// ? Get.off(() => OnBoardingPage())
|
||||
// : box.read(BoxName.email) != null &&
|
||||
// box.read(BoxName.phone) != null &&
|
||||
// box.read(BoxName.isVerified) == '1'
|
||||
// // ? Get.off(() => const MapPagePassenger())
|
||||
// ? await Get.put(LoginController()).loginUsingCredentials(
|
||||
// box.read(BoxName.passengerID).toString(),
|
||||
// box.read(BoxName.email).toString(),
|
||||
// )
|
||||
// : Get.off(() => LoginPage());
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
animationController.dispose();
|
||||
_progressTimer?.cancel();
|
||||
_animationController.dispose();
|
||||
super.onClose();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user