Refactor settings to use FirebaseAuth for sign out
Replaces the previous mock-based authentication in client settings with FirebaseAuth for sign out functionality. Updates dependencies and imports accordingly, and adds firebase_auth to the settings package and firebase_core to the client app. Also includes minor Dart type improvements and dependency reordering.
This commit is contained in:
@@ -20,10 +20,10 @@ void main() async {
|
||||
/// The main application module for the Client app.
|
||||
class AppModule extends Module {
|
||||
@override
|
||||
List<Module> get imports => [core_localization.LocalizationModule()];
|
||||
List<Module> get imports => <Module>[core_localization.LocalizationModule()];
|
||||
|
||||
@override
|
||||
void routes(r) {
|
||||
void routes(RouteManager r) {
|
||||
// Initial route points to the client authentication flow
|
||||
r.module('/', module: client_authentication.ClientAuthenticationModule());
|
||||
|
||||
@@ -47,7 +47,7 @@ class AppWidget extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider<core_localization.LocaleBloc>(
|
||||
create: (context) =>
|
||||
create: (BuildContext context) =>
|
||||
Modular.get<core_localization.LocaleBloc>()
|
||||
..add(const core_localization.LoadLocale()),
|
||||
child:
|
||||
@@ -55,23 +55,25 @@ class AppWidget extends StatelessWidget {
|
||||
core_localization.LocaleBloc,
|
||||
core_localization.LocaleState
|
||||
>(
|
||||
builder: (context, state) {
|
||||
return core_localization.TranslationProvider(
|
||||
child: MaterialApp.router(
|
||||
debugShowCheckedModeBanner: false,
|
||||
title: "Krow Client",
|
||||
theme: UiTheme.light,
|
||||
routerConfig: Modular.routerConfig,
|
||||
locale: state.locale,
|
||||
supportedLocales: state.supportedLocales,
|
||||
localizationsDelegates: const [
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
builder:
|
||||
(BuildContext context, core_localization.LocaleState state) {
|
||||
return core_localization.TranslationProvider(
|
||||
child: MaterialApp.router(
|
||||
debugShowCheckedModeBanner: false,
|
||||
title: "Krow Client",
|
||||
theme: UiTheme.light,
|
||||
routerConfig: Modular.routerConfig,
|
||||
locale: state.locale,
|
||||
supportedLocales: state.supportedLocales,
|
||||
localizationsDelegates:
|
||||
const <LocalizationsDelegate<dynamic>>[
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,11 +10,6 @@ environment:
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
cupertino_icons: ^1.0.8
|
||||
flutter_modular: ^6.3.2
|
||||
flutter_bloc: ^8.1.3
|
||||
flutter_localizations:
|
||||
sdk: flutter
|
||||
|
||||
# Architecture Packages
|
||||
design_system:
|
||||
@@ -31,6 +26,13 @@ dependencies:
|
||||
path: ../../packages/features/client/settings
|
||||
client_hubs:
|
||||
path: ../../packages/features/client/hubs
|
||||
|
||||
cupertino_icons: ^1.0.8
|
||||
flutter_modular: ^6.3.2
|
||||
flutter_bloc: ^8.1.3
|
||||
flutter_localizations:
|
||||
sdk: flutter
|
||||
firebase_core: ^4.4.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
@@ -169,10 +169,10 @@ class ClientHubsPage extends StatelessWidget {
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Text(
|
||||
t.client_hubs.title,
|
||||
style: const TextStyle(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:flutter_modular/flutter_modular.dart';
|
||||
import 'package:krow_data_connect/krow_data_connect.dart';
|
||||
import 'src/data/repositories_impl/settings_repository_impl.dart';
|
||||
import 'src/domain/repositories/settings_repository_interface.dart';
|
||||
import 'src/domain/usecases/sign_out_usecase.dart';
|
||||
@@ -8,14 +8,11 @@ import 'src/presentation/pages/client_settings_page.dart';
|
||||
|
||||
/// A [Module] for the client settings feature.
|
||||
class ClientSettingsModule extends Module {
|
||||
@override
|
||||
List<Module> get imports => [DataConnectModule()];
|
||||
|
||||
@override
|
||||
void binds(Injector i) {
|
||||
// Repositories
|
||||
i.addLazySingleton<SettingsRepositoryInterface>(
|
||||
() => SettingsRepositoryImpl(mock: i.get<AuthRepositoryMock>()),
|
||||
() => SettingsRepositoryImpl(firebaseAuth: FirebaseAuth.instance),
|
||||
);
|
||||
|
||||
// UseCases
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
import 'package:krow_data_connect/krow_data_connect.dart';
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import '../../domain/repositories/settings_repository_interface.dart';
|
||||
|
||||
/// Implementation of [SettingsRepositoryInterface].
|
||||
///
|
||||
/// This implementation delegates data access to the [AuthRepositoryMock]
|
||||
/// from the `data_connect` package.
|
||||
/// This implementation delegates authentication operations to [FirebaseAuth].
|
||||
class SettingsRepositoryImpl implements SettingsRepositoryInterface {
|
||||
/// The auth mock from data connect.
|
||||
final AuthRepositoryMock mock;
|
||||
/// The Firebase Auth instance.
|
||||
final FirebaseAuth _firebaseAuth;
|
||||
|
||||
/// Creates a [SettingsRepositoryImpl] with the required [mock].
|
||||
SettingsRepositoryImpl({required this.mock});
|
||||
/// Creates a [SettingsRepositoryImpl] with the required [_firebaseAuth].
|
||||
SettingsRepositoryImpl({required FirebaseAuth firebaseAuth})
|
||||
: _firebaseAuth = firebaseAuth;
|
||||
|
||||
@override
|
||||
Future<void> signOut() {
|
||||
return mock.signOut();
|
||||
Future<void> signOut() async {
|
||||
try {
|
||||
await _firebaseAuth.signOut();
|
||||
} catch (e) {
|
||||
throw Exception('Error signing out: ${e.toString()}');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ dependencies:
|
||||
flutter_modular: ^6.3.0
|
||||
equatable: ^2.0.5
|
||||
lucide_icons: ^0.257.0
|
||||
firebase_auth: ^6.1.2
|
||||
|
||||
# Architecture Packages
|
||||
design_system:
|
||||
|
||||
Reference in New Issue
Block a user