mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Add permanent device deletion and refine frontend UI/snackbars
Backend:
- Add db::devices::delete to erase a device and its events atomically
- Expose DELETE /api/devices/{mac}/permanently, wired to OpenAPI
- Cover the new db method and endpoint with tests
Frontend:
- Delete action for not-registered devices (detail screen + list row)
and an opt-in "permanently delete" checkbox in the Forget dialog
- Navigate to the devices list after deleting from the detail screen
- Refine button emphasis to M3: single filled primary, error-colored
text buttons for destructive actions, Test demoted to filled-tonal
- Flash the backend-config Test button red on a failed connection test
- Render snackbars through a top-level ScaffoldMessenger host so they
show above dialogs; keep the built-in SnackBar (with an Overlay host)
Docs:
- CLAUDE.md: rustfmt edition 2024, don't revert formatter-only changes,
prefer built-in Flutter components, follow existing patterns + M3
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
2541d0989c
commit
587e097291
+131
-120
@@ -246,135 +246,146 @@ class _MainShellState extends State<MainShell> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final selectedIndex = _selectedIndex(_destinations, context);
|
||||
final width = constraints.maxWidth;
|
||||
// The shell gets its own ScaffoldMessenger so its Scaffold does not also
|
||||
// render snackbars: those are shown through the top-level messenger in
|
||||
// main.dart (rootMessengerKey), which paints above dialogs.
|
||||
return ScaffoldMessenger(
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final selectedIndex = _selectedIndex(_destinations, context);
|
||||
final width = constraints.maxWidth;
|
||||
|
||||
if (width < Breakpoints.medium) {
|
||||
if (width < Breakpoints.medium) {
|
||||
return Scaffold(
|
||||
appBar: _buildAppBar(context, selectedIndex),
|
||||
// The overlay pins the pagination progress bar flush against the
|
||||
// bottom of the body, i.e. the top of the navigation bar below.
|
||||
body: PaginationProgressOverlay(
|
||||
child: Column(
|
||||
children: [
|
||||
const OfflineBanner(),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(Insets.lg),
|
||||
child: widget.child,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: NavigationBar(
|
||||
selectedIndex: _selectedIndex(_barDestinations, context),
|
||||
onDestinationSelected: (index) =>
|
||||
_onDestinationSelected(_barDestinations[index], context),
|
||||
destinations: _barDestinations
|
||||
.map(
|
||||
(d) => NavigationDestination(
|
||||
icon: Icon(d.icon),
|
||||
selectedIcon: Icon(d.activeIcon),
|
||||
label: d.label,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final mediaPadding = MediaQuery.paddingOf(context);
|
||||
return Scaffold(
|
||||
appBar: _buildAppBar(context, selectedIndex),
|
||||
// The overlay pins the pagination progress bar flush against the
|
||||
// bottom of the body, i.e. the top of the navigation bar below.
|
||||
body: PaginationProgressOverlay(
|
||||
child: Column(
|
||||
children: [
|
||||
const OfflineBanner(),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(Insets.lg),
|
||||
child: widget.child,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: NavigationBar(
|
||||
selectedIndex: _selectedIndex(_barDestinations, context),
|
||||
onDestinationSelected: (index) =>
|
||||
_onDestinationSelected(_barDestinations[index], context),
|
||||
destinations: _barDestinations
|
||||
.map(
|
||||
(d) => NavigationDestination(
|
||||
icon: Icon(d.icon),
|
||||
selectedIcon: Icon(d.activeIcon),
|
||||
label: d.label,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final mediaPadding = MediaQuery.paddingOf(context);
|
||||
return Scaffold(
|
||||
appBar: _buildAppBar(context, selectedIndex),
|
||||
// The body is a Stack so the collapse/expand toggle can be positioned
|
||||
// freely within the rail (the rail's own slots give it an unbounded
|
||||
// width, which prevents reliable horizontal alignment).
|
||||
body: Stack(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
SafeArea(
|
||||
child: NavigationRail(
|
||||
backgroundColor: Theme.of(
|
||||
context,
|
||||
).colorScheme.surfaceContainerLow,
|
||||
minWidth: _kRailCompactWidth,
|
||||
minExtendedWidth: _kRailExtendedWidth,
|
||||
extended:
|
||||
width >= Breakpoints.expanded && _navRailExtended,
|
||||
destinations: _destinations
|
||||
.map(
|
||||
(d) => NavigationRailDestination(
|
||||
icon: Icon(d.icon),
|
||||
selectedIcon: Icon(d.activeIcon),
|
||||
label: Text(d.label),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
selectedIndex: selectedIndex,
|
||||
onDestinationSelected: (index) =>
|
||||
_onDestinationSelected(_destinations[index], context),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
// The overlay pins the pagination progress bar flush
|
||||
// against the very bottom of the content region (the
|
||||
// screen bottom).
|
||||
child: PaginationProgressOverlay(
|
||||
child: Column(
|
||||
children: [
|
||||
const OfflineBanner(),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(Insets.lg),
|
||||
child: widget.child,
|
||||
// The body is a Stack so the collapse/expand toggle can be positioned
|
||||
// freely within the rail (the rail's own slots give it an unbounded
|
||||
// width, which prevents reliable horizontal alignment).
|
||||
body: Stack(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
SafeArea(
|
||||
child: NavigationRail(
|
||||
backgroundColor: Theme.of(
|
||||
context,
|
||||
).colorScheme.surfaceContainerLow,
|
||||
minWidth: _kRailCompactWidth,
|
||||
minExtendedWidth: _kRailExtendedWidth,
|
||||
extended:
|
||||
width >= Breakpoints.expanded && _navRailExtended,
|
||||
destinations: _destinations
|
||||
.map(
|
||||
(d) => NavigationRailDestination(
|
||||
icon: Icon(d.icon),
|
||||
selectedIcon: Icon(d.activeIcon),
|
||||
label: Text(d.label),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
selectedIndex: selectedIndex,
|
||||
onDestinationSelected: (index) =>
|
||||
_onDestinationSelected(
|
||||
_destinations[index],
|
||||
context,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
// The overlay pins the pagination progress bar flush
|
||||
// against the very bottom of the content region (the
|
||||
// screen bottom).
|
||||
child: PaginationProgressOverlay(
|
||||
child: Column(
|
||||
children: [
|
||||
const OfflineBanner(),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(Insets.lg),
|
||||
child: widget.child,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
// The collapse/expand toggle, pinned to the bottom of the rail.
|
||||
// It sits centred like the other icons when the rail is compact
|
||||
// and slides to the rail's right side when it is extended. The
|
||||
// double chevron points the way the rail will move: inward («) to
|
||||
// collapse, outward (») to expand.
|
||||
if (width >= Breakpoints.expanded)
|
||||
AnimatedPositioned(
|
||||
// Match the rail's own extend/collapse animation so the toggle
|
||||
// slides with the edge instead of jumping after it settles.
|
||||
duration: kThemeAnimationDuration,
|
||||
curve: Curves.easeInOut,
|
||||
bottom: mediaPadding.bottom + Insets.md,
|
||||
left: _navRailExtended
|
||||
? mediaPadding.left +
|
||||
_kRailExtendedWidth -
|
||||
kMinInteractiveDimension -
|
||||
Insets.sm
|
||||
: mediaPadding.left +
|
||||
(_kRailCompactWidth - kMinInteractiveDimension) / 2,
|
||||
child: IconButton(
|
||||
icon: Icon(
|
||||
_navRailExtended
|
||||
? Icons.keyboard_double_arrow_left
|
||||
: Icons.keyboard_double_arrow_right,
|
||||
),
|
||||
tooltip: _navRailExtended ? 'Collapse menu' : 'Expand menu',
|
||||
onPressed: _toggleNavRailExtended,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
// The collapse/expand toggle, pinned to the bottom of the rail.
|
||||
// It sits centred like the other icons when the rail is compact
|
||||
// and slides to the rail's right side when it is extended. The
|
||||
// double chevron points the way the rail will move: inward («) to
|
||||
// collapse, outward (») to expand.
|
||||
if (width >= Breakpoints.expanded)
|
||||
AnimatedPositioned(
|
||||
// Match the rail's own extend/collapse animation so the toggle
|
||||
// slides with the edge instead of jumping after it settles.
|
||||
duration: kThemeAnimationDuration,
|
||||
curve: Curves.easeInOut,
|
||||
bottom: mediaPadding.bottom + Insets.md,
|
||||
left: _navRailExtended
|
||||
? mediaPadding.left +
|
||||
_kRailExtendedWidth -
|
||||
kMinInteractiveDimension -
|
||||
Insets.sm
|
||||
: mediaPadding.left +
|
||||
(_kRailCompactWidth - kMinInteractiveDimension) /
|
||||
2,
|
||||
child: IconButton(
|
||||
icon: Icon(
|
||||
_navRailExtended
|
||||
? Icons.keyboard_double_arrow_left
|
||||
: Icons.keyboard_double_arrow_right,
|
||||
),
|
||||
tooltip: _navRailExtended
|
||||
? 'Collapse menu'
|
||||
: 'Expand menu',
|
||||
onPressed: _toggleNavRailExtended,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user