Skip to content

Add custom color palette library with iCloud sync#178

Closed
nwoodfine wants to merge 2 commits intosuperhighfives:mainfrom
nwoodfine:custom-palettes
Closed

Add custom color palette library with iCloud sync#178
nwoodfine wants to merge 2 commits intosuperhighfives:mainfrom
nwoodfine:custom-palettes

Conversation

@nwoodfine
Copy link
Copy Markdown

@nwoodfine nwoodfine commented Mar 1, 2026

Addresses #180

Adds user-defined color palettes in a text format with support for all color formats. Palettes appear as swatch bars below color history and sync via iCloud Key-Value Store.

new-color-history-palettes

settings-custom-color-palettes

NOTE: Stacked PR: This builds on #177 (Color History). The diff currently includes PR 1's commits. Please review and merge PR 1 first, then I'll rebase so only PR 2 changes remain.

This is PR 2 of 3 in a stacked series:

  1. Color History (Add persistent color history bar #177) → base: main
  2. Custom Color Palettes (this PR) → base: main (depends on PR 1)
  3. Menubar Popover Mode (Add menubar popover mode with window option #176) → base: main (depends on PRs 1 & 2)

Changes (this PR only)

  • PaletteParser: INI-style [Name] headers with comma-separated colors, optional (label) names
  • ColorPaletteBar / ColorPalettes: SwatchBar-based palette display
  • PaletteEditor: Monospaced text input with debounced validation and "Saved" feedback
  • PaletteSyncManager: Bidirectional iCloud KVS sync with feedback-loop prevention; graceful degradation when entitlement is absent
  • NSColor.fromColorString(): Reverse parsing for all supported formats (hex, rgb, hsl, hsb, lab, oklch, opengl)
  • Limits: up to 5 palettes, 20 colors each (seemed about right)
  • Dynamic window resizing based on palette count
  • Added com.apple.developer.ubiquity-kvstore-identifier entitlement for iCloud KVS. KVS requires no portal setup beyond enabling the capability in Xcode; the runtime check in PaletteSyncManager falls back to local-only storage if the entitlement is absent

New files

  • Pika/Models/ColorPalette.swift
  • Pika/Utilities/PaletteSyncManager.swift
  • Pika/Views/ColorPaletteBar.swift
  • Pika/Views/ColorPalettes.swift
  • Pika/Views/PaletteEditor.swift

Testing

  • Built and tested with Xcode 26.3 on macOS 26.3

Test plan

  • Add palettes in Preferences with various formats (hex, rgb, hsl, etc.)
  • Verify palettes appear as swatch bars in main interface
  • Tap a palette swatch — should apply as foreground and copy
  • Verify validation feedback (max 5 palettes, 20 colors)
  • Verify iCloud sync between devices (if applicable)
  • Verify window resizes when palettes are added/removed
  • Verify color names display correctly on hover

Note on dependencies

These changes were developed and tested with locally updated dependencies. The PRs intentionally do not include these dependency bumps — they remain on the versions currently in main. The features do not require the newer versions to build or run. For reference, the development environment used:

Dependency main version Dev/test version
SwiftLint (Mintfile) 0.52.4 0.57.1
SwiftFormat (Mintfile) 0.55.1 0.55.5
KeyboardShortcuts (SPM) 2.3.0 2.4.0
Sparkle (SPM) revision 891afd44c707 2.9.0

@nwoodfine nwoodfine force-pushed the custom-palettes branch 2 times, most recently from b62bc44 to 97a46d5 Compare March 1, 2026 07:59
@nwoodfine nwoodfine marked this pull request as ready for review March 1, 2026 08:02
@nwoodfine nwoodfine marked this pull request as draft March 1, 2026 08:03
nwoodfine added 2 commits March 1, 2026 15:49
Addresses superhighfives#139

Adds a color history bar below the footer showing recently picked colors.
Tapping a swatch applies it as the foreground and copies to clipboard.

- ColorHistoryManager: MRU list with immediate and debounced recording
- SwatchBar: Reusable swatch component (shared with future palette feature)
- Refactored system color picker to use togglePicker() directly
- Dynamic window resizing when history appears/disappears
Adds user-defined color palettes in a text format with support for all
color formats (hex, rgb, hsl, hsb, lab, oklch). Palettes appear as
swatch bars below color history and sync via iCloud Key-Value Store.

- PaletteParser: INI-style [Name] headers with comma-separated colors
- NSColor.fromColorString(): Reverse parsing for all supported formats
- PaletteSyncManager: Bidirectional iCloud KVS sync with loop prevention
- PaletteEditor: Monospaced text input with validation feedback
- Up to 5 palettes, 20 colors each
@superhighfives
Copy link
Copy Markdown
Owner

I love this idea, and I think it makes sense for Pika to eventually have palettes. Going to close this for now, but I really appreciate the push to dig into it. The color history beta I just pushed out is the first step toward it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants