Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
40ba6a869d |
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [1.3.1] - 2026-01-05
|
||||
|
||||
### Fixed
|
||||
- Default room preference now applies on app load
|
||||
- Root `/` redirects to user's preferred default room
|
||||
- Front Hall moved to `/front-hall` route (was `/`)
|
||||
|
||||
## [1.3.0] - 2026-01-05
|
||||
|
||||
### Added
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:tatlock_ui/core/auth/auth_provider.dart';
|
||||
import 'package:tatlock_ui/features/control_room/router.dart';
|
||||
import 'package:tatlock_ui/features/front_hall/presentation/pages/front_hall_page.dart';
|
||||
import 'package:tatlock_ui/features/security/router.dart';
|
||||
@@ -19,18 +20,44 @@ Page<void> noTransitionPage(BuildContext context, GoRouterState state, Widget ch
|
||||
|
||||
/// Route paths as constants.
|
||||
abstract class AppRoutes {
|
||||
static const frontHall = '/';
|
||||
static const root = '/';
|
||||
static const frontHall = '/front-hall';
|
||||
static const parlor = '/parlor';
|
||||
static const settings = '/settings';
|
||||
}
|
||||
|
||||
/// Maps defaultRoom preference value to route path.
|
||||
String _routeForDefaultRoom(String? defaultRoom) {
|
||||
return switch (defaultRoom) {
|
||||
'control-room' => ControlRoomRoutes.containers,
|
||||
'security' => SecurityRoutes.users,
|
||||
'parlor' => AppRoutes.parlor,
|
||||
_ => AppRoutes.frontHall,
|
||||
};
|
||||
}
|
||||
|
||||
/// Provides the GoRouter instance.
|
||||
@riverpod
|
||||
GoRouter appRouter(Ref ref) {
|
||||
final authState = ref.watch(authProvider);
|
||||
|
||||
return GoRouter(
|
||||
initialLocation: AppRoutes.frontHall,
|
||||
initialLocation: AppRoutes.root,
|
||||
debugLogDiagnostics: true,
|
||||
redirect: (context, state) {
|
||||
// Redirect from root to user's default room preference
|
||||
if (state.matchedLocation == AppRoutes.root) {
|
||||
final defaultRoom = authState.value?.preferences?.defaultRoom;
|
||||
return _routeForDefaultRoom(defaultRoom);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
routes: [
|
||||
// Root redirects to default room (handled by redirect callback above)
|
||||
GoRoute(
|
||||
path: AppRoutes.root,
|
||||
redirect: (context, state) => AppRoutes.frontHall,
|
||||
),
|
||||
// Main app routes (inside shell with app scaffold)
|
||||
ShellRoute(
|
||||
builder: (context, state, child) => AppScaffold(child: child),
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
# In Windows, build-name is used as the major, minor, and patch parts
|
||||
# of the product and file versions while build-number is used as the build suffix.
|
||||
version: 1.3.0+1
|
||||
version: 1.3.1+1
|
||||
|
||||
environment:
|
||||
sdk: ^3.10.4
|
||||
|
||||
Reference in New Issue
Block a user