Files
driver_tripz/lib/controller/home/splash_screen_controlle.dart
Hamza-Ayed 4af52f4392 5/29/3
2024-05-29 16:09:37 +03:00

69 lines
2.0 KiB
Dart

import 'dart:async';
import 'package:SEFER/controller/auth/captin/login_captin_controller.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../constant/box_name.dart';
import '../../main.dart';
import '../../onbording_page.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;
@override
void onInit() {
super.onInit();
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(LoginCaptinController()).loginFromSignInGoogle(
box.read(BoxName.driverID).toString(),
box.read(BoxName.emailDriver))
: Get.off(() => LoginCaptin());
});
}
@override
void onClose() {
animationController.dispose();
super.onClose();
}
}