Skip to content

feat: let the host set the sheet background and badge the address field - #11

Open
romchornyi wants to merge 4 commits into
masterfrom
feat/bottom-sheet-background
Open

feat: let the host set the sheet background and badge the address field#11
romchornyi wants to merge 4 commits into
masterfrom
feat/bottom-sheet-background

Conversation

@romchornyi

@romchornyi romchornyi commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Issue being fixed or feature implemented

Two components could not be adapted by their hosts without forking them.

BottomSheet hard-coded Color.dash.primaryBackground in three places, so a
sheet that belongs on a different surface had no way to say so. Restyling only
the content is not enough: the background is also what the presentation detent
paints behind the home-indicator inset, so a host that overrode its own content
still got a strip of the original colour along the bottom edge.

AddressFieldView had nowhere to put anything beside its label. The consumer
in dashwallet-ios needs a badge there naming what an entered address decoded to
— a property of the field, not an action on it.

What was done?

BottomSheet takes a background: Color, defaulting to
.dash.primaryBackground so every existing call site renders exactly as
before. It is applied to the sheet body, to both content branches, and to the
presentation background, so the bottom-edge strip cannot reappear.

AddressFieldView became generic over an Accessory view placed opposite the
label, with a Spacer between them. Callers that want none keep the shape they
already had: a constrained extension on Accessory == EmptyView supplies the
old initializer verbatim, so no existing call site changes.

Its Layout constants moved out of the type to file scope. A generic type
cannot hold static stored properties — worth knowing that SwiftPM compiled the
nested version anyway and only Xcode rejected it, so swift build alone does
not prove this file.

How Has This Been Tested?

swift build clean, plus a full dashpay build in dashwallet-ios pinned to
this branch — that consumer is the one exercising both new parameters, and it
is the build that catches what SwiftPM misses. Exercised on the simulator: the
address step with the destination badge, and the sheets that pass a background.

Existing call sites were not touched, and both defaults reproduce the previous
rendering.

Breaking Changes

None at call sites — both additions are defaulted, and the EmptyView
extension keeps AddressFieldView's original initializer.

Worth flagging for anyone writing the type name explicitly: AddressFieldView
is now generic, so an explicit annotation needs a parameter
(AddressFieldView<EmptyView>). Inferred usage is unaffected.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

Summary by CodeRabbit

  • New Features

    • Added optional accessory views to address field labels, such as badges or status indicators.
    • Added configurable background colors for bottom sheets and self-sizing sheets.
    • Bottom sheet backgrounds now extend through the presentation area, including the home-indicator region.
  • Documentation

    • Updated bottom sheet examples and guidance to cover custom presentation backgrounds.

jeanpierreroma and others added 3 commits August 10, 2026 18:17
The fill was hardcoded to `primaryBackground` in five places, and the
presentation background — the one that covers the home-indicator inset —
was only applied when a `cornerRadius` happened to be passed. A host that
wanted anything else had two bad options: restyle its own content and
live with a pale strip along the bottom edge, or pass a corner radius it
did not want purely for the side effect.

`background` is now a parameter on `BottomSheet`, on the `selfSizing`
factory and on `selfSizingSheet(…)`, defaulting to what it was. The
presentation fill applies on iOS 16.4+ regardless of corner radius, so
the strip matches whatever the sheet is filled with.

Why the strip exists at all: the natural-height path deliberately measures
without the bottom safe area, and `presentationDetents([.height])` adds
that inset back — so it lies outside the sheet's own stack and needs the
presentation background to be covered.
The label row was a bare Text, so a host with something to say about the
address it decoded — which chain it turned out to belong to — had nowhere to
put it and had to draw its own label row above the field, printing the label
twice.

An optional accessory sits opposite the label. It is deliberately not inside
the field: the controls in there act on the address (paste, scan, clear),
while this describes it.

Generic over the accessory with an EmptyView convenience initializer, the same
shape NavigationBar uses, so existing callers are untouched.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A generic type cannot hold static stored properties, so the nested Layout enum
stopped compiling the moment the view gained its accessory parameter. SwiftPM
accepted it; Xcode did not, which is where it surfaced.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 7aff4808-85a5-4d21-8780-4c9560690923

📥 Commits

Reviewing files that changed from the base of the PR and between d8dff73 and fc5dbe5.

📒 Files selected for processing (2)
  • Sources/DashUIKit/Components/AddressFieldView.swift
  • Sources/DashUIKit/Components/BottomSheet.swift
🚧 Files skipped from review as they are similar to previous changes (2)
  • Sources/DashUIKit/Components/BottomSheet.swift
  • Sources/DashUIKit/Components/AddressFieldView.swift

Included review availability: Your plan includes up to 3 reviews per rolling hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

AddressFieldView now supports trailing label accessories while preserving its original initializer. BottomSheet now accepts and propagates a configurable background color through fixed-height and self-sizing presentations. Previews and documentation show the new configurations.

Changes

UI component enhancements

Layer / File(s) Summary
AddressFieldView label accessory
Sources/DashUIKit/Components/AddressFieldView.swift
AddressFieldView is generic over an accessory view and displays it beside the label. An EmptyView specialization preserves the existing initializer shape.
BottomSheet background propagation
Sources/DashUIKit/Components/BottomSheet.swift, docs/navigation-and-containers.md
BottomSheet, selfSizing, and selfSizingSheet accept a background color. The color applies to sheet content and presentation backgrounds. Previews and documentation show the configuration.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to fc5db

