Skip to content

refactor: share in-app & OS widget content#557

Merged
jvsena42 merged 12 commits into
feat/os-widgetsfrom
fix/widgets-polish
May 21, 2026
Merged

refactor: share in-app & OS widget content#557
jvsena42 merged 12 commits into
feat/os-widgetsfrom
fix/widgets-polish

Conversation

@jvsena42
Copy link
Copy Markdown
Member

@jvsena42 jvsena42 commented May 20, 2026

This PR:

  1. Shares each widget's content views between the in-app feed and the home-screen extension, so Blocks, Price, News, Facts, and Weather render from a single source instead of duplicated layouts.
  2. Fixes the Weather home-screen widget rendering illegibly in tinted/monochrome Smart Stacks, and makes every OS widget adapt to widgetRenderingMode.
  3. Adapts widget row spacing to the available height so content fits on smaller screens like iPhone SE.
  4. Reuses the same localization keys across in-app and home-screen widgets and ports the latest translations from Android.

Description

Before this PR, only the Weather widget shared its SwiftUI content between the app and the WidgetKit extension. Blocks, Price, News, and Facts each kept a second, hand-written copy of their layout inside BitkitWidget/, and the two copies had already drifted (different fonts vs. text components, spacing, and colors). Each widget now has one content view per layout (wide + compact) under Bitkit/Components/Widgets/, reused by the in-app feed, the carousel preview, and the home-screen widget.

Colors are centralized in a new WidgetPalette driven by widgetRenderingMode: full color maps to the dark-theme palette, while accented/monochrome Smart Stack rendering falls back to system colors with a transparent background. Outside a widget the mode defaults to full color, so the in-app widgets keep their current appearance. This also fixes the Weather widget, which previously hard-coded white text and rendered illegibly in tinted stacks.

The shared content views render inner content only; the card background, padding, and corner radius are applied by the caller — BaseWidget in the feed, the preview card in the carousel, or .containerBackground on the home screen. The Bitcoin Facts badge and the Price chart became rendering-mode-aware so both targets share one implementation, and the Blocks row spacing now uses ViewThatFits so it tightens automatically on iPhone SE instead of clipping. Localization keys are shared between the in-app and home-screen widgets and synced with bitkit-android.

Net change removes roughly 600 lines of duplicated view code.

Linked Issues/Tasks

N/A

Screenshot / Video

iphone-16-home-widgets.mp4
SE-home-widgets.mp4
iphone-16-in-app-widgets.mp4
iphone-SE-in-app-widgets.mp4

QA Notes

Manual Tests

  • 1. Wallet home → Blocks / Price / News / Facts / Weather widgets: render unchanged from before.
  • 2a. Widgets → each widget → preview: Compact↔Wide carousel, both pages show the gray card with correct content.
    • 2b. regression: edit options → preview and feed reflect the changes.
  • 3a. Home screen → add each widget (small + medium), full color: layout matches the in-app card.
    • 3b. Smart Stack tinted/accented → same widgets: text legible, accent elements tint, background transparent.
  • 4. iPhone SE → Blocks home-screen widget (small + medium): all selected rows fit, no clipping.
  • 5. Settings → Language → switch (e.g. Portuguese) → OS widgets: strings flip to the selected language.

Automated Checks

  • Build: xcodebuild -workspace Bitkit.xcodeproj/project.xcworkspace -scheme Bitkit -destination 'platform=iOS Simulator,name=iPhone 16' build — app + BitkitWidgetExtension compile and link clean. Use a concrete arm64 simulator; the generic/platform=iOS Simulator destination trips the pre-existing x86_64 link gap in the unrelated BitkitNotification target.
  • SwiftFormat run on the changed files.
  • No unit tests added or changed: this is a view-layer extraction and the widgets have no existing test coverage.
  • Changelog: no new fragment — these v61 widgets are unreleased and already covered by changelog.d/next/*-widget-v61.added.md on the base branch.

@jvsena42 jvsena42 self-assigned this May 20, 2026
@jvsena42 jvsena42 added this to the 2.3.0 milestone May 20, 2026
@jvsena42 jvsena42 marked this pull request as draft May 20, 2026 16:41
@jvsena42 jvsena42 marked this pull request as ready for review May 20, 2026 17:23
Comment thread Bitkit/Components/Widgets/FactsWidget.swift
Comment thread BitkitWidget/NewsHomeScreenWidget.swift
Base automatically changed from feat/weather-v61 to feat/os-widgets May 21, 2026 09:44
@jvsena42

This comment was marked as outdated.

@jvsena42 jvsena42 marked this pull request as draft May 21, 2026 11:14
@jvsena42
Copy link
Copy Markdown
Member Author

re-drafted to sync with target branch. Github is not displaying the update button for some reason

@jvsena42 jvsena42 force-pushed the fix/widgets-polish branch from 3374163 to 78b5f58 Compare May 21, 2026 11:16
@jvsena42
Copy link
Copy Markdown
Member Author

Tests after rebase and implement the space-between logic for news and blocks

iphone16-home-widgets.mp4
iphone16-in-app-widgets.mp4
iphoneSE-home-widgets.mp4
iphone-se-in-app-widgets.mp4

@jvsena42 jvsena42 marked this pull request as ready for review May 21, 2026 11:41
@jvsena42 jvsena42 requested a review from pwltr May 21, 2026 12:54
@jvsena42 jvsena42 merged commit 55c187b into feat/os-widgets May 21, 2026
15 of 17 checks passed
@jvsena42 jvsena42 deleted the fix/widgets-polish branch May 21, 2026 17:45
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