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