- Integrated Firebase SDK in both Flutter apps (google-services, firebase_options) - Fixed auth flow, API client, and pairing/status blocs for dev environment - Added full Flutter project scaffolds (android, ios, web, etc.) - Added phase 3 chat engine requirement document - Added bugreport zip pattern to gitignore Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
46 lines
1.5 KiB
Dart
46 lines
1.5 KiB
Dart
import 'dart:async';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import 'core/auth/auth_bloc.dart';
|
|
import 'features/auth/screens/login_screen.dart';
|
|
import 'features/auth/screens/otp_screen.dart';
|
|
import 'features/home/home_screen.dart';
|
|
import 'features/chat/screens/active_sessions_screen.dart';
|
|
|
|
class _BlocRefreshNotifier extends ChangeNotifier {
|
|
late final StreamSubscription _subscription;
|
|
|
|
_BlocRefreshNotifier(AuthBloc bloc) {
|
|
_subscription = bloc.stream.listen((_) => notifyListeners());
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_subscription.cancel();
|
|
super.dispose();
|
|
}
|
|
}
|
|
|
|
GoRouter buildRouter(AuthBloc authBloc) {
|
|
return GoRouter(
|
|
initialLocation: '/login',
|
|
refreshListenable: _BlocRefreshNotifier(authBloc),
|
|
redirect: (context, state) {
|
|
final authState = authBloc.state;
|
|
final isAuthRoute = state.matchedLocation.startsWith('/login') ||
|
|
state.matchedLocation.startsWith('/otp');
|
|
|
|
if (authState is AuthLoading) return null;
|
|
if (authState is AuthAuthenticated) return isAuthRoute ? '/home' : null;
|
|
if (!isAuthRoute) return '/login';
|
|
return null;
|
|
},
|
|
routes: [
|
|
GoRoute(path: '/login', builder: (_, __) => const LoginScreen()),
|
|
GoRoute(path: '/otp', builder: (context, state) => OtpScreen(phone: state.extra as String)),
|
|
GoRoute(path: '/home', builder: (_, __) => const HomeScreen()),
|
|
GoRoute(path: '/sessions', builder: (_, __) => const ActiveSessionsScreen()),
|
|
],
|
|
);
|
|
}
|