This commit is contained in:
Hamza-Ayed
2024-12-24 17:35:15 +03:00
parent 1e0e4a5b48
commit 1cbf0183d1
56 changed files with 3081 additions and 2560 deletions

View File

@@ -13,112 +13,84 @@ 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;
with GetTickerProviderStateMixin {
late AnimationController _animationController;
late Animation<double> animation;
final progress = 0.0.obs;
Timer? _progressTimer;
String packageInfo = '';
late String version = '1.5.48';
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
version = version1.toString();
print('version: ${version}');
Future<void> _getPackageInfo() async {
final info = await PackageInfo.fromPlatform();
packageInfo = info.version;
box.write(BoxName.packagInfo, packageInfo);
update();
}
StreamSubscription? _sub;
// Future<void> initUniLinks() async {
// // Handle initial URI if the app was launched from a link
// try {
// final initialUri = await getInitialUri();
// if (initialUri != null) {
// handleLink(initialUri);
// }
// } on PlatformException {
// // Handle exception by warning the user their action did not succeed
// print("Failed to get initial uri");
// }
@override
void onInit() {
super.onInit();
_getPackageInfo();
_animationController = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 1500), // Reduced duration
)..forward();
// // Listen to new links while the app is running
// _sub = uriLinkStream.listen((Uri? uri) {
// if (uri != null) {
// handleLink(uri);
// }
// }, onError: (Object err) {
// print('Error occurred: $err');
// });
// }
animation =
CurvedAnimation(parent: _animationController, curve: Curves.easeOut);
void handleLink(Uri uri) {
if (uri.host == 'sefer.live' && uri.path == '/tripmonitor') {
final rideId = uri.queryParameters['rideId'];
final driverId = uri.queryParameters['driverId'];
if (rideId != null && driverId != null) {
Get.toNamed('/tripmonitor', parameters: {
'rideId': rideId,
'driverId': driverId,
});
} else {
// Handle the case where rideId or driverId is null
print('Invalid parameters in the deep link');
// You might want to show an error message to the user or handle this case differently
}
}
startTimer();
_startProgressTimer();
}
@override
void onInit() async {
super.onInit();
checkForUpdate();
// initUniLinks();
animationController = AnimationController(
vsync: this,
duration: const Duration(seconds: 4),
);
void _startProgressTimer() {
const totalTime = 3000; // 5 seconds in milliseconds
const interval = 50; // Update every 50ms
int elapsed = 0;
zoomInAnimation = Tween<double>(begin: 1.0, end: 1.5).animate(
CurvedAnimation(
parent: animationController,
curve: Curves.easeInOut,
),
);
_progressTimer =
Timer.periodic(const Duration(milliseconds: interval), (timer) async {
elapsed += interval;
progress.value = (elapsed / totalTime).clamp(0.0, 1.0);
zoomOutAnimation = Tween<double>(begin: 1.5, end: 1.0).animate(
CurvedAnimation(
parent: animationController,
curve: Curves.easeInOut,
),
);
animationController.repeat(reverse: true);
startTimer();
if (elapsed >= totalTime) {
timer.cancel();
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());
}
});
}
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());
// 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();
}
}