Add color preview pill with animated swap button#198
Conversation
Adds a new 'Show foreground color on background color' toggle in
Preferences (Selection Settings) that displays a preview strip between
the color pickers and the footer. The strip renders sample text ("Aa"
and a pangram) in the foreground color against the background color,
giving a real-time preview of how the two colors look together.
Closes #138
https://claude.ai/code/session_01N89CKFrrN1kfSZrNmvZhhu
- Register ColorPreview.swift in project.pbxproj (PBXFileReference, PBXBuildFile for both targets, and Views group membership) - Qualify AnyTransition explicitly to resolve contextual inference errors https://claude.ai/code/session_01N89CKFrrN1kfSZrNmvZhhu
Removes the pangram sentence — the large "Aa" alone is cleaner and less visually busy while still clearly previewing the color pair. https://claude.ai/code/session_01N89CKFrrN1kfSZrNmvZhhu
Instead of a full-width strip between the pickers and footer, the preview is now a capsule-shaped pill (background color fill, foreground color text) that floats at the bottom of the color swatch area via an overlay. Restores the "Aa" + pangram text at a compact size. https://claude.ai/code/session_01N89CKFrrN1kfSZrNmvZhhu
- Pill gets a thin strokeBorder: black (40% opacity) in dark mode, white (60% opacity) in light mode - "P" toggles the preview, wired through the same notification/action pattern as "H" for history: notification name, AppDelegate @IBAction, hidden button in NavigationMenu, gear menu item, ContentView handler - Shortcut listed in HelpView Actions group https://claude.ai/code/session_01N89CKFrrN1kfSZrNmvZhhu
Prevents the pill from overlapping the type labels. When the preview is shown the pill itself communicates the color relationship, so the labels are redundant anyway. https://claude.ai/code/session_01N89CKFrrN1kfSZrNmvZhhu
- Translate sample text into all 7 supported languages (de, es, fr, hr, pl, zh-Hans, zh-Hant); ColorPreview now uses NSLocalizedString - Pill border opacity: dark 0.4→0.2, light 0.6→0.3 - Suppress swiftlint line_length on the test assertion that can't be meaningfully shortened https://claude.ai/code/session_01N89CKFrrN1kfSZrNmvZhhu
When color preview is on, the pill replaces the swap button at the top-center of the swatch area — same hover visibility, same position, same swap action. The swap icon sits inside the pill and rotates on click (and on the X shortcut). No more separate centered overlay. Transition is now a plain opacity fade instead of scale+fade. https://claude.ai/code/session_01N89CKFrrN1kfSZrNmvZhhu
- Preview pill is display-only again (no swap integration), always visible when enabled, centered over the swatches - Swap button is independent, original appearance, shows on hover - Pill uses fade-only transition https://claude.ai/code/session_01N89CKFrrN1kfSZrNmvZhhu
When preview is on, the pill and swap button live in a shared HStack centered over the swatches. The swap button slides in from behind the pill (leading edge) on a spring animation, and both end up horizontally centered together. When preview is off, the original top-center hover-to-show swap button is restored. https://claude.ai/code/session_01N89CKFrrN1kfSZrNmvZhhu
Replaces the separate pill overlay and swap button with a single SwapPreviewButton at the swap button's position (top center, hover to show). - No preview: behaves exactly like the old swap button (icon only, "Swap" label slides in on hover) - Preview on: always expanded — shows icon + "Swap" + separator + "Aa" + sample text, using the foreground/background colors as fill/text; hover label expansion is skipped since it's already full Removes label-hiding from EyedropperButton since there is no longer a centered pill to conflict with. https://claude.ai/code/session_01N89CKFrrN1kfSZrNmvZhhu
There was a problem hiding this comment.
Pull request overview
This PR introduces an optional “color preview pill” UI that shows sample foreground text rendered on the current background color, integrates a new toggle (Preferences + menu + P shortcut), and refactors the swap control to animate/expand alongside the preview mode.
Changes:
- Added a new preview + swap composite control (
SwapPreviewButton/PreviewPill) and wired it into the main picker UI. - Introduced a persisted preference (
showColorPreview) with UI + menu actions + keyboard shortcut + help entry. - Updated swap button style to support an expanded “Swap” label state and adjusted some UI affordances (history clear icon).
Reviewed changes
Copilot reviewed 20 out of 22 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| Pika/Views/ColorPreview.swift | New preview pill + swap composite view and its transitions/animations. |
| Pika/Views/ContentView.swift | Uses the new composite control and adds notification handling to toggle preview mode. |
| Pika/ButtonStyles/SwapButtonStyle.swift | Adds “expanded” state and updates animation behavior for label reveal. |
| Pika/Constants/Defaults.swift | Adds persisted showColorPreview default key. |
| Pika/Constants/Constants.swift | Adds notification + localized text constants for preview toggle and preference label. |
| Pika/AppDelegate.swift | Adds an action to dispatch the toggle preview notification. |
| Pika/Views/PreferencesView.swift | Adds Preferences toggle for showColorPreview. |
| Pika/Views/NavigationMenu.swift | Adds hidden keyboard shortcut handler (p) for toggling preview. |
| Pika/Views/NavigationMenuItems.swift | Adds menu item for toggling preview. |
| Pika/Views/HelpView.swift | Documents the new P shortcut in help. |
| Pika/Views/EyedropperButton.swift | Fades out “Foreground/Background” labels when preview mode is enabled. |
| Pika/Views/ColorHistoryDrawer.swift | Changes clear-history icon to trash.fill. |
| Pika/Assets/en.lproj/Localizable.strings | Adds new preview-related localized strings (toggle, preference label, sample text). |
| Pika/Assets/de.lproj/Localizable.strings | Adds sample preview text localization. |
| Pika/Assets/es.lproj/Localizable.strings | Adds sample preview text localization. |
| Pika/Assets/fr.lproj/Localizable.strings | Adds sample preview text localization. |
| Pika/Assets/hr.lproj/Localizable.strings | Adds sample preview text localization. |
| Pika/Assets/pl.lproj/Localizable.strings | Adds sample preview text localization. |
| Pika/Assets/zh-Hans.lproj/Localizable.strings | Adds Simplified Chinese localization file (currently appears corrupted). |
| Pika/Assets/zh-Hant.lproj/Localizable.strings | Adds Traditional Chinese localization file (currently appears corrupted). |
| PikaTests/NSColorHexTests.swift | SwiftLint line-length suppression for a long XCTest failure message. |
| Pika.xcodeproj/project.pbxproj | Adds ColorPreview.swift to the Xcode project build sources. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…le keys - Replace DispatchQueue.main.asyncAfter with cancellable Task for the preview/standalone fade transition to handle rapid toggles safely - Add .allowsHitTesting(fadePhase == .visible) to prevent ghost clicks during fade-out - Add missing preferences.preview.show and color.preview.toggle keys to de, es, fr, hr, pl locale files Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@copilot, do we need to also update the localizable strings for the chinese localizations: |
Agent-Logs-Url: https://github.com/superhighfives/pika/sessions/c424733f-8daa-42d9-b158-9916242cc08a Co-authored-by: superhighfives <449385+superhighfives@users.noreply.github.com>
... Yes, both
|
…ding
- Add 6 missing history keys to zh-Hans and zh-Hant locale files
- Convert both Chinese files from UTF-16LE to UTF-8 for consistent
encoding and proper git diff/merge support
- Fix untranslated app.designed in zh-Hans ("Designed by" → "设计者")
- Fix incomplete color.swap.detail in both zh-Hans and zh-Hant
- Fix French app.designed mistranslation ("Idée de" → "Conçu par")
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fix missing and corrupted locale translations
Add geometryGroup() to isolate the pill's internal text layout from the parent HStack animation, and clipShape() to prevent text overflow. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add eye icon button to navigation menu for toggling color preview - Load history colors in Eyedroppers init to avoid animated transition on launch - Even out icon button spacing in navigation menu Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
preferences.preview.showandcolor.preview.toggletranslations to German localepreferences.preview.showandcolor.preview.toggletranslations to Spanish localepreferences.preview.showandcolor.preview.toggletranslations to French localepreferences.preview.showandcolor.preview.toggletranslations to Croatian localepreferences.preview.showandcolor.preview.toggletranslations to Polish localepreferences.preview.showandcolor.preview.toggletranslations to Chinese Simplified (zh-Hans) localepreferences.preview.showandcolor.preview.toggletranslations to Chinese Traditional (zh-Hant) locale