diff --git a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift index 118e0299b..ec64eac22 100644 --- a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift +++ b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift @@ -20,6 +20,7 @@ struct WebReader: PlatformViewRepresentable { @Binding var showNavBarActionID: UUID? @Binding var shareActionID: UUID? @Binding var annotation: String + @Binding var showBottomBar: Bool @Binding var showHighlightAnnotationModal: Bool func makeCoordinator() -> WebReaderCoordinator { @@ -90,6 +91,9 @@ struct WebReader: PlatformViewRepresentable { context.coordinator.webViewActionHandler = webViewActionHandler context.coordinator.updateNavBarVisibility = navBarVisibilityUpdater context.coordinator.scrollPercentHandler = scrollPercentHandler + context.coordinator.updateShowBottomBar = { newValue in + self.showBottomBar = newValue + } context.coordinator.articleContentID = articleContent.id loadContent(webView: webView) diff --git a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift index 122c90395..b922c8298 100644 --- a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift +++ b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift @@ -21,6 +21,7 @@ struct WebReaderContainerView: View { @State private var hasPerformedHighlightMutations = false @State var showHighlightAnnotationModal = false @State private var navBarVisible = true + @State var showBottomBar = true @State private var progressViewOpacity = 0.0 @State var readerSettingsChangedTransactionID: UUID? @State var annotationSaveTransactionID: UUID? @@ -86,6 +87,7 @@ struct WebReaderContainerView: View { private func tapHandler() { withAnimation(.easeIn(duration: 0.08)) { navBarVisible = !navBarVisible + showBottomBar = navBarVisible showNavBarActionID = UUID() } } @@ -114,6 +116,7 @@ struct WebReaderContainerView: View { case "dismissNavBars": withAnimation { navBarVisible = false + showBottomBar = false showNavBarActionID = UUID() } default: @@ -380,6 +383,7 @@ struct WebReaderContainerView: View { navBarVisibilityUpdater: { visible in withAnimation { navBarVisible = visible + showBottomBar = visible } }, readerSettingsChangedTransactionID: $readerSettingsChangedTransactionID, @@ -387,6 +391,7 @@ struct WebReaderContainerView: View { showNavBarActionID: $showNavBarActionID, shareActionID: $shareActionID, annotation: $annotation, + showBottomBar: $showBottomBar, showHighlightAnnotationModal: $showHighlightAnnotationModal ) .background(ThemeManager.currentBgColor) @@ -586,13 +591,13 @@ struct WebReaderContainerView: View { if let audioProperties = audioController.itemAudioProperties { MiniPlayerViewer(itemAudioProperties: audioProperties) .padding(.top, 10) - .padding(.bottom, navBarVisible ? 10 : 40) + .padding(.bottom, showBottomBar ? 10 : 40) .background(Color.themeTabBarColor) .onTapGesture { showExpandedAudioPlayer = true } } - if navBarVisible { + if showBottomBar { CustomToolBar( isFollowing: item.folder == "following", isArchived: item.isArchived, diff --git a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderCoordinator.swift b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderCoordinator.swift index 213a2218c..50dcb5c1e 100644 --- a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderCoordinator.swift +++ b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderCoordinator.swift @@ -20,6 +20,7 @@ final class WebReaderCoordinator: NSObject { var previousShowNavBarActionID: UUID? var previousShareActionID: UUID? var updateNavBarVisibility: (Bool) -> Void = { _ in } + var updateShowBottomBar: (Bool) -> Void = { _ in } var articleContentID = UUID() private var yOffsetAtStartOfDrag: Double? private var lastYOffset: Double = 0 @@ -123,8 +124,9 @@ extension WebReaderCoordinator: WKNavigationDelegate { // if at bottom show the controls if yOffset + scrollView.visibleSize.height > scrollView.contentSize.height - 140 { - navBarVisible = true - scrollView.contentInset.top = navBarVisible ? readerViewNavBarHeight : 0 + updateShowBottomBar(true) + } else { + updateShowBottomBar(false) } let percent = Int(((yOffset + scrollView.visibleSize.height) / scrollView.contentSize.height) * 100)