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