Files
tripz/lib/controller/home/splash_screen_controlle.dart
Hamza-Ayed 08d31bc4d1 6/28/1
2024-06-28 19:10:34 +03:00

67 lines
1.8 KiB
Dart

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:SEFER/views/auth/login_page.dart';
import '../../constant/box_name.dart';
import '../../main.dart';
import '../../onbording_page.dart';
import '../auth/login_controller.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 {
Timer(const Duration(seconds: 5), () async {
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();
super.onClose();
}
}