diff --git a/lib/screens/auth_gate.dart b/lib/screens/auth_gate.dart new file mode 100644 index 0000000..f02c749 --- /dev/null +++ b/lib/screens/auth_gate.dart @@ -0,0 +1,23 @@ +/// Routes to [LoginScreen] or [MainShell] based on PocketBase auth. +library; + +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../providers/auth_provider.dart'; +import 'login_screen.dart'; +import 'main_shell.dart'; + +/// Root after splash: signed-out users see login; signed-in users see the shell. +class AuthGate extends StatelessWidget { + const AuthGate({super.key}); + + @override + Widget build(BuildContext context) { + final auth = context.watch(); + if (!auth.isLoggedIn) { + return const LoginScreen(asRoot: true); + } + return const MainShell(); + } +}