64 lines
2.1 KiB
Dart
64 lines
2.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:lottie/lottie.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:citycards_customer/intro_screens/views/intro_screen_view.dart';
|
|
import 'package:citycards_customer/core/route_constants.dart';
|
|
import '../../home/views/first_time_user_home_page.dart';
|
|
import '../bloc/app_start_bloc.dart';
|
|
import '../bloc/app_start_event.dart';
|
|
import '../bloc/app_start_state.dart';
|
|
|
|
class SplashScreen extends StatelessWidget {
|
|
const SplashScreen({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocProvider(
|
|
create: (_) => AppStartBloc()..add(CheckAppStartStatus()),
|
|
child: BlocListener<AppStartBloc, AppStartState>(
|
|
listener: (context, state) {
|
|
if (state is NavigateToIntro) {
|
|
Future.delayed(const Duration(seconds: 4), () {
|
|
if (context.mounted) {
|
|
Navigator.pushReplacement(
|
|
context,
|
|
MaterialPageRoute(builder: (_) => IntroScreensView()),
|
|
);
|
|
}
|
|
});
|
|
} else if (state is NavigateToFirstTimeHome) {
|
|
Future.delayed(const Duration(seconds: 4), () {
|
|
if (context.mounted) {
|
|
Navigator.pushReplacement(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (_) => const FirstTimeUserHomePage(),
|
|
),
|
|
);
|
|
}
|
|
});
|
|
} else if (state is NavigateToHome) {
|
|
Future.delayed(const Duration(seconds: 4), () {
|
|
if (context.mounted) {
|
|
Navigator.pushReplacementNamed(
|
|
context,
|
|
RouteConstants.home,
|
|
);
|
|
}
|
|
});
|
|
}
|
|
},
|
|
child: Scaffold(
|
|
backgroundColor: Color(0xFFFB695C),
|
|
body: Center(
|
|
child: Lottie.asset(
|
|
'assets/intro/citycards_splash_screen.json',
|
|
fit: BoxFit.cover,
|
|
repeat: false,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
} |