From 28826970fc2a6a01b0cc2758d7e899baf20d76d4 Mon Sep 17 00:00:00 2001 From: Satindar Dhillon Date: Tue, 13 Sep 2022 08:08:04 -0700 Subject: [PATCH 1/2] dismiss current reader view when tapping view article from audio sheet --- .../App/Views/Home/HomeFeedViewModel.swift | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewModel.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewModel.swift index a06d06fdc..264cbbcb5 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewModel.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewModel.swift @@ -36,8 +36,26 @@ import Views ) func handleReaderItemNotification(objectID: NSManagedObjectID, dataService: DataService) { - selectedItem = dataService.viewContext.object(with: objectID) as? LinkedItem - linkIsActive = true + // Pop the current selected item if needed + if selectedItem != nil, selectedItem?.objectID != objectID { + // Temporarily disable animation to avoid excessive animations + UIView.setAnimationsEnabled(false) + + linkIsActive = false + selectedItem = nil + + DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(100)) { + self.selectedItem = dataService.viewContext.object(with: objectID) as? LinkedItem + self.linkIsActive = true + } + + DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(200)) { + UIView.setAnimationsEnabled(true) + } + } else { + selectedItem = dataService.viewContext.object(with: objectID) as? LinkedItem + linkIsActive = true + } } var cursor: String? From eab6911bcba0d31984b57e4d0c6110e14626e92c Mon Sep 17 00:00:00 2001 From: Satindar Dhillon Date: Tue, 13 Sep 2022 08:39:23 -0700 Subject: [PATCH 2/2] mask bottom of mini player safe area so list view doesn't peek through there --- .../App/Views/AudioPlayer/MiniPlayer.swift | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/MiniPlayer.swift b/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/MiniPlayer.swift index e29f62ff0..5081ed0d1 100644 --- a/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/MiniPlayer.swift +++ b/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/MiniPlayer.swift @@ -348,15 +348,20 @@ public struct MiniPlayer: View { public var body: some View { ZStack(alignment: .center) { presentingView - VStack { - Spacer(minLength: 0) - if let itemAudioProperties = self.audioController.itemAudioProperties, isPresented { - playerContent(itemAudioProperties) - .offset(y: offset) - .frame(maxHeight: expanded ? .infinity : 88) - .tint(.appGrayTextContrast) - .gesture(DragGesture().onEnded(onDragEnded(value:)).onChanged(onDragChanged(value:))) - .background(expanded ? .clear : .systemBackground) + if let itemAudioProperties = self.audioController.itemAudioProperties, isPresented { + ZStack(alignment: .bottom) { + Color.systemBackground.edgesIgnoringSafeArea(.bottom) + .frame(height: 88, alignment: .bottom) + + VStack { + Spacer(minLength: 0) + playerContent(itemAudioProperties) + .offset(y: offset) + .frame(maxHeight: expanded ? .infinity : 88) + .tint(.appGrayTextContrast) + .gesture(DragGesture().onEnded(onDragEnded(value:)).onChanged(onDragChanged(value:))) + .background(expanded ? .clear : .systemBackground) + } } } }