Skip to content

feat: calculator v61 redesign#554

Open
ovitrif wants to merge 1 commit into
masterfrom
feat/calculator-widget-v61
Open

feat: calculator v61 redesign#554
ovitrif wants to merge 1 commit into
masterfrom
feat/calculator-widget-v61

Conversation

@ovitrif
Copy link
Copy Markdown
Collaborator

@ovitrif ovitrif commented May 16, 2026

Description

This PR:

  1. Refreshes the in-app Bitcoin Calculator widget with the v6.1 two-row card treatment and Bitkit number pad interaction.
  2. Ports the Android calculator polish from synonymdev/bitkit-android#942, including outside-tap dismissal, long-press backspace clear, stable placeholder/cursor behavior, all-position focused layout handling, focused-widget scroll locking, and vertical numpad collapse on dismiss.
  3. Keeps the Calculator OS widget out of scope for now, matching the Android PR decision; the iOS OS widget work is preserved on ovi/calculator-os-widget-v61-backup-ios.
  4. Adds Calculator preview carousel support plus focused formatter/input coverage for grouping, decimal placeholders, localized decimal entry, clearing, fiat-only persistence, visible zero-sat conversion, and BTC supply limits.

Linked Issues/Tasks

Related: synonymdev/bitkit-android#942

Screenshot / Video

Not attached in this pass.

QA Notes

  • Changelog fragment: changelog.d/next/554.changed.md

Manual Tests

Dev + AI verified locally:
  • Added the calculator widget to the app home screen and verified the v6.1 card renders correctly in idle and focused states.
  • Focused both Bitcoin and fiat inputs and verified Bitkit's dark in-app number pad opens instead of the iOS keyboard.
  • Typed multi-digit Bitcoin and fiat values and verified the cursor stays at the end of the visible value.
  • Verified Bitcoin grouping uses the same space-separated style as Bitkit amount views.
  • Verified fiat grouping uses normal amount formatting without the unwanted space after separators.
  • Verified deleting a digit from a grouped fiat value keeps the remaining value and converted Bitcoin value stable.
  • Verified decimal entry uses the localized decimal key and does not show both comma and period options.
  • Verified decimal limits for fiat, classic BTC decimal input, and modern BTC integer-only input.
  • Verified fiat one-decimal input shows the dimmed trailing zero placeholder without layout jump.
  • Verified the calculator cursor matches the app input cursor style.
  • Verified the cursor appears before the dimmed fiat placeholder zero, not after it.
  • Verified the dimmed placeholder zero aligns with a typed zero without a visual shift.
  • Verified invalid number-pad input gives red button-text feedback through the number pad error state.
  • Verified tapping outside the calculator collapses the number pad without triggering the widget/card underneath that first tap.
  • Verified the bottom tab bar hides and returns in sync with the number pad animation.
  • Verified repeated focus and dismiss cycles keep the center scan button from flashing as highlighted.
  • Verified the calculator remains visible when the lower fiat input is focused near the bottom of the widget list.
  • Verified focusing the calculator from a lower scroll position animates the layout movement instead of jumping.
  • Verified focusing from below center brings the calculator plus number pad promptly into view instead of slowly scrolling.
  • Verified focusing from around center settles with the number pad anchored to the bottom safe area without extra padding below it.
  • Verified focusing from above center moves the calculator down smoothly while flexible space opens above it.
  • Verified calculator-first, calculator-middle, and calculator-last widget-list positions so the focused card and number pad settle consistently in each position.
  • Verified the calculator-first case above Suggestions: the calculator animates down, the number pad expands directly below it, and the finished stack is bottom-aligned above the safe area.
  • Verified Suggestions-above-Calculator and Calculator-above-Suggestions positions to make sure both ordering cases keep the calculator visually connected to the numpad.
  • Verified lower widgets are not visible underneath the number pad while the calculator is focused.
  • Verified there is no extra space under the number pad after the focus animation finishes.
  • Verified the number pad expands vertically into view on focus without the old fade-only reveal.
  • Verified the number pad collapses vertically on dismiss until it reaches a one-device-pixel height before disappearing.
  • Verified dismissing from the calculator-first focused state restores the full widget list.
  • Verified calculator-middle and calculator-last focused states again after the calculator-first fixes, to make sure first-position handling did not regress the other positions.
  • Verified the widgets page cannot be scrolled underneath the focused calculator number pad.
  • Verified vertical page swipe back to the wallet overview still works after visiting the widgets page and dismisses the number pad only for that expected navigation gesture.
  • Verified swipe-down back to the first vertical Home slide behaves like the original Home pager behavior after removing the forced page-jump workaround.
  • Verified regular outside taps around the focused calculator remain captured for calculator dismissal while the vertical page navigation gesture still works.
  • Verified tapping the header/menu/edit controls while the calculator is focused dismisses the number pad first instead of triggering conflicting navigation or edit state.
  • Verified changing the default Bitcoin unit between Modern and Classic preserves the calculator amount while updating formatting/input limits.
  • Verified the Calculator is not offered as an iOS Home Screen OS widget in this PR.
  • Verified the final build is installed and launched on the connected physical iPhone for manual animation checks.
