refactor: move HubDetailsPage edit/delete actions to a bottom navigation bar and display hub name/address within the body, adding loading state management.

This commit is contained in:
Achintha Isuru
2026-02-24 14:06:58 -05:00
parent e084dad4a7
commit f30cd89217

View File

@@ -42,26 +42,59 @@ class HubDetailsPage extends StatelessWidget {
); );
} }
}, },
child: Scaffold( child: BlocBuilder<HubDetailsBloc, HubDetailsState>(
builder: (BuildContext context, HubDetailsState state) {
final bool isLoading = state.status == HubDetailsStatus.loading;
return Scaffold(
appBar: UiAppBar( appBar: UiAppBar(
title: hub.name, title: t.client_hubs.hub_details.title,
subtitle: t.client_hubs.hub_details.title,
onLeadingPressed: () => Modular.to.pop(), onLeadingPressed: () => Modular.to.pop(),
actions: <Widget>[
IconButton(
onPressed: () => _confirmDeleteHub(context),
icon: const Icon(UiIcons.delete, color: UiColors.iconSecondary),
), ),
UiIconButton( bottomNavigationBar: SafeArea(
icon: UiIcons.edit, child: Column(
onTap: () => _navigateToEditPage(context), mainAxisSize: MainAxisSize.min,
backgroundColor: UiColors.transparent, children: <Widget>[
iconColor: UiColors.iconSecondary, const Divider(height: 1, thickness: 0.5),
Padding(
padding: const EdgeInsets.all(UiConstants.space5),
child: Row(
children: <Widget>[
Expanded(
child: UiButton.secondary(
onPressed: isLoading
? null
: () => _confirmDeleteHub(context),
text: t.common.delete,
leadingIcon: UiIcons.delete,
style: OutlinedButton.styleFrom(
foregroundColor: UiColors.destructive,
side: const BorderSide(
color: UiColors.destructive,
),
),
),
),
const SizedBox(width: UiConstants.space4),
Expanded(
child: UiButton.secondary(
onPressed: isLoading
? null
: () => _navigateToEditPage(context),
text: t.client_hubs.hub_details.edit_button,
leadingIcon: UiIcons.edit,
),
), ),
], ],
), ),
),
],
),
),
backgroundColor: UiColors.bgMenu, backgroundColor: UiColors.bgMenu,
body: SingleChildScrollView( body: Stack(
children: <Widget>[
SingleChildScrollView(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[ children: <Widget>[
@@ -75,7 +108,9 @@ class HubDetailsPage extends StatelessWidget {
Container( Container(
width: 114, width: 114,
decoration: BoxDecoration( decoration: BoxDecoration(
color: UiColors.primary.withValues(alpha: 0.08), color: UiColors.primary.withValues(
alpha: 0.08,
),
borderRadius: BorderRadius.circular( borderRadius: BorderRadius.circular(
UiConstants.radiusBase, UiConstants.radiusBase,
), ),
@@ -92,14 +127,18 @@ class HubDetailsPage extends StatelessWidget {
const SizedBox(width: UiConstants.space4), const SizedBox(width: UiConstants.space4),
Expanded( Expanded(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
Text( Text(
hub.name, hub.name,
style: UiTypography.headline1b.textPrimary, style:
UiTypography.headline1b.textPrimary,
),
const SizedBox(
height: UiConstants.space1,
), ),
const SizedBox(height: UiConstants.space1),
Row( Row(
children: <Widget>[ children: <Widget>[
const Icon( const Icon(
@@ -107,11 +146,15 @@ class HubDetailsPage extends StatelessWidget {
size: 16, size: 16,
color: UiColors.textSecondary, color: UiColors.textSecondary,
), ),
const SizedBox(width: UiConstants.space1), const SizedBox(
width: UiConstants.space1,
),
Expanded( Expanded(
child: Text( child: Text(
hub.address, hub.address,
style: UiTypography.body2r.textSecondary, style: UiTypography
.body2r
.textSecondary,
maxLines: 2, maxLines: 2,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
@@ -146,6 +189,15 @@ class HubDetailsPage extends StatelessWidget {
], ],
), ),
), ),
if (isLoading)
Container(
color: UiColors.black.withValues(alpha: 0.1),
child: const Center(child: CircularProgressIndicator()),
),
],
),
);
},
), ),
), ),
); );
@@ -210,11 +262,11 @@ class HubDetailsPage extends StatelessWidget {
title: Text(t.client_hubs.delete_dialog.title), title: Text(t.client_hubs.delete_dialog.title),
content: Text(t.client_hubs.delete_dialog.message(hubName: hub.name)), content: Text(t.client_hubs.delete_dialog.message(hubName: hub.name)),
actions: <Widget>[ actions: <Widget>[
TextButton( UiButton.text(
onPressed: () => Navigator.of(context).pop(false), onPressed: () => Navigator.of(context).pop(false),
child: Text(t.client_hubs.delete_dialog.cancel), child: Text(t.client_hubs.delete_dialog.cancel),
), ),
TextButton( UiButton.text(
onPressed: () => Navigator.of(context).pop(true), onPressed: () => Navigator.of(context).pop(true),
style: TextButton.styleFrom(foregroundColor: UiColors.destructive), style: TextButton.styleFrom(foregroundColor: UiColors.destructive),
child: Text(t.client_hubs.delete_dialog.delete), child: Text(t.client_hubs.delete_dialog.delete),