Enable open in browser toolbar button.

This commit is contained in:
Maurice Parker 2020-07-17 17:08:08 -05:00
parent 74b878fa6f
commit 78fdf0a0d0
2 changed files with 19 additions and 1 deletions

View File

@ -6,7 +6,11 @@
// Copyright © 2020 Ranchero Software. All rights reserved.
//
import Foundation
#if os(macOS)
import AppKit
#else
import UIKit
#endif
import Combine
import Account
import Articles
@ -54,6 +58,19 @@ final class SceneModel: ObservableObject {
}
}
// MARK Navigation API
func openInBrowser() {
guard let link = selectedArticles.first?.preferredLink else { return }
#if os(macOS)
Browser.open(link, invertPreference: NSApp.currentEvent?.modifierFlags.contains(.shift) ?? false)
#else
guard let url = URL(string: link) else { return }
UIApplication.shared.open(url, options: [:])
#endif
}
// MARK: Article Management API
func toggleReadStatusForSelectedArticles() {

View File

@ -158,6 +158,7 @@ struct SceneNavigationView: View {
}
ToolbarItem {
Button {
sceneModel.openInBrowser()
} label: {
AppAssets.openInBrowserImage
}