import 'package:flutter/material.dart';

import '../../../core/l10n/app_localizations.dart';
import '../../../core/theme/app_colors.dart';

/// 网络错误占位体（无 Scaffold/AppBar）
/// 用于嵌入已有页面内容区，需要完整路由页面时使用 [NetworkErrorScreen]。
class NetworkErrorBody extends StatelessWidget {
  const NetworkErrorBody({super.key, required this.onRetry});
  final VoidCallback onRetry;

  @override
  Widget build(BuildContext context) {
    final cs = Theme.of(context).colorScheme;
    final l10n = AppLocalizations.of(context)!;
    return Center(
      child: Padding(
        padding: const EdgeInsets.symmetric(horizontal: 40),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            Container(
              width: 100, height: 100,
              decoration: const BoxDecoration(color: Color(0xFFF2F2F2), shape: BoxShape.circle),
              child: const Icon(Icons.wifi_off_rounded, size: 52, color: Color(0xFFBBBBBB)),
            ),
            const SizedBox(height: 28),
            Text(l10n.pageLoadFailed, style: TextStyle(color: cs.onSurface, fontSize: 17, fontWeight: FontWeight.w600)),
            const SizedBox(height: 10),
            Text(
              l10n.networkConnectionError,
              textAlign: TextAlign.center,
              style: TextStyle(color: cs.onSurface.withAlpha(153), fontSize: 13, height: 1.5),
            ),
            const SizedBox(height: 36),
            SizedBox(
              width: double.infinity, height: 50,
              child: FilledButton.icon(
                onPressed: onRetry,
                style: FilledButton.styleFrom(
                  backgroundColor: AppColors.brand,
                  foregroundColor: Colors.black,
                  shape: const StadiumBorder(),
                ),
                icon: const Icon(Icons.refresh_rounded, size: 18),
                label: Text(l10n.reload, style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w500)),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
