fix(apps): consolidate FormzInput validators and fix login screen
- Move FormzInput validators to core/form_inputs/form_inputs.dart - Fix login_screen.dart syntax error (missing 'class' keyword) - Remove unused _isLoading field - Fix unnecessary const keywords - Update login_cubit and register_cubit imports - Remove duplicate FormzInput definitions from register_cubit - Add Toast and Banner UI feedback system - Remove legacy login/register screens (login_code, login_email, login_password, register_step2) - Remove unused warning_banner widget - Update tests for new error messages and DI setup
This commit is contained in:
@@ -12,17 +12,22 @@ import '../../features/auth/presentation/bloc/auth_bloc.dart';
|
||||
final sl = GetIt.instance;
|
||||
|
||||
Future<void> configureDependencies() async {
|
||||
if (sl.isRegistered<ApiClient>()) {
|
||||
await sl.reset();
|
||||
}
|
||||
|
||||
final dio = Dio(BaseOptions(baseUrl: Env.apiUrl));
|
||||
final secureStorage = const FlutterSecureStorage();
|
||||
final tokenStorage = SecureTokenStorage(secureStorage);
|
||||
|
||||
sl.registerSingleton<Dio>(dio);
|
||||
sl.registerSingleton<FlutterSecureStorage>(secureStorage);
|
||||
sl.registerSingleton<TokenStorage>(tokenStorage);
|
||||
|
||||
final authApi = AuthApi(
|
||||
ApiClient(baseUrl: Env.apiUrl, tokenStorage: tokenStorage, dio: dio),
|
||||
final apiClient = ApiClient(
|
||||
baseUrl: Env.apiUrl,
|
||||
tokenStorage: tokenStorage,
|
||||
dio: dio,
|
||||
);
|
||||
sl.registerSingleton<ApiClient>(apiClient);
|
||||
|
||||
final authApi = AuthApi(apiClient);
|
||||
sl.registerSingleton<AuthApi>(authApi);
|
||||
|
||||
final authRepository = AuthRepositoryImpl(
|
||||
@@ -31,22 +36,14 @@ Future<void> configureDependencies() async {
|
||||
);
|
||||
sl.registerSingleton<AuthRepository>(authRepository);
|
||||
|
||||
sl.unregister<ApiClient>();
|
||||
sl.registerSingleton<ApiClient>(
|
||||
ApiClient(
|
||||
baseUrl: Env.apiUrl,
|
||||
tokenStorage: tokenStorage,
|
||||
dio: dio,
|
||||
refreshToken: (token) async {
|
||||
try {
|
||||
await authRepository.refresh(token);
|
||||
return true;
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
apiClient.setRefreshCallback((token) async {
|
||||
try {
|
||||
await authRepository.refresh(token);
|
||||
return true;
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
sl.registerSingleton<AuthBloc>(AuthBloc(authRepository));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user