mirror of
https://github.com/yattee/yattee.git
synced 2025-08-09 04:04:07 +00:00
Basic Safari extension
This commit is contained in:
@@ -35,9 +35,6 @@ struct ContentView: View {
|
||||
}
|
||||
.onAppear(perform: configure)
|
||||
|
||||
.handlesExternalEvents(preferring: Set(["*"]), allowing: Set(["*"]))
|
||||
.onOpenURL(perform: handleOpenedURL)
|
||||
|
||||
.environmentObject(accounts)
|
||||
.environmentObject(instances)
|
||||
.environmentObject(navigation)
|
||||
@@ -72,6 +69,8 @@ struct ContentView: View {
|
||||
}
|
||||
#endif
|
||||
#if !os(tvOS)
|
||||
.handlesExternalEvents(preferring: Set(["*"]), allowing: Set(["*"]))
|
||||
.onOpenURL(perform: handleOpenedURL)
|
||||
.sheet(isPresented: $navigation.presentingAddToPlaylist) {
|
||||
AddToPlaylistView(video: navigation.videoToAddToPlaylist)
|
||||
.environmentObject(playlists)
|
||||
@@ -118,24 +117,26 @@ struct ContentView: View {
|
||||
navigation.presentingWelcomeScreen = true
|
||||
}
|
||||
|
||||
func handleOpenedURL(_ url: URL) {
|
||||
guard !accounts.current.isNil else {
|
||||
return
|
||||
}
|
||||
#if !os(tvOS)
|
||||
func handleOpenedURL(_ url: URL) {
|
||||
guard !accounts.current.isNil else {
|
||||
return
|
||||
}
|
||||
|
||||
let parser = VideoURLParser(url: url)
|
||||
let parser = VideoURLParser(url: url)
|
||||
|
||||
guard let id = parser.id else {
|
||||
return
|
||||
}
|
||||
guard let id = parser.id else {
|
||||
return
|
||||
}
|
||||
|
||||
accounts.api.video(id).load().onSuccess { response in
|
||||
if let video: Video = response.typedContent() {
|
||||
self.player.playNow(video, at: parser.time)
|
||||
self.player.presentPlayer()
|
||||
accounts.api.video(id).load().onSuccess { response in
|
||||
if let video: Video = response.typedContent() {
|
||||
self.player.playNow(video, at: parser.time)
|
||||
self.player.presentPlayer()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
struct ContentView_Previews: PreviewProvider {
|
||||
|
@@ -11,8 +11,8 @@ struct PearvidiousApp: App {
|
||||
WindowGroup {
|
||||
ContentView()
|
||||
}
|
||||
.handlesExternalEvents(matching: Set(["*"]))
|
||||
#if !os(tvOS)
|
||||
.handlesExternalEvents(matching: Set(["*"]))
|
||||
.commands {
|
||||
SidebarCommands()
|
||||
}
|
||||
|
@@ -95,16 +95,19 @@ struct PlaybackBar: View {
|
||||
}
|
||||
|
||||
private var restoreLastSkippedSegmentButton: some View {
|
||||
Button {
|
||||
player.restoreLastSkippedSegment()
|
||||
} label: {
|
||||
HStack(spacing: 4) {
|
||||
Image(systemName: "arrow.uturn.left.circle")
|
||||
Text(player.lastSkipped!.category)
|
||||
Text("•")
|
||||
HStack(spacing: 4) {
|
||||
Button {
|
||||
player.restoreLastSkippedSegment()
|
||||
} label: {
|
||||
HStack(spacing: 4) {
|
||||
Image(systemName: "arrow.uturn.left.circle")
|
||||
Text(player.lastSkipped!.title())
|
||||
}
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
|
||||
Text("•")
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
|
||||
private var streamControl: some View {
|
||||
|
@@ -5,9 +5,6 @@ struct InstancesSettings: View {
|
||||
@Default(.instances) private var instances
|
||||
|
||||
@EnvironmentObject<AccountsModel> private var accounts
|
||||
@EnvironmentObject<InstancesModel> private var instancesModel
|
||||
@EnvironmentObject<SubscriptionsModel> private var subscriptions
|
||||
@EnvironmentObject<PlaylistsModel> private var playlists
|
||||
|
||||
@State private var selectedInstanceID: Instance.ID?
|
||||
@State private var selectedAccount: Account?
|
||||
@@ -69,6 +66,5 @@ struct InstancesSettingsView_Previews: PreviewProvider {
|
||||
InstancesSettings()
|
||||
}
|
||||
.frame(width: 400, height: 270)
|
||||
.environmentObject(InstancesModel())
|
||||
}
|
||||
}
|
||||
|
@@ -2,10 +2,6 @@ import Defaults
|
||||
import SwiftUI
|
||||
|
||||
struct HorizontalCells: View {
|
||||
#if os(iOS)
|
||||
@Environment(\.verticalSizeClass) private var verticalSizeClass
|
||||
#endif
|
||||
|
||||
var items = [ContentItem]()
|
||||
|
||||
var body: some View {
|
||||
|
@@ -7,10 +7,6 @@ struct SignInRequiredView<Content: View>: View {
|
||||
|
||||
@EnvironmentObject<AccountsModel> private var accounts
|
||||
|
||||
#if !os(macOS)
|
||||
@EnvironmentObject<NavigationModel> private var navigation
|
||||
#endif
|
||||
|
||||
@Default(.instances) private var instances
|
||||
|
||||
init(title: String, @ViewBuilder content: @escaping () -> Content) {
|
||||
|
@@ -5,7 +5,6 @@ struct WelcomeScreen: View {
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
|
||||
@EnvironmentObject<AccountsModel> private var accounts
|
||||
@EnvironmentObject<NavigationModel> private var navigation
|
||||
|
||||
@Default(.accounts) private var allAccounts
|
||||
|
||||
|
Reference in New Issue
Block a user