From 0c7f5174c737d133d4d3b649fa2035603e59d135 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Fri, 21 Oct 2022 14:11:26 +0800 Subject: [PATCH] Open the audio player expanded the first time the user uses it. Minimize animation issues --- .../Sources/App/Views/AudioPlayer/ExpandedPlayer.swift | 4 +++- .../Sources/App/Views/AudioPlayer/MiniPlayer.swift | 3 ++- apple/OmnivoreKit/Sources/Utils/UserDefaultKeys.swift | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/ExpandedPlayer.swift b/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/ExpandedPlayer.swift index bd30a42a0..a81abec01 100644 --- a/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/ExpandedPlayer.swift +++ b/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/ExpandedPlayer.swift @@ -111,7 +111,9 @@ func viewArticle() { if let objectID = audioController.itemAudioProperties?.objectID { NSNotification.pushReaderItem(objectID: objectID) - dismiss() + DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(100)) { + dismiss() + } } } diff --git a/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/MiniPlayer.swift b/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/MiniPlayer.swift index 20db25aab..8004ee722 100644 --- a/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/MiniPlayer.swift +++ b/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/MiniPlayer.swift @@ -4,6 +4,7 @@ import Models import Services import SwiftUI + import Utils import Views public struct MiniPlayer: View { @@ -11,7 +12,7 @@ @Environment(\.colorScheme) private var colorScheme: ColorScheme private let presentingView: AnyView - @State var expanded = false + @AppStorage(UserDefaultKey.audioPlayerExpanded.rawValue) var expanded = true init( presentingView: PresentingView diff --git a/apple/OmnivoreKit/Sources/Utils/UserDefaultKeys.swift b/apple/OmnivoreKit/Sources/Utils/UserDefaultKeys.swift index 5abfe6c5f..a12253a37 100644 --- a/apple/OmnivoreKit/Sources/Utils/UserDefaultKeys.swift +++ b/apple/OmnivoreKit/Sources/Utils/UserDefaultKeys.swift @@ -18,4 +18,5 @@ public enum UserDefaultKey: String { case textToSpeechDefaultLanguage case textToSpeechPreloadEnabled case recentSearchTerms + case audioPlayerExpanded }