Skip to content

Commit b399b05

Browse files
committed
receive: hide select amount for liquid bip21
Signed-off-by: Luca Vaccaro <me@lvaccaro.com>
1 parent f10922f commit b399b05

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

gaios/Receive/ReceiveViewController.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -395,10 +395,11 @@ class ReceiveViewController: KeyboardViewController {
395395
let storyboard = UIStoryboard(name: "Dialogs", bundle: nil)
396396
if let vc = storyboard.instantiateViewController(withIdentifier: "DialogListViewController") as? DialogListViewController {
397397
vc.delegate = self
398-
399-
vc.viewModel = DialogListViewModel(title: "id_more_options".localized,
400-
type: .moreOptPrefs,
401-
items: MoreOptPrefs.getItems(account: viewModel.account))
398+
let options = MoreOptPrefs.getItems(account: viewModel.account, assetId: viewModel.asset)
399+
vc.viewModel = DialogListViewModel(
400+
title: "id_more_options".localized,
401+
type: .moreOptPrefs,
402+
items: options)
402403
vc.modalPresentationStyle = .overFullScreen
403404
present(vc, animated: false, completion: nil)
404405
}
@@ -575,7 +576,7 @@ extension ReceiveViewController: DialogListViewControllerDelegate {
575576
switch type {
576577
case .moreOptPrefs:
577578

578-
if let item = MoreOptPrefs.getPrefs(account: viewModel.account)[safe: index] {
579+
if let item = MoreOptPrefs.getPrefs(account: viewModel.account, assetId: viewModel.asset)[safe: index] {
579580
switch item {
580581
case .requestAmount:
581582
optRequestAmount()

gaios/Shared/Models/MoreOptPrefs.swift

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,16 @@ enum MoreOptPrefs: Int, CaseIterable {
2828
}
2929
}
3030

31-
static func getPrefs(account: WalletItem) -> [MoreOptPrefs] {
31+
static func getPrefs(account: WalletItem, assetId: String) -> [MoreOptPrefs] {
3232

3333
let hideSweep = account.gdkNetwork.liquid || account.gdkNetwork.lightning
3434
let hideSign = account.gdkNetwork.lightning
35+
let hideAmountRequest = account.gdkNetwork.lightning || !AssetInfo.baseIds.contains(assetId)
3536

36-
var prefs: [MoreOptPrefs] = [ .requestAmount ]
37-
37+
var prefs: [MoreOptPrefs] = []
38+
if hideAmountRequest == false {
39+
prefs.append(.requestAmount)
40+
}
3841
if hideSweep == false {
3942
prefs.append(.sweep)
4043
}
@@ -44,10 +47,13 @@ enum MoreOptPrefs: Int, CaseIterable {
4447
return prefs
4548
}
4649

47-
static func getItems(account: WalletItem) -> [DialogListCellModel] {
48-
49-
return MoreOptPrefs.getPrefs(account: account).map { DialogListCellModel(type: .list,
50-
icon: $0.icon,
51-
title: $0.name) }
50+
static func getItems(account: WalletItem, assetId: String) -> [DialogListCellModel] {
51+
return MoreOptPrefs.getPrefs(account: account, assetId: assetId)
52+
.map {
53+
DialogListCellModel(
54+
type: .list,
55+
icon: $0.icon,
56+
title: $0.name)
57+
}
5258
}
5359
}

0 commit comments

Comments
 (0)