Files
umbrix/lib/features/common/custom_splash_screen.dart

83 lines
2.2 KiB
Dart
Raw Normal View History

import 'dart:math' as math;
import 'package:flutter/material.dart';
class CustomSplashScreen extends StatefulWidget {
const CustomSplashScreen({
super.key,
required this.onInitializationComplete,
});
final VoidCallback onInitializationComplete;
@override
State<CustomSplashScreen> createState() => _CustomSplashScreenState();
}
class _CustomSplashScreenState extends State<CustomSplashScreen> with SingleTickerProviderStateMixin {
late AnimationController _controller;
@override
void initState() {
super.initState();
_controller = AnimationController(
duration: const Duration(seconds: 2),
vsync: this,
)..repeat();
// Имитируем время загрузки, затем вызываем callback
Future.delayed(const Duration(milliseconds: 100), () {
if (mounted) {
widget.onInitializationComplete();
}
});
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
// UMBRIX: Всегда используем темную тему для splash screen
const isDark = true;
return Material(
color: const Color(0xFF191f23),
child: Center(
child: Stack(
alignment: Alignment.center,
children: [
// Крутящийся индикатор
AnimatedBuilder(
animation: _controller,
builder: (context, child) {
return Transform.rotate(
angle: _controller.value * 2 * math.pi,
child: const SizedBox(
width: 120,
height: 120,
child: CircularProgressIndicator(
strokeWidth: 6,
valueColor: AlwaysStoppedAnimation<Color>(
Color(0xFF2fbea5),
),
),
),
);
},
),
// Логотип в центре
Image.asset(
'assets/images/logo_splash.png',
width: 80,
height: 80,
),
],
),
),
);
}
}