feat(settings): refactor SettingsRepositoryImpl and update client settings page UI
This commit is contained in:
@@ -1,21 +1,21 @@
|
|||||||
import 'package:firebase_auth/firebase_auth.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 authentication operations to [FirebaseAuth].
|
/// This implementation delegates authentication operations to [FirebaseAuth].
|
||||||
class SettingsRepositoryImpl implements SettingsRepositoryInterface {
|
class SettingsRepositoryImpl implements SettingsRepositoryInterface {
|
||||||
/// The Firebase Auth instance.
|
/// Creates a [SettingsRepositoryImpl] with the required [_firebaseAuth].
|
||||||
final FirebaseAuth _firebaseAuth;
|
const SettingsRepositoryImpl({required this.firebaseAuth});
|
||||||
|
|
||||||
/// Creates a [SettingsRepositoryImpl] with the required [_firebaseAuth].
|
/// The Firebase Auth instance.
|
||||||
SettingsRepositoryImpl({required FirebaseAuth firebaseAuth})
|
final FirebaseAuth firebaseAuth;
|
||||||
: _firebaseAuth = firebaseAuth;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> signOut() async {
|
Future<void> signOut() async {
|
||||||
try {
|
try {
|
||||||
await _firebaseAuth.signOut();
|
await firebaseAuth.signOut();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw Exception('Error signing out: ${e.toString()}');
|
throw Exception('Error signing out: ${e.toString()}');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import 'package:design_system/design_system.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_modular/flutter_modular.dart';
|
import 'package:flutter_modular/flutter_modular.dart';
|
||||||
|
|
||||||
import '../blocs/client_settings_bloc.dart';
|
import '../blocs/client_settings_bloc.dart';
|
||||||
import '../widgets/client_settings_page/settings_actions.dart';
|
import '../widgets/client_settings_page/settings_actions.dart';
|
||||||
import '../widgets/client_settings_page/settings_profile_header.dart';
|
import '../widgets/client_settings_page/settings_profile_header.dart';
|
||||||
import '../widgets/client_settings_page/settings_quick_links.dart';
|
|
||||||
|
|
||||||
/// Page for client settings and profile management.
|
/// Page for client settings and profile management.
|
||||||
///
|
///
|
||||||
@@ -20,9 +19,9 @@ class ClientSettingsPage extends StatelessWidget {
|
|||||||
/// Builds the client settings page UI.
|
/// Builds the client settings page UI.
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocProvider<ClientSettingsBloc>(
|
return BlocProvider<ClientSettingsBloc>(
|
||||||
create: (context) => Modular.get<ClientSettingsBloc>(),
|
create: (BuildContext context) => Modular.get<ClientSettingsBloc>(),
|
||||||
child: BlocListener<ClientSettingsBloc, ClientSettingsState>(
|
child: BlocListener<ClientSettingsBloc, ClientSettingsState>(
|
||||||
listener: (context, state) {
|
listener: (BuildContext context, ClientSettingsState state) {
|
||||||
if (state is ClientSettingsSignOutSuccess) {
|
if (state is ClientSettingsSignOutSuccess) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
const SnackBar(content: Text('Signed out successfully')),
|
const SnackBar(content: Text('Signed out successfully')),
|
||||||
@@ -36,12 +35,10 @@ class ClientSettingsPage extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: const Scaffold(
|
child: const Scaffold(
|
||||||
backgroundColor: UiColors.background,
|
|
||||||
body: CustomScrollView(
|
body: CustomScrollView(
|
||||||
slivers: [
|
slivers: <Widget>[
|
||||||
SettingsProfileHeader(),
|
SettingsProfileHeader(),
|
||||||
SettingsActions(),
|
SettingsActions(),
|
||||||
SettingsQuickLinks(),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -24,10 +24,8 @@ class SettingsActions extends StatelessWidget {
|
|||||||
delegate: SliverChildListDelegate(<Widget>[
|
delegate: SliverChildListDelegate(<Widget>[
|
||||||
const SizedBox(height: UiConstants.space5),
|
const SizedBox(height: UiConstants.space5),
|
||||||
|
|
||||||
// Edit profile button
|
/// TODO: FEATURE_NOT_YET_IMPLEMENTED
|
||||||
UiButton.primary(text: labels.edit_profile, onPressed: () {}),
|
// Edit profile is not yet implemented
|
||||||
|
|
||||||
const SizedBox(height: UiConstants.space4),
|
|
||||||
|
|
||||||
// Hubs button
|
// Hubs button
|
||||||
UiButton.primary(
|
UiButton.primary(
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ class SettingsQuickLinks extends StatelessWidget {
|
|||||||
title: labels.clock_in_hubs,
|
title: labels.clock_in_hubs,
|
||||||
onTap: () => Modular.to.pushHubs(),
|
onTap: () => Modular.to.pushHubs(),
|
||||||
),
|
),
|
||||||
|
|
||||||
_QuickLinkItem(
|
_QuickLinkItem(
|
||||||
icon: UiIcons.building,
|
icon: UiIcons.building,
|
||||||
title: labels.billing_payments,
|
title: labels.billing_payments,
|
||||||
|
|||||||
Reference in New Issue
Block a user