mirror of
https://github.com/yattee/yattee.git
synced 2025-08-06 10:44:06 +00:00
Add Defaults library
This commit is contained in:
@@ -1,37 +1,38 @@
|
||||
import Defaults
|
||||
import SwiftUI
|
||||
|
||||
struct ContentView: View {
|
||||
@ObservedObject private var state = AppState()
|
||||
@ObservedObject private var profile = Profile()
|
||||
|
||||
@SceneStorage("tabSelection") var tabSelection = TabSelection.subscriptions
|
||||
@Default(.tabSelection) var tabSelection
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
TabView(selection: $tabSelection) {
|
||||
SubscriptionsView(tabSelection: $tabSelection)
|
||||
SubscriptionsView()
|
||||
.tabItem { Text("Subscriptions") }
|
||||
.tag(TabSelection.subscriptions)
|
||||
|
||||
PopularVideosView(tabSelection: $tabSelection)
|
||||
PopularVideosView()
|
||||
.tabItem { Text("Popular") }
|
||||
.tag(TabSelection.popular)
|
||||
|
||||
if state.showingChannel {
|
||||
ChannelView(tabSelection: $tabSelection)
|
||||
ChannelView()
|
||||
.tabItem { Text("\(state.channel) Channel") }
|
||||
.tag(TabSelection.channel)
|
||||
}
|
||||
|
||||
TrendingView(tabSelection: $tabSelection)
|
||||
TrendingView()
|
||||
.tabItem { Text("Trending") }
|
||||
.tag(TabSelection.trending)
|
||||
|
||||
PlaylistsView(tabSelection: $tabSelection)
|
||||
PlaylistsView()
|
||||
.tabItem { Text("Playlists") }
|
||||
.tag(TabSelection.playlists)
|
||||
|
||||
SearchView(tabSelection: $tabSelection)
|
||||
SearchView()
|
||||
.tabItem { Image(systemName: "magnifyingglass") }
|
||||
.tag(TabSelection.search)
|
||||
}
|
||||
|
6
Shared/Defaults.swift
Normal file
6
Shared/Defaults.swift
Normal file
@@ -0,0 +1,6 @@
|
||||
import Defaults
|
||||
|
||||
extension Defaults.Keys {
|
||||
static let layout = Key<ListingLayout>("listingLayout", default: .cells)
|
||||
static let tabSelection = Key<TabSelection>("tabSelection", default: .subscriptions)
|
||||
}
|
14
Shared/ListingLayout.swift
Normal file
14
Shared/ListingLayout.swift
Normal file
@@ -0,0 +1,14 @@
|
||||
import Defaults
|
||||
|
||||
enum ListingLayout: String, CaseIterable, Defaults.Serializable {
|
||||
case list, cells
|
||||
|
||||
var name: String {
|
||||
switch self {
|
||||
case .list:
|
||||
return "List"
|
||||
case .cells:
|
||||
return "Cells"
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,6 @@
|
||||
import Defaults
|
||||
import Foundation
|
||||
|
||||
enum TabSelection: String {
|
||||
enum TabSelection: String, DefaultsSerializable {
|
||||
case subscriptions, popular, trending, playlists, channel, search
|
||||
}
|
||||
|
Reference in New Issue
Block a user