Added configuration redirect and partial settings form

This commit is contained in:
rzuasti
2026-03-02 19:41:01 -05:00
parent e6b5594226
commit 1d029c8c5f
3 changed files with 119 additions and 4 deletions
+12 -1
View File
@@ -1,9 +1,12 @@
import 'package:flutter/material.dart';
import 'package:frontend/settings/settings.dart';
import 'package:go_router/go_router.dart';
import 'notifications/notification_list.dart';
import 'utils/pref_utils.dart';
// Routes definitions
final GoRouter router = GoRouter(
// If there is no API base URL send the user to settings
initialLocation: '/notifications',
routes: [
ShellRoute(
@@ -15,16 +18,18 @@ final GoRouter router = GoRouter(
path: '/notifications',
name: 'notifications',
builder: (context, state) => NotificationList(),
redirect: (context, state) => _redirectToSettings(),
),
GoRoute(
path: '/devices',
name: 'devices',
builder: (context, state) => const Placeholder(),
redirect: (context, state) => _redirectToSettings(),
),
GoRoute(
path: '/settings',
name: 'settings',
builder: (context, state) => const Placeholder(),
builder: (context, state) => Settings(),
),
GoRoute(
path: '/about',
@@ -103,6 +108,12 @@ class MainShell extends StatelessWidget {
}
}
String? _redirectToSettings() {
return (PrefUtil.getValue("base_url", "") as String == "")
? '/settings'
: null;
}
int _calculateSelectedIndex(BuildContext context) {
final location = GoRouterState.of(context).uri.path;
if (location.startsWith('/notifications')) return 0;