feat: splash page done

This commit is contained in:
jahongireshonqulov
2025-10-31 12:29:30 +05:00
parent ab1ac6e6fa
commit 077ea23416
229 changed files with 3187 additions and 13517 deletions

View File

@@ -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));
}
}
}

View File

@@ -0,0 +1,6 @@
part of 'splash_bloc.dart';
@freezed
class SplashEvent with _$SplashEvent {
const factory SplashEvent.started() = _Started;
}

View File

@@ -0,0 +1,8 @@
part of 'splash_bloc.dart';
@freezed
abstract class SplashState with _$SplashState {
const factory SplashState({
@Default(RequestStatus.initial) RequestStatus status,
}) = _SplashState;
}