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) {
    return ColoredBox(
      color: _shellBackgroundColor,
      child: Center(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            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(
              '页面加载中',
              style: TextStyle(
                fontSize: 24,
                fontWeight: FontWeight.w800,
                color: _shellTextColor,
              ),
            ),
            const SizedBox(height: 10),
            Text(
              '正在为你启动 H5 页面',
              style: TextStyle(color: _shellMutedTextColor, fontSize: 14),
            ),
            const SizedBox(height: 36),
            Padding(
              padding: const EdgeInsets.symmetric(horizontal: 64),
              child: ClipRRect(
                borderRadius: BorderRadius.circular(6),
                child: LinearProgressIndicator(
                  minHeight: 6,
                  value: hasMeasuredProgress ? progress / 100 : null,
                  backgroundColor: const Color(0xFFE7F3EB),
                  valueColor: AlwaysStoppedAnimation<Color>(
                    _shellAccentColor,
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
