fix(ui): 打磨推荐追剧我的设置页间距与图标

This commit is contained in:
Vicky authored and trae-solo-agent committed 2026-10-28 16:36:51 +08:00
1 parent de7da64886
commit 5346be40a9
33 files changed
+1408 -811

No files matched your search

+161 -97
View File
@@ -17,28 +17,31 @@ import '../../core/theme/app_colors.dart';
import '../../core/theme/app_dimens.dart';
import '../../core/widgets/empty_state.dart';
import '../../l10n/app_localizations.dart';
import '../discover/search_page.dart';
import '../player/open_player.dart';
import '../recommend/widgets/search_gift_glyphs.dart';
import 'following_edit_bar.dart';
import 'following_favorites_grid.dart';
import 'following_history_card.dart';
import 'following_keep_alive_tab.dart';
import 'following_paged_grid.dart';
const double _doneFontSize = 14;
const double _doneTextGap = 12;
class FollowingPage extends StatefulWidget {
const FollowingPage({
super.key,
required this.onGoHome,
required this.favoriteController,
this.historyRequest = 0,
this.visible = true,
});
final VoidCallback onGoHome;
final FavoriteController favoriteController;
final int historyRequest;
/// 当前是否为首页选中的 tab;重新可见时刷新观看历史,保证横幅是最新进度。
final bool visible;
@override
State<FollowingPage> createState() => _FollowingPageState();
}
@@ -102,6 +105,9 @@ class _FollowingPageState extends State<FollowingPage> {
@override
void didUpdateWidget(covariant FollowingPage oldWidget) {
super.didUpdateWidget(oldWidget);
if (!oldWidget.visible && widget.visible) {
unawaited(_history.load());
}
if (oldWidget.historyRequest == widget.historyRequest) return;
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) _selectTab(FollowingTab.history);
@@ -111,9 +117,21 @@ class _FollowingPageState extends State<FollowingPage> {
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
return ColoredBox(
return DecoratedBox(
key: const Key('following-page'),
color: AppColors.appBackground,
// 纯黑底 + 顶部暗红光晕,与设计稿一致。
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
AppColors.followingGlow,
AppColors.followingGlowMid,
AppColors.appBackground,
],
stops: [0, 0.14, 0.3],
),
),
child: SafeArea(
bottom: false,
child: Column(
@@ -128,6 +146,7 @@ class _FollowingPageState extends State<FollowingPage> {
FollowingKeepAliveTab(
child: FollowingFavoritesGrid(
controller: widget.favoriteController,
history: _history,
selection: FollowingFavoriteSelection(
editing: _editing,
selected: _selected,
@@ -135,6 +154,9 @@ class _FollowingPageState extends State<FollowingPage> {
),
scrollController: _favoriteScroll,
onGoHome: widget.onGoHome,
onContinueRecord: (record) => unawaited(
_openHistory(context, _history, record),
),
),
),
FollowingKeepAliveTab(
@@ -165,119 +187,165 @@ class _FollowingPageState extends State<FollowingPage> {
}
Widget _header(AppLocalizations l10n) {
return SizedBox(
return Padding(
key: const Key('following-header'),
height: AppDimens.followingHeaderHeight,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: AppDimens.feedPageHorizontal,
),
child: ValueListenableBuilder<FollowingTab>(
valueListenable: _tab,
builder: (context, selectedTab, _) {
return ValueListenableBuilder<bool>(
valueListenable: _editing,
builder: (context, editing, _) {
padding: const EdgeInsets.fromLTRB(
AppDimens.feedPageHorizontal,
AppDimens.followingTitleTopGap,
AppDimens.feedPageHorizontal,
0,
),
child: Column(
children: [
SizedBox(
height: AppDimens.followingTitleRowHeight,
child: Row(
children: [
Expanded(
child: Text(
l10n.followingTab,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: AppColors.textPrimary,
fontSize: AppDimens.followingTitleFont,
fontWeight: FontWeight.w400,
height: 1.0,
),
),
),
_searchButton(l10n),
const SizedBox(width: AppDimens.followingHeaderActionGap),
_manageButton(l10n),
],
),
),
SizedBox(
height: AppDimens.followingSegmentRowHeight,
child: ValueListenableBuilder<FollowingTab>(
valueListenable: _tab,
builder: (context, selectedTab, _) {
return Row(
children: [
Expanded(
child: Row(
children: [
Flexible(
fit: FlexFit.loose,
child: _tabButton(
FollowingTab.favorites,
l10n.followingTab,
'favorites',
selectedTab == FollowingTab.favorites,
),
ListenableBuilder(
listenable: widget.favoriteController,
builder: (context, _) {
return _segment(
FollowingTab.favorites,
Text(
'${l10n.myFavorites} ${widget.favoriteController.total}',
maxLines: 1,
),
const SizedBox(width: AppDimens.followingTabGap),
Flexible(
fit: FlexFit.loose,
child: _tabButton(
FollowingTab.history,
l10n.watchHistory,
'history',
selectedTab == FollowingTab.history,
),
),
],
),
'favorites',
selectedTab == FollowingTab.favorites,
);
},
),
const SizedBox(width: AppDimens.followingSegmentGap),
_segment(
FollowingTab.history,
Text(l10n.watchHistory, maxLines: 1),
'history',
selectedTab == FollowingTab.history,
),
if (editing)
InkWell(
key: const Key('following-edit'),
onTap: _toggleEditing,
child: Padding(
padding: const EdgeInsets.only(left: _doneTextGap),
child: Text(
l10n.done,
style: const TextStyle(
color: AppColors.textPrimary,
fontSize: _doneFontSize,
fontWeight: FontWeight.w500,
),
),
),
)
else
Semantics(
button: true,
label: l10n.edit,
child: SizedBox(
width: AppDimens.followingEditHitSize,
height: AppDimens.followingEditHitSize,
child: InkWell(
key: const Key('following-edit'),
onTap: _toggleEditing,
child: const Align(
alignment: Alignment.centerRight,
child: Icon(
Icons.edit_outlined,
size: AppDimens.followingEditIconSize,
color: AppColors.textTabInactive,
),
),
),
),
),
],
);
},
);
},
),
),
],
),
);
}
Widget _searchButton(AppLocalizations l10n) {
return Semantics(
button: true,
label: l10n.search,
child: InkWell(
key: const Key('following-search'),
borderRadius: BorderRadius.circular(8),
onTap: () {
Navigator.of(context).push<void>(
MaterialPageRoute(builder: (_) => const SearchPage()),
);
},
child: Padding(
padding: EdgeInsets.all(4),
child: SearchGlyph(
size: AppDimens.followingSearchIcon,
color: AppColors.textPrimary,
),
),
),
);
}
Widget _tabButton(
Widget _manageButton(AppLocalizations l10n) {
return ValueListenableBuilder<bool>(
valueListenable: _editing,
builder: (context, editing, _) {
return InkWell(
key: const Key('following-edit'),
borderRadius: BorderRadius.circular(8),
onTap: _toggleEditing,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 2, vertical: 8),
child: Text(
editing ? l10n.done : l10n.manage,
style: const TextStyle(
color: AppColors.textPrimary,
fontSize: AppDimens.followingManageFont,
fontWeight: FontWeight.w400,
height: 1.0,
),
),
),
);
},
);
}
Widget _segment(
FollowingTab tab,
String label,
Widget label,
String keyName,
bool selected,
) {
return InkWell(
key: Key('following-tab-$keyName'),
onTap: () => _selectTab(tab),
child: SizedBox(
height: AppDimens.followingHeaderHeight,
child: Align(
alignment: Alignment.centerLeft,
widthFactor: 1,
child: AnimatedDefaultTextStyle(
borderRadius: BorderRadius.circular(8),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
AnimatedDefaultTextStyle(
duration: AppDimens.followingTabAnimationDuration,
style: TextStyle(
color: selected
? AppColors.textPrimary
: AppColors.textTabInactive,
fontSize: AppDimens.followingTabFont,
fontWeight: selected ? FontWeight.w600 : FontWeight.w400,
fontSize: AppDimens.followingSegmentFont,
fontWeight: FontWeight.w400,
),
child: Text(label, maxLines: 1, overflow: TextOverflow.ellipsis),
child: label,
),
),
const SizedBox(height: AppDimens.followingSegmentIndicatorTopGap),
AnimatedContainer(
duration: AppDimens.followingTabAnimationDuration,
curve: Curves.easeOut,
width: selected
? AppDimens.followingSegmentIndicatorWidth
: 0,
height: AppDimens.followingSegmentIndicatorHeight,
decoration: BoxDecoration(
color: AppColors.brandRed,
borderRadius: BorderRadius.circular(
AppDimens.followingSegmentIndicatorRadius,
),
),
),
],
),
);
}
@@ -329,10 +397,7 @@ class _FollowingPageState extends State<FollowingPage> {
Future<void> _cancelSelected() async {
final ids = _selected.value.toList();
if (ids.isEmpty || !mounted || !await confirmCancelFollowing(context)) {
return;
}
if (!mounted) return;
if (ids.isEmpty || !mounted) return;
final removed = await widget.favoriteController.removeMany(ids);
if (!removed || !mounted) return;
_selected.value = {};
@@ -424,8 +489,7 @@ class _HistoryList extends StatelessWidget {
onTap: openRecord,
onContinue: openRecord,
onRemove: () async {
if (await confirmHistoryRemove(context) &&
await controller.remove(record.dramaId) &&
if (await controller.remove(record.dramaId) &&
controller.records.isEmpty) {
onListEmptied();
}