diff --git a/EhPanda.xcodeproj/project.pbxproj b/EhPanda.xcodeproj/project.pbxproj index b8beb161..aaa88d58 100644 --- a/EhPanda.xcodeproj/project.pbxproj +++ b/EhPanda.xcodeproj/project.pbxproj @@ -632,7 +632,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = EhPanda/EhPanda.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 42; + CURRENT_PROJECT_VERSION = 43; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = 9SKQ7QTZ74; ENABLE_PREVIEWS = YES; @@ -658,7 +658,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = EhPanda/EhPanda.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 42; + CURRENT_PROJECT_VERSION = 43; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = 9SKQ7QTZ74; ENABLE_PREVIEWS = YES; diff --git a/EhPanda/App/Common.swift b/EhPanda/App/Common.swift index b68b1c86..f97ff697 100644 --- a/EhPanda/App/Common.swift +++ b/EhPanda/App/Common.swift @@ -56,7 +56,7 @@ public var appBuild: String { } public var exx: Bool { - UserDefaults.standard.string(forKey: "entry") == "eHMAnGN4whvHsmfceGGZ" + UserDefaults.standard.string(forKey: "entry") == "eLo8cLfAzfcub2sufyGd" } public var isPad: Bool { @@ -255,13 +255,20 @@ public func postSlideMenuShouldCloseNotification() { ) } -public func postAppWidthDidChangeNotification () { +public func postAppWidthDidChangeNotification() { NotificationCenter.default.post( name: NSNotification.Name("AppWidthDidChange"), object: nil ) } +public func postDetailViewOnDisappearNotification() { + NotificationCenter.default.post( + name: NSNotification.Name("DetailViewOnDisappear"), + object: nil + ) +} + // MARK: Storage Management public func readableUnit(bytes: I) -> String { diff --git a/EhPanda/View/Content/ContentView.swift b/EhPanda/View/Content/ContentView.swift index 85ccb45d..a83f53f1 100644 --- a/EhPanda/View/Content/ContentView.swift +++ b/EhPanda/View/Content/ContentView.swift @@ -14,14 +14,6 @@ struct ContentView: View { @EnvironmentObject var store: Store @State var readingProgress: Int = -1 - let timer = Timer - .publish( - every: 1, - on: .main, - in: .common - ) - .autoconnect() - let id: String var environment: AppState.Environment { store.appState.environment @@ -101,6 +93,13 @@ struct ContentView: View { NetworkErrorView(retryAction: fetchMangaContents) } } + .onReceive( + NotificationCenter.default.publisher( + for: Notification.Name("DetailViewOnDisappear") + ) + ) { _ in + onReceiveDetailViewOnDisappearNotification() + } .onReceive( NotificationCenter.default.publisher( for: UIApplication.willResignActiveNotification @@ -115,9 +114,6 @@ struct ContentView: View { ) { _ in onResignActive() } - .onReceive(timer) { _ in - onTimerFire() - } .onAppear(perform: onAppear) .onDisappear(perform: onDisappear) .navigationBarBackButtonHidden(true) @@ -134,7 +130,7 @@ struct ContentView: View { func onResignActive() { saveReadingProgress() } - func onTimerFire() { + func onReceiveDetailViewOnDisappearNotification() { toggleNavBarHiddenIfNeeded() } func onLazyVStackAppear(_ proxy: ScrollViewProxy) { diff --git a/EhPanda/View/Detail/DetailView.swift b/EhPanda/View/Detail/DetailView.swift index 27e2fdfa..12e5d76e 100644 --- a/EhPanda/View/Detail/DetailView.swift +++ b/EhPanda/View/Detail/DetailView.swift @@ -149,6 +149,7 @@ struct DetailView: View { } } .onAppear(perform: onAppear) + .onDisappear(perform: onDisappear) .navigationBarItems(trailing: menu) .navigationBarHidden(environment.navBarHidden) .sheet(item: environmentBinding.detailViewSheetState) { item in @@ -192,6 +193,9 @@ struct DetailView: View { } updateHistoryItems() } + func onDisappear() { + postDetailViewOnDisappearNotification() + } func onArchiveButtonTap() { toggleSheetState(.archive) }