From 0e0cdec040b5956a13da32f8915dcc10117eca64 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Fri, 9 Oct 2026 11:41:08 -0700 Subject: [PATCH] Create and use isActiveSelection function. --- iOS/MainTimeline/Cell/MainTimelineCell.swift | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/iOS/MainTimeline/Cell/MainTimelineCell.swift b/iOS/MainTimeline/Cell/MainTimelineCell.swift index bf434aae3..2733a17ee 100644 --- a/iOS/MainTimeline/Cell/MainTimelineCell.swift +++ b/iOS/MainTimeline/Cell/MainTimelineCell.swift @@ -102,15 +102,14 @@ final class MainTimelineCell: UICollectionViewCell { backgroundConfig.cornerRadius = 0 } - // Matches the feeds list: accent background when the timeline is first responder, gray otherwise. - let isActiveSelection = state.isSelected && isInExpandedSplitView && enclosingViewController?.isFirstResponder == true + let showsAccentSelection = isActiveSelection(state) if state.isSwiped { backgroundConfig.backgroundColor = .secondarySystemFill } else if state.isSelected { // When collapsed, keep the standard system selection color from updated(for: state). if isInExpandedSplitView { - backgroundConfig.backgroundColor = isActiveSelection ? Assets.Colors.primaryAccent : .tertiarySystemFill + backgroundConfig.backgroundColor = showsAccentSelection ? Assets.Colors.primaryAccent : .tertiarySystemFill } } else { backgroundConfig.backgroundColor = .clear @@ -126,8 +125,8 @@ final class MainTimelineCell: UICollectionViewCell { topSeparator.alpha = (isActive || isPreview) ? 0.0 : 1.0 // Text goes white only on the accent background. On gray, labels keep their normal colors. - updateColors(active: isActiveSelection) - updateIndicatorView(active: isActiveSelection) + updateColors(active: showsAccentSelection) + updateIndicatorView(active: showsAccentSelection) } func setIconImage(_ image: IconImage) { @@ -216,13 +215,18 @@ private extension MainTimelineCell { iconView.isHidden = true } - let active = configurationState.isSelected && isInExpandedSplitView + let active = isActiveSelection(configurationState) updateColors(active: active) updateIndicatorView(active: active) updateAccessibilityLabel() setNeedsLayout() } + /// Matches the feeds list: accent background (and white text) when the timeline is first responder, gray otherwise. + func isActiveSelection(_ state: UICellConfigurationState) -> Bool { + state.isSelected && isInExpandedSplitView && enclosingViewController?.isFirstResponder == true + } + func updateColors(active: Bool) { titleView.textColor = active ? .white : .label summaryView.textColor = active ? .white : (cellData.title.isEmpty ? .label : .secondaryLabel)