diff --git a/apple/Omnivore.xcodeproj/project.pbxproj b/apple/Omnivore.xcodeproj/project.pbxproj index b5a8ddf51..021c0043c 100644 --- a/apple/Omnivore.xcodeproj/project.pbxproj +++ b/apple/Omnivore.xcodeproj/project.pbxproj @@ -1251,7 +1251,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 47; + CURRENT_PROJECT_VERSION = 49; DEVELOPMENT_TEAM = QJF2XZ86HB; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = InfoPlists/ShareExtensionMac.plist; @@ -1261,7 +1261,7 @@ "@executable_path/../../../../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 11.0; - MARKETING_VERSION = 1.3.3; + MARKETING_VERSION = 1.3.7; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "app.omnivore.app.ShareExtension-Mac"; @@ -1282,7 +1282,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 47; + CURRENT_PROJECT_VERSION = 49; DEVELOPMENT_TEAM = QJF2XZ86HB; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = InfoPlists/ShareExtensionMac.plist; @@ -1292,7 +1292,7 @@ "@executable_path/../../../../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 11.0; - MARKETING_VERSION = 1.3.3; + MARKETING_VERSION = 1.3.7; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "app.omnivore.app.ShareExtension-Mac"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1363,7 +1363,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 47; + CURRENT_PROJECT_VERSION = 49; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = QJF2XZ86HB; ENABLE_HARDENED_RUNTIME = YES; @@ -1374,7 +1374,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 11.0; - MARKETING_VERSION = 1.3.3; + MARKETING_VERSION = 1.3.7; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = app.omnivore.app; @@ -1397,7 +1397,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 47; + CURRENT_PROJECT_VERSION = 49; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = QJF2XZ86HB; ENABLE_HARDENED_RUNTIME = YES; @@ -1408,7 +1408,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 11.0; - MARKETING_VERSION = 1.3.3; + MARKETING_VERSION = 1.3.7; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = app.omnivore.app; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1560,7 +1560,7 @@ CODE_SIGN_ENTITLEMENTS = "Entitlements/SafariExtension-Mac.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 47; + CURRENT_PROJECT_VERSION = 49; DEVELOPMENT_TEAM = QJF2XZ86HB; ENABLE_HARDENED_RUNTIME = YES; GENERATE_INFOPLIST_FILE = YES; @@ -1573,7 +1573,7 @@ "@executable_path/../../../../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 11.0; - MARKETING_VERSION = 1.3.3; + MARKETING_VERSION = 1.3.7; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; OTHER_LDFLAGS = ( @@ -1598,7 +1598,7 @@ CODE_SIGN_ENTITLEMENTS = "Entitlements/SafariExtension-Mac.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 47; + CURRENT_PROJECT_VERSION = 49; DEVELOPMENT_TEAM = QJF2XZ86HB; ENABLE_HARDENED_RUNTIME = YES; GENERATE_INFOPLIST_FILE = YES; @@ -1611,7 +1611,7 @@ "@executable_path/../../../../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 11.0; - MARKETING_VERSION = 1.3.3; + MARKETING_VERSION = 1.3.7; MTL_FAST_MATH = YES; OTHER_LDFLAGS = ( "-framework", diff --git a/apple/OmnivoreKit/Sources/Views/Article/WebAppView.swift b/apple/OmnivoreKit/Sources/Views/Article/WebAppView.swift index 261ed3604..fd5eb6870 100644 --- a/apple/OmnivoreKit/Sources/Views/Article/WebAppView.swift +++ b/apple/OmnivoreKit/Sources/Views/Article/WebAppView.swift @@ -92,6 +92,7 @@ import WebKit let rawAuthCookie: String? let openLinkAction: (URL) -> Void let webViewActionHandler: (WKScriptMessage) -> Void + let navBarVisibilityRatioUpdater: (Double) -> Void @Binding var annotation: String @Binding var annotationSaveTransactionID: UUID? @Binding var sendIncreaseFontSignal: Bool diff --git a/apple/OmnivoreKit/Sources/Views/Article/WebAppViewCoordinator.swift b/apple/OmnivoreKit/Sources/Views/Article/WebAppViewCoordinator.swift index bbc3e7591..1f54a5fdd 100644 --- a/apple/OmnivoreKit/Sources/Views/Article/WebAppViewCoordinator.swift +++ b/apple/OmnivoreKit/Sources/Views/Article/WebAppViewCoordinator.swift @@ -45,59 +45,61 @@ extension WebAppViewCoordinator: WKNavigationDelegate { } } -extension WebAppViewCoordinator: UIScrollViewDelegate { - func scrollViewWillBeginDragging(_ scrollView: UIScrollView) { - hasDragged = true - yOffsetAtStartOfDrag = scrollView.contentOffset.y + scrollView.contentInset.top - } +#if os(iOS) + extension WebAppViewCoordinator: UIScrollViewDelegate { + func scrollViewWillBeginDragging(_ scrollView: UIScrollView) { + hasDragged = true + yOffsetAtStartOfDrag = scrollView.contentOffset.y + scrollView.contentInset.top + } - func scrollViewDidScroll(_ scrollView: UIScrollView) { - guard hasDragged else { return } + func scrollViewDidScroll(_ scrollView: UIScrollView) { + guard hasDragged else { return } - let yOffset = scrollView.contentOffset.y + let yOffset = scrollView.contentOffset.y - if yOffset == 0 { + if yOffset == 0 { + scrollView.contentInset.top = navBarHeight + navBarVisibilityRatio = 1 + return + } + + if yOffset < 0 { + navBarVisibilityRatio = 1 + scrollView.contentInset.top = navBarHeight + return + } + + if yOffset < navBarHeight { + let isScrollingUp = yOffsetAtStartOfDrag ?? 0 > yOffset + navBarVisibilityRatio = isScrollingUp || yOffset < 0 ? 1 : min(1, 1 - (yOffset / navBarHeight)) + scrollView.contentInset.top = navBarVisibilityRatio * navBarHeight + return + } + + guard let yOffsetAtStartOfDrag = yOffsetAtStartOfDrag else { return } + + if yOffset > yOffsetAtStartOfDrag, !isNavBarHidden { + let translation = yOffset - yOffsetAtStartOfDrag + let ratio = translation < navBarHeight ? 1 - (translation / navBarHeight) : 0 + navBarVisibilityRatio = min(ratio, 1) + scrollView.contentInset.top = navBarVisibilityRatio * navBarHeight + } + } + + func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) { + if decelerate, scrollView.contentOffset.y + scrollView.contentInset.top < (yOffsetAtStartOfDrag ?? 0) { + scrollView.contentInset.top = navBarHeight + navBarVisibilityRatio = 1 + } + } + + func scrollViewShouldScrollToTop(_ scrollView: UIScrollView) -> Bool { scrollView.contentInset.top = navBarHeight navBarVisibilityRatio = 1 - return - } - - if yOffset < 0 { - navBarVisibilityRatio = 1 - scrollView.contentInset.top = navBarHeight - return - } - - if yOffset < navBarHeight { - let isScrollingUp = yOffsetAtStartOfDrag ?? 0 > yOffset - navBarVisibilityRatio = isScrollingUp || yOffset < 0 ? 1 : min(1, 1 - (yOffset / navBarHeight)) - scrollView.contentInset.top = navBarVisibilityRatio * navBarHeight - return - } - - guard let yOffsetAtStartOfDrag = yOffsetAtStartOfDrag else { return } - - if yOffset > yOffsetAtStartOfDrag, !isNavBarHidden { - let translation = yOffset - yOffsetAtStartOfDrag - let ratio = translation < navBarHeight ? 1 - (translation / navBarHeight) : 0 - navBarVisibilityRatio = min(ratio, 1) - scrollView.contentInset.top = navBarVisibilityRatio * navBarHeight + return false } } - - func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) { - if decelerate, scrollView.contentOffset.y + scrollView.contentInset.top < (yOffsetAtStartOfDrag ?? 0) { - scrollView.contentInset.top = navBarHeight - navBarVisibilityRatio = 1 - } - } - - func scrollViewShouldScrollToTop(_ scrollView: UIScrollView) -> Bool { - scrollView.contentInset.top = navBarHeight - navBarVisibilityRatio = 1 - return false - } -} +#endif struct WebViewConfig { let url: URL diff --git a/apple/OmnivoreKit/Sources/Views/LinkedItemDetail/LinkItemDetailView.swift b/apple/OmnivoreKit/Sources/Views/LinkedItemDetail/LinkItemDetailView.swift index 3c1a3ad2e..3250a37e8 100644 --- a/apple/OmnivoreKit/Sources/Views/LinkedItemDetail/LinkItemDetailView.swift +++ b/apple/OmnivoreKit/Sources/Views/LinkedItemDetail/LinkItemDetailView.swift @@ -101,57 +101,59 @@ public struct LinkItemDetailView: View { .background(Color.systemBackground) } - @ViewBuilder private var compactInnerBody: some View { - if let webAppWrapperViewModel = viewModel.webAppWrapperViewModel { - ZStack { - WebAppWrapperView( - viewModel: webAppWrapperViewModel, - navBarVisibilityRatioUpdater: { - if $0 < 1 { - showFontSizePopover = false - } - navBarVisibilityRatio = $0 - } - ) - if showFontSizePopover { - VStack { - Color.clear - .contentShape(Rectangle()) - .frame(height: LinkItemDetailView.navBarHeight) - HStack { - Spacer() - fontAdjustmentPopoverView - .background(Color.appButtonBackground) - .cornerRadius(8) - .padding(.trailing, 5) - } - Spacer() - } - .background( - Color.clear - .contentShape(Rectangle()) - .onTapGesture { + #if os(iOS) + @ViewBuilder private var compactInnerBody: some View { + if let webAppWrapperViewModel = viewModel.webAppWrapperViewModel { + ZStack { + WebAppWrapperView( + viewModel: webAppWrapperViewModel, + navBarVisibilityRatioUpdater: { + if $0 < 1 { showFontSizePopover = false } + navBarVisibilityRatio = $0 + } ) + if showFontSizePopover { + VStack { + Color.clear + .contentShape(Rectangle()) + .frame(height: LinkItemDetailView.navBarHeight) + HStack { + Spacer() + fontAdjustmentPopoverView + .background(Color.appButtonBackground) + .cornerRadius(8) + .padding(.trailing, 5) + } + Spacer() + } + .background( + Color.clear + .contentShape(Rectangle()) + .onTapGesture { + showFontSizePopover = false + } + ) + } + VStack(spacing: 0) { + navBar + Spacer() + } } + .navigationBarHidden(true) + } else { VStack(spacing: 0) { navBar Spacer() } + .onAppear { + viewModel.performActionSubject.send(.load) + } + .navigationBarHidden(true) } - .navigationBarHidden(true) - } else { - VStack(spacing: 0) { - navBar - Spacer() - } - .onAppear { - viewModel.performActionSubject.send(.load) - } - .navigationBarHidden(true) } - } + #endif @ViewBuilder private var innerBody: some View { if let pdfURL = viewModel.item.pdfURL { @@ -195,14 +197,16 @@ public struct LinkItemDetailView: View { } } -// Enable swipe to go back behavior if nav bar is hidden -extension UINavigationController: UIGestureRecognizerDelegate { - override open func viewDidLoad() { - super.viewDidLoad() - interactivePopGestureRecognizer?.delegate = self - } +#if os(iOS) + // Enable swipe to go back behavior if nav bar is hidden + extension UINavigationController: UIGestureRecognizerDelegate { + override open func viewDidLoad() { + super.viewDidLoad() + interactivePopGestureRecognizer?.delegate = self + } - public func gestureRecognizerShouldBegin(_: UIGestureRecognizer) -> Bool { - viewControllers.count > 1 + public func gestureRecognizerShouldBegin(_: UIGestureRecognizer) -> Bool { + viewControllers.count > 1 + } } -} +#endif