Haptic feedback when refreshing timeline

This commit is contained in:
Thomas Ricouard 2022-12-29 09:10:59 +01:00
parent 5bc262da33
commit 789adc8b22

View file

@ -18,6 +18,8 @@ public struct TimelineView: View {
@StateObject private var viewModel = TimelineViewModel() @StateObject private var viewModel = TimelineViewModel()
@Binding var timeline: TimelineFilter @Binding var timeline: TimelineFilter
private let feedbackGenerator = UIImpactFeedbackGenerator()
public init(timeline: Binding<TimelineFilter>) { public init(timeline: Binding<TimelineFilter>) {
_timeline = timeline _timeline = timeline
} }
@ -46,7 +48,9 @@ public struct TimelineView: View {
viewModel.timeline = timeline viewModel.timeline = timeline
} }
.refreshable { .refreshable {
feedbackGenerator.impactOccurred(intensity: 0.3)
await viewModel.fetchStatuses(userIntent: true) await viewModel.fetchStatuses(userIntent: true)
feedbackGenerator.impactOccurred(intensity: 0.7)
} }
.onChange(of: watcher.latestEvent?.id) { id in .onChange(of: watcher.latestEvent?.id) { id in
if let latestEvent = watcher.latestEvent { if let latestEvent = watcher.latestEvent {