Skip to content

Commit ce54edf

Browse files
authored
ui: price animation spring
1 parent 4f0a4db commit ce54edf

File tree

2 files changed

+28
-18
lines changed

2 files changed

+28
-18
lines changed

BDKSwiftExampleWallet/Resources/Localizable.xcstrings

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,6 @@
181181
}
182182
}
183183
}
184-
},
185-
"$" : {
186-
187184
},
188185
"12 Word Seed Phrase (Optional)" : {
189186
"extractionState" : "stale",

BDKSwiftExampleWallet/View/WalletView.swift

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,28 +58,41 @@ struct WalletView: View {
5858
}
5959
.accessibilityLabel("Bitcoin Balance")
6060
.accessibilityValue("\(viewModel.balanceTotal.formattedSatoshis()) sats")
61-
6261
HStack {
6362
if viewModel.walletSyncState == .syncing {
6463
Image(systemName: "chart.bar.fill")
65-
.symbolEffect(
66-
.variableColor.cumulative
67-
)
68-
}
69-
if viewModel.walletSyncState == .synced {
70-
Text(viewModel.satsPrice, format: .currency(code: "USD"))
71-
.fontDesign(.rounded)
72-
.contentTransition(.numericText())
73-
.animation(.spring(response: 0.5, dampingFraction: 0.6, blendDuration: 0.5), value: viewModel.satsPrice)
74-
} else {
75-
Text("$")
76-
.foregroundStyle(.secondary)
77-
.fontDesign(.rounded)
78-
.transition(.opacity)
64+
.symbolEffect(.variableColor.cumulative)
65+
.transition(.symbolEffect(.appear))
7966
}
67+
Text(
68+
viewModel.satsPrice > 0 || viewModel.walletSyncState == .synced
69+
? viewModel.satsPrice.formatted(.currency(code: "USD")) : ""
70+
)
71+
.fontDesign(.rounded)
72+
.foregroundStyle(
73+
viewModel.walletSyncState == .synced ? .secondary : .tertiary
74+
)
75+
.opacity(
76+
viewModel.walletSyncState == .syncing && viewModel.satsPrice == 0
77+
? 0.7 : 1
78+
)
79+
.contentTransition(.numericText())
80+
.animation(
81+
.spring(response: 0.5, dampingFraction: 0.6, blendDuration: 0.5),
82+
value: viewModel.satsPrice
83+
)
8084
}
8185
.foregroundStyle(.secondary)
8286
.font(.subheadline)
87+
.animation(
88+
.interpolatingSpring(
89+
mass: 1,
90+
stiffness: 100,
91+
damping: 10,
92+
initialVelocity: 0
93+
),
94+
value: viewModel.walletSyncState
95+
)
8396
}
8497
.padding(.vertical, 20.0)
8598

0 commit comments

Comments
 (0)