Add an action to the newly introduced FloatingDateBadge that scrolls the timeline to that day. (#5350)

and replace the TimelnieTableViewController's `floatingDateText` with a pure date.
This commit is contained in:
Stefan Ceriu
2026-04-14 11:27:27 +03:00
committed by GitHub
parent 07b139b307
commit 7ff2cf618b
11 changed files with 73 additions and 37 deletions
@@ -13,6 +13,7 @@ import SwiftUI
/// fades out shortly after scrolling stops.
struct FloatingDateBadge: View {
let dateText: String?
var onTap: (() -> Void)?
@Environment(\.colorScheme) private var colorScheme: ColorScheme
@@ -28,14 +29,18 @@ struct FloatingDateBadge: View {
var body: some View {
ZStack {
if let dateText {
Text(dateText)
.font(.compound.bodySMSemibold)
.foregroundColor(.compound.textPrimary)
.padding(.horizontal, 16)
.padding(.vertical, 8)
.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)
Button { onTap?() } label: {
Text(dateText)
.font(.compound.bodySMSemibold)
.foregroundColor(.compound.textPrimary)
.padding(.horizontal, 16)
.padding(.vertical, 8)
.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)
}
.buttonStyle(.plain)
.disabled(onTap == nil)
.transition(.opacity)
}
}
.animation(.easeInOut(duration: 0.15).disabledDuringTests(), value: dateText)
@@ -83,8 +83,9 @@ struct TimelineViewRepresentable: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> TimelineTableViewController {
TimelineTableViewController(coordinator: context.coordinator,
isScrolledToBottom: $viewModelContext.isScrolledToBottom,
floatingDateText: $viewModelContext.floatingDateText,
scrollToBottomPublisher: viewModelContext.viewState.timelineState.scrollToBottomPublisher)
floatingDate: $viewModelContext.floatingDate,
scrollToBottomPublisher: viewModelContext.viewState.timelineState.scrollToBottomPublisher,
scrollToFirstItemForDatePublisher: viewModelContext.viewState.timelineState.scrollToFirstItemForDatePublisher)
}
func updateUIViewController(_ uiViewController: TimelineTableViewController, context: Context) {