chore: Refactor navigation and button actions in settings page

Replaced Navigator calls with Modular navigation for consistency. Updated button order and styling in the logout dialog, and added comments for clarity. The Hubs button now uses Modular navigation to push the Hubs page.
This commit is contained in:
Achintha Isuru
2026-01-22 13:49:00 -05:00
parent 5da56eb769
commit a7540954cb

View File

@@ -1,7 +1,9 @@
import 'package:client_settings/src/presentation/navigation/client_settings_navigator.dart';
import 'package:core_localization/core_localization.dart';
import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_modular/flutter_modular.dart';
import '../../blocs/client_settings_bloc.dart';
/// A widget that displays the primary actions for the settings page.
@@ -11,19 +13,31 @@ class SettingsActions extends StatelessWidget {
@override
Widget build(BuildContext context) {
final labels = t.client_settings.profile;
// Get the translations for the client settings profile.
final TranslationsClientSettingsProfileEn labels =
t.client_settings.profile;
return SliverPadding(
padding: const EdgeInsets.symmetric(horizontal: UiConstants.space5),
sliver: SliverList(
delegate: SliverChildListDelegate([
delegate: SliverChildListDelegate(<Widget>[
const SizedBox(height: UiConstants.space5),
// Edit profile button
UiButton.primary(text: labels.edit_profile, onPressed: () {}),
const SizedBox(height: UiConstants.space4),
UiButton.primary(text: labels.hubs, onPressed: () {}),
// Hubs button
UiButton.primary(
text: labels.hubs,
onPressed: () => Modular.to.pushHubs(),
),
const SizedBox(height: UiConstants.space4),
// Log out button
BlocBuilder<ClientSettingsBloc, ClientSettingsState>(
builder: (context, state) {
builder: (BuildContext context, ClientSettingsState state) {
return UiButton.secondary(
text: labels.log_out,
onPressed: state is ClientSettingsLoading
@@ -53,24 +67,27 @@ class SettingsActions extends StatelessWidget {
'Are you sure you want to log out?',
style: UiTypography.body2r.textSecondary,
),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: Text(
t.common.cancel,
style: UiTypography.buttonM.textSecondary,
),
),
actions: <Widget>[
// Log out button
TextButton(
onPressed: () {
Navigator.of(context).pop();
Modular.to.pop();
BlocProvider.of<ClientSettingsBloc>(
context,
).add(const ClientSettingsSignOutRequested());
},
child: Text(
t.client_settings.profile.log_out,
style: UiTypography.buttonM.textError,
style: UiTypography.buttonM.textSecondary,
),
),
// Cancel button
TextButton(
onPressed: () => Modular.to.pop(),
child: Text(
t.common.cancel,
style: UiTypography.buttonM.textPrimary,
),
),
],