Add Piped support

This commit is contained in:
Arkadiusz Fal
2021-10-17 00:48:58 +02:00
parent a68d89cb6f
commit 62e17d5a18
44 changed files with 919 additions and 327 deletions

View File

@@ -6,7 +6,7 @@ struct ChannelVideosView: View {
@StateObject private var store = Store<Channel>()
@EnvironmentObject<InvidiousAPI> private var api
@EnvironmentObject<AccountsModel> private var accounts
@EnvironmentObject<NavigationModel> private var navigation
@EnvironmentObject<SubscriptionsModel> private var subscriptions
@@ -99,7 +99,7 @@ struct ChannelVideosView: View {
}
var resource: Resource {
let resource = api.channel(channel.id)
let resource = accounts.invidious.channel(channel.id)
resource.addObserver(store)
return resource

View File

@@ -52,6 +52,10 @@ struct PlayerControlsView<Content: View>: View {
.padding(.vertical, 20)
.contentShape(Rectangle())
}
#if !os(tvOS)
.keyboardShortcut("o")
#endif
Group {
if model.isPlaying {
Button(action: {
@@ -65,7 +69,7 @@ struct PlayerControlsView<Content: View>: View {
}) {
Label("Play", systemImage: "play.fill")
}
.disabled(model.player.currentItem == nil)
.disabled(model.player.currentItem.isNil)
}
}
.frame(minWidth: 30)

View File

@@ -4,10 +4,10 @@ import SwiftUI
struct PopularView: View {
@StateObject private var store = Store<[Video]>()
@EnvironmentObject<InvidiousAPI> private var api
@EnvironmentObject<AccountsModel> private var accounts
var resource: Resource {
api.popular
accounts.invidious.popular
}
var body: some View {

View File

@@ -5,12 +5,14 @@ struct SignInRequiredView<Content: View>: View {
let title: String
let content: Content
@EnvironmentObject<InvidiousAPI> private var api
@Default(.instances) private var instances
@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) {
self.title = title
self.content = content()
@@ -18,7 +20,7 @@ struct SignInRequiredView<Content: View>: View {
var body: some View {
Group {
if api.signedIn {
if accounts.signedIn {
content
} else {
prompt

View File

@@ -4,7 +4,11 @@ import SwiftUI
struct SubscriptionsView: View {
@StateObject private var store = Store<[Video]>()
@EnvironmentObject<InvidiousAPI> private var api
@EnvironmentObject<AccountsModel> private var accounts
var api: InvidiousAPI {
accounts.invidious
}
var feed: Resource {
api.feed
@@ -17,10 +21,7 @@ struct SubscriptionsView: View {
.onAppear {
loadResources()
}
.onChange(of: api.account) { _ in
loadResources(force: true)
}
.onChange(of: feed) { _ in
.onChange(of: accounts.account) { _ in
loadResources(force: true)
}
}