Skip to content

Commit 5cb5ccf

Browse files
committed
feat: merchant denominations SwiftUI view
1 parent 9658add commit 5cb5ccf

4 files changed

Lines changed: 117 additions & 5 deletions

File tree

DashWallet.xcodeproj/project.pbxproj

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,8 @@
548548
753261AE2CBC1040003CDE00 /* InvitationFlowViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 753261AD2CBC1040003CDE00 /* InvitationFlowViewController.swift */; };
549549
753261B02CBC11BF003CDE00 /* WelcomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 753261AF2CBC11BF003CDE00 /* WelcomeViewController.swift */; };
550550
753261B22CBC157F003CDE00 /* GetStartedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 753261B12CBC157F003CDE00 /* GetStartedViewController.swift */; };
551+
75387B4A2E0400C300BCCC72 /* MerchantDenominations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75387B492E0400C300BCCC72 /* MerchantDenominations.swift */; };
552+
75387B4B2E0400C300BCCC72 /* MerchantDenominations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75387B492E0400C300BCCC72 /* MerchantDenominations.swift */; };
551553
753E46E82DE1E24300A3FF2A /* CTXSpendModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 753E46E72DE1E24300A3FF2A /* CTXSpendModels.swift */; };
552554
753E46E92DE1E24300A3FF2A /* CTXSpendModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 753E46E72DE1E24300A3FF2A /* CTXSpendModels.swift */; };
553555
753F75342DD0D42300D40DFE /* DashSpendPayScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 753F75332DD0D41900D40DFE /* DashSpendPayScreen.swift */; };
@@ -2469,6 +2471,7 @@
24692471
753261AD2CBC1040003CDE00 /* InvitationFlowViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InvitationFlowViewController.swift; sourceTree = "<group>"; };
24702472
753261AF2CBC11BF003CDE00 /* WelcomeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WelcomeViewController.swift; sourceTree = "<group>"; };
24712473
753261B12CBC157F003CDE00 /* GetStartedViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GetStartedViewController.swift; sourceTree = "<group>"; };
2474+
75387B492E0400C300BCCC72 /* MerchantDenominations.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MerchantDenominations.swift; sourceTree = "<group>"; };
24722475
753E46E72DE1E24300A3FF2A /* CTXSpendModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CTXSpendModels.swift; sourceTree = "<group>"; };
24732476
753F75332DD0D41900D40DFE /* DashSpendPayScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashSpendPayScreen.swift; sourceTree = "<group>"; };
24742477
753F75362DD0D75F00D40DFE /* DashSpendPayViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashSpendPayViewModel.swift; sourceTree = "<group>"; };
@@ -6115,24 +6118,25 @@
61156118
isa = PBXGroup;
61166119
children = (
61176120
7581B19C2CE3509A00714007 /* Dialogs */,
6121+
75EBAA112BB99B6B004488E3 /* BottomSheet.swift */,
6122+
759ADD562BF3447400767ACD /* Button.swift */,
6123+
75CDD7852C08D61300F433D2 /* DashAmount.swift */,
61186124
750CEFA02CCA6EA100E87A32 /* TextInput.swift */,
61196125
75EBAA082BB9791B004488E3 /* Icon.swift */,
61206126
7566F4892BB6CAF2005238D2 /* MenuItem.swift */,
61216127
75EBAA0B2BB9792F004488E3 /* FeatureTopText.swift */,
61226128
754C27CB2CC3C14F00BA7B9F /* FeatureSingleItem.swift */,
61236129
75EBAA0E2BB99036004488E3 /* TextIntro.swift */,
6124-
75EBAA112BB99B6B004488E3 /* BottomSheet.swift */,
61256130
758C4C4E2DFAC1C30028549B /* RadioButtonRow.swift */,
61266131
75BDE7AB2BF3287400556791 /* Toast.swift */,
6127-
759ADD562BF3447400767ACD /* Button.swift */,
61286132
75AA33CE2BF9D44A00F12465 /* ButtonsGroup.swift */,
61296133
75AA33D12BF9E18E00F12465 /* Color+DWStyle.swift */,
61306134
75AA33D42BF9E1D400F12465 /* Font+DWStyle.swift */,
61316135
75AA33D72BFB4A5A00F12465 /* Extensions.swift */,
61326136
75CDD77F2C0898E400F433D2 /* Shape.swift */,
61336137
75CDD7822C0898FA00F433D2 /* Wrapper.swift */,
6134-
75CDD7852C08D61300F433D2 /* DashAmount.swift */,
61356138
759609222C455B2000F3BF04 /* SendIntro.swift */,
6139+
75387B492E0400C300BCCC72 /* MerchantDenominations.swift */,
61366140
7545ED5F2DA91FC60075F45C /* NumericKeyboardView.swift */,
61376141
756FE7092CDCD6CD00E6C195 /* ValidationCheck.swift */,
61386142
);
@@ -9049,6 +9053,7 @@
90499053
C956AF282A5CAD4D002FAB75 /* TitleCell.swift in Sources */,
90509054
C9F42FA429DBC6E5001BC549 /* PaymentsViewController.swift in Sources */,
90519055
4774DCDD28F43A68008CF87D /* ServiceDataSource.swift in Sources */,
9056+
75387B4A2E0400C300BCCC72 /* MerchantDenominations.swift in Sources */,
90529057
47838B7A2900196F0003E8AB /* ConverterView.swift in Sources */,
90539058
2A0C69CA23142E11001B8C90 /* DWModalBaseAnimation.m in Sources */,
90549059
C956AF262A5CACE6002FAB75 /* TitleValueCell.swift in Sources */,
@@ -9840,6 +9845,7 @@
98409845
C943B5082A40A54600AF23C5 /* DWDPTxListCell.m in Sources */,
98419846
75FFD6BC2BF48DF80032879E /* HomeViewController+JailbreakCheck.swift in Sources */,
98429847
C9D2C8942A320AA000D15901 /* DerivationPathKeysHeaderView.swift in Sources */,
9848+
75387B4B2E0400C300BCCC72 /* MerchantDenominations.swift in Sources */,
98439849
759063ED2C42687F002F2AA9 /* RootEditProfileViewController.swift in Sources */,
98449850
C9D2C8952A320AA000D15901 /* ConvertCryptoOrderPreviewModel.swift in Sources */,
98459851
75CDD7872C08D61300F433D2 /* DashAmount.swift in Sources */,

DashWallet/Sources/Models/Explore Dash/Infrastructure/DAO Impl/MerchantDAO.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ class MerchantDAO: PointOfUseDAO {
5757
let typeColumn = ExplorePointOfUse.type
5858
let paymentMethodColumn = ExplorePointOfUse.paymentMethod
5959
let territoryColumn = ExplorePointOfUse.territory
60-
let denominationsTypeColumn = ExplorePointOfUse.denominationsType
6160

6261
var queryFilter = Expression<Bool>(value: true)
6362

DashWallet/Sources/Models/Explore Dash/Services/ExploreDatabaseSyncManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import Foundation
2020
import SSZipArchive
2121

2222
// TODO: Move it to plist and note in release process
23-
let gsFilePath = "gs://dash-wallet-firebase.appspot.com/explore/explore-v3.db"
23+
let gsFilePath = "gs://dash-wallet-firebase.appspot.com/explore/explore-v3-testnet.db"
2424

2525
private let fileName = "explore"
2626

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
//
2+
// Created by Andrei Ashikhmin
3+
// Copyright © 2024 Dash Core Group. All rights reserved.
4+
//
5+
// Licensed under the MIT License (the "License");
6+
// you may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
//
9+
// https://opensource.org/licenses/MIT
10+
//
11+
// Unless required by applicable law or agreed to in writing, software
12+
// distributed under the License is distributed on an "AS IS" BASIS,
13+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
// See the License for the specific language governing permissions and
15+
// limitations under the License.
16+
//
17+
18+
import SwiftUI
19+
20+
struct MerchantDenominations: View {
21+
let denominations: [Int]
22+
let currency: String = "USD"
23+
@Binding var selectedDenomination: Int?
24+
let canContinue: Bool = true
25+
let onDenominationSelected: (Int) -> Void = { _ in }
26+
let onContinue: () -> Void = { }
27+
28+
private var numberFormatter: NumberFormatter {
29+
let formatter = NumberFormatter()
30+
formatter.numberStyle = .currency
31+
formatter.currencyCode = currency
32+
formatter.minimumFractionDigits = 0
33+
formatter.maximumFractionDigits = 0
34+
return formatter
35+
}
36+
37+
private let columns = [
38+
GridItem(.adaptive(minimum: 76, maximum: 120), spacing: 16)
39+
]
40+
41+
var body: some View {
42+
VStack(alignment: .leading, spacing: 0) {
43+
Text(NSLocalizedString("Select amount", comment: "DashSpend denomination selection"))
44+
.font(.h5Bold)
45+
.foregroundColor(.primaryText)
46+
47+
Text(NSLocalizedString("Select fixed amount", comment: "DashSpend denomination selection subtitle"))
48+
.font(.body2)
49+
.foregroundColor(.secondaryText)
50+
.padding(.top, 4)
51+
52+
LazyVGrid(columns: columns, spacing: 16) {
53+
ForEach(denominations, id: \.self) { denomination in
54+
DenominationChip(
55+
denomination: denomination,
56+
isSelected: denomination == selectedDenomination,
57+
formattedValue: numberFormatter.string(from: NSNumber(value: denomination)) ?? "\(denomination)",
58+
onTap: {
59+
onDenominationSelected(denomination)
60+
}
61+
)
62+
}
63+
}
64+
.padding(.top, 20)
65+
66+
DashButton(
67+
text: NSLocalizedString("Continue", comment: ""),
68+
style: .filled,
69+
size: .large,
70+
stretch: true,
71+
isEnabled: selectedDenomination != nil && selectedDenomination != 0 && canContinue,
72+
action: onContinue
73+
)
74+
.padding(.top, 20)
75+
}
76+
}
77+
}
78+
79+
private struct DenominationChip: View {
80+
let denomination: Int
81+
let isSelected: Bool
82+
let formattedValue: String
83+
let onTap: () -> Void
84+
85+
var body: some View {
86+
Button(action: onTap) {
87+
Text(formattedValue)
88+
.font(.subtitle1)
89+
.foregroundColor(.primaryText)
90+
.multilineTextAlignment(.center)
91+
.frame(maxWidth: .infinity)
92+
.frame(width: 76, height: 54)
93+
.background(
94+
RoundedRectangle(cornerRadius: 14)
95+
.fill(isSelected ? Color.dashBlue.opacity(0.1) : Color.clear)
96+
)
97+
.overlay(
98+
RoundedRectangle(cornerRadius: 14)
99+
.stroke(
100+
isSelected ? Color.dashBlue : Color.gray400,
101+
lineWidth: 1.5
102+
)
103+
)
104+
}
105+
.buttonStyle(PlainButtonStyle())
106+
}
107+
}

0 commit comments

Comments
 (0)