Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 30 additions & 24 deletions DashWallet.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "PiggyCards.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "PiggyCards@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "PiggyCards@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@

class CTXConstants {
static let baseURI = "https://spend.ctx.com/"
static let ctxGiftCardAgreementUrl = "https://ctx.com/gift-card-agreement/"
static let termsAndConditionsUrl = "https://ctx.com/gift-card-agreement/"
static let supportEmail = "support@ctx.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//
// Created by Andrei Ashikhmin
// Copyright © 2025 Dash Core Group. All rights reserved.
//
// Licensed under the MIT License (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://opensource.org/licenses/MIT
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation

enum GiftCardProvider: CaseIterable {
case ctx
case piggyCards

var displayName: String {
switch self {
case .ctx:
return "CTXSpend"
case .piggyCards:
return "PiggyCards"
}
}

var logoName: String {
switch self {
case .ctx:
return "ctx.logo"
case .piggyCards:
return "piggycards.logo"
}
}

var termsUrl: String {
switch self {
case .ctx:
return CTXConstants.termsAndConditionsUrl
case .piggyCards:
return "https://piggy.cards/index.php?route=information/information&information_id=5"
}
}

var supportEmail: String {
switch self {
case .ctx:
return CTXConstants.supportEmail
case .piggyCards:
return "" // TODO: Confirm correct support email
}
}

func isUserSignedIn() -> Bool {
switch self {
case .ctx:
return CTXSpendService.shared.isUserSignedIn
case .piggyCards:
// TODO: Implement PiggyCards authentication
return false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ + (NSString *)transactionURLFormat {

+ (NSString *)logoutURLString {
return @"https://uphold.com/";

}

@end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@
<color red="0.45882352941176469" green="0.50196078431372548" blue="0.54117647058823526" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<systemColor name="systemPinkColor">
<color red="1" green="0.17647058823529413" blue="0.33333333333333331" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="1" green="0.1764705882" blue="0.33333333329999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
</resources>
</document>
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ extension PointOfUseDetailsViewController {
vc.sellDashHandler = wSelf.sellDashHandler
wSelf.navigationController?.pushViewController(vc, animated: true)
}
detailsView.buyGiftCardHandler = { [weak self] in
self?.showDashSpendPayScreen()
detailsView.buyGiftCardHandler = { [weak self] provider in
self?.showDashSpendPayScreen(provider: provider)
}
detailsView.dashSpendAuthHandler = { [weak self] in
self?.showCTXSpendLoginInfo()
detailsView.dashSpendAuthHandler = { [weak self] provider in
self?.showDashSpendLoginInfo(provider: provider)
}

detailsView.translatesAutoresizingMaskIntoConstraints = false
Expand Down Expand Up @@ -181,52 +181,55 @@ extension PointOfUseDetailsViewController {
// Mark: DashSpend

extension PointOfUseDetailsViewController {
private func showCTXSpendLoginInfo() {
let swiftUIView = CTXSpendLoginInfoView(
// TODO: This is a temporary UI element for testing/selecting between services
// Will be removed once service selection is finalized
private func showDashSpendLoginInfo(provider: GiftCardProvider) {
let swiftUIView = DashSpendLoginInfoView(
provider: provider,
onCreateNewAccount: { [weak self] in
self?.dismiss(animated: true) {
self?.showCTXSpendTerms()
self?.showDashSpendTerms(provider: provider)
}
},
onLogIn: { [weak self] in
self?.dismiss(animated: true) {
self?.showCTXSpendAuth(authType: .signIn)
self?.showDashSpendAuth(authType: .signIn, provider: provider)
}
},
onTermsAndConditions: {
UIApplication.shared.open(URL(string: CTXConstants.ctxGiftCardAgreementUrl)!, options: [:], completionHandler: nil)
UIApplication.shared.open(URL(string: provider.termsUrl)!, options: [:], completionHandler: nil)
}
)
let hostingController = UIHostingController(rootView: swiftUIView)
hostingController.setDetent(450)
self.present(hostingController, animated: true)
}

private func showCTXSpendTerms() {
private func showDashSpendTerms(provider: GiftCardProvider) {
let hostingController = UIHostingController(
rootView: CTXSpendTermsScreen {
rootView: DashSpendTermsScreen(provider: provider) {
self.navigationController?.popToViewController(ofType: PointOfUseDetailsViewController.self, animated: false)
self.showDashSpendPayScreen(justAuthenticated: true)
self.showDashSpendPayScreen(provider: provider, justAuthenticated: true)
}
)
hostingController.modalPresentationStyle = .fullScreen
self.navigationController?.pushViewController(hostingController, animated: true)
}

private func showCTXSpendAuth(authType: CTXSpendUserAuthType) {
private func showDashSpendAuth(authType: DashSpendUserAuthType, provider: GiftCardProvider) {
let hostingController = UIHostingController(
rootView: CTXSpendUserAuthScreen(authType: authType) {
rootView: DashSpendUserAuthScreen(authType: authType) {
self.navigationController?.popViewController(animated: false)
self.showDashSpendPayScreen(justAuthenticated: true)
self.showDashSpendPayScreen(provider: provider, justAuthenticated: true)
}
)

self.navigationController?.pushViewController(hostingController, animated: true)
}

private func showDashSpendPayScreen(justAuthenticated: Bool = false) {
private func showDashSpendPayScreen(provider: GiftCardProvider, justAuthenticated: Bool = false) {
let hostingController = UIHostingController(
rootView: DashSpendPayScreen(merchant: self.pointOfUse, justAuthenticated: justAuthenticated) { [weak self] txId in
rootView: DashSpendPayScreen(merchant: self.pointOfUse, provider: provider, justAuthenticated: justAuthenticated) { [weak self] txId in
// Navigate back to home and show gift card details
self?.onGiftCardPurchased?(txId)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class PointOfUseDetailsView: UIView, SyncingActivityMonitorObserver, NetworkReac

public var payWithDashHandler: (()->())?
public var sellDashHandler: (()->())?
public var dashSpendAuthHandler: (()->())?
public var buyGiftCardHandler: (()->())?
public var dashSpendAuthHandler: ((GiftCardProvider)->())?
public var buyGiftCardHandler: ((GiftCardProvider)->())?
public var showAllLocationsActionBlock: (() -> ())?

var containerView: UIStackView!
Expand All @@ -47,6 +47,8 @@ class PointOfUseDetailsView: UIView, SyncingActivityMonitorObserver, NetworkReac
var subLabel: UILabel!
var addressLabel: UILabel!
private var payButton: ActionButton!
private var piggyCardsCheckbox: UISwitch?
private var selectedProvider: GiftCardProvider = .piggyCards

internal let merchant: ExplorePointOfUse
internal var isShowAllHidden: Bool
Expand Down Expand Up @@ -155,10 +157,10 @@ class PointOfUseDetailsView: UIView, SyncingActivityMonitorObserver, NetworkReac
UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url)
} else if case .merchant(let m) = merchant.category, m.paymentMethod == .giftCard {
if ctxSpendService.isUserSignedIn {
buyGiftCardHandler?()
if selectedProvider.isUserSignedIn() {
buyGiftCardHandler?(selectedProvider)
} else {
dashSpendAuthHandler?()
dashSpendAuthHandler?(selectedProvider)
}
} else {
payWithDashHandler?()
Expand Down Expand Up @@ -340,6 +342,11 @@ extension PointOfUseDetailsView {

@objc
internal func configureBottomButton() {
// Add PiggyCards checkbox for CTXSpend merchants (temporary UI element)
if case .merchant(let m) = merchant.category, m.paymentMethod == .giftCard {
configurePiggyCardsCheckbox()
}

payButton = ActionButton()
payButton.translatesAutoresizingMaskIntoConstraints = false
payButton.addTarget(self, action: #selector(payAction), for: .touchUpInside)
Expand Down Expand Up @@ -380,6 +387,36 @@ extension PointOfUseDetailsView {
updateButtonState()
}

private func configurePiggyCardsCheckbox() {
// TODO: This is a temporary UI element for testing PiggyCards
// Change to false to enable service selection

let checkboxContainer = UIStackView()
checkboxContainer.axis = .horizontal
checkboxContainer.spacing = 8
checkboxContainer.alignment = .center

piggyCardsCheckbox = UISwitch()
piggyCardsCheckbox?.isOn = true
piggyCardsCheckbox?.addTarget(self, action: #selector(piggyCardsCheckboxTapped), for: .touchUpInside)

let label = UILabel()
label.text = "Open PiggyCards"
label.font = .dw_font(forTextStyle: .footnote)
label.textColor = .dw_secondaryText()

checkboxContainer.addArrangedSubview(piggyCardsCheckbox!)
checkboxContainer.addArrangedSubview(label)
checkboxContainer.addArrangedSubview(UIView()) // Spacer

containerView.addArrangedSubview(checkboxContainer)
}

@objc
private func piggyCardsCheckboxTapped() {
selectedProvider = piggyCardsCheckbox?.isOn == true ? .piggyCards : .ctx
}

private static func getEmailText() -> String {
if let email = CTXSpendService.shared.userEmail, !email.isEmpty {
let maskedEmail = maskEmail(email)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@

import SwiftUI

struct CTXSpendTermsScreen: View {
struct DashSpendTermsScreen: View {
@Environment(\.presentationMode) private var presentationMode
@State private var isTermsAccepted: Bool = false
@State private var hasViewedTerms: Bool = false
@State private var shouldShakeLink: Bool = false
@State private var navigateToCreateAccount: Bool = false

let provider: GiftCardProvider
let onAuthSuccess: () -> Void

var body: some View {
Expand Down Expand Up @@ -53,7 +54,7 @@ struct CTXSpendTermsScreen: View {
label: NSLocalizedString("Terms & conditions", comment: "Terms & conditions"),
labelIcon: .custom("external.link"),
linkAction: {
UIApplication.shared.open(URL(string: CTXConstants.ctxGiftCardAgreementUrl)!, options: [:], completionHandler: nil)
UIApplication.shared.open(URL(string: provider.termsUrl)!, options: [:], completionHandler: nil)
hasViewedTerms = true
shouldShakeLink = false
},
Expand Down Expand Up @@ -116,7 +117,7 @@ struct CTXSpendTermsScreen: View {
.edgesIgnoringSafeArea(.top)

NavigationLink(
destination: CTXSpendUserAuthScreen(
destination: DashSpendUserAuthScreen(
authType: .createAccount,
onAuthSuccess: onAuthSuccess
).navigationBarHidden(true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import SwiftUI
import Combine

enum CTXSpendUserAuthType {
enum DashSpendUserAuthType {
case createAccount
case signIn
case otp
Expand Down Expand Up @@ -55,13 +55,13 @@ enum CTXSpendUserAuthType {
}
}

struct CTXSpendUserAuthScreen: View {
struct DashSpendUserAuthScreen: View {
@Environment(\.presentationMode) private var presentationMode
@StateObject private var viewModel = CTXSpendUserAuthViewModel()
@StateObject private var viewModel = DashSpendUserAuthViewModel()
@FocusState private var isTextFieldFocused: Bool
@State private var navigateToOtp: Bool = false

let authType: CTXSpendUserAuthType
let authType: DashSpendUserAuthType
let onAuthSuccess: () -> Void

var body: some View {
Expand Down Expand Up @@ -172,7 +172,7 @@ struct CTXSpendUserAuthScreen: View {
}

NavigationLink(
destination: CTXSpendUserAuthScreen(
destination: DashSpendUserAuthScreen(
authType: .otp,
onAuthSuccess: onAuthSuccess
).navigationBarHidden(true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

import SwiftUI

struct CTXSpendLoginInfoView: View {
struct DashSpendLoginInfoView: View {
let provider: GiftCardProvider
let onCreateNewAccount: () -> Void
let onLogIn: () -> Void
let onTermsAndConditions: () -> Void
Expand All @@ -27,7 +28,7 @@ struct CTXSpendLoginInfoView: View {
BottomSheet(showBackButton: .constant(false)) {
VStack {
TextIntro(
icon: .custom("ctx.logo", maxHeight: 60),
icon: .custom(provider.logoName, maxHeight: 60),
inProgress: $inProgress
) {
FeatureTopText(
Expand Down Expand Up @@ -59,7 +60,8 @@ struct CTXSpendLoginInfoView: View {
}

#Preview {
CTXSpendLoginInfoView(
DashSpendLoginInfoView(
provider: .ctx,
onCreateNewAccount: {},
onLogIn: {},
onTermsAndConditions: {}
Expand Down
Loading
Loading