refactor(apps): 重构数据层目录结构并新增启动预热编排器
This commit is contained in:
@@ -1,18 +1,45 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
class AuthBootScreen extends StatelessWidget {
|
||||
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 Scaffold(
|
||||
backgroundColor: colorScheme.surface,
|
||||
body: SafeArea(
|
||||
child: Center(
|
||||
child: Image.asset(
|
||||
'assets/branding/assistant_octopus_foreground.png',
|
||||
width: 260,
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user