From 1fbd0a5e641df778e60dbf1a819a6b0bd0fdf090 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Tue, 30 May 2023 22:25:50 +0800 Subject: [PATCH 01/11] Fixes to build on Macos --- .../App/Views/WebReader/WebReader.swift | 16 ++++--- .../Views/WebReader/WebReaderContainer.swift | 46 ++++++++++--------- .../Article/HighlightAnnotationSheet.swift | 29 ++++++------ .../Views/Article/OmnivoreWebView.swift | 2 +- .../Views/FeedItem/LibraryItemCard.swift | 12 +++-- 5 files changed, 57 insertions(+), 48 deletions(-) diff --git a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift index 7a5aefa56..2d817fcb6 100644 --- a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift +++ b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift @@ -116,13 +116,15 @@ struct WebReader: PlatformViewRepresentable { (webView as? OmnivoreWebView)?.updateTitle(title: item.title ?? "") (webView as? OmnivoreWebView)?.updateJustifyText() - webView.backgroundColor = UIColor(ThemeManager.currentBgColor) - webView.tintColor = UIColor(ThemeManager.currentHighlightColor) - webView.underPageBackgroundColor = UIColor(ThemeManager.currentBgColor) - webView.scrollView.backgroundColor = UIColor(ThemeManager.currentBgColor) - webView.scrollView.indicatorStyle = ThemeManager.currentTheme.isDark ? - UIScrollView.IndicatorStyle.white : - UIScrollView.IndicatorStyle.black + #if os(iOS) + webView.backgroundColor = UIColor(ThemeManager.currentBgColor) + webView.tintColor = UIColor(ThemeManager.currentHighlightColor) + webView.underPageBackgroundColor = UIColor(ThemeManager.currentBgColor) + webView.scrollView.backgroundColor = UIColor(ThemeManager.currentBgColor) + webView.scrollView.indicatorStyle = ThemeManager.currentTheme.isDark ? + UIScrollView.IndicatorStyle.white : + UIScrollView.IndicatorStyle.black + #endif } if showNavBarActionID != context.coordinator.previousShowNavBarActionID { diff --git a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift index cfff418af..4c4289dab 100644 --- a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift +++ b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift @@ -288,30 +288,30 @@ struct WebReaderContainerView: View { #if os(iOS) audioNavbarItem - #endif - Button( - action: { - if UIDevice.current.userInterfaceIdiom == .phone { - showPreferencesFormsheet.toggle() - } else { - showPreferencesPopover.toggle() + Button( + action: { + if UIDevice.current.userInterfaceIdiom == .phone { + showPreferencesFormsheet.toggle() + } else { + showPreferencesPopover.toggle() + } + }, + label: { + Image(systemName: "textformat.size") + .font(.appNavbarIcon) } - }, - label: { - Image(systemName: "textformat.size") - .font(.appNavbarIcon) + ) + .padding(.horizontal, 5) + .scaleEffect(navBarVisibilityRatio) + .popover(isPresented: $showPreferencesPopover) { + webPreferencesPopoverView + .frame(maxWidth: 400, maxHeight: 475) } - ) - .padding(.horizontal, 5) - .scaleEffect(navBarVisibilityRatio) - .popover(isPresented: $showPreferencesPopover) { - webPreferencesPopoverView - .frame(maxWidth: 400, maxHeight: 475) - } - .formSheet(isPresented: $showPreferencesFormsheet, modalSize: CGSize(width: 400, height: 475)) { - webPreferencesPopoverView - } + .formSheet(isPresented: $showPreferencesFormsheet, modalSize: CGSize(width: 400, height: 475)) { + webPreferencesPopoverView + } + #endif #if os(macOS) Spacer() @@ -596,7 +596,9 @@ struct WebReaderContainerView: View { #if os(iOS) UIPasteboard.general.string = deepLink.absoluteString #else - Pasteboard.general.string = deepLink.absoluteString + let pasteBoard = NSPasteboard.general + pasteBoard.clearContents() + pasteBoard.writeObjects([deepLink.absoluteString as NSString]) #endif showInSnackbar("Deeplink Copied") } else { diff --git a/apple/OmnivoreKit/Sources/Views/Article/HighlightAnnotationSheet.swift b/apple/OmnivoreKit/Sources/Views/Article/HighlightAnnotationSheet.swift index 2c59dfa16..3221fe154 100644 --- a/apple/OmnivoreKit/Sources/Views/Article/HighlightAnnotationSheet.swift +++ b/apple/OmnivoreKit/Sources/Views/Article/HighlightAnnotationSheet.swift @@ -50,19 +50,22 @@ public struct HighlightAnnotationSheet: View { } .padding() .navigationTitle("Note") - .navigationBarTitleDisplayMode(.inline) - .navigationBarItems(leading: Button(action: onCancel, label: { - Text("Cancel") - })) - .navigationBarItems(trailing: Button(action: onSave, label: { - Text("Save").bold() - })) + #if os(iOS) + .navigationBarTitleDisplayMode(.inline) + + .navigationBarItems(leading: Button(action: onCancel, label: { + Text("Cancel") + })) + .navigationBarItems(trailing: Button(action: onSave, label: { + Text("Save").bold() + })) + #endif .listStyle(PlainListStyle()) - .alert(errorAlertMessage ?? LocalText.readerError, isPresented: $showErrorAlertMessage) { - Button(LocalText.genericOk, role: .cancel, action: { - errorAlertMessage = nil - showErrorAlertMessage = false - }) - } + .alert(errorAlertMessage ?? LocalText.readerError, isPresented: $showErrorAlertMessage) { + Button(LocalText.genericOk, role: .cancel, action: { + errorAlertMessage = nil + showErrorAlertMessage = false + }) + } } } diff --git a/apple/OmnivoreKit/Sources/Views/Article/OmnivoreWebView.swift b/apple/OmnivoreKit/Sources/Views/Article/OmnivoreWebView.swift index 1816a4a0f..b3e07b9a6 100644 --- a/apple/OmnivoreKit/Sources/Views/Article/OmnivoreWebView.swift +++ b/apple/OmnivoreKit/Sources/Views/Article/OmnivoreWebView.swift @@ -187,7 +187,7 @@ public final class OmnivoreWebView: WKWebView { override public func viewDidChangeEffectiveAppearance() { super.viewDidChangeEffectiveAppearance() if ThemeManager.currentTheme == .system { - try dispatchEvent(.updateTheme(themeName: ThemeManager.currentTheme.themeKey)) + try? dispatchEvent(.updateTheme(themeName: ThemeManager.currentTheme.themeKey)) } } #endif diff --git a/apple/OmnivoreKit/Sources/Views/FeedItem/LibraryItemCard.swift b/apple/OmnivoreKit/Sources/Views/FeedItem/LibraryItemCard.swift index 965404147..1e460d7b2 100644 --- a/apple/OmnivoreKit/Sources/Views/FeedItem/LibraryItemCard.swift +++ b/apple/OmnivoreKit/Sources/Views/FeedItem/LibraryItemCard.swift @@ -4,11 +4,13 @@ import Utils public extension View { func draggableItem(item: LinkedItem) -> some View { - if #available(iOS 16.0, *), let url = item.deepLink { - return AnyView(self.draggable(url) { - Label(item.unwrappedTitle, systemImage: "link") - }) - } + #if os(iOS) + if #available(iOS 16.0, *), let url = item.deepLink { + return AnyView(self.draggable(url) { + Label(item.unwrappedTitle, systemImage: "link") + }) + } + #endif return AnyView(self) } } From b482e20d0a11f73a2e22015638ab1a3b74ee1ab4 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Wed, 31 May 2023 12:30:24 +0800 Subject: [PATCH 02/11] Improve the cards in the Mac app, use the same as iOS --- apple/Omnivore.xcodeproj/project.pbxproj | 8 +- .../Components/FeedCardNavigationLink.swift | 4 +- .../App/Views/Home/HomeFeedViewMac.swift | 81 +++++++++---------- 3 files changed, 45 insertions(+), 48 deletions(-) diff --git a/apple/Omnivore.xcodeproj/project.pbxproj b/apple/Omnivore.xcodeproj/project.pbxproj index 1be4154fc..71f95bc8c 100644 --- a/apple/Omnivore.xcodeproj/project.pbxproj +++ b/apple/Omnivore.xcodeproj/project.pbxproj @@ -1388,7 +1388,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 80; + CURRENT_PROJECT_VERSION = 82; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = QJF2XZ86HB; @@ -1400,7 +1400,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 12.0; - MARKETING_VERSION = 1.23.0; + MARKETING_VERSION = 1.24.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = app.omnivore.app; @@ -1423,7 +1423,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 80; + CURRENT_PROJECT_VERSION = 82; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = QJF2XZ86HB; @@ -1435,7 +1435,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 12.0; - MARKETING_VERSION = 1.23.0; + MARKETING_VERSION = 1.24.0; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = app.omnivore.app; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/Components/FeedCardNavigationLink.swift b/apple/OmnivoreKit/Sources/App/Views/Home/Components/FeedCardNavigationLink.swift index f14b02ae3..dd146461f 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/Components/FeedCardNavigationLink.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/Components/FeedCardNavigationLink.swift @@ -28,9 +28,7 @@ struct MacFeedCardNavigationLink: View { .onAppear { Task { await viewModel.itemAppeared(item: item, dataService: dataService) } } - FeedCard(item: item, viewer: dataService.currentViewer) { - viewModel.selectedLinkItem = item.objectID - } + LibraryItemCard(item: item, viewer: dataService.currentViewer) } } } diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift index 23deaddc4..762a89920 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift @@ -35,59 +35,58 @@ import Views } } List { - Section { - ForEach(viewModel.items) { item in - MacFeedCardNavigationLink( - item: item, - viewModel: viewModel + ForEach(viewModel.items) { item in + MacFeedCardNavigationLink( + item: item, + viewModel: viewModel + ) + .contextMenu { + Button( + action: { viewModel.itemUnderTitleEdit = item }, + label: { Label("Edit Info", systemImage: "info.circle") } ) - .contextMenu { - Button( - action: { viewModel.itemUnderTitleEdit = item }, - label: { Label("Edit Info", systemImage: "info.circle") } - ) - Button( - action: { viewModel.itemUnderLabelEdit = item }, - label: { Label(item.labels?.count == 0 ? "Add Labels" : "Edit Labels", systemImage: "tag") } - ) - Button(action: { - withAnimation(.linear(duration: 0.4)) { - viewModel.setLinkArchived( - dataService: dataService, - objectID: item.objectID, - archived: !item.isArchived - ) - } - }, label: { - Label( - item.isArchived ? "Unarchive" : "Archive", - systemImage: item.isArchived ? "tray.and.arrow.down.fill" : "archivebox" + Button( + action: { viewModel.itemUnderLabelEdit = item }, + label: { Label(item.labels?.count == 0 ? "Add Labels" : "Edit Labels", systemImage: "tag") } + ) + Button(action: { + withAnimation(.linear(duration: 0.4)) { + viewModel.setLinkArchived( + dataService: dataService, + objectID: item.objectID, + archived: !item.isArchived ) - }) - Button( - action: { - itemToRemove = item - confirmationShown = true - }, - label: { Label("Delete", systemImage: "trash") } + } + }, label: { + Label( + item.isArchived ? "Unarchive" : "Archive", + systemImage: item.isArchived ? "tray.and.arrow.down.fill" : "archivebox" ) - if FeatureFlag.enableSnooze { - Button { - viewModel.itemToSnoozeID = item.id - viewModel.snoozePresented = true - } label: { - Label { Text(LocalText.genericSnooze) } icon: { Image.moon } - } + }) + Button( + action: { + itemToRemove = item + confirmationShown = true + }, + label: { Label("Delete", systemImage: "trash") } + ) + if FeatureFlag.enableSnooze { + Button { + viewModel.itemToSnoozeID = item.id + viewModel.snoozePresented = true + } label: { + Label { Text(LocalText.genericSnooze) } icon: { Image.moon } } } } + Divider().padding(5) } if viewModel.isLoading { LoadingSection() } } - .listStyle(PlainListStyle()) + // .listStyle(PlainListStyle()) .navigationTitle("Home") .searchable( text: $viewModel.searchTerm, From dfc3a890e7fc072d06046749adbb34993a5b3b26 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Wed, 31 May 2023 13:49:31 +0800 Subject: [PATCH 03/11] Move to just two panes on mac for now --- .../Sources/App/MacMenuCommands.swift | 21 +++++++++++++++---- .../App/Views/Home/HomeFeedViewMac.swift | 2 ++ .../Sources/App/Views/Home/HomeView.swift | 16 ++++++++++++++ .../App/Views/PrimaryContentView.swift | 7 ------- 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/apple/OmnivoreKit/Sources/App/MacMenuCommands.swift b/apple/OmnivoreKit/Sources/App/MacMenuCommands.swift index 49c18e1c9..8616567d6 100644 --- a/apple/OmnivoreKit/Sources/App/MacMenuCommands.swift +++ b/apple/OmnivoreKit/Sources/App/MacMenuCommands.swift @@ -9,10 +9,11 @@ import Views ) @AppStorage(UserDefaultKey.preferredWebLineSpacing.rawValue) var storedLineSpacing = 150 @AppStorage(UserDefaultKey.preferredWebMaxWidthPercentage.rawValue) var storedMaxWidthPercentage = 100 - @AppStorage(UserDefaultKey.enableHighlightOnRelease.rawValue) var enableHighlightOnRelease = false @Binding var preferredFont: String @Binding var prefersHighContrastText: Bool + @Binding var justifyText: Bool + @Binding var currentThemeName: String public var fontSizeButtons: some View { Group { @@ -85,10 +86,14 @@ import Views public init( preferredFont: Binding, - prefersHighContrastText: Binding + prefersHighContrastText: Binding, + justifyText: Binding, + currentThemeName: Binding ) { self._preferredFont = preferredFont self._prefersHighContrastText = prefersHighContrastText + self._justifyText = justifyText + self._currentThemeName = currentThemeName } public var body: some Commands { @@ -111,14 +116,22 @@ import Views } } + Picker(selection: $currentThemeName, label: Text("Theme")) { + ForEach(Theme.allCases, id: \.self) { theme in + Text(theme.rawValue).tag(theme.rawValue).tag(theme.rawValue) + } + }.onChange(of: currentThemeName) { _ in + NSNotification.readerSettingsChanged() + } + Toggle( isOn: $prefersHighContrastText, label: { Text(LocalText.genericHighContrastText) } ) Toggle( - isOn: $enableHighlightOnRelease, - label: { Text(LocalText.genericHighContrastText) } + isOn: $justifyText, + label: { Text(LocalText.enableJustifyText) } ) } } diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift index 762a89920..b5a38102c 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift @@ -35,6 +35,8 @@ import Views } } List { + Spacer(minLength: 10) + ForEach(viewModel.items) { item in MacFeedCardNavigationLink( item: item, diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeView.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeView.swift index 6c2c49875..ebc82f97e 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeView.swift @@ -1,4 +1,6 @@ import SwiftUI +import Utils +import Views struct HomeView: View { @StateObject private var viewModel = HomeFeedViewModel() @@ -22,6 +24,20 @@ struct HomeView: View { } #elseif os(macOS) HomeFeedView(viewModel: viewModel) + .frame(minWidth: 320) + .toolbar { + ToolbarItem { + Button( + action: { + NSApp.keyWindow?.firstResponder?.tryToPerform( + #selector(NSSplitViewController.toggleSidebar(_:)), with: nil + ) + }, + label: { Label(LocalText.navigationSelectSidebarToggle, systemImage: "sidebar.left") } + ) + } + } + #endif } } diff --git a/apple/OmnivoreKit/Sources/App/Views/PrimaryContentView.swift b/apple/OmnivoreKit/Sources/App/Views/PrimaryContentView.swift index 376b2c53b..ddd54e1ca 100644 --- a/apple/OmnivoreKit/Sources/App/Views/PrimaryContentView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/PrimaryContentView.swift @@ -24,14 +24,7 @@ public struct PrimaryContentView: View { #if os(macOS) private var splitView: some View { NavigationView { - // The first column is the sidebar. - PrimaryContentSidebar(categories: categories) - .navigationTitle("Categories") - - // Second column is the Primary Nav Stack PrimaryContentCategory.feed.destinationView - - // Third column is the detail view Text(LocalText.navigationSelectLink) } .accentColor(.appGrayTextContrast) From bf799a6534b8db9c962500b38d6df4b059b889ac Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Wed, 31 May 2023 13:50:02 +0800 Subject: [PATCH 04/11] Better default font --- apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift index 2d817fcb6..9c8e27b66 100644 --- a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift +++ b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift @@ -191,7 +191,7 @@ struct WebReader: PlatformViewRepresentable { } }() - let fontFamily = fontFamilyValue.flatMap { WebFont(rawValue: $0) } ?? .system + let fontFamily = fontFamilyValue.flatMap { WebFont(rawValue: $0) } ?? .atkinsonHyperlegible let htmlString = WebReaderContent( item: item, From 94099281ae7260a8b8064f5bba82c2fb09af9865 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Wed, 31 May 2023 13:50:42 +0800 Subject: [PATCH 05/11] Add theme and justify-text to reader settings --- apple/OmnivoreKit/Sources/Views/LocalText.swift | 2 +- .../Views/Resources/en.lproj/Localizable.strings | 3 ++- apple/Sources/MainApp.swift | 14 +++++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/apple/OmnivoreKit/Sources/Views/LocalText.swift b/apple/OmnivoreKit/Sources/Views/LocalText.swift index 46219ab36..86ebd4499 100644 --- a/apple/OmnivoreKit/Sources/Views/LocalText.swift +++ b/apple/OmnivoreKit/Sources/Views/LocalText.swift @@ -164,7 +164,7 @@ public enum LocalText { public static let genericLoading = localText(key: "genericLoading") public static let genericFontFamily = localText(key: "genericFontFamily") public static let genericHighContrastText = localText(key: "genericHighContrastText") - public static let enableHighlightOnReleaseText = localText(key: "enableHighlightOnReleaseText") + public static let enableJustifyText = localText(key: "enableJustifyText") public static let genericFont = localText(key: "genericFont") public static let genericHighlight = localText(key: "genericHighlight") public static let labelsGeneric = localText(key: "labelsGeneric") diff --git a/apple/OmnivoreKit/Sources/Views/Resources/en.lproj/Localizable.strings b/apple/OmnivoreKit/Sources/Views/Resources/en.lproj/Localizable.strings index 08503bd95..62b25a688 100644 --- a/apple/OmnivoreKit/Sources/Views/Resources/en.lproj/Localizable.strings +++ b/apple/OmnivoreKit/Sources/Views/Resources/en.lproj/Localizable.strings @@ -163,7 +163,8 @@ "genericLoading" = "Loading..."; "genericFontFamily" = "Font Family"; "genericHighContrastText" = "High Contrast Text"; -"enableHighlightOnReleaseText" = "Auto Highlight Mode:"; +"enableHighlightOnReleaseText" = "Auto Highlight Mode"; +"enableJustifyText" = "Justify Text"; "genericFont" = "Font"; "genericHighlight" = "Highlight"; "labelsGeneric" = "Labels"; diff --git a/apple/Sources/MainApp.swift b/apple/Sources/MainApp.swift index 43fbf54eb..a5dc0dc0e 100644 --- a/apple/Sources/MainApp.swift +++ b/apple/Sources/MainApp.swift @@ -17,6 +17,9 @@ struct MainApp: App { @NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate @AppStorage(UserDefaultKey.preferredWebFont.rawValue) var preferredFont = WebFont.inter.rawValue @AppStorage(UserDefaultKey.prefersHighContrastWebFont.rawValue) var prefersHighContrastText = true + @AppStorage(UserDefaultKey.justifyText.rawValue) var justifyText = false + @AppStorage(UserDefaultKey.themeName.rawValue) var currentThemeName = "System" + #elseif os(iOS) @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate #endif @@ -39,7 +42,9 @@ struct MainApp: App { .commands { MacMenuCommands( preferredFont: $preferredFont, - prefersHighContrastText: $prefersHighContrastText + prefersHighContrastText: $prefersHighContrastText, + justifyText: $justifyText, + currentThemeName: $currentThemeName ) } .onChange(of: preferredFont) { _ in @@ -48,6 +53,13 @@ struct MainApp: App { .onChange(of: prefersHighContrastText) { _ in NSNotification.readerSettingsChanged() } + .onChange(of: justifyText) { _ in + NSNotification.readerSettingsChanged() + } + .onChange(of: currentThemeName) { _ in + NSNotification.readerSettingsChanged() + } + #endif } } From 27d8c26180ec7b5203714eeb4aa8a109390fad29 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Wed, 31 May 2023 13:52:32 +0800 Subject: [PATCH 06/11] Change search bar position --- apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift index b5a38102c..aafd42382 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift @@ -92,7 +92,7 @@ import Views .navigationTitle("Home") .searchable( text: $viewModel.searchTerm, - placement: .toolbar + placement: .sidebar ) { if viewModel.searchTerm.isEmpty { Text(LocalText.inboxGeneric).searchCompletion("in:inbox ") From e13d7d30c1ca67477a96a602cc350b4436097b19 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Wed, 31 May 2023 14:04:19 +0800 Subject: [PATCH 07/11] Add reset reader settings --- .../Sources/App/MacMenuCommands.swift | 36 ++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/apple/OmnivoreKit/Sources/App/MacMenuCommands.swift b/apple/OmnivoreKit/Sources/App/MacMenuCommands.swift index 8616567d6..aab150d3c 100644 --- a/apple/OmnivoreKit/Sources/App/MacMenuCommands.swift +++ b/apple/OmnivoreKit/Sources/App/MacMenuCommands.swift @@ -84,6 +84,26 @@ import Views } } + public var resetButton: some View { + Group { + Button( + action: { + storedLineSpacing = max(storedLineSpacing - 25, 100) + + ThemeManager.currentThemeName = Theme.system.rawValue + storedFontSize = 16 + storedLineSpacing = 150 + storedMaxWidthPercentage = 80 + preferredFont = WebFont.inter.rawValue + prefersHighContrastText = true + + NSNotification.readerSettingsChanged() + }, + label: { Text("Reset") } + ) + } + } + public init( preferredFont: Binding, prefersHighContrastText: Binding, @@ -96,8 +116,8 @@ import Views self._currentThemeName = currentThemeName } - public var body: some Commands { - CommandMenu("Reader Display") { + var spacingButtons: some View { + Group { fontSizeButtons Divider() @@ -109,6 +129,12 @@ import Views lineSpacingButtons Divider() + } + } + + public var body: some Commands { + CommandMenu("Reader Display") { + spacingButtons Picker(selection: $preferredFont, label: Text(LocalText.genericFontFamily)) { ForEach(WebFont.allCases, id: \.self) { font in @@ -120,8 +146,6 @@ import Views ForEach(Theme.allCases, id: \.self) { theme in Text(theme.rawValue).tag(theme.rawValue).tag(theme.rawValue) } - }.onChange(of: currentThemeName) { _ in - NSNotification.readerSettingsChanged() } Toggle( @@ -133,6 +157,10 @@ import Views isOn: $justifyText, label: { Text(LocalText.enableJustifyText) } ) + + Divider() + + resetButton } } } From 4e7bd972977be050ab975b483274ddd77093b9ec Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Wed, 31 May 2023 14:05:58 +0800 Subject: [PATCH 08/11] Smaller default max width percentage --- apple/OmnivoreKit/Sources/App/MacMenuCommands.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apple/OmnivoreKit/Sources/App/MacMenuCommands.swift b/apple/OmnivoreKit/Sources/App/MacMenuCommands.swift index aab150d3c..f9bfbdca1 100644 --- a/apple/OmnivoreKit/Sources/App/MacMenuCommands.swift +++ b/apple/OmnivoreKit/Sources/App/MacMenuCommands.swift @@ -8,7 +8,7 @@ import Views NSFont.userFont(ofSize: 16)?.pointSize ?? 16 ) @AppStorage(UserDefaultKey.preferredWebLineSpacing.rawValue) var storedLineSpacing = 150 - @AppStorage(UserDefaultKey.preferredWebMaxWidthPercentage.rawValue) var storedMaxWidthPercentage = 100 + @AppStorage(UserDefaultKey.preferredWebMaxWidthPercentage.rawValue) var storedMaxWidthPercentage = 80 @Binding var preferredFont: String @Binding var prefersHighContrastText: Bool From 3460150d5ed142c530bbfc653c101de2c7061d48 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Wed, 31 May 2023 15:56:17 +0800 Subject: [PATCH 09/11] Update copy to say library instead of feed --- apple/OmnivoreKit/Sources/App/MacMenuCommands.swift | 9 +++++++++ .../Sources/App/Views/Home/HomeFeedViewMac.swift | 7 +++++++ .../Sources/App/Views/Profile/ProfileView.swift | 1 + .../Sources/Services/NSNotification+Operation.swift | 9 +++++++++ .../Sources/Views/Resources/en.lproj/Localizable.strings | 2 +- 5 files changed, 27 insertions(+), 1 deletion(-) diff --git a/apple/OmnivoreKit/Sources/App/MacMenuCommands.swift b/apple/OmnivoreKit/Sources/App/MacMenuCommands.swift index f9bfbdca1..72250e257 100644 --- a/apple/OmnivoreKit/Sources/App/MacMenuCommands.swift +++ b/apple/OmnivoreKit/Sources/App/MacMenuCommands.swift @@ -15,6 +15,8 @@ import Views @Binding var justifyText: Bool @Binding var currentThemeName: String + @Environment(\.openURL) var openURL + public var fontSizeButtons: some View { Group { Button( @@ -133,6 +135,13 @@ import Views } public var body: some Commands { + CommandGroup(after: .appInfo) { + Button("Open Online", action: { + if let url = URL(string: "https://omnivore.app/") { + NSWorkspace.shared.open(url) + } + }) + } CommandMenu("Reader Display") { spacingButtons diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift index aafd42382..566d451d5 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift @@ -11,6 +11,7 @@ import Views @EnvironmentObject var audioController: AudioController @State private var itemToRemove: LinkedItem? @State private var confirmationShown = false + @State private var presentProfileSheet = false @ObservedObject var viewModel: HomeFeedViewModel @@ -144,6 +145,12 @@ import Views .sheet(item: $viewModel.itemUnderTitleEdit) { item in LinkedItemMetadataEditView(item: item) } + .sheet(isPresented: $presentProfileSheet) { + ProfileView() + } + .onReceive(NSNotification.displayProfilePublisher) { _ in + presentProfileSheet = true + } .task { if viewModel.items.isEmpty { loadItems(isRefresh: true) diff --git a/apple/OmnivoreKit/Sources/App/Views/Profile/ProfileView.swift b/apple/OmnivoreKit/Sources/App/Views/Profile/ProfileView.swift index 76422d7c1..5a8cb711f 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Profile/ProfileView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Profile/ProfileView.swift @@ -82,6 +82,7 @@ struct ProfileView: View { innerBody } .listStyle(InsetListStyle()) + .frame(minWidth: 400, minHeight: 400) #endif } diff --git a/apple/OmnivoreKit/Sources/Services/NSNotification+Operation.swift b/apple/OmnivoreKit/Sources/Services/NSNotification+Operation.swift index a588435ff..45296f027 100644 --- a/apple/OmnivoreKit/Sources/Services/NSNotification+Operation.swift +++ b/apple/OmnivoreKit/Sources/Services/NSNotification+Operation.swift @@ -9,6 +9,7 @@ public extension NSNotification { static let OperationFailure = Notification.Name("OperationFailure") static let ReaderSettingsChanged = Notification.Name("ReaderSettingsChanged") static let SpeakingReaderItem = Notification.Name("SpeakingReaderItem") + static let DisplayProfile = Notification.Name("DisplayProfile") static var pushFeedItemPublisher: NotificationCenter.Publisher { NotificationCenter.default.publisher(for: PushJSONArticle) @@ -34,6 +35,10 @@ public extension NSNotification { NotificationCenter.default.publisher(for: SpeakingReaderItem) } + static var displayProfilePublisher: NotificationCenter.Publisher { + NotificationCenter.default.publisher(for: DisplayProfile) + } + internal var operationMessage: String? { if let message = userInfo?["message"] as? String { return message @@ -68,4 +73,8 @@ public extension NSNotification { static func readerSettingsChanged() { NotificationCenter.default.post(name: NSNotification.ReaderSettingsChanged, object: nil) } + + static func displayProfile() { + NotificationCenter.default.post(name: NSNotification.DisplayProfile, object: nil) + } } diff --git a/apple/OmnivoreKit/Sources/Views/Resources/en.lproj/Localizable.strings b/apple/OmnivoreKit/Sources/Views/Resources/en.lproj/Localizable.strings index 62b25a688..127dd0811 100644 --- a/apple/OmnivoreKit/Sources/Views/Resources/en.lproj/Localizable.strings +++ b/apple/OmnivoreKit/Sources/Views/Resources/en.lproj/Localizable.strings @@ -115,7 +115,7 @@ "menuDebugApiEnv" = "API Environment:"; // Navigation -"navigationSelectLink" = "Select a link from the feed"; +"navigationSelectLink" = "Select a link from your library"; "navigationSelectSidebarToggle" = "Toggle sidebar"; // Welcome View From 2f879386a367c6293f06a9acf392189503f9cbac Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Wed, 31 May 2023 16:10:09 +0800 Subject: [PATCH 10/11] Fix label selection on macos --- .../OmnivoreKit/Sources/App/Views/Labels/ApplyLabelsView.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apple/OmnivoreKit/Sources/App/Views/Labels/ApplyLabelsView.swift b/apple/OmnivoreKit/Sources/App/Views/Labels/ApplyLabelsView.swift index d34614f38..1ffa6cba7 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Labels/ApplyLabelsView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Labels/ApplyLabelsView.swift @@ -72,9 +72,11 @@ struct ApplyLabelsView: View { Image(systemName: "checkmark") } } + .contentShape(Rectangle()) } ) .padding(.vertical, 5) + .frame(maxWidth: .infinity, alignment: .leading) #if os(macOS) .buttonStyle(PlainButtonStyle()) #endif From f53ce940495d9723674661b9f08e9a1ea113e867 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Wed, 31 May 2023 19:08:09 +0800 Subject: [PATCH 11/11] Add a logout option --- apple/InfoPlists/MacOmnivore.plist | 2 ++ apple/Omnivore.xcodeproj/project.pbxproj | 8 ++++---- apple/OmnivoreKit/Sources/App/MacMenuCommands.swift | 5 +++++ .../Sources/App/Views/Home/HomeFeedViewMac.swift | 5 +++++ .../Sources/Services/NSNotification+Operation.swift | 9 +++++++++ apple/OmnivoreKit/Sources/Views/LocalText.swift | 1 + 6 files changed, 26 insertions(+), 4 deletions(-) diff --git a/apple/InfoPlists/MacOmnivore.plist b/apple/InfoPlists/MacOmnivore.plist index d18829a1d..c2b3483f0 100644 --- a/apple/InfoPlists/MacOmnivore.plist +++ b/apple/InfoPlists/MacOmnivore.plist @@ -2,6 +2,8 @@ + ITSAppUsesNonExemptEncryption + CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleExecutable diff --git a/apple/Omnivore.xcodeproj/project.pbxproj b/apple/Omnivore.xcodeproj/project.pbxproj index 71f95bc8c..6e02bb21e 100644 --- a/apple/Omnivore.xcodeproj/project.pbxproj +++ b/apple/Omnivore.xcodeproj/project.pbxproj @@ -1388,7 +1388,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 82; + CURRENT_PROJECT_VERSION = 90; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = QJF2XZ86HB; @@ -1400,7 +1400,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 12.0; - MARKETING_VERSION = 1.24.0; + MARKETING_VERSION = 1.27.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = app.omnivore.app; @@ -1423,7 +1423,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 82; + CURRENT_PROJECT_VERSION = 90; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = QJF2XZ86HB; @@ -1435,7 +1435,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 12.0; - MARKETING_VERSION = 1.24.0; + MARKETING_VERSION = 1.27.0; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = app.omnivore.app; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/apple/OmnivoreKit/Sources/App/MacMenuCommands.swift b/apple/OmnivoreKit/Sources/App/MacMenuCommands.swift index 72250e257..4f9567126 100644 --- a/apple/OmnivoreKit/Sources/App/MacMenuCommands.swift +++ b/apple/OmnivoreKit/Sources/App/MacMenuCommands.swift @@ -142,6 +142,11 @@ import Views } }) } + CommandGroup(after: .appTermination) { + Button("Logout", action: { + NSNotification.logout() + }) + } CommandMenu("Reader Display") { spacingButtons diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift index 566d451d5..fa14d1faf 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift @@ -9,6 +9,8 @@ import Views struct HomeFeedView: View { @EnvironmentObject var dataService: DataService @EnvironmentObject var audioController: AudioController + @EnvironmentObject var authenticator: Authenticator + @State private var itemToRemove: LinkedItem? @State private var confirmationShown = false @State private var presentProfileSheet = false @@ -151,6 +153,9 @@ import Views .onReceive(NSNotification.displayProfilePublisher) { _ in presentProfileSheet = true } + .onReceive(NSNotification.logoutPublisher) { _ in + authenticator.logout(dataService: dataService) + } .task { if viewModel.items.isEmpty { loadItems(isRefresh: true) diff --git a/apple/OmnivoreKit/Sources/Services/NSNotification+Operation.swift b/apple/OmnivoreKit/Sources/Services/NSNotification+Operation.swift index 45296f027..2a94c20bd 100644 --- a/apple/OmnivoreKit/Sources/Services/NSNotification+Operation.swift +++ b/apple/OmnivoreKit/Sources/Services/NSNotification+Operation.swift @@ -10,6 +10,7 @@ public extension NSNotification { static let ReaderSettingsChanged = Notification.Name("ReaderSettingsChanged") static let SpeakingReaderItem = Notification.Name("SpeakingReaderItem") static let DisplayProfile = Notification.Name("DisplayProfile") + static let Logout = Notification.Name("Logout") static var pushFeedItemPublisher: NotificationCenter.Publisher { NotificationCenter.default.publisher(for: PushJSONArticle) @@ -39,6 +40,10 @@ public extension NSNotification { NotificationCenter.default.publisher(for: DisplayProfile) } + static var logoutPublisher: NotificationCenter.Publisher { + NotificationCenter.default.publisher(for: Logout) + } + internal var operationMessage: String? { if let message = userInfo?["message"] as? String { return message @@ -74,6 +79,10 @@ public extension NSNotification { NotificationCenter.default.post(name: NSNotification.ReaderSettingsChanged, object: nil) } + static func logout() { + NotificationCenter.default.post(name: NSNotification.Logout, object: nil) + } + static func displayProfile() { NotificationCenter.default.post(name: NSNotification.DisplayProfile, object: nil) } diff --git a/apple/OmnivoreKit/Sources/Views/LocalText.swift b/apple/OmnivoreKit/Sources/Views/LocalText.swift index 86ebd4499..13a5ba82c 100644 --- a/apple/OmnivoreKit/Sources/Views/LocalText.swift +++ b/apple/OmnivoreKit/Sources/Views/LocalText.swift @@ -165,6 +165,7 @@ public enum LocalText { public static let genericFontFamily = localText(key: "genericFontFamily") public static let genericHighContrastText = localText(key: "genericHighContrastText") public static let enableJustifyText = localText(key: "enableJustifyText") + public static let enableHighlightOnReleaseText = localText(key: "enableHighlightOnReleaseText") public static let genericFont = localText(key: "genericFont") public static let genericHighlight = localText(key: "genericHighlight") public static let labelsGeneric = localText(key: "labelsGeneric")