feat: for tvOS
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
import SwiftUI
|
||||
|
||||
enum AppTab: String, CaseIterable, Identifiable {
|
||||
enum AppTab: String, Identifiable {
|
||||
case home
|
||||
case movie
|
||||
case series
|
||||
case variety
|
||||
case anime
|
||||
case search
|
||||
case settings
|
||||
|
||||
var id: String { rawValue }
|
||||
@@ -17,6 +18,7 @@ enum AppTab: String, CaseIterable, Identifiable {
|
||||
case .series: return "电视剧"
|
||||
case .variety: return "综艺"
|
||||
case .anime: return "动漫"
|
||||
case .search: return "搜索"
|
||||
case .settings: return "设置"
|
||||
}
|
||||
}
|
||||
@@ -28,6 +30,7 @@ enum AppTab: String, CaseIterable, Identifiable {
|
||||
case .series: return "tv"
|
||||
case .variety: return "theatermasks"
|
||||
case .anime: return "sparkles"
|
||||
case .search: return "magnifyingglass"
|
||||
case .settings: return "gearshape"
|
||||
}
|
||||
}
|
||||
@@ -41,6 +44,14 @@ enum AppTab: String, CaseIterable, Identifiable {
|
||||
default: return nil
|
||||
}
|
||||
}
|
||||
|
||||
static var visibleTabs: [AppTab] {
|
||||
#if os(tvOS)
|
||||
return [.home, .movie, .series, .variety, .anime, .search, .settings]
|
||||
#else
|
||||
return [.home, .movie, .series, .variety, .anime, .settings]
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
struct AppNavigation: View {
|
||||
@@ -55,6 +66,8 @@ struct AppNavigation: View {
|
||||
var body: some View {
|
||||
#if os(macOS)
|
||||
sidebarLayout
|
||||
#elseif os(tvOS)
|
||||
tabLayout
|
||||
#elseif os(visionOS)
|
||||
sidebarLayout
|
||||
#else
|
||||
@@ -68,7 +81,7 @@ struct AppNavigation: View {
|
||||
|
||||
private var tabLayout: some View {
|
||||
TabView(selection: $selectedTab) {
|
||||
ForEach(AppTab.allCases) { tab in
|
||||
ForEach(AppTab.visibleTabs) { tab in
|
||||
NavigationStack {
|
||||
tabContent(for: tab)
|
||||
}
|
||||
@@ -82,7 +95,7 @@ struct AppNavigation: View {
|
||||
|
||||
private var sidebarLayout: some View {
|
||||
NavigationSplitView {
|
||||
List(AppTab.allCases, selection: $selectedTab) { tab in
|
||||
List(AppTab.visibleTabs, selection: $selectedTab) { tab in
|
||||
Label(tab.title, systemImage: tab.icon)
|
||||
.tag(tab)
|
||||
}
|
||||
@@ -107,6 +120,12 @@ struct AppNavigation: View {
|
||||
BrowseView(category: .variety, viewModel: varietyVM)
|
||||
case .anime:
|
||||
BrowseView(category: .anime, viewModel: animeVM)
|
||||
case .search:
|
||||
#if os(tvOS)
|
||||
TVSearchView()
|
||||
#else
|
||||
EmptyView()
|
||||
#endif
|
||||
case .settings:
|
||||
SettingsView()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user