Files
social-app/apps/lib/features/auth/presentation/screens/auth_boot_screen.dart
T

49 lines
1.3 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../../../app/di/injection.dart';
import '../../../../app/services/app_prewarm_orchestrator.dart';
import '../bloc/auth_bloc.dart';
import '../bloc/auth_state.dart';
class AuthBootScreen extends StatefulWidget {
const AuthBootScreen({super.key});
@override
State<AuthBootScreen> createState() => _AuthBootScreenState();
}
class _AuthBootScreenState extends State<AuthBootScreen> {
@override
void initState() {
super.initState();
_triggerPrewarmIfAuthenticated(context.read<AuthBloc>().state);
}
void _triggerPrewarmIfAuthenticated(AuthState state) {
if (state is! AuthAuthenticated) {
return;
}
sl<AppPrewarmOrchestrator>().ensureStartedFor(state.user.id);
}
@override
Widget build(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;
return BlocListener<AuthBloc, AuthState>(
listener: (context, state) => _triggerPrewarmIfAuthenticated(state),
child: Scaffold(
backgroundColor: colorScheme.surface,
body: SafeArea(
child: Center(
child: Image.asset(
'assets/branding/assistant_octopus_foreground.png',
width: 260,
),
),
),
),
);
}
}