merge: 合并 K34-H 吸顶闪动修复

This commit is contained in:
Zhou Weidong committed 2026-10-20 15:25:15 +08:00
commit fdee89b345
2 files changed
+30 -17

No files matched your search

+20 -16
View File
@@ -37,7 +37,7 @@ const double _categoryTabGap = 20;
const double _categorySelectedFontSize = 16;
const double _categoryFontSize = 15;
const double _stickyHeaderHeight = 44;
const Duration _stickyHeaderTransition = Duration(milliseconds: 200);
const Duration _stickyHeaderTransition = Duration(milliseconds: 160);
/// K28-A2 剧场页:搜索、分类/语言 chips 与双列剧库。
class DiscoverPage extends StatefulWidget {
@@ -113,19 +113,23 @@ class _DiscoverPageState extends State<DiscoverPage> {
Widget _page(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
final categories = context.watch<CategoryController>();
final content = SafeArea(
bottom: !embedded,
child: Column(
children: [
DiscoverHeader(
controller: logic.search,
focusNode: logic.searchFocus,
onChanged: (_) => logic.onSearchChanged(),
loading: logic.searchLoading,
),
Expanded(child: _feed(l10n, categories)),
if (!embedded) _bottomNav(l10n),
],
final content = ColoredBox(
key: const Key('theater-page-surface'),
color: AppColors.ink,
child: SafeArea(
bottom: !embedded,
child: Column(
children: [
DiscoverHeader(
controller: logic.search,
focusNode: logic.searchFocus,
onChanged: (_) => logic.onSearchChanged(),
loading: logic.searchLoading,
),
Expanded(child: _feed(l10n, categories)),
if (!embedded) _bottomNav(l10n),
],
),
),
);
return AnnotatedRegion<SystemUiOverlayStyle>(
@@ -183,7 +187,7 @@ class _DiscoverPageState extends State<DiscoverPage> {
}
Widget _stickyHeader(AppLocalizations l10n, CategoryController categories) {
// 只有背景随吸顶状态变化,分类行内容(child)不参与重建,避免上滑闪烁。
// 背景常驻 ink,只有分隔线/阴影随吸顶状态过渡,避免透明→实色的闪动。
return ValueListenableBuilder<bool>(
valueListenable: _headerPinned,
builder: (context, pinned, child) => AnimatedContainer(
@@ -191,7 +195,7 @@ class _DiscoverPageState extends State<DiscoverPage> {
duration: _stickyHeaderTransition,
curve: Curves.easeOut,
decoration: BoxDecoration(
color: pinned ? AppColors.ink : Colors.transparent,
color: AppColors.ink,
border: Border(
bottom: BorderSide(
color: pinned ? AppColors.border : Colors.transparent,
+10 -1
View File
@@ -215,7 +215,7 @@ void main() {
final before = tester.getRect(
find.byKey(const Key('theater-sticky-header')),
);
expect(header().color, Colors.transparent);
expect(header().color, AppColors.ink);
await tester.drag(_verticalFeed, const Offset(0, -220));
await tester.pumpAndSettle();
@@ -227,6 +227,15 @@ void main() {
expect(header().color, AppColors.ink);
});
testWidgets('should_paint_theater_surface_with_ink', (tester) async {
await _pumpTheater(tester, categoryRepository: _GridCategoryRepository());
final surface = tester.widget<ColoredBox>(
find.byKey(const Key('theater-page-surface')),
);
expect(surface.color, AppColors.ink);
});
testWidgets('should_keep_category_row_stable_across_scrolls', (tester) async {
await _pumpTheater(
tester,