From 30771c3498029199bb5be99bd7738b5c275babd1 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Mon, 18 Dec 2023 11:31:59 +0800 Subject: [PATCH] Only open read now in the inbox view --- .../App/Views/Home/HomeFeedViewIOS.swift | 24 +--------- .../App/Views/Home/LibraryListConfig.swift | 1 + .../Sources/App/Views/LibrarySplitView.swift | 2 + .../Sources/App/Views/LibraryTabView.swift | 45 ++++++++++++++----- 4 files changed, 39 insertions(+), 33 deletions(-) diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift index 7a48e13eb..7ecbe4e11 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift @@ -148,26 +148,6 @@ struct AnimatingCellHeight: AnimatableModifier { viewModel.selectedItem = linkedItem viewModel.linkIsActive = true } - .onOpenURL { url in - viewModel.linkRequest = nil - if let deepLink = DeepLink.make(from: url) { - switch deepLink { - case let .search(query): - viewModel.searchTerm = query - case let .savedSearch(named): - if let filter = viewModel.findFilter(dataService, named: named) { - viewModel.appliedFilter = filter - } - case let .webAppLinkRequest(requestID): - DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(100)) { - withoutAnimation { - viewModel.linkRequest = LinkRequest(id: UUID(), serverID: requestID) - viewModel.presentWebContainer = true - } - } - } - } - } .fullScreenCover(isPresented: $searchPresented) { LibrarySearchView(homeFeedViewModel: self.viewModel) } @@ -294,7 +274,7 @@ struct AnimatingCellHeight: AnimatableModifier { var body: some View { VStack(spacing: 0) { - if let linkRequest = viewModel.linkRequest { + if let linkRequest = viewModel.linkRequest, viewModel.listConfig.hasReadNowSection { PresentationLink( transition: PresentationLinkTransition.slide( options: PresentationLinkTransition.SlideTransitionOptions(edge: .trailing, @@ -998,7 +978,7 @@ struct ScrollViewOffsetPreferenceKey: PreferenceKey { #if os(iOS) // Allows us to present a sheet without animation // Used to configure full screen modal view coming from share extension read now button action - private extension View { + public extension View { func withoutAnimation(_ completion: @escaping () -> Void) { UIView.setAnimationsEnabled(false) completion() diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/LibraryListConfig.swift b/apple/OmnivoreKit/Sources/App/Views/Home/LibraryListConfig.swift index 46200aa35..47e196177 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/LibraryListConfig.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/LibraryListConfig.swift @@ -14,6 +14,7 @@ enum CardStyle { struct LibraryListConfig { var hasFeatureCards = false + var hasReadNowSection = false var leadingSwipeActions = [SwipeAction]() var trailingSwipeActions = [SwipeAction]() var cardStyle = CardStyle.library diff --git a/apple/OmnivoreKit/Sources/App/Views/LibrarySplitView.swift b/apple/OmnivoreKit/Sources/App/Views/LibrarySplitView.swift index 762f2bfce..1da9c8612 100644 --- a/apple/OmnivoreKit/Sources/App/Views/LibrarySplitView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/LibrarySplitView.swift @@ -11,6 +11,7 @@ public struct LibrarySplitView: View { fetcher: LibraryItemFetcher(), listConfig: LibraryListConfig( hasFeatureCards: true, + hasReadNowSection: true, leadingSwipeActions: [.pin], trailingSwipeActions: [.archive, .delete], cardStyle: .library @@ -22,6 +23,7 @@ public struct LibrarySplitView: View { fetcher: LibraryItemFetcher(), listConfig: LibraryListConfig( hasFeatureCards: false, + hasReadNowSection: false, leadingSwipeActions: [.moveToInbox], trailingSwipeActions: [.archive, .delete], cardStyle: .library diff --git a/apple/OmnivoreKit/Sources/App/Views/LibraryTabView.swift b/apple/OmnivoreKit/Sources/App/Views/LibraryTabView.swift index e5457d87b..1ca4c9e33 100644 --- a/apple/OmnivoreKit/Sources/App/Views/LibraryTabView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/LibraryTabView.swift @@ -29,28 +29,30 @@ struct LibraryTabView: View { UITabBar.appearance().isHidden = true } - @StateObject private var followingViewModel = HomeFeedViewModel( - folder: "following", - fetcher: LibraryItemFetcher(), - listConfig: LibraryListConfig( - hasFeatureCards: false, - leadingSwipeActions: [.moveToInbox], - trailingSwipeActions: [.archive, .delete], - cardStyle: .library - ) - ) - @StateObject private var libraryViewModel = HomeFeedViewModel( folder: "inbox", fetcher: LibraryItemFetcher(), listConfig: LibraryListConfig( hasFeatureCards: true, + hasReadNowSection: true, leadingSwipeActions: [.pin], trailingSwipeActions: [.archive, .delete], cardStyle: .library ) ) + @StateObject private var followingViewModel = HomeFeedViewModel( + folder: "following", + fetcher: LibraryItemFetcher(), + listConfig: LibraryListConfig( + hasFeatureCards: false, + hasReadNowSection: false, + leadingSwipeActions: [.moveToInbox], + trailingSwipeActions: [.archive, .delete], + cardStyle: .library + ) + ) + private let syncManager = LibrarySyncManager() var body: some View { @@ -97,5 +99,26 @@ struct LibraryTabView: View { await syncManager.syncItems(dataService: dataService) } } + .onOpenURL { url in + libraryViewModel.linkRequest = nil + if let deepLink = DeepLink.make(from: url) { + switch deepLink { + case let .search(query): + libraryViewModel.searchTerm = query + case let .savedSearch(named): + if let filter = libraryViewModel.findFilter(dataService, named: named) { + libraryViewModel.appliedFilter = filter + } + case let .webAppLinkRequest(requestID): + DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(100)) { + withoutAnimation { + libraryViewModel.linkRequest = LinkRequest(id: UUID(), serverID: requestID) + libraryViewModel.presentWebContainer = true + } + } + } + } + selectedTab = "inbox" + } } }