Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 47 additions & 10 deletions lib/pages/whitelist_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -344,24 +344,61 @@ class WhitelistPageState extends State<WhitelistPage> {
],
),

// 说明 + 搜索栏
// 说明文本(随列表滚动,不吸顶)
SliverToBoxAdapter(
child: Container(
child: Padding(
padding: const EdgeInsets.fromLTRB(16, 0, 16, 12),
child: AppListSearchHeader(
countText: _ctrl.showSystemApps
child: Text(
_ctrl.showSystemApps
? l10n.enabledAppsCountWithSystem(enabledCount)
: l10n.enabledAppsCount(enabledCount),
showCountText: true,
searchController: _searchCtrl,
searchFocusNode: _searchFocus,
hintText: l10n.searchApps,
onChanged: _ctrl.setSearch,
onClear: _clearSearch,
style: Theme.of(
context,
).textTheme.bodyMedium?.copyWith(color: cs.onSurfaceVariant),
),
),
),

// 搜索栏(仅搜索框吸顶)
SliverPersistentHeader(
pinned: true,
delegate: FixedSliverHeaderDelegate(
height: 60,
minHeight: 60,
builder: (context, overlapsContent, collapseProgress) {
final appBarTheme = Theme.of(context).appBarTheme;
final elevation = appBarTheme.scrolledUnderElevation ?? 3.0;
final pinnedBg = overlapsContent
? ElevationOverlay.applySurfaceTint(
cs.surface,
cs.surfaceTint,
elevation,
)
: cs.surface;
return Material(
color: pinnedBg,
surfaceTintColor: Theme.of(context).colorScheme.surfaceTint,
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

surfaceTintColor is provided on this Material, but elevation is always 0, so the tint will not be applied by Material (and the actual background tinting is already handled via ElevationOverlay.applySurfaceTint). Consider removing surfaceTintColor to avoid confusion, or set elevation to match the intended scrolled-under behavior and let Material handle tinting.

Suggested change
surfaceTintColor: Theme.of(context).colorScheme.surfaceTint,

Copilot uses AI. Check for mistakes.
elevation: 0,
child: Container(
padding: const EdgeInsets.fromLTRB(16, 0, 16, 12),
child: AppListSearchHeader(
countText: '',
showCountText: false,
searchController: _searchCtrl,
searchFocusNode: _searchFocus,
hintText: l10n.searchApps,
searchBarBackgroundColor: overlapsContent
? Colors.white
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

searchBarBackgroundColor is set to Colors.white when the header is pinned. This hard-codes a light color and will look incorrect (and may reduce contrast) in dark theme / dynamic color. Consider deriving the pinned search bar background from the current ColorScheme (e.g., a surface/container token, or conditional on Theme.of(context).brightness).

Suggested change
? Colors.white
? cs.surfaceContainerHighest

Copilot uses AI. Check for mistakes.
: cs.surfaceContainerHighest,
onChanged: _ctrl.setSearch,
onClear: _clearSearch,
),
),
);
},
),
),

// 内容区
if (_ctrl.loading)
const SliverFillRemaining(
Expand Down
6 changes: 5 additions & 1 deletion lib/widgets/app_list_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class AppListSearchHeader extends StatelessWidget {
super.key,
required this.countText,
this.showCountText = true,
this.searchBarBackgroundColor,
required this.searchController,
required this.searchFocusNode,
required this.hintText,
Expand All @@ -16,6 +17,7 @@ class AppListSearchHeader extends StatelessWidget {

final String countText;
final bool showCountText;
final Color? searchBarBackgroundColor;
final TextEditingController searchController;
final FocusNode searchFocusNode;
final String hintText;
Expand Down Expand Up @@ -53,7 +55,9 @@ class AppListSearchHeader extends StatelessWidget {
EdgeInsets.symmetric(horizontal: 16),
),
elevation: const WidgetStatePropertyAll(0),
backgroundColor: WidgetStatePropertyAll(cs.surfaceContainerHighest),
backgroundColor: WidgetStatePropertyAll(
searchBarBackgroundColor ?? cs.surfaceContainerHighest,
),
constraints: const BoxConstraints(minHeight: 48, maxHeight: 48),
),
],
Expand Down
Loading