Skip to content

refactor: AmountInputViewModel to @Observable#586

Open
CypherPoet wants to merge 5 commits into
synonymdev:masterfrom
CypherPoet:refactor/amount-input-observable
Open

refactor: AmountInputViewModel to @Observable#586
CypherPoet wants to merge 5 commits into
synonymdev:masterfrom
CypherPoet:refactor/amount-input-observable

Conversation

@CypherPoet
Copy link
Copy Markdown
Contributor

Depends on

Depends on #584 and #585; a no-behavior @Observable refactor stacked on both. Merge #584 then #585 first. This PR targets master, so until they land its diff also contains their commits; review the refactor: migrate AmountInputViewModel to @Observable commit (012ae401) for this PR's changes.

Description

This PR migrates AmountInputViewModel from the legacy ObservableObject pattern to the @observable macro, matching the project's stated SwiftUI direction. There is no behavior change.

The view model swaps ObservableObject and @published for @observable, NumberPadTextField drops @ObservedObject, and the eight amount-entry screens move from @StateObject to @State. No @bindable is needed anywhere, since nothing creates two-way bindings to the view model; every consumer reads its values or calls its methods.

Linked Issues/Tasks

Follows up #346 and the amount-screen cap work.

Screenshot / Video

N/A; no behavior change.

QA Notes

Manual Tests

  • 1. regression: Send -> Amount: typing updates the displayed amount and fiat conversion; the cap still works.
  • 2. regression: Receive -> Amount: typing updates the invoice amount.
  • 3. regression: Transfer -> Spending Amount: typing updates and caps as before.
  • 4. regression: LNURL Pay / Withdraw -> Amount: typing and cap behave as before.

Automated Checks

  • Built app-wide for iOS Simulator (Debug) locally; the whole app target compiles against the migrated view model and BitkitTests/NumberPadTests passes (24 tests).
  • No coverage changed: pure refactor (about 13 mechanical line edits across 10 files).
  • CI: standard build/test checks run by the PR bot.

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: 012ae40175

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread changelog.d/next/585.fixed.md
@CypherPoet CypherPoet force-pushed the refactor/amount-input-observable branch from 012ae40 to 1d13030 Compare June 5, 2026 21:52
The send number pad now rejects keystrokes that would push the amount above the available sendable balance, reusing the existing over-max block (haptic + error flash) via a dynamic maxAmountOverride. Continue-button validation is unchanged as a backstop.

Closes synonymdev#346
@CypherPoet CypherPoet force-pushed the refactor/amount-input-observable branch from 1d13030 to 64655dc Compare June 6, 2026 09:13
The cap rejected every keystroke whose result still exceeded it, including deletions. When an amount lands above the cap (a prefilled invoice over the available balance, or a cap that dropped after input), the user could not backspace to reduce it, since each intermediate value was still over the cap. Deletions now always apply; the cap only blocks growing the amount.
Applies the maxAmountOverride cap (from the send-amount fix) to the LNURL pay/withdraw, spending, advanced-spending, and manual channel-funding screens, so the number pad refuses entry above each screen's contextual maximum. FundManualAmountView also gains the previously-missing upper-bound button validation, which let users proceed above the fundable balance.

Receive and CJIT amount screens are intentionally left uncapped (a receive amount has no balance ceiling).
Replaces the legacy ObservableObject/@StateObject/@ObservedObject pattern with @observable + @State, aligning with the project's stated SwiftUI direction. No behavior change: there are no two-way bindings to the view model, so no @bindable is needed. Touches the view model, NumberPadTextField, and the 8 amount-entry call sites.
@CypherPoet CypherPoet force-pushed the refactor/amount-input-observable branch from 64655dc to 9bcbe3a Compare June 6, 2026 12:10
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.

1 participant