55 lines
1.4 KiB
Dart
55 lines
1.4 KiB
Dart
|
|
import 'package:flutter/material.dart';
|
||
|
|
import 'package:forui/forui.dart';
|
||
|
|
|
||
|
|
import 'app_error_state.dart';
|
||
|
|
import 'media_row_metrics.dart';
|
||
|
|
import 'media_poster_card.dart';
|
||
|
|
|
||
|
|
class ErrorMediaRow extends StatelessWidget {
|
||
|
|
final String title;
|
||
|
|
final String message;
|
||
|
|
final VoidCallback onRetry;
|
||
|
|
final MediaCardVariant cardVariant;
|
||
|
|
final Color? titleColor;
|
||
|
|
|
||
|
|
const ErrorMediaRow({
|
||
|
|
super.key,
|
||
|
|
required this.title,
|
||
|
|
required this.onRetry,
|
||
|
|
this.message = '加载失败',
|
||
|
|
this.cardVariant = MediaCardVariant.poster,
|
||
|
|
this.titleColor,
|
||
|
|
});
|
||
|
|
|
||
|
|
@override
|
||
|
|
Widget build(BuildContext context) {
|
||
|
|
final theme = Theme.of(context);
|
||
|
|
final compact = MediaRowMetrics.isCompact(context);
|
||
|
|
final rowHeight = MediaRowMetrics.rowHeight(cardVariant, compact: compact);
|
||
|
|
return Column(
|
||
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||
|
|
children: [
|
||
|
|
Padding(
|
||
|
|
padding: const EdgeInsets.fromLTRB(20, 16, 20, 12),
|
||
|
|
child: Text(
|
||
|
|
title,
|
||
|
|
style: theme.textTheme.titleMedium?.copyWith(color: titleColor),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
SizedBox(
|
||
|
|
height: rowHeight,
|
||
|
|
child: AppErrorState(
|
||
|
|
message: message,
|
||
|
|
compact: true,
|
||
|
|
action: FButton(
|
||
|
|
variant: FButtonVariant.outline,
|
||
|
|
onPress: onRetry,
|
||
|
|
child: const Text('重试'),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
],
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|