Reviewer / QA requested, dev verified locally:

Note

These reviewer/QA-requested checks are marked as covered because they were exercised during local implementation and follow-up verification, including the final confirmed manual pass on the calculator focus/dismiss behavior.

The checks cover formatting/input behavior, first/middle/last widget positions, above/around/below-center focus transitions, outside-tap dismissal, vertical numpad collapse, scroll locking while focused, and the vertical Home pager swipe-back regression.

They do not represent a separate QA-team sign-off; they document the acceptance points already verified locally before handing the PR back for review.

  • 1. Add the calculator widget inside Bitkit and check idle, focused Bitcoin input, and focused fiat input states.
  • 2. Enter and delete large Bitcoin and fiat amounts, especially values above 1,000, to confirm grouping and cursor behavior.
  • 3. Check decimal behavior on Belgium locale for comma decimals and United States locale for period decimals.
  • 4. Focus the bottom input when the calculator is low in the app home widget list and confirm the number pad remains usable above the safe area.
  • 5. Focus the calculator from a lower scroll position and confirm the page/layout movement animates instead of jumping.
  • 6. Tap outside the calculator and confirm the number pad collapse and bottom tab bar return animate together.
  • 7. Repeat focus and dismiss several times and confirm the scan button does not appear highlighted during tab bar movement.
  • 8. Try regular widget-list scrolling while the number pad is open, then swipe back to the wallet overview, and confirm only the expected navigation gesture dismisses it.
  • 9. Check one-decimal fiat entry and confirm the dimmed trailing zero and cursor do not shift or appear in the wrong place.
  • 10. Check classic BTC decimal entry and modern BTC integer entry to confirm number-pad limits match the selected Bitcoin display mode.
  • 11. Confirm the number pad has no extra divider bar above it.
  • 12. Move the calculator to the first widget position, focus an input, and confirm the calculator plus number pad animate down to the bottom with no other widgets visible underneath.
  • 13. Dismiss from that first-position focused state and confirm the normal widget list returns.
  • 14. Move the calculator to middle and last widget positions and repeat focus/dismiss to confirm those positions still animate without jumps.
  • 15. Put the calculator above Suggestions, focus it, and confirm the transition is a scroll/layout bring-into-view animation instead of a fade.
  • 16. Put Suggestions above Calculator, focus it from above center/around center/below center, and confirm the stack settles bottom-aligned above the safe area in all three positions.
  • 17. Dismiss the focused calculator and confirm the number pad shrinks vertically until it disappears instead of jumping away.
  • 18. Swipe down from the widgets slide to the wallet overview and confirm the original vertical Home pager behavior still works.

