Skip to content

Commit

Permalink
Show send selector after scan qr-address.
Browse files Browse the repository at this point in the history
Fix parsing amounts with ',' as separator.
  • Loading branch information
ant013 committed Nov 25, 2024
1 parent 787d8f5 commit d49b664
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ extension AddressAppShowModule: IEventHandler {
}
var uri = AddressUri(scheme: "")
uri.address = text
return
showSendTokenList(source: source, eventType: eventType, uri: uri, allowedBlockchainTypes: types)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class MultiSwapViewModel: ObservableObject {
private let marketKit = App.shared.marketKit
private let walletManager = App.shared.walletManager
private let adapterManager = App.shared.adapterManager
private let decimalParser = AmountDecimalParser()

@Published var currency: Currency

Expand Down Expand Up @@ -170,7 +171,7 @@ class MultiSwapViewModel: ObservableObject {
syncQuotes()
syncFiatAmountIn()

let amount = Decimal(string: amountString)
let amount = decimalParser.parseAnyDecimal(from: amountString)

if amount != amountIn {
amountString = amountIn?.description ?? ""
Expand All @@ -180,7 +181,7 @@ class MultiSwapViewModel: ObservableObject {

@Published var amountString: String = "" {
didSet {
let amount = Decimal(string: amountString)
let amount = decimalParser.parseAnyDecimal(from: amountString)

guard amount != amountIn else {
return
Expand All @@ -196,7 +197,7 @@ class MultiSwapViewModel: ObservableObject {
didSet {
syncAmountIn()

let amount = Decimal(string: fiatAmountString)?.rounded(decimal: 2)
let amount = decimalParser.parseAnyDecimal(from: fiatAmountString)?.rounded(decimal: 2)

if amount != fiatAmountIn {
fiatAmountString = fiatAmountIn?.description ?? ""
Expand All @@ -206,7 +207,7 @@ class MultiSwapViewModel: ObservableObject {

@Published var fiatAmountString: String = "" {
didSet {
let amount = Decimal(string: fiatAmountString)?.rounded(decimal: 2)
let amount = decimalParser.parseAnyDecimal(from: fiatAmountString)?.rounded(decimal: 2)

guard amount != fiatAmountIn else {
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class PreSendViewModel: ObservableObject {
private let marketKit = App.shared.marketKit
private let walletManager = App.shared.walletManager
private let adapterManager = App.shared.adapterManager
private let decimalParser = AmountDecimalParser()

private var cancellables = Set<AnyCancellable>()

Expand All @@ -19,7 +20,7 @@ class PreSendViewModel: ObservableObject {
syncFiatAmount()
syncSendData()

let amount = Decimal(string: amountString)
let amount = decimalParser.parseAnyDecimal(from: amountString)

if amount != self.amount {
amountString = self.amount?.description ?? ""
Expand All @@ -29,7 +30,7 @@ class PreSendViewModel: ObservableObject {

@Published var amountString: String = "" {
didSet {
var amount = Decimal(string: amountString)
var amount = decimalParser.parseAnyDecimal(from: amountString)

if amount == 0 {
amount = nil
Expand All @@ -49,7 +50,7 @@ class PreSendViewModel: ObservableObject {
didSet {
syncAmount()

let amount = Decimal(string: fiatAmountString)?.rounded(decimal: 2)
let amount = decimalParser.parseAnyDecimal(from: fiatAmountString)?.rounded(decimal: 2)

if amount != fiatAmount {
fiatAmountString = fiatAmount?.description ?? ""
Expand All @@ -59,7 +60,7 @@ class PreSendViewModel: ObservableObject {

@Published var fiatAmountString: String = "" {
didSet {
let amount = Decimal(string: fiatAmountString)?.rounded(decimal: 2)
let amount = decimalParser.parseAnyDecimal(from: fiatAmountString)?.rounded(decimal: 2)

guard amount != fiatAmount else {
return
Expand Down

0 comments on commit d49b664

Please sign in to comment.