The changes add optional sheet background and address-field accessory customization while preserving existing call-site behavior; no actionable merge-blocking risk remains.

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant BottomSheet
  participant SelfSizingSheet
  participant Presentation
  Caller->>BottomSheet: Provide background color
  BottomSheet->>SelfSizingSheet: Propagate background
  SelfSizingSheet->>Presentation: Apply presentation background
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes both primary changes: configurable sheet backgrounds and address field accessories.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/bottom-sheet-background

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 7

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Sources/DashUIKit/Components/BottomSheet.swift (1)

190-210: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Restrict the presentation-background guarantee to iOS 16.4 and later.

presentationDetents supports iOS 16.0, but presentationBackground supports iOS 16.4 and later. On iOS 16.0–16.3, selfSizingSheet does not fill the presentation’s bottom safe-area strip. Update the source documentation and the two statements in docs/navigation-and-containers.md, or add a UIKit fallback. The existing no-op path below iOS 16 satisfies the iOS 14 fallback requirement.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Sources/DashUIKit/Components/BottomSheet.swift` around lines 190 - 210,
Restrict the presentation-background guarantee to iOS 16.4 and later: update the
selfSizingSheet documentation in Sources/DashUIKit/Components/BottomSheet.swift
and both affected statements in docs/navigation-and-containers.md at lines 98
and 112-116 to state that iOS 16.0–16.3 do not fill the bottom safe-area strip,
while preserving the existing no-op behavior below iOS 16; no direct code change
is required in the shown modifier branch unless adding a UIKit fallback instead.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Sources/DashUIKit/Components/AddressFieldView.swift`:
- Around line 341-365: Wrap the iOS 17/macOS 14 `#Preview("Label accessory")`
declaration in `#if DEBUG` and `#endif`, preserving the existing preview
implementation unchanged.
- Around line 352-353: Replace the direct Image(systemName:) badge icon in
AddressFieldView with an appropriate DashIconSource, then render that source
using Image(dash: source) while preserving the existing size and weight styling.
- Around line 343-356: Localize the preview’s user-facing strings in
AddressFieldView by wrapping “Address,” “Dash address,” and “Transparent
address” with NSLocalizedString using bundle: .module and appropriate comments;
add matching entries to the module’s localization resources.
- Around line 31-32: Restore compatibility in AddressFieldView by isolating the
`@FocusState-dependent` behavior and text-field branches behind iOS 15/macOS 12
availability, and provide an equivalent iOS 14/macOS 11 fallback. Then update
AddressFieldView and its compatibility initializer availability to iOS 14/macOS
11 while preserving focus behavior on newer platforms.

In `@Sources/DashUIKit/Components/BottomSheet.swift`:
- Around line 179-188: The selfSizingSheet modifier’s default background must
match the enclosing BottomSheet background. Update the BottomSheet and
selfSizingSheet flow to propagate and reuse the configured sheet color via the
existing environment mechanism, or require the modifier caller to provide it
explicitly; remove the incorrect independent .dash.primaryBackground default and
preserve matching content and presentation colors.
- Around line 305-326: Wrap the `#Preview` declaration for “BottomSheet Custom
Background” in `#if` DEBUG and a matching `#endif`, preserving its existing iOS
17/macOS 14 availability and preview content.
- Around line 190-206: Update the macOS path in the availability-gated modifier
flow around SelfSizingSheetModifier so presentationBackground(background) is
applied on macOS 13.3 and later. Keep the existing iOS-specific corner-radius
handling intact, and ensure older macOS versions continue using the fallback
behavior.

---

Outside diff comments:
In `@Sources/DashUIKit/Components/BottomSheet.swift`:
- Around line 190-210: Restrict the presentation-background guarantee to iOS
16.4 and later: update the selfSizingSheet documentation in
Sources/DashUIKit/Components/BottomSheet.swift and both affected statements in
docs/navigation-and-containers.md at lines 98 and 112-116 to state that iOS
16.0–16.3 do not fill the bottom safe-area strip, while preserving the existing
no-op behavior below iOS 16; no direct code change is required in the shown
modifier branch unless adding a UIKit fallback instead.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 53993a54-173b-43e7-968e-c6816a0d573d

📥 Commits

Reviewing files that changed from the base of the PR and between 88bf41f and d8dff73.

📒 Files selected for processing (3)
  • Sources/DashUIKit/Components/AddressFieldView.swift
  • Sources/DashUIKit/Components/BottomSheet.swift
  • docs/navigation-and-containers.md

Comment thread Sources/DashUIKit/Components/AddressFieldView.swift
Comment thread Sources/DashUIKit/Components/AddressFieldView.swift
Comment thread Sources/DashUIKit/Components/AddressFieldView.swift
Comment thread Sources/DashUIKit/Components/AddressFieldView.swift Outdated
Comment thread Sources/DashUIKit/Components/BottomSheet.swift
Comment thread Sources/DashUIKit/Components/BottomSheet.swift
Comment thread Sources/DashUIKit/Components/BottomSheet.swift
- `selfSizingSheet` docs no longer claim the background defaults to the
  wrapped sheet's own — the modifier cannot see it, so a custom colour
  has to be passed here too (or go through `BottomSheet.selfSizing`).
- Apply `presentationBackground` on macOS 13.3+ as well; the parameter
  was silently dropped there because only the iOS branch used it.
- Wrap the `BottomSheet` previews in `#if DEBUG`, matching the rest of
  the library.
- Badge preview uses `DashIcon.Common.iconDashCurrency` instead of an
  SF Symbol.
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