part of '../../core_app.dart';

/// 首屏启动阶段显示的加载浮层。
class LaunchOverlay extends StatelessWidget {
  /// 创建壳应用启动阶段的加载浮层。
  const LaunchOverlay({
    required this.progress,
    required this.hasMeasuredProgress,
    super.key,
  });

  /// 当前加载进度。
  final int progress;

  /// 当前进度值是否由 WebView 实际回传。
  final bool hasMeasuredProgress;

  @override
  Widget build(BuildContext context) {
    final splashImage = _env.splashImage;

    return ColoredBox(
      color: _shellBackgroundColor,
      child: Center(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            // ── 品牌 Logo ──
            if (splashImage != null)
              Container(
                width: 88,
                height: 88,
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(24),
                  boxShadow: <BoxShadow>[
                    BoxShadow(
                      color: _shellAccentColor.withValues(alpha: 0.2),
                      blurRadius: 20,
                      offset: const Offset(0, 6),
                    ),
                  ],
                ),
                child: ClipRRect(
                  borderRadius: BorderRadius.circular(24),
                  child: Image(
                    image: splashImage,
                    width: 88,
                    height: 88,
                    fit: BoxFit.contain,
                  ),
                ),
              )
            else
              Container(
                width: 88,
                height: 88,
                decoration: BoxDecoration(
                  gradient: LinearGradient(
                    colors: <Color>[
                      const Color(0xFF66E59A),
                      _shellAccentColor,
                    ],
                    begin: Alignment.topLeft,
                    end: Alignment.bottomRight,
                  ),
                  borderRadius: BorderRadius.circular(24),
                  boxShadow: <BoxShadow>[
                    BoxShadow(
                      color: _shellAccentColor.withValues(alpha: 0.3),
                      blurRadius: 20,
                      offset: const Offset(0, 6),
                    ),
                  ],
                ),
                alignment: Alignment.center,
                child: const Icon(
                  Icons.language_rounded,
                  size: 42,
                  color: Colors.white,
                ),
              ),
            const SizedBox(height: 24),
            // ── 品牌名称 ──
            Text(
              _env.appName,
              style: TextStyle(
                fontSize: 24,
                fontWeight: FontWeight.w800,
                color: _shellTextColor,
              ),
            ),
            const SizedBox(height: 36),
            // ── 不定态转圈 ──
            SizedBox(
              width: 32,
              height: 32,
              child: CircularProgressIndicator(
                strokeWidth: 3,
                valueColor: AlwaysStoppedAnimation<Color>(_shellAccentColor),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
