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