Skip to content

Split complication settings views, add floating live preview#5079

Merged
bgoncal merged 2 commits into
mainfrom
refactor/complication-list-view-split
Jul 13, 2026
Merged

Split complication settings views, add floating live preview#5079
bgoncal merged 2 commits into
mainfrom
refactor/complication-list-view-split

Conversation

@bgoncal

@bgoncal bgoncal commented Jul 13, 2026

Copy link
Copy Markdown
Member

Summary

  • One view per file: ComplicationListView.swift held three view structs; ComplicationsRootView and WatchComplicationBuilderEditView now live in their own files (code moved verbatim), and the legacy list gained its missing #Preview. The one-type-per-file + #Preview rule is now surfaced in a "Non-Negotiable Conventions" section of AGENTS.md.
  • Previews work without onboarding: FakeServerManager is now public, and the builder's #Preview seeds Current.servers with it, so the server-gated form (including the live complication mock) renders in Xcode previews.
  • Floating live preview: new reusable FloatingPanel in HADesignSystem (registered in the components gallery) — a picture-in-picture panel that follows the finger, snaps to the nearest corner on release (flick-aware via predicted end point), and resizes by tap-toggle or pinch. In the complication builder, once the inline preview section scrolls off-screen the preview re-appears floating over the form, showing only the selected family centered and zoomed to fit a compact watch face; the panel chrome radius is concentric with the watch bezel.
  • Customize disclosure persists: the editor's "Customize" toggle is stored in a new nullable isCustomized column on WatchComplicationConfig (added automatically by the existing column migration); rows saved before the flag fall back to inferring it from per-size overrides.
CleanShot 2026-07-13 at 23 39 03@2x

- Split ComplicationListView.swift into one view per file
  (ComplicationsRootView, ComplicationListView,
  WatchComplicationBuilderEditView), per the one-struct-per-file rule;
  the legacy list gained its missing #Preview. Surface that rule in a
  new Non-Negotiable Conventions section of AGENTS.md.
- Make FakeServerManager public and seed it in the builder #Preview so
  the server-gated form (including the complication mock) renders in
  Xcode previews.
- New FloatingPanel component in HADesignSystem: drag anywhere with
  corner snapping (flick-aware), tap or pinch to resize, configurable
  corner radius; registered in the components gallery.
- In the complication builder, the preview floats over the form once
  its inline section scrolls away, showing only the selected family
  centered and zoomed to fit a compact watch face whose bezel radius
  the panel chrome matches concentrically.
- Persist the editor's Customize disclosure as a new nullable
  isCustomized column (auto-added by the column migration); older rows
  fall back to inferring it from per-size overrides.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 13, 2026 21:44
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ SwiftLint disabled in this PR

The following added lines contain // swiftlint:disable. Please verify this is necessary.

@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

⚠️ Unused L10n strings detected

Found 1 unused localization strings in the codebase.

Click to see details
Parsing Strings.swift...
Found 1989 L10n strings

Reading all Swift source code...
Read 6709958 characters of Swift code

Checking for unused strings...
Checked 100/1989 strings...
Checked 200/1989 strings...
Checked 300/1989 strings...
Checked 400/1989 strings...
Checked 500/1989 strings...
Checked 600/1989 strings...
Checked 700/1989 strings...
Checked 800/1989 strings...
Checked 900/1989 strings...
Checked 1000/1989 strings...
Checked 1100/1989 strings...
Checked 1200/1989 strings...
Checked 1300/1989 strings...
Checked 1400/1989 strings...
Checked 1500/1989 strings...
Checked 1600/1989 strings...
Checked 1700/1989 strings...
Checked 1800/1989 strings...
Checked 1900/1989 strings...

================================================================================
UNUSED STRINGS REPORT
================================================================================

Found 1 unused strings:


INTENTS:
  - L10n.Intents.serverRequiredForValue
    Key: intents.server_required_for_value
    Line: 1999

================================================================================
Total unused: 1
================================================================================

================================================================================
Copy-paste these keys into the "Lokalise: Delete Keys" workflow (keys input):
================================================================================
intents.server_required_for_value

To remove them, run the
Lokalise: Delete Keys
workflow — it deletes the keys from Lokalise and opens a PR removing them from
Localizable.strings and regenerating Strings.swift. Copy-paste these keys into the keys input:

intents.server_required_for_value

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors Apple Watch complication settings UI to follow the “one type per file” convention, improves Xcode previewability by seeding a fake server environment, and introduces a reusable floating picture-in-picture live preview panel (including persistence for the “Customize” disclosure state).

Changes:

  • Split complication settings views into dedicated files and add missing #Previews.
  • Add a reusable FloatingPanel component and integrate it as a floating live complication preview when the inline preview scrolls off-screen.
  • Persist the editor’s “Customize” disclosure state via a new nullable isCustomized column on WatchComplicationConfig, with backward-compatible inference for older rows.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Sources/Shared/Database/GRDB+Initialization.swift Adds new nullable isCustomized column to the complications config table.
Sources/Shared/API/Server+Fakes.swift Makes FakeServerManager public for previews/tests and annotates helper methods.
Sources/HAModels/Sources/WatchComplicationConfig.swift Adds isCustomized persistence + showsCustomized() fallback behavior.
Sources/HAModels/Sources/DatabaseTables.swift Registers the new isCustomized database column name.
Sources/HADesignSystem/Sources/Gallery/DesignSystemComponent.swift Adds FloatingPanel to the design system component gallery.
Sources/HADesignSystem/Sources/Components/FloatingPanel.swift New draggable/snapping, pinch/tap-resizable floating panel component.
Sources/App/Settings/AppleWatch/Complications/WatchComplicationBuilderEditView.swift Moves builder into its own file; adds floating live preview + preview seeding.
Sources/App/Settings/AppleWatch/Complications/Preview/AllFamiliesComplicationPreview.swift Adds single-family compact rendering mode for the floating preview.
Sources/App/Settings/AppleWatch/Complications/ComplicationsRootView.swift Moves root complications settings view into its own file with preview.
Sources/App/Settings/AppleWatch/Complications/ComplicationListView.swift Removes embedded root/builder views; adds legacy list preview.
HomeAssistant.xcodeproj/project.pbxproj Adds the new SwiftUI files to the Xcode project.
AGENTS.md Documents the “one type per file + #Preview” rule as non-negotiable.

Comment thread Sources/HADesignSystem/Sources/Components/FloatingPanel.swift
Comment thread Sources/Shared/Database/GRDB+Initialization.swift Outdated
@bgoncal bgoncal enabled auto-merge (squash) July 13, 2026 21:53
@bgoncal bgoncal merged commit a28459d into main Jul 13, 2026
11 checks passed
@bgoncal bgoncal deleted the refactor/complication-list-view-split branch July 13, 2026 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants