53 lines
1.4 KiB
Dart
53 lines
1.4 KiB
Dart
import 'dart:async';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:proxibuy/presentation/auth/bloc/auth_bloc.dart';
|
|
import 'package:proxibuy/presentation/pages/onboarding_page.dart';
|
|
import 'package:proxibuy/presentation/pages/offers_page.dart';
|
|
import 'package:proxibuy/core/gen/assets.gen.dart';
|
|
|
|
class SplashScreen extends StatefulWidget {
|
|
const SplashScreen({super.key});
|
|
|
|
@override
|
|
State<SplashScreen> createState() => _SplashScreenState();
|
|
}
|
|
|
|
class _SplashScreenState extends State<SplashScreen> {
|
|
late final StreamSubscription _authSubscription;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
final authBloc = context.read<AuthBloc>();
|
|
|
|
_authSubscription = authBloc.stream.listen((state) {
|
|
_authSubscription.cancel();
|
|
if (state is AuthSuccess) {
|
|
Navigator.of(context).pushReplacement(
|
|
MaterialPageRoute(builder: (_) => const OffersPage()),
|
|
);
|
|
} else {
|
|
Navigator.of(context).pushReplacement(
|
|
MaterialPageRoute(builder: (_) => const OnboardingPage()),
|
|
);
|
|
}
|
|
});
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_authSubscription.cancel();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Colors.white,
|
|
body: Center(
|
|
child: Assets.icons.logo.svg(height: 160),
|
|
),
|
|
);
|
|
}
|
|
} |