Scroll to today's meeting when the meeting view appears

This commit is contained in:
Benoit Martins 2025-06-25 09:27:28 +02:00
parent dc722938c1
commit 54fa7be51d
2 changed files with 6 additions and 2 deletions

View file

@ -153,11 +153,11 @@ struct MeetingsFragment: View {
.listRowSeparator(.hidden)
}
.onAppear {
proxyReader.scrollTo(meetingsListViewModel.todayIdx)
proxyReader.scrollTo(meetingsListViewModel.todayIdx, anchor: .top)
}
.onReceive(NotificationCenter.default.publisher(for: MeetingsListViewModel.ScrollToTodayNotification)) { _ in
withAnimation {
proxyReader.scrollTo(meetingsListViewModel.todayIdx)
proxyReader.scrollTo(meetingsListViewModel.todayIdx, anchor: .top)
}
}
.safeAreaInset(edge: .top, content: {

View file

@ -118,6 +118,10 @@ class MeetingsListViewModel: ObservableObject {
self.todayIdx = todayIdx
self.meetingsList = meetingsListTmp
}
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
NotificationCenter.default.post(name: MeetingsListViewModel.ScrollToTodayNotification, object: nil)
}
}
}