Skip to content

Commit

Permalink
Merge pull request #896 from novasamatech/fix/swaps-polishing
Browse files Browse the repository at this point in the history
Swaps polishing
  • Loading branch information
ERussel authored Nov 22, 2023
2 parents e82c8c8 + 1f6827a commit eb3896e
Show file tree
Hide file tree
Showing 14 changed files with 159 additions and 142 deletions.
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ abstract_target 'novawalletAll' do
pod 'SwiftLint'
pod 'R.swift', :inhibit_warnings => true
pod 'SoraKeystore', '~> 1.0.0'
pod 'SoraUI', :git => 'https://github.com/ERussel/UIkit-iOS.git', :tag => '1.11.1'
pod 'SoraUI', :git => 'https://github.com/ERussel/UIkit-iOS.git', :tag => '1.12.0'
pod 'RobinHood', '~> 2.6.0'
pod 'SoraFoundation', :git => 'https://github.com/ERussel/Foundation-iOS.git', :tag => '1.1.0'
pod 'SwiftyBeaver'
Expand Down
60 changes: 30 additions & 30 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -60,38 +60,38 @@ PODS:
- SoraFoundation/NotificationHandlers
- SoraFoundation/ViewModel (1.1.0)
- SoraKeystore (1.0.0)
- SoraUI (1.11.1):
- SoraUI/AdaptiveDesign (= 1.11.1)
- SoraUI/Animator (= 1.11.1)
- SoraUI/Camera (= 1.11.1)
- SoraUI/Controls (= 1.11.1)
- SoraUI/DetailsView (= 1.11.1)
- SoraUI/EmptyState (= 1.11.1)
- SoraUI/Helpers (= 1.11.1)
- SoraUI/LoadingView (= 1.11.1)
- SoraUI/ModalPresentation (= 1.11.1)
- SoraUI/PageLoader (= 1.11.1)
- SoraUI/PinView (= 1.11.1)
- SoraUI/Skrull (= 1.11.1)
- SoraUI/AdaptiveDesign (1.11.1)
- SoraUI/Animator (1.11.1)
- SoraUI/Camera (1.11.1)
- SoraUI/Controls (1.11.1):
- SoraUI (1.12.0):
- SoraUI/AdaptiveDesign (= 1.12.0)
- SoraUI/Animator (= 1.12.0)
- SoraUI/Camera (= 1.12.0)
- SoraUI/Controls (= 1.12.0)
- SoraUI/DetailsView (= 1.12.0)
- SoraUI/EmptyState (= 1.12.0)
- SoraUI/Helpers (= 1.12.0)
- SoraUI/LoadingView (= 1.12.0)
- SoraUI/ModalPresentation (= 1.12.0)
- SoraUI/PageLoader (= 1.12.0)
- SoraUI/PinView (= 1.12.0)
- SoraUI/Skrull (= 1.12.0)
- SoraUI/AdaptiveDesign (1.12.0)
- SoraUI/Animator (1.12.0)
- SoraUI/Camera (1.12.0)
- SoraUI/Controls (1.12.0):
- SoraUI/Animator
- SoraUI/DetailsView (1.11.1):
- SoraUI/DetailsView (1.12.0):
- SoraUI/Controls
- SoraUI/EmptyState (1.11.1):
- SoraUI/EmptyState (1.12.0):
- SoraUI/Animator
- SoraUI/Helpers (1.11.1)
- SoraUI/LoadingView (1.11.1):
- SoraUI/Helpers (1.12.0)
- SoraUI/LoadingView (1.12.0):
- SoraUI/Controls
- SoraUI/ModalPresentation (1.11.1):
- SoraUI/ModalPresentation (1.12.0):
- SoraUI/Animator
- SoraUI/Controls
- SoraUI/PageLoader (1.11.1)
- SoraUI/PinView (1.11.1):
- SoraUI/PageLoader (1.12.0)
- SoraUI/PinView (1.12.0):
- SoraUI/Controls
- SoraUI/Skrull (1.11.1)
- SoraUI/Skrull (1.12.0)
- Sourcery (1.4.1)
- Starscream (4.0.8)
- SubstrateSdk (1.14.0):
Expand Down Expand Up @@ -159,7 +159,7 @@ DEPENDENCIES:
- SnapKit (~> 5.0.0)
- SoraFoundation (from `https://github.com/ERussel/Foundation-iOS.git`, tag `1.1.0`)
- SoraKeystore (~> 1.0.0)
- SoraUI (from `https://github.com/ERussel/UIkit-iOS.git`, tag `1.11.1`)
- SoraUI (from `https://github.com/ERussel/UIkit-iOS.git`, commit `a4eb0139a27d77f11b8e5083e125c38ea82d8e5e`)
- Sourcery (~> 1.4)
- Starscream (from `https://github.com/ERussel/Starscream.git`, tag `4.0.8`)
- SubstrateSdk (from `https://github.com/nova-wallet/substrate-sdk-ios.git`, tag `1.14.0`)
Expand Down Expand Up @@ -213,8 +213,8 @@ EXTERNAL SOURCES:
:git: https://github.com/ERussel/Foundation-iOS.git
:tag: 1.1.0
SoraUI:
:commit: a4eb0139a27d77f11b8e5083e125c38ea82d8e5e
:git: https://github.com/ERussel/UIkit-iOS.git
:tag: 1.11.1
Starscream:
:git: https://github.com/ERussel/Starscream.git
:tag: 4.0.8
Expand Down Expand Up @@ -244,8 +244,8 @@ CHECKOUT OPTIONS:
:git: https://github.com/ERussel/Foundation-iOS.git
:tag: 1.1.0
SoraUI:
:commit: a4eb0139a27d77f11b8e5083e125c38ea82d8e5e
:git: https://github.com/ERussel/UIkit-iOS.git
:tag: 1.11.1
Starscream:
:git: https://github.com/ERussel/Starscream.git
:tag: 4.0.8
Expand Down Expand Up @@ -285,7 +285,7 @@ SPEC CHECKSUMS:
SnapKit: 97b92857e3df3a0c71833cce143274bf6ef8e5eb
SoraFoundation: 5b9d3c82d602150d2c2e65481c5eca5f5987c12c
SoraKeystore: 92cff6e2a12f212dd64ed089970ff7c365247b1c
SoraUI: e5ceb2cffe40145e589aa464e2e0a8d054011e0b
SoraUI: a3c1163a95c9dd1b6758ca90eb5bda2f4639d634
Sourcery: db66600e8b285c427701821598d07cf3c7e6c476
Starscream: b676ee89781677a2d8d36029a78c970710e2d3eb
SubstrateSdk: 1cb78eac5b05f2c259487f3027c3ae807f24c097
Expand All @@ -303,6 +303,6 @@ SPEC CHECKSUMS:
ZMarkupParser: a92d31ba40695b790f1da5fec98c3d4505341aff
ZNSTextAttachment: 4a9b4e8ee1ed087fc893ae6657dfb678f1a00340

