feat: splash page done
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:food_delivery_client/food_delivery_client.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'splash_event.dart';
|
||||
|
||||
part 'splash_state.dart';
|
||||
|
||||
part 'splash_bloc.freezed.dart';
|
||||
|
||||
@injectable
|
||||
class SplashBloc extends Bloc<SplashEvent, SplashState> {
|
||||
final StorageService _storageService;
|
||||
|
||||
SplashBloc(this._storageService) : super(const SplashState()) {
|
||||
on<_Started>(_onStarted);
|
||||
}
|
||||
|
||||
_onStarted(_Started event, Emitter<SplashState> emit) async {
|
||||
await Future.delayed(TimeDelayConst.duration2);
|
||||
final token = _storageService.getString(key: AppLocaleKeys.token);
|
||||
if (token != null) {
|
||||
emit(state.copyWith(status: RequestStatus.loaded));
|
||||
} else {
|
||||
emit(state.copyWith(status: RequestStatus.error));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
part of 'splash_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class SplashEvent with _$SplashEvent {
|
||||
const factory SplashEvent.started() = _Started;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
part of 'splash_bloc.dart';
|
||||
|
||||
@freezed
|
||||
abstract class SplashState with _$SplashState {
|
||||
const factory SplashState({
|
||||
@Default(RequestStatus.initial) RequestStatus status,
|
||||
}) = _SplashState;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import '../../../../../food_delivery_client.dart';
|
||||
|
||||
class OnboardingPage extends StatelessWidget {
|
||||
const OnboardingPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WLayout(child: Scaffold());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
import 'package:food_delivery_client/feature/onboarding/presentation/blocs/splash_bloc/splash_bloc.dart';
|
||||
|
||||
import '../../../../../food_delivery_client.dart';
|
||||
|
||||
class SplashPage extends StatelessWidget {
|
||||
const SplashPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (context) => sl<SplashBloc>()..add(SplashEvent.started()),
|
||||
child: BlocListener<SplashBloc, SplashState>(
|
||||
listener: (context, state) {
|
||||
if (state.status.isError()) {
|
||||
context.go(Routes.onBoarding);
|
||||
}
|
||||
},
|
||||
child: WLayout(
|
||||
bottom: false,
|
||||
top: false,
|
||||
child: Scaffold(
|
||||
body: Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: SvgPicture.asset(context.appThemeIcons.icSplash),
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Center(child: SvgPicture.asset(AppIcons.icLogo)),
|
||||
ShaderMask(
|
||||
shaderCallback: (bounds) =>
|
||||
const LinearGradient(
|
||||
begin: AlignmentGeometry.bottomCenter,
|
||||
end: AlignmentGeometry.topCenter,
|
||||
colors: [AppColors.cFF6F00, AppColors.cFFAB40],
|
||||
).createShader(
|
||||
Rect.fromLTWH(0, 0, bounds.width, bounds.height),
|
||||
),
|
||||
child: Text(
|
||||
"Felix Eats",
|
||||
style: context.appThemeTextStyles.size64Black,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user