62 lines
1.9 KiB
Dart
62 lines
1.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
import '/logic/user/user_cubit.dart';
|
|
|
|
class SplashScreen extends StatelessWidget {
|
|
const SplashScreen({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: BlocBuilder<UserCubit, UserState>(
|
|
builder: (context, state) {
|
|
if (state is UserLoading) {
|
|
return Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
const CircularProgressIndicator(),
|
|
const SizedBox(height: 20),
|
|
Text(
|
|
state.message,
|
|
style: Theme.of(context).textTheme.bodyLarge,
|
|
),
|
|
const SizedBox(height: 10),
|
|
Text(
|
|
'${(state.progress * 100).toInt()}%',
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
if (state is UserError) {
|
|
return Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Text(
|
|
'Ошибка загрузки',
|
|
style: Theme.of(context).textTheme.titleLarge,
|
|
),
|
|
const SizedBox(height: 20),
|
|
Text(state.message),
|
|
const SizedBox(height: 20),
|
|
ElevatedButton(
|
|
onPressed: () => context.read<UserCubit>().init(),
|
|
child: const Text('Повторить'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
return const Center(child: CircularProgressIndicator());
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|