feat(app): 剧场页九宫格与极简我的页
This commit is contained in:
1 parent
dc8ca7b743
commit
35338cbfc8
46 files changed
+2353
-4358
No files matched your search
@@ -0,0 +1,65 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/data/models/drama.dart';
|
||||
import '../../../core/formatting/error_text.dart';
|
||||
import '../../../core/widgets/empty_state.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
import 'drama_grid.dart';
|
||||
|
||||
/// 剧场搜索结果:加载、失败与空结果都留在同一页内。
|
||||
class DiscoverSearchResults extends StatelessWidget {
|
||||
const DiscoverSearchResults({
|
||||
super.key,
|
||||
required this.loading,
|
||||
required this.error,
|
||||
required this.results,
|
||||
required this.onRetry,
|
||||
required this.onOpen,
|
||||
});
|
||||
|
||||
final bool loading;
|
||||
final String? error;
|
||||
final List<Drama> results;
|
||||
final VoidCallback onRetry;
|
||||
final ValueChanged<Drama> onOpen;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 12),
|
||||
child: _content(l10n),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _content(AppLocalizations l10n) {
|
||||
if (loading) {
|
||||
return const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 80),
|
||||
child: Center(child: CircularProgressIndicator(strokeWidth: 2)),
|
||||
);
|
||||
}
|
||||
final message = error;
|
||||
if (message != null) {
|
||||
return EmptyState(
|
||||
key: const Key('discover-search-error'),
|
||||
icon: Icons.cloud_off_rounded,
|
||||
title: errorText(l10n, message, l10n.searchFailed),
|
||||
actionLabel: l10n.retry,
|
||||
actionKey: const Key('discover-search-retry'),
|
||||
onAction: onRetry,
|
||||
);
|
||||
}
|
||||
if (results.isEmpty) {
|
||||
return EmptyState(
|
||||
key: const Key('discover-search-empty'),
|
||||
icon: Icons.search_off_rounded,
|
||||
title: l10n.noSearchResults,
|
||||
subtitle: l10n.emptyHint,
|
||||
);
|
||||
}
|
||||
return DramaGrid(l10n: l10n, dramas: results, onOpen: onOpen);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user