initial commit

This commit is contained in:
2026-07-27 14:42:23 +02:00
commit 833c68a189
257 changed files with 17947 additions and 0 deletions
+72
View File
@@ -0,0 +1,72 @@
import 'package:flutter/foundation.dart';
import 'package:go_router/go_router.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import '../../features/backups/backups_screen.dart';
import '../../features/dashboard/dashboard_screen.dart';
import '../../features/fleet/fleet_screen.dart';
import '../../features/services/services_screen.dart';
import '../../features/settings/settings_screen.dart';
import '../../features/updates/updates_screen.dart';
import '../connections/connection_providers.dart';
import '../widgets/nav_rail_shell.dart';
import 'route_paths.dart';
part 'app_router.g.dart';
/// Bridges Riverpod's [activeConnectionProvider] to go_router's
/// [Listenable]-based `refreshListenable` — so removing/adding the active
/// connection re-evaluates the top-level redirect immediately, not just on
/// the next navigation.
class _ConnectionRefreshListenable extends ChangeNotifier {
_ConnectionRefreshListenable(Ref ref) {
ref.listen(activeConnectionProvider, (previous, next) => notifyListeners());
}
}
@Riverpod(keepAlive: true)
GoRouter appRouter(Ref ref) {
return GoRouter(
initialLocation: RoutePaths.dashboard,
refreshListenable: _ConnectionRefreshListenable(ref),
redirect: (context, state) {
final hasConnection = ref.read(activeConnectionProvider) != null;
final onSettings = state.matchedLocation == RoutePaths.settings;
if (!hasConnection && !onSettings) return RoutePaths.settings;
return null;
},
routes: [
ShellRoute(
builder: (context, state, child) {
return NavRailShell(currentPath: state.uri.path, child: child);
},
routes: [
GoRoute(
path: RoutePaths.dashboard,
builder: (context, state) => const DashboardScreen(),
),
GoRoute(
path: RoutePaths.services,
builder: (context, state) => ServicesScreen(serviceId: state.uri.queryParameters['id']),
),
GoRoute(
path: RoutePaths.backups,
builder: (context, state) => const BackupsScreen(),
),
GoRoute(
path: RoutePaths.fleet,
builder: (context, state) => const FleetScreen(),
),
GoRoute(
path: RoutePaths.updates,
builder: (context, state) => const UpdatesScreen(),
),
GoRoute(
path: RoutePaths.settings,
builder: (context, state) => const SettingsScreen(),
),
],
),
],
);
}
+51
View File
@@ -0,0 +1,51 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'app_router.dart';
// **************************************************************************
// RiverpodGenerator
// **************************************************************************
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint, type=warning
@ProviderFor(appRouter)
const appRouterProvider = AppRouterProvider._();
final class AppRouterProvider
extends $FunctionalProvider<GoRouter, GoRouter, GoRouter>
with $Provider<GoRouter> {
const AppRouterProvider._()
: super(
from: null,
argument: null,
retry: null,
name: r'appRouterProvider',
isAutoDispose: false,
dependencies: null,
$allTransitiveDependencies: null,
);
@override
String debugGetCreateSourceHash() => _$appRouterHash();
@$internal
@override
$ProviderElement<GoRouter> $createElement($ProviderPointer pointer) =>
$ProviderElement(pointer);
@override
GoRouter create(Ref ref) {
return appRouter(ref);
}
/// {@macro riverpod.override_with_value}
Override overrideWithValue(GoRouter value) {
return $ProviderOverride(
origin: this,
providerOverride: $SyncValueProvider<GoRouter>(value),
);
}
}
String _$appRouterHash() => r'564cdc8b6bb47dea31d32b10bbfa1253170018af';
+17
View File
@@ -0,0 +1,17 @@
/// Route path constants — the single source of truth so screens and the
/// nav rail never hand-type a path string more than once.
abstract final class RoutePaths {
static const dashboard = '/dashboard';
static const services = '/services';
static const backups = '/backups';
static const fleet = '/fleet';
static const updates = '/updates';
static const settings = '/settings';
/// The service id is a query parameter (`?id=`), not a path segment.
/// `/services` and `/services?id=x` are the *same* go_router route, so
/// switching between them updates the existing page in place — no page
/// transition — which is what makes the slide-over panel read as an
/// overlay on the list rather than a navigation to a new screen.
static String serviceDetail(String id) => '/services?id=$id';
}