pr suggestions

This commit is contained in:
Mauro Romito
2026-03-30 13:50:48 +02:00
committed by Mauro
parent 96a13f718e
commit 42ac71cbc0
2 changed files with 8 additions and 7 deletions
@@ -521,11 +521,13 @@ extension TimelineTableViewController {
/// Computes the formatted date text for the topmost visible timeline item /// Computes the formatted date text for the topmost visible timeline item
/// and updates the floating date binding. /// and updates the floating date binding.
func updateFloatingDate() { func updateFloatingDate() {
guard let dateText = topmostVisibleDateText() else { guard let dateText = newestVisibleDateText() else {
return return
} }
// Before updating it already schedule it's removal or the future // Before updating it already schedule it's removal or the future.
// The schedule needs to happen regardless of a value change
// to extend the display duration of the floating date.
scheduleFloatingDateHide() scheduleFloatingDateHide()
// Only update on changes to avoid needless SwiftUI recomputation. // Only update on changes to avoid needless SwiftUI recomputation.
@@ -544,12 +546,12 @@ extension TimelineTableViewController {
DispatchQueue.main.asyncAfter(deadline: .now() + 2.0, execute: workItem) DispatchQueue.main.asyncAfter(deadline: .now() + 2.0, execute: workItem)
} }
/// Returns the formatted date text for the topmost visible timeline item. /// Returns the formatted date text for the newest visible timeline item.
/// ///
/// The table view is flipped (unless VoiceOver is running), so the "topmost" /// The table view is flipped (unless VoiceOver is running), so the "newest"
/// visible cell on screen is actually the *last* index path in `indexPathsForVisibleRows` /// visible cell on screen is actually the *last* index path in `indexPathsForVisibleRows`
/// when the table is flipped, or the *first* when it is not. /// when the table is flipped, or the *first* when it is not.
private func topmostVisibleDateText() -> String? { private func newestVisibleDateText() -> String? {
guard let visibleIndexPaths = tableView.indexPathsForVisibleRows, guard let visibleIndexPaths = tableView.indexPathsForVisibleRows,
!visibleIndexPaths.isEmpty else { !visibleIndexPaths.isEmpty else {
return nil return nil
@@ -33,8 +33,7 @@ struct FloatingDateBadge: View {
.foregroundColor(.compound.textPrimary) .foregroundColor(.compound.textPrimary)
.padding(.horizontal, 16) .padding(.horizontal, 16)
.padding(.vertical, 8) .padding(.vertical, 8)
.background(Capsule() .background(backgroundColor, in: .capsule)
.fill(backgroundColor))
.shadow(color: Color(red: 0.11, green: 0.11, blue: 0.13).opacity(0.1), radius: 12, x: 0, y: 4) .shadow(color: Color(red: 0.11, green: 0.11, blue: 0.13).opacity(0.1), radius: 12, x: 0, y: 4)
.transition(.opacity) .transition(.opacity)
} }