diff --git a/ElementX/Sources/Screens/Timeline/TimelineTableViewController.swift b/ElementX/Sources/Screens/Timeline/TimelineTableViewController.swift index 624693f8e..fd46ad3de 100644 --- a/ElementX/Sources/Screens/Timeline/TimelineTableViewController.swift +++ b/ElementX/Sources/Screens/Timeline/TimelineTableViewController.swift @@ -521,11 +521,13 @@ extension TimelineTableViewController { /// Computes the formatted date text for the topmost visible timeline item /// and updates the floating date binding. func updateFloatingDate() { - guard let dateText = topmostVisibleDateText() else { + guard let dateText = newestVisibleDateText() else { 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() // Only update on changes to avoid needless SwiftUI recomputation. @@ -544,12 +546,12 @@ extension TimelineTableViewController { 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` /// 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, !visibleIndexPaths.isEmpty else { return nil diff --git a/ElementX/Sources/Screens/Timeline/View/FloatingDateBadge.swift b/ElementX/Sources/Screens/Timeline/View/FloatingDateBadge.swift index 9b72fa6ab..624c677b0 100644 --- a/ElementX/Sources/Screens/Timeline/View/FloatingDateBadge.swift +++ b/ElementX/Sources/Screens/Timeline/View/FloatingDateBadge.swift @@ -33,8 +33,7 @@ struct FloatingDateBadge: View { .foregroundColor(.compound.textPrimary) .padding(.horizontal, 16) .padding(.vertical, 8) - .background(Capsule() - .fill(backgroundColor)) + .background(backgroundColor, in: .capsule) .shadow(color: Color(red: 0.11, green: 0.11, blue: 0.13).opacity(0.1), radius: 12, x: 0, y: 4) .transition(.opacity) }