games_app/prediqo_mobile/lib/shared/widgets/section_error.dart

67 lines
1.9 KiB
Dart

import 'package:flutter/material.dart';
import '../../core/theme/app_colors.dart';
import '../../l10n/app_strings.dart';
/// Localized section failure with a single retry action (no full-page blank).
class SectionError extends StatelessWidget {
const SectionError({
super.key,
required this.message,
required this.onRetry,
this.compact = false,
this.retrying = false,
});
final String message;
final VoidCallback? onRetry;
final bool compact;
final bool retrying;
@override
Widget build(BuildContext context) {
final s = context.strings;
final pad = compact ? 12.0 : 16.0;
return Container(
width: double.infinity,
padding: EdgeInsets.all(pad),
decoration: BoxDecoration(
color: AppColors.surfaceCard,
borderRadius: BorderRadius.circular(16),
border: Border.all(color: AppColors.border),
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Icon(
Icons.wifi_off_rounded,
color: AppColors.warning,
size: compact ? 20 : 24,
),
const SizedBox(width: 12),
Expanded(
child: Text(
message,
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: AppColors.textSecondary,
),
),
),
const SizedBox(width: 8),
IconButton(
key: const Key('section_error_retry'),
tooltip: s.retry,
onPressed: retrying ? null : onRetry,
icon: retrying
? const SizedBox(
width: 18,
height: 18,
child: CircularProgressIndicator(strokeWidth: 2),
)
: const Icon(Icons.refresh_rounded, color: AppColors.primary),
),
],
),
);
}
}