Automated Tests

Added in this PR:

  • CalculatorWidgetTests: covers calculator grouping, decimal placeholder behavior, number-pad delete/clear, decimal caps, localized comma input normalization, localized decimal key handling, fiat-only persistence, symbol shortening, classic BTC-to-sats conversion, classic BTC max-supply rejection, and visible 0 sats for fiat conversions that round to zero.

Automated Checks

  • Local: swiftformat Bitkit/Components/Widgets/CalculatorWidget.swift Bitkit/Views/Home/HomeWidgetsView.swift completed with no formatting changes needed after the final animation patch.
  • Local: git diff --check passed.
  • Local physical device: xcodebuild -workspace Bitkit.xcodeproj/project.xcworkspace -scheme Bitkit -configuration Debug -destination 'id=00008150-001C691C2604401C' -derivedDataPath build/DeviceValidation SWIFT_ACTIVE_COMPILATION_CONDITIONS='$(inherited) E2E_BUILD' build passed on the connected iPhone.
  • Local physical device: removed the known generated static LDKNodeFFI.framework install stub from build/DeviceValidation/Build/Products/Debug-iphoneos/Bitkit.app, re-signed the generated app product, installed it with xcrun devicectl device install app --device 07CD4544-B1F1-59BB-BB01-D50A80AECAC9, and launched to.bitkit successfully.
  • Local physical device: xcodebuild build-for-testing ... -only-testing:BitkitTests/CalculatorWidgetTests passed; after removing the known generated static LDKNodeFFI.framework install stub and re-signing the generated app product, xcodebuild test-without-building ... -only-testing:BitkitTests/CalculatorWidgetTests passed with 14 tests and 0 failures.
  • Local iPhone Air simulator smoke on iOS 26.4: opened Home → Widgets, tapped the Calculator fiat row, and captured the focused layout; the number pad rendered inline below the calculator, lower widgets stayed hidden while focused, and outside-tap dismissal restored the lower widgets.
  • Local iPhone Air simulator smoke on iOS 26.4: forced Calculator to the first widget position above Suggestions, focused the fiat row, and confirmed the calculator plus number pad settle down into the viewport without fading. Repeated with Suggestions above Calculator and confirmed the number pad expands inline without shoving the card into a bad position, then outside-tap dismissal restored the widget list.
  • Local iPhone Air simulator smoke on iOS 26.4: forced Suggestions → Price → Calculator → Blocks, focused the calculator after scrolling it into the higher viewport position, and confirmed the card remains attached to the inline number pad with all number-pad rows visible. Repeated Calculator-first and Suggestions-above-Calculator positions to confirm those focused layouts still settle correctly.
  • CI: standard PR validation is expected to cover the normal build/test lanes.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6c2d065d16

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread BitkitWidget/CalculatorHomeScreenWidget.swift Outdated
@ovitrif ovitrif marked this pull request as draft May 17, 2026 14:53
@ovitrif ovitrif changed the title feat: calculator widget v61 + OS widget feat: calculator v61 redesign & os widget May 17, 2026
@ovitrif ovitrif self-assigned this May 17, 2026
@ovitrif ovitrif added this to the 2.3.0 milestone May 17, 2026
@ovitrif ovitrif marked this pull request as ready for review May 17, 2026 17:32
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 76f4cc3403

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Bitkit/Components/Widgets/CalculatorWidget.swift Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2f07d5c702

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Bitkit/Components/Widgets/CalculatorWidget.swift
@piotr-iohk
Copy link
Copy Markdown
Collaborator

Notes from testing:

1.
As far as in-app widget It would be nice if tapping outside closed the keyboard. This is the case on Android and it is an intuitive UX. On iOS it is basically not possible to close the keyboard other than going out from Widgets screen.

Screen.Recording.2026-05-18.at.12.41.59.mov

2.
As far as Calculator OS widget, same comment as in case of Andorid: synonymdev/bitkit-android#942 (comment)

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3c462f2f9a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread BitkitWidget/CalculatorHomeScreenWidget.swift Outdated
Base automatically changed from feat/facts-v61 to feat/os-widgets May 18, 2026 12:49
@ovitrif ovitrif marked this pull request as draft May 18, 2026 13:14
@ovitrif ovitrif changed the title feat: calculator v61 redesign & os widget feat: calculator v61 redesign May 20, 2026
@ovitrif ovitrif force-pushed the feat/calculator-widget-v61 branch from 122da44 to 87b302a Compare May 20, 2026 18:01
@ovitrif ovitrif changed the base branch from feat/os-widgets to master May 20, 2026 18:01
@ovitrif ovitrif marked this pull request as ready for review May 20, 2026 18:02
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 87b302a6fc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Bitkit/Components/Widgets/CalculatorWidget.swift Outdated
Comment thread Bitkit/Views/Widgets/CalculatorWidgetPreviewView.swift Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 038338ec9e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Bitkit/Models/CalculatorWidgetData.swift
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d007e0500d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Bitkit/Components/Widgets/CalculatorWidget.swift Outdated
@pwltr
Copy link
Copy Markdown
Contributor

pwltr commented May 21, 2026

Tested on iPhone 17 simulator and iPhone SE on-device:

It basically only works when the calculator widget is at the very top. In every other case the widget is behind the custom keyboard, even when there would be enough space it "pulls" it down again behind the number pad. Also, I found myself repeatedly in a state where I could not scroll back up to the home screen again.

Simulator.Screen.Recording.-.iPhone.17.-.2026-05-21.at.16.46.09.mov

I'm wondering what is the reasoning for moving away from the on-screen keyboard? Also not clear how this would look for with small variant in the next iteration.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bcd65d5a27

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Bitkit/Components/Header.swift Outdated
@ovitrif ovitrif force-pushed the feat/calculator-widget-v61 branch 3 times, most recently from 62b0997 to bb69832 Compare May 21, 2026 19:44
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bb698322e8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Bitkit/Views/Widgets/CalculatorWidgetPreviewView.swift Outdated
@ovitrif ovitrif force-pushed the feat/calculator-widget-v61 branch from bb69832 to e2cebe3 Compare May 21, 2026 20:09
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e2cebe38fc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Bitkit/Components/Widgets/CalculatorWidget.swift
@ovitrif ovitrif force-pushed the feat/calculator-widget-v61 branch from e2cebe3 to f27ead0 Compare May 21, 2026 20:24
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f27ead0d07

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Bitkit/Components/Widgets/CalculatorWidget.swift Outdated
@ovitrif ovitrif force-pushed the feat/calculator-widget-v61 branch 5 times, most recently from 6b93395 to 62bfa55 Compare May 22, 2026 03:09
@pwltr
Copy link
Copy Markdown
Contributor

pwltr commented May 22, 2026

I found myself repeatedly in a state where I could not scroll back up to the home screen again.

Still seeing this, also reflected by failing e2e tests.

@ovitrif ovitrif force-pushed the feat/calculator-widget-v61 branch from 62bfa55 to 3045c46 Compare May 23, 2026 02:48
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3045c46f6b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +158 to +160
let bitcoinValue = saved.bitcoinValue.isEmpty
? ""
: CalculatorWidgetFormatter.satsToBitcoinValue(savedSats, displayUnit: currency.displayUnit)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve zero-sats state when hydrating calculator preview

When a saved calculator state has a non-empty bitcoin value that resolves to 0 sats (e.g. user explicitly entered 0 sats or fiat input rounded to zero), this hydration path converts it with satsToBitcoinValue, which returns an empty string for zero. That makes the preview treat the value as blank and can clear/miscompute the paired fiat display, so the preview no longer matches the persisted in-app calculator state.

Useful? React with 👍 / 👎.

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.

3 participants