Skip to content

refactor: AmountInputViewModel to @Observable#3

Closed
CypherPoet wants to merge 1 commit into
fix/amount-screens-capfrom
refactor/amount-input-observable
Closed

refactor: AmountInputViewModel to @Observable#3
CypherPoet wants to merge 1 commit into
fix/amount-screens-capfrom
refactor/amount-input-observable

Conversation

@CypherPoet

@CypherPoet CypherPoet commented Jun 5, 2026

Copy link
Copy Markdown
Owner

Depends on

This PR is based on #2's branch (fix/amount-screens-cap), and transitively on #4. It targets that branch as its base, so the diff below shows only this PR's changes. Land #4 then #2 first, then re-target this to master.

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 synonymdev#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.

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

Copy link
Copy Markdown
Owner Author

Re-opened upstream as synonymdev#586. Closing this fork self-review PR.

@CypherPoet CypherPoet closed this Jun 5, 2026
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