mirror of
https://github.com/yattee/yattee.git
synced 2026-06-04 13:54:19 +00:00
Add List/Grid layout option for Home sections
Introduces a "Display sections as" picker in Home settings with List and Grid modes. Grid renders each section as a horizontal shelf of video cards, defaulting to Grid on tvOS and List on iOS/macOS. Per-platform defaults are preserved via a platform-specific settings key. On tvOS the shelf is a focus section so swiping up/down between rows of different lengths works without getting stuck at the end of a row.
This commit is contained in:
@@ -17,6 +17,7 @@ struct HomeSettingsView: View {
|
||||
@State private var sectionOrder: [HomeSectionItem] = []
|
||||
@State private var sectionVisibility: [HomeSectionItem: Bool] = [:]
|
||||
@State private var sectionItemsLimit: Int = 5
|
||||
@State private var sectionLayout: HomeSectionLayout = HomeSectionLayout.platformDefault
|
||||
|
||||
// Available items (not yet added to Home)
|
||||
@State private var availableShortcutsByInstance: [(instance: Instance, cards: [HomeShortcutItem])] = []
|
||||
@@ -125,6 +126,16 @@ struct HomeSettingsView: View {
|
||||
|
||||
private var sectionsSection: some View {
|
||||
Section {
|
||||
Picker(String(localized: "home.settings.sections.layout"), selection: $sectionLayout) {
|
||||
ForEach(HomeSectionLayout.allCases, id: \.self) { layout in
|
||||
Label(layout.displayName, systemImage: layout.systemImage)
|
||||
.tag(layout)
|
||||
}
|
||||
}
|
||||
#if !os(tvOS)
|
||||
.pickerStyle(.segmented)
|
||||
#endif
|
||||
|
||||
#if os(tvOS)
|
||||
ForEach(Array(sectionOrder.enumerated()), id: \.element.id) { index, section in
|
||||
if section != .downloads {
|
||||
@@ -257,6 +268,7 @@ struct HomeSettingsView: View {
|
||||
sectionOrder = settings.homeSectionOrder
|
||||
sectionVisibility = settings.homeSectionVisibility
|
||||
sectionItemsLimit = settings.homeSectionItemsLimit
|
||||
sectionLayout = settings.homeSectionLayout
|
||||
|
||||
// Load available items
|
||||
let instances = env.instancesManager.instances
|
||||
@@ -276,6 +288,7 @@ struct HomeSettingsView: View {
|
||||
settings.homeSectionOrder = sectionOrder
|
||||
settings.homeSectionVisibility = sectionVisibility
|
||||
settings.homeSectionItemsLimit = sectionItemsLimit
|
||||
settings.homeSectionLayout = sectionLayout
|
||||
}
|
||||
|
||||
// MARK: - Available Item Management
|
||||
|
||||
Reference in New Issue
Block a user