feat(app): 客户端展示多语言并支持筛选分页

This commit is contained in:
Zhou Weidong committed 2026-10-24 17:20:24 +08:00
1 parent 8481611372
commit 8b50b5bd06
68 files changed
+2742 -1120

No files matched your search

@@ -0,0 +1,89 @@
// Author: fruit.com.cn
// 剧场顶部分类标签和选中下划线。
import 'package:flutter/material.dart';
import '../../../core/theme/app_colors.dart';
const double _selectedFontSize = 16;
const double _fontSize = 15;
const double _underlineWidth = 20;
const double _underlineHeight = 3;
const double _underlineStrokeWidth = 2;
/// 一个可横向滚动的分类标签。
class DiscoverCategoryTab extends StatelessWidget {
const DiscoverCategoryTab({
super.key,
required this.id,
required this.anchorKey,
required this.label,
required this.selected,
required this.onTap,
});
final String id;
final GlobalKey anchorKey;
final String label;
final bool selected;
final VoidCallback onTap;
@override
Widget build(BuildContext context) {
return KeyedSubtree(
key: anchorKey,
child: GestureDetector(
key: Key('theater-category-$id'),
behavior: HitTestBehavior.opaque,
onTap: onTap,
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
label,
maxLines: 1,
style: TextStyle(
color: selected ? AppColors.onSurface : AppColors.muted,
fontSize: selected ? _selectedFontSize : _fontSize,
fontWeight: selected ? FontWeight.w800 : FontWeight.w500,
),
),
const SizedBox(height: 4),
CustomPaint(
key: Key('theater-category-underline-$id'),
size: const Size(_underlineWidth, _underlineHeight),
painter: CategoryUnderlinePainter(
color: selected ? AppColors.blue : AppColors.transparent,
),
),
],
),
),
);
}
}
/// 分类 tab 的弧形选中线。
class CategoryUnderlinePainter extends CustomPainter {
const CategoryUnderlinePainter({required this.color});
final Color color;
@override
void paint(Canvas canvas, Size size) {
final paint = Paint()
..color = color
..style = PaintingStyle.stroke
..strokeWidth = _underlineStrokeWidth
..strokeCap = StrokeCap.round;
final path = Path()
..moveTo(1, 1)
..quadraticBezierTo(size.width / 2, size.height + 1, size.width - 1, 1);
canvas.drawPath(path, paint);
}
@override
bool shouldRepaint(covariant CategoryUnderlinePainter oldDelegate) =>
color != oldDelegate.color;
}
@@ -0,0 +1,119 @@
// Author: fruit.com.cn
// 剧场页筛选、排行、新剧、预约四个入口。
import 'package:flutter/material.dart';
import '../../../core/theme/app_colors.dart';
import '../../../l10n/app_localizations.dart';
import '../../filter/filter_page.dart';
import '../../new_releases/new_releases_page.dart';
import '../../ranking/ranking_page.dart';
import '../../reserve/reserve_page.dart';
const double _toolbarHeight = 36;
const double _toolbarGap = 10;
const double _toolbarRadius = 10;
const Color _filterIconColor = AppColors.blueSoft;
const Color _newIconColor = AppColors.blueSoft;
/// 剧场工具条。点按后由调用方打开对应页面。
class DiscoverToolbar extends StatelessWidget {
const DiscoverToolbar({super.key, required this.onOpen});
final void Function(Widget page) onOpen;
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
return Padding(
padding: const EdgeInsets.fromLTRB(14, 2, 14, 12),
child: Row(
children: [
Expanded(
child: _button(
key: const Key('theater-toolbar-filter'),
icon: Icons.tune_rounded,
color: _filterIconColor,
label: l10n.filter,
onTap: () => onOpen(const FilterPage()),
),
),
const SizedBox(width: _toolbarGap),
Expanded(
child: _button(
key: const Key('theater-toolbar-ranking'),
icon: Icons.local_fire_department_rounded,
color: AppColors.blue,
label: l10n.rankingTab,
onTap: () => onOpen(const RankingPage()),
),
),
const SizedBox(width: _toolbarGap),
Expanded(
child: _button(
key: const Key('theater-toolbar-new'),
icon: Icons.play_circle_fill_rounded,
color: _newIconColor,
label: l10n.newDramas,
onTap: () => onOpen(const NewReleasesPage()),
),
),
const SizedBox(width: _toolbarGap),
Expanded(
child: _button(
key: const Key('theater-toolbar-reserve'),
icon: Icons.calendar_month_rounded,
color: AppColors.blue,
label: l10n.reserve,
onTap: () => onOpen(const ReservePage()),
),
),
],
),
);
}
Widget _button({
required Key key,
required IconData icon,
required Color color,
required String label,
required VoidCallback onTap,
}) {
return Material(
color: AppColors.card,
borderRadius: BorderRadius.circular(_toolbarRadius),
child: InkWell(
key: key,
onTap: onTap,
borderRadius: BorderRadius.circular(_toolbarRadius),
child: Container(
height: _toolbarHeight,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(_toolbarRadius),
border: Border.all(color: AppColors.border),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(icon, size: 16, color: color),
const SizedBox(width: 4),
Flexible(
child: Text(
label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: AppColors.onSurface,
fontSize: 13,
fontWeight: FontWeight.w600,
),
),
),
],
),
),
),
);
}
}
+9 -7
View File
@@ -96,9 +96,9 @@ class DramaGridCard extends StatelessWidget {
children: [
_cover(),
const SizedBox(height: _titleGap),
_title(),
_title(context),
const SizedBox(height: _tagsGap),
_tags(),
_tags(context),
],
),
);
@@ -151,9 +151,9 @@ class DramaGridCard extends StatelessWidget {
);
}
Widget _title() {
Widget _title(BuildContext context) {
return Text(
drama.title,
drama.localizedTitle(Localizations.localeOf(context).languageCode),
key: Key('home-drama-title-${drama.id}'),
maxLines: 2,
overflow: TextOverflow.ellipsis,
@@ -166,8 +166,8 @@ class DramaGridCard extends StatelessWidget {
);
}
Widget _tags() {
final tags = _tagValues();
Widget _tags(BuildContext context) {
final tags = _tagValues(context);
if (tags.isEmpty) return const SizedBox.shrink();
return Wrap(
spacing: 6,
@@ -193,7 +193,9 @@ class DramaGridCard extends StatelessWidget {
);
}
List<String> _tagValues() {
List<String> _tagValues(BuildContext context) {
final localized = drama.localizedTypeLabels(Localizations.localeOf(context).languageCode);
if (localized.isNotEmpty) return localized.take(3).toList(growable: false);
final result = <String>[];
for (final value in [drama.genre, drama.category]) {
for (final part in value.split(_tagSplitter)) {
@@ -16,7 +16,7 @@ class SearchResultCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
final tags = _tags();
final tags = _tags(context);
return Material(
key: Key('search-result-card-${drama.id}'),
color: AppColors.transparent,
@@ -60,7 +60,7 @@ class SearchResultCard extends StatelessWidget {
),
const SizedBox(height: AppDimens.searchResultTitleGap),
Text(
drama.title,
drama.localizedTitle(Localizations.localeOf(context).languageCode),
key: Key('search-result-title-${drama.id}'),
maxLines: 2,
overflow: TextOverflow.ellipsis,
@@ -92,7 +92,9 @@ class SearchResultCard extends StatelessWidget {
);
}
List<String> _tags() {
List<String> _tags(BuildContext context) {
final localized = drama.localizedTypeLabels(Localizations.localeOf(context).languageCode);
if (localized.isNotEmpty) return localized.take(3).toList(growable: false);
final seen = <String>{};
return [drama.genre, drama.category]
.expand((value) => value.split(RegExp(r'[,/、·]')))