PODFILE CHECKSUM: f37e3724d47617fb7ce7ed5e0a583491617b5899
PODFILE CHECKSUM: 812e09964099216590d3e74fcb350c38b2ccbd38

COCOAPODS: 1.13.0
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ final class AssetDetailsViewLayout: UIView {
)
receiveButton.invalidateLayout()

swapButton.imageWithTitleView?.title = R.string.localizable.commonSwap(
swapButton.imageWithTitleView?.title = R.string.localizable.commonSwapAction(
preferredLanguages: languages
)
swapButton.invalidateLayout()
Expand Down
23 changes: 20 additions & 3 deletions novawallet/Modules/AssetList/Models/AssetListAssetModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,31 @@ struct AssetListAssetModel: Identifiable {
let externalBalancesResult: Result<BigUInt, Error>?
let externalBalancesValue: Decimal?

var totalAmount: BigUInt? {
let totalAmountDecimal: Decimal?
let totalAmount: BigUInt?

init(
assetModel: AssetModel,
balanceResult: Result<BigUInt, Error>?,
balanceValue: Decimal?,
externalBalancesResult: Result<BigUInt, Error>?,
externalBalancesValue: Decimal?
) {
self.assetModel = assetModel
self.balanceResult = balanceResult
self.balanceValue = balanceValue
self.externalBalancesResult = externalBalancesResult
self.externalBalancesValue = externalBalancesValue

let maybeBalanceAmount = try? balanceResult?.get()
let maybeExternalBalances = try? externalBalancesResult?.get()
if let balanceAmount = maybeBalanceAmount, let externalBalancesAmount = maybeExternalBalances {
return balanceAmount + externalBalancesAmount
totalAmount = balanceAmount + externalBalancesAmount
} else {
return maybeBalanceAmount ?? maybeExternalBalances
totalAmount = maybeBalanceAmount ?? maybeExternalBalances
}

totalAmountDecimal = totalAmount?.decimal(precision: assetModel.precision)
}

var totalValue: Decimal? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ enum AssetListModelHelpers {
from assets: [AssetListAssetModel]
) -> ListDifferenceCalculator<AssetListAssetModel> {
let sortingBlock: (AssetListAssetModel, AssetListAssetModel) -> Bool = { model1, model2 in
let balance1 = (try? model1.balanceResult?.get()) ?? 0
let balance2 = (try? model2.balanceResult?.get()) ?? 0
let balance1 = model1.totalAmountDecimal ?? 0
let balance2 = model2.totalAmountDecimal ?? 0

let assetValue1 = model1.totalValue ?? 0
let assetValue2 = model2.totalValue ?? 0
Expand All @@ -68,7 +68,7 @@ enum AssetListModelHelpers {
} else if assetValue2 > 0 {
return false
} else if balance1 > 0, balance2 > 0 {
return model1.assetModel.assetId < model2.assetModel.assetId
return balance1 > balance2
} else if balance1 > 0 {
return true
} else if balance2 > 0 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ final class AssetListTotalBalanceCell: UICollectionViewCell {
icon: R.image.iconReceive()
)
lazy var swapButton = createActionButton(
title: R.string.localizable.commonSwap(
title: R.string.localizable.commonSwapAction(
preferredLanguages: locale.rLanguages
),
icon: R.image.iconActionChange()
Expand Down Expand Up @@ -217,7 +217,7 @@ final class AssetListTotalBalanceCell: UICollectionViewCell {
buyButton.imageWithTitleView?.title = R.string.localizable.walletAssetBuy(
preferredLanguages: locale.rLanguages
)
swapButton.imageWithTitleView?.title = R.string.localizable.commonSwap(
swapButton.imageWithTitleView?.title = R.string.localizable.commonSwapAction(
preferredLanguages: locale.rLanguages
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final class SwapConfirmViewController: UIViewController, ViewHolder {

private func setupLocalization() {
rootView.setup(locale: selectedLocale)
title = R.string.localizable.commonSwap(
title = R.string.localizable.commonSwapTitle(
preferredLanguages: selectedLocale.rLanguages
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ final class SwapSetupViewController: UIViewController, ViewHolder {
}

private func setupLocalization() {
title = R.string.localizable.commonSwap(preferredLanguages: selectedLocale.rLanguages)
title = R.string.localizable.commonSwapTitle(preferredLanguages: selectedLocale.rLanguages)
rootView.setup(locale: selectedLocale)
setupAccessoryView()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ enum WalletHistoryFilterRow: Int, CaseIterable {
}
case .swaps:
return LocalizableResource { locale in
R.string.localizable.commonSwap(preferredLanguages: locale.rLanguages)
R.string.localizable.commonSwapTitle(preferredLanguages: locale.rLanguages)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ final class TransactionHistoryViewModelFactory {
return .init(
identifier: data.identifier,
timestamp: data.timestamp,
title: R.string.localizable.commonSwap(preferredLanguages: locale.rLanguages),
title: R.string.localizable.commonSwapTitle(preferredLanguages: locale.rLanguages),
subtitle: subtitle,
amount: balance.amount,
amountDetails: amountDetails,
Expand Down
2 changes: 1 addition & 1 deletion novawallet/en.lproj/InfoPlist.strings
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"NSFaceIDUsageDescription" = "Face ID is used to authorize in Nova Wallet";
"NSPhotoLibraryUsageDescription" = "Photo library access is used to allow selection of QR code with addresses, Polkadot Vault transactions, or connect via WalletConnect";
"NSPhotoLibraryAddUsageDescription" = "Save transfer request as a qr code";
"NSBluetoothAlwaysUsageDescription" = "Bluetooth is used to communicate with Ledger Nano X devices";
"NSBluetoothAlwaysUsageDescription" = "Bluetooth is used to communicate with Ledger Nano X devices";
Loading

0 comments on commit eb3896e

Please sign in to comment.