2022-12-11 11:38:57 +00:00
|
|
|
import Defaults
|
2022-12-10 02:01:59 +00:00
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct SubscriptionsView: View {
|
2022-12-11 11:38:57 +00:00
|
|
|
enum Page: String, CaseIterable, Defaults.Serializable {
|
|
|
|
case feed
|
|
|
|
case channels
|
2022-12-10 02:01:59 +00:00
|
|
|
}
|
|
|
|
|
2022-12-11 11:38:57 +00:00
|
|
|
@Default(.subscriptionsViewPage) private var subscriptionsViewPage
|
|
|
|
|
2022-12-10 02:01:59 +00:00
|
|
|
var body: some View {
|
2022-12-10 21:37:14 +00:00
|
|
|
SignInRequiredView(title: "Subscriptions".localized()) {
|
2022-12-11 11:38:57 +00:00
|
|
|
switch subscriptionsViewPage {
|
|
|
|
case .feed:
|
|
|
|
FeedView()
|
|
|
|
case .channels:
|
|
|
|
ChannelsView()
|
|
|
|
#if os(tvOS)
|
|
|
|
.ignoresSafeArea(.all, edges: .horizontal)
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
2022-12-10 02:01:59 +00:00
|
|
|
|
2022-12-11 11:38:57 +00:00
|
|
|
#if os(iOS)
|
|
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
|
|
.toolbar {
|
|
|
|
ToolbarItem(placement: .principal) {
|
|
|
|
subscriptionsMenu
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2022-12-10 20:08:03 +00:00
|
|
|
|
2022-12-11 11:38:57 +00:00
|
|
|
#if os(iOS)
|
|
|
|
var subscriptionsMenu: some View {
|
|
|
|
Menu {
|
|
|
|
Picker("Page", selection: $subscriptionsViewPage) {
|
|
|
|
Label("Feed", systemImage: "film").tag(Page.feed)
|
|
|
|
Label("Channels", systemImage: "person.3.fill").tag(Page.channels)
|
2022-12-10 02:01:59 +00:00
|
|
|
}
|
2022-12-11 22:15:56 +00:00
|
|
|
|
|
|
|
Section {
|
|
|
|
SettingsButtons()
|
|
|
|
}
|
2022-12-11 11:38:57 +00:00
|
|
|
} label: {
|
|
|
|
HStack(spacing: 12) {
|
|
|
|
Text(menuLabel)
|
|
|
|
.font(.headline)
|
|
|
|
.foregroundColor(.primary)
|
|
|
|
|
|
|
|
Image(systemName: "chevron.down.circle.fill")
|
|
|
|
.foregroundColor(.accentColor)
|
|
|
|
.imageScale(.small)
|
2022-12-10 02:01:59 +00:00
|
|
|
}
|
2022-12-11 11:38:57 +00:00
|
|
|
.transaction { t in t.animation = nil }
|
2022-12-10 02:01:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-11 11:38:57 +00:00
|
|
|
var menuLabel: String {
|
|
|
|
subscriptionsViewPage == .channels ? "Channels" : "Feed"
|
2022-12-10 02:01:59 +00:00
|
|
|
}
|
2022-12-11 11:38:57 +00:00
|
|
|
#endif
|
2022-12-10 02:01:59 +00:00
|
|
|
}
|
|
|
|
|
2022-12-11 11:38:57 +00:00
|
|
|
struct SubscriptionsView_Previews: PreviewProvider {
|
2022-12-10 02:01:59 +00:00
|
|
|
static var previews: some View {
|
2022-12-11 11:38:57 +00:00
|
|
|
NavigationView {
|
|
|
|
SubscriptionsView()
|
|
|
|
}
|
2022-12-10 02:01:59 +00:00
|
|
|
}
|
|
|
|
}
|