yattee/Shared/Settings/BrowsingSettings.swift

51 lines
1.4 KiB
Swift
Raw Normal View History

2021-11-04 23:25:51 +00:00
import Defaults
import SwiftUI
struct BrowsingSettings: View {
@Default(.channelOnThumbnail) private var channelOnThumbnail
@Default(.timeOnThumbnail) private var timeOnThumbnail
2021-11-07 20:51:22 +00:00
#if os(iOS)
@Default(.tabNavigationSection) private var tabNavigationSection
#endif
2021-11-04 23:25:51 +00:00
var body: some View {
2021-11-07 20:51:22 +00:00
Section(header: SettingsHeader(text: "Browsing"), footer: footer) {
2021-11-04 23:25:51 +00:00
Toggle("Display channel names on thumbnails", isOn: $channelOnThumbnail)
Toggle("Display video length on thumbnails", isOn: $timeOnThumbnail)
2021-11-07 20:51:22 +00:00
#if os(iOS)
preferredTabPicker
#endif
2021-11-04 23:25:51 +00:00
}
.frame(minWidth: 0, maxWidth: .infinity, alignment: .leading)
#if os(macOS)
Spacer()
#endif
}
2021-11-07 20:51:22 +00:00
var footer: some View {
#if os(iOS)
Text("This tab will be displayed when there is no space to display all tabs")
#else
EmptyView()
#endif
}
#if os(iOS)
var preferredTabPicker: some View {
Picker("Preferred tab", selection: $tabNavigationSection) {
Text("Trending").tag(TabNavigationSectionSetting.trending)
Text("Popular").tag(TabNavigationSectionSetting.popular)
}
}
#endif
2021-11-04 23:25:51 +00:00
}
struct BrowsingSettings_Previews: PreviewProvider {
static var previews: some View {
BrowsingSettings()
.injectFixtureEnvironmentObjects()
}
}