mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
Fix #190
This commit is contained in:
parent
485e1b060e
commit
117c4fc9b6
@ -86,7 +86,8 @@ final class NavigationModel: ObservableObject {
|
|||||||
_ channel: Channel,
|
_ channel: Channel,
|
||||||
player: PlayerModel,
|
player: PlayerModel,
|
||||||
recents: RecentsModel,
|
recents: RecentsModel,
|
||||||
navigation: NavigationModel
|
navigation: NavigationModel,
|
||||||
|
navigationStyle: NavigationStyle
|
||||||
) {
|
) {
|
||||||
guard channel.id != Video.fixtureChannelID else {
|
guard channel.id != Video.fixtureChannelID else {
|
||||||
return
|
return
|
||||||
@ -104,17 +105,22 @@ final class NavigationModel: ObservableObject {
|
|||||||
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
|
||||||
recents.add(recent)
|
recents.add(recent)
|
||||||
|
|
||||||
|
if navigationStyle == .sidebar {
|
||||||
navigation.sidebarSectionChanged.toggle()
|
navigation.sidebarSectionChanged.toggle()
|
||||||
navigation.tabSelection = .recentlyOpened(recent.tag)
|
navigation.tabSelection = .recentlyOpened(recent.tag)
|
||||||
|
} else {
|
||||||
navigation.presentingChannel = true
|
navigation.presentingChannel = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static func openChannelPlaylist(
|
static func openChannelPlaylist(
|
||||||
_ playlist: ChannelPlaylist,
|
_ playlist: ChannelPlaylist,
|
||||||
player: PlayerModel,
|
player: PlayerModel,
|
||||||
recents: RecentsModel,
|
recents: RecentsModel,
|
||||||
navigation: NavigationModel
|
navigation: NavigationModel,
|
||||||
|
navigationStyle: NavigationStyle
|
||||||
) {
|
) {
|
||||||
navigation.presentingChannel = false
|
navigation.presentingChannel = false
|
||||||
navigation.presentingPlaylist = false
|
navigation.presentingPlaylist = false
|
||||||
@ -128,11 +134,15 @@ final class NavigationModel: ObservableObject {
|
|||||||
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
|
||||||
recents.add(recent)
|
recents.add(recent)
|
||||||
|
|
||||||
|
if navigationStyle == .sidebar {
|
||||||
navigation.sidebarSectionChanged.toggle()
|
navigation.sidebarSectionChanged.toggle()
|
||||||
navigation.tabSelection = .recentlyOpened(recent.tag)
|
navigation.tabSelection = .recentlyOpened(recent.tag)
|
||||||
|
} else {
|
||||||
navigation.presentingPlaylist = true
|
navigation.presentingPlaylist = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static func openSearchQuery(
|
static func openSearchQuery(
|
||||||
_ searchQuery: String?,
|
_ searchQuery: String?,
|
||||||
|
@ -87,7 +87,8 @@ struct ContentView: View {
|
|||||||
navigation: navigation,
|
navigation: navigation,
|
||||||
recents: recents,
|
recents: recents,
|
||||||
player: player,
|
player: player,
|
||||||
search: search
|
search: search,
|
||||||
|
navigationStyle: navigationStyle
|
||||||
).handle($0)
|
).handle($0)
|
||||||
}
|
}
|
||||||
.background(
|
.background(
|
||||||
@ -115,6 +116,16 @@ struct ContentView: View {
|
|||||||
.alert(isPresented: $navigation.presentingAlert) { navigation.alert }
|
.alert(isPresented: $navigation.presentingAlert) { navigation.alert }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var navigationStyle: NavigationStyle {
|
||||||
|
#if os(iOS)
|
||||||
|
return horizontalSizeClass == .compact ? .tab : .sidebar
|
||||||
|
#elseif os(tvOS)
|
||||||
|
return .tab
|
||||||
|
#else
|
||||||
|
return .sidebar
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
func openWelcomeScreenIfAccountEmpty() {
|
func openWelcomeScreenIfAccountEmpty() {
|
||||||
guard Defaults[.instances].isEmpty else {
|
guard Defaults[.instances].isEmpty else {
|
||||||
return
|
return
|
||||||
|
@ -10,6 +10,7 @@ struct OpenURLHandler {
|
|||||||
var recents: RecentsModel
|
var recents: RecentsModel
|
||||||
var player: PlayerModel
|
var player: PlayerModel
|
||||||
var search: SearchModel
|
var search: SearchModel
|
||||||
|
var navigationStyle = NavigationStyle.sidebar
|
||||||
|
|
||||||
func handle(_ url: URL) {
|
func handle(_ url: URL) {
|
||||||
if accounts.current.isNil {
|
if accounts.current.isNil {
|
||||||
@ -132,7 +133,8 @@ struct OpenURLHandler {
|
|||||||
playlist,
|
playlist,
|
||||||
player: player,
|
player: player,
|
||||||
recents: recents,
|
recents: recents,
|
||||||
navigation: navigation
|
navigation: navigation,
|
||||||
|
navigationStyle: navigationStyle
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -163,7 +165,8 @@ struct OpenURLHandler {
|
|||||||
channel,
|
channel,
|
||||||
player: player,
|
player: player,
|
||||||
recents: recents,
|
recents: recents,
|
||||||
navigation: navigation
|
navigation: navigation,
|
||||||
|
navigationStyle: navigationStyle
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -256,7 +256,8 @@ struct CommentView: View {
|
|||||||
comment.channel,
|
comment.channel,
|
||||||
player: player,
|
player: player,
|
||||||
recents: recents,
|
recents: recents,
|
||||||
navigation: navigation
|
navigation: navigation,
|
||||||
|
navigationStyle: navigationStyle
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,12 +55,12 @@ struct VideoDetails: View {
|
|||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(alignment: .leading, spacing: 0) {
|
VStack(alignment: .leading, spacing: 0) {
|
||||||
ControlsBar(
|
ControlsBar(
|
||||||
|
fullScreen: $fullScreen,
|
||||||
presentingControls: false,
|
presentingControls: false,
|
||||||
backgroundEnabled: false,
|
backgroundEnabled: false,
|
||||||
borderTop: false,
|
borderTop: false,
|
||||||
detailsTogglePlayer: false,
|
detailsTogglePlayer: false,
|
||||||
detailsToggleFullScreen: true,
|
detailsToggleFullScreen: true
|
||||||
fullScreen: $fullScreen
|
|
||||||
)
|
)
|
||||||
|
|
||||||
HStack(spacing: 4) {
|
HStack(spacing: 4) {
|
||||||
|
@ -322,7 +322,8 @@ struct SearchView: View {
|
|||||||
channel,
|
channel,
|
||||||
player: player,
|
player: player,
|
||||||
recents: recents,
|
recents: recents,
|
||||||
navigation: navigation
|
navigation: navigation,
|
||||||
|
navigationStyle: navigationStyle
|
||||||
)
|
)
|
||||||
case .playlist:
|
case .playlist:
|
||||||
guard let playlist = item.playlist else {
|
guard let playlist = item.playlist else {
|
||||||
@ -333,7 +334,8 @@ struct SearchView: View {
|
|||||||
playlist,
|
playlist,
|
||||||
player: player,
|
player: player,
|
||||||
recents: recents,
|
recents: recents,
|
||||||
navigation: navigation
|
navigation: navigation,
|
||||||
|
navigationStyle: navigationStyle
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} label: {
|
} label: {
|
||||||
|
@ -307,7 +307,8 @@ struct VideoCell: View {
|
|||||||
video.channel,
|
video.channel,
|
||||||
player: player,
|
player: player,
|
||||||
recents: recents,
|
recents: recents,
|
||||||
navigation: navigation
|
navigation: navigation,
|
||||||
|
navigationStyle: navigationStyle
|
||||||
)
|
)
|
||||||
} label: {
|
} label: {
|
||||||
if badge {
|
if badge {
|
||||||
|
@ -17,7 +17,8 @@ struct ChannelCell: View {
|
|||||||
channel,
|
channel,
|
||||||
player: player,
|
player: player,
|
||||||
recents: recents,
|
recents: recents,
|
||||||
navigation: navigation
|
navigation: navigation,
|
||||||
|
navigationStyle: navigationStyle
|
||||||
)
|
)
|
||||||
} label: {
|
} label: {
|
||||||
content
|
content
|
||||||
|
@ -3,6 +3,13 @@ import SDWebImageSwiftUI
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct ControlsBar: View {
|
struct ControlsBar: View {
|
||||||
|
@Binding var fullScreen: Bool
|
||||||
|
|
||||||
|
@State private var presentingShareSheet = false
|
||||||
|
@State private var shareURL: URL?
|
||||||
|
|
||||||
|
@Environment(\.navigationStyle) private var navigationStyle
|
||||||
|
|
||||||
@EnvironmentObject<AccountsModel> private var accounts
|
@EnvironmentObject<AccountsModel> private var accounts
|
||||||
@EnvironmentObject<NavigationModel> private var navigation
|
@EnvironmentObject<NavigationModel> private var navigation
|
||||||
@EnvironmentObject<PlayerControlsModel> private var playerControls
|
@EnvironmentObject<PlayerControlsModel> private var playerControls
|
||||||
@ -11,9 +18,6 @@ struct ControlsBar: View {
|
|||||||
@EnvironmentObject<RecentsModel> private var recents
|
@EnvironmentObject<RecentsModel> private var recents
|
||||||
@EnvironmentObject<SubscriptionsModel> private var subscriptions
|
@EnvironmentObject<SubscriptionsModel> private var subscriptions
|
||||||
|
|
||||||
@State private var presentingShareSheet = false
|
|
||||||
@State private var shareURL: URL?
|
|
||||||
|
|
||||||
var presentingControls = true
|
var presentingControls = true
|
||||||
var backgroundEnabled = true
|
var backgroundEnabled = true
|
||||||
var borderTop = true
|
var borderTop = true
|
||||||
@ -21,8 +25,6 @@ struct ControlsBar: View {
|
|||||||
var detailsTogglePlayer = true
|
var detailsTogglePlayer = true
|
||||||
var detailsToggleFullScreen = false
|
var detailsToggleFullScreen = false
|
||||||
|
|
||||||
@Binding var fullScreen: Bool
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
HStack(spacing: 0) {
|
HStack(spacing: 0) {
|
||||||
detailsButton
|
detailsButton
|
||||||
@ -170,7 +172,8 @@ struct ControlsBar: View {
|
|||||||
video.channel,
|
video.channel,
|
||||||
player: model,
|
player: model,
|
||||||
recents: recents,
|
recents: recents,
|
||||||
navigation: navigation
|
navigation: navigation,
|
||||||
|
navigationStyle: navigationStyle
|
||||||
)
|
)
|
||||||
} label: {
|
} label: {
|
||||||
Label("\(video.author) Channel", systemImage: "rectangle.stack.fill.badge.person.crop")
|
Label("\(video.author) Channel", systemImage: "rectangle.stack.fill.badge.person.crop")
|
||||||
|
@ -197,7 +197,8 @@ struct VideoContextMenuView: View {
|
|||||||
video.channel,
|
video.channel,
|
||||||
player: player,
|
player: player,
|
||||||
recents: recents,
|
recents: recents,
|
||||||
navigation: navigation
|
navigation: navigation,
|
||||||
|
navigationStyle: navigationStyle
|
||||||
)
|
)
|
||||||
} label: {
|
} label: {
|
||||||
Label("\(video.author) Channel", systemImage: "rectangle.stack.fill.badge.person.crop")
|
Label("\(video.author) Channel", systemImage: "rectangle.stack.fill.badge.person.crop")
|
||||||
|
Loading…
Reference in New Issue
Block a user