mirror of
https://github.com/yattee/yattee.git
synced 2026-07-21 06:42:01 +00:00
Add position-based colorful Home shortcut palettes
Colorful shortcut cards now color by grid position instead of shortcut identity, so colors stay in the same slot when shortcuts are reordered. Adds a Palette option (Classic default, plus Sunset, Meadow, Berry, Grape) and a Custom palette with a swatch-list editor (ColorPicker + hex fields) and a switchable comma-separated text field. Color is resolved per position and wraps by palette length, wired via a new homeShortcutColorfulColor environment value and a Color(hex:) extension.
This commit is contained in:
@@ -379,9 +379,12 @@ struct HomeView: View {
|
||||
let gridSpacing: CGFloat = 16
|
||||
#endif
|
||||
|
||||
let shortcuts = settingsManager?.visibleShortcuts() ?? HomeShortcutItem.defaultOrder
|
||||
|
||||
return LazyVGrid(columns: columns, spacing: gridSpacing) {
|
||||
ForEach(settingsManager?.visibleShortcuts() ?? HomeShortcutItem.defaultOrder) { shortcut in
|
||||
ForEach(Array(shortcuts.enumerated()), id: \.element.id) { index, shortcut in
|
||||
shortcutCardView(for: shortcut)
|
||||
.environment(\.homeShortcutColorfulColor, colorfulColor(atPosition: index))
|
||||
#if !os(tvOS)
|
||||
.contextMenu { editShortcutsButton }
|
||||
#endif
|
||||
@@ -396,6 +399,14 @@ struct HomeView: View {
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Resolves the colorful-style color for a shortcut at the given grid
|
||||
/// position from the selected palette (and custom colors when applicable).
|
||||
private func colorfulColor(atPosition position: Int) -> Color {
|
||||
let palette = settingsManager?.homeShortcutColorfulPalette ?? .classic
|
||||
let customHex = settingsManager?.homeShortcutCustomPaletteColors ?? []
|
||||
return HomeShortcutColorfulPalette.color(forPosition: position, palette: palette, customHex: customHex)
|
||||
}
|
||||
|
||||
private var shortcutsList: some View {
|
||||
let shortcuts = settingsManager?.visibleShortcuts() ?? HomeShortcutItem.defaultOrder
|
||||
return ForEach(Array(shortcuts.enumerated()), id: \.element) { index, shortcut in
|
||||
|
||||
Reference in New Issue
Block a user