-
Notifications
You must be signed in to change notification settings - Fork 54
fix(swift-example-app): unhide Create Identity submit button and auto-dismiss sheet on success #3694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v3.1-dev
Are you sure you want to change the base?
fix(swift-example-app): unhide Create Identity submit button and auto-dismiss sheet on success #3694
Changes from 3 commits
4368dee
dbb9613
d66b84a
50ef472
fb8a110
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -146,10 +146,6 @@ struct CreateIdentityView: View { | |||||||||||||||||||||||||||
| /// User-facing error surfaced via the `.alert` modifier. | ||||||||||||||||||||||||||||
| @State private var submitError: SubmitError? = nil | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| /// Success payload. Populated after the identity is persisted; | ||||||||||||||||||||||||||||
| /// the submit section swaps to a success banner and auto-dismiss. | ||||||||||||||||||||||||||||
| @State private var createdIdentityId: Data? = nil | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| /// Active registration controller for the Core-funded path. | ||||||||||||||||||||||||||||
| /// Stored only so `submitCoreFunded` has a local reference | ||||||||||||||||||||||||||||
| /// after spawning it; the canonical lifetime owner is | ||||||||||||||||||||||||||||
|
|
@@ -892,8 +888,8 @@ struct CreateIdentityView: View { | |||||||||||||||||||||||||||
| identityIndex: identityIndex | ||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||
| try modelContext.save() | ||||||||||||||||||||||||||||
| self.createdIdentityId = created.identityId | ||||||||||||||||||||||||||||
| self.isCreating = false | ||||||||||||||||||||||||||||
| dismiss() | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } catch { | ||||||||||||||||||||||||||||
| await MainActor.run { | ||||||||||||||||||||||||||||
|
|
@@ -990,7 +986,7 @@ struct CreateIdentityView: View { | |||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| /// Bridge a controller's phase transitions to this view's | ||||||||||||||||||||||||||||
| /// `createdIdentityId` / `submitError` / `isCreating` state. | ||||||||||||||||||||||||||||
| /// `submitError` / `isCreating` state. | ||||||||||||||||||||||||||||
| /// The observer task auto-cancels when this view deallocates | ||||||||||||||||||||||||||||
| /// (Swift task lifecycle on the captured `self`), but the | ||||||||||||||||||||||||||||
| /// controller itself outlives the view. | ||||||||||||||||||||||||||||
|
|
@@ -1014,7 +1010,6 @@ struct CreateIdentityView: View { | |||||||||||||||||||||||||||
| identityIndex: identityIndex | ||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||
| try modelContext.save() | ||||||||||||||||||||||||||||
| self.createdIdentityId = identityId | ||||||||||||||||||||||||||||
| } catch { | ||||||||||||||||||||||||||||
| self.submitError = .init( | ||||||||||||||||||||||||||||
| message: error.localizedDescription | ||||||||||||||||||||||||||||
|
|
@@ -1269,21 +1264,25 @@ struct CreateIdentityView: View { | |||||||||||||||||||||||||||
| else { | ||||||||||||||||||||||||||||
| return "" | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| let dash: Double | ||||||||||||||||||||||||||||
| switch account.accountType { | ||||||||||||||||||||||||||||
| case 14: | ||||||||||||||||||||||||||||
| let balance = accountBalance(account) | ||||||||||||||||||||||||||||
| if balance == 0 { return "" } | ||||||||||||||||||||||||||||
| let dash = Double(balance) / Double(Self.creditsPerDash) | ||||||||||||||||||||||||||||
| return String(format: "%g", dash) | ||||||||||||||||||||||||||||
| dash = Double(balance) / Double(Self.creditsPerDash) | ||||||||||||||||||||||||||||
| case 0, 1: | ||||||||||||||||||||||||||||
| let available = coreAccountBalanceDuffs(account) | ||||||||||||||||||||||||||||
| let defaultDuffs = min(available, Self.defaultCoreFundingDuffs) | ||||||||||||||||||||||||||||
| if defaultDuffs == 0 { return "" } | ||||||||||||||||||||||||||||
| let dash = Double(defaultDuffs) / Double(Self.duffsPerDash) | ||||||||||||||||||||||||||||
| return String(format: "%g", dash) | ||||||||||||||||||||||||||||
| dash = Double(defaultDuffs) / Double(Self.duffsPerDash) | ||||||||||||||||||||||||||||
| default: | ||||||||||||||||||||||||||||
| return "" | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| let truncated = (dash * 10_000).rounded(.down) / 10_000 | ||||||||||||||||||||||||||||
| var s = String(format: "%.4f", truncated) | ||||||||||||||||||||||||||||
| while s.last == "0" { s.removeLast() } | ||||||||||||||||||||||||||||
| if s.last == "." { s.removeLast() } | ||||||||||||||||||||||||||||
| return s | ||||||||||||||||||||||||||||
|
Comment on lines
+1533
to
+1538
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Suggestion: Sub-0.0001 DASH balances still collapse the prefill to an unparseable "0" The truncation logic fixes the original rounding-up regression but introduces the same submit-button-disappears failure mode at the low end. When the selected Platform Payment balance is below 10_000_000 credits (0.0001 DASH), or the Core/CoinJoin default min(available, 250_000) is below 10_000 duffs,
Suggested change
source: ['claude', 'codex'] |
||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| /// Parse the amount text back into credits. Returns `nil` on | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.