feat:login page done

This commit is contained in:
jahongireshonqulov
2025-10-29 12:00:33 +05:00
parent d3ad5b8ddd
commit 2ed2c430c0
27 changed files with 524 additions and 178 deletions

View File

@@ -1,4 +1,5 @@
import 'package:food_delivery_client/feature/auth/domain/usecases/login_usecase.dart';
import 'package:food_delivery_client/feature/common/presentation/widgets/w_toastification.dart';
import 'package:food_delivery_client/food_delivery_client.dart';
part 'login_event.dart';
@@ -10,8 +11,10 @@ part 'login_bloc.freezed.dart';
@injectable
class LoginBloc extends Bloc<LoginEvent, LoginState> {
final LoginUseCase _loginUseCase;
final StorageService _storageService;
LoginBloc(this._loginUseCase) : super(const LoginState()) {
LoginBloc(this._loginUseCase, this._storageService)
: super(const LoginState()) {
on<_Login>(_onLogin);
}
@@ -23,10 +26,12 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
response.fold(
(l) {
log("${l.errorMessage}");
showErrorToast(l.errorMessage);
emit(state.copyWith(status: RequestStatus.error));
},
(r) {
log(r.token);
showSuccessToast("Login success");
_storageService.setString(key: AppLocaleKeys.token, value: r.token);
emit(state.copyWith(status: RequestStatus.loaded));
},
);