-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into button-color-update
- Loading branch information
Showing
37 changed files
with
839 additions
and
315 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
Demo/Demo/SwiftUIComponents/CommonComponents/LabelViewText.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import SwiftUI | ||
|
||
struct LabelViewText: View { | ||
|
||
var titleText: String | ||
var bodyText: String | ||
|
||
var body: some View { | ||
HStack { | ||
Text(titleText).fontWeight(.bold) | ||
Text(bodyText) | ||
} | ||
} | ||
|
||
init(_ titleText: String, bodyText: String) { | ||
self.titleText = titleText | ||
self.bodyText = bodyText | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
Demo/Demo/SwiftUIComponents/PayPalVaultViews/PayPalVaultResultView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import SwiftUI | ||
import PayPalWebPayments | ||
|
||
struct PayPalVaultResultView: View { | ||
|
||
@ObservedObject var viewModel: PayPalVaultViewModel | ||
|
||
var body: some View { | ||
switch viewModel.state.paypalVaultTokenResponse { | ||
case .idle, .loading: | ||
EmptyView() | ||
case .loaded(let vaultResult): | ||
getSuccessView(result: vaultResult) | ||
case .error(let errorMessage): | ||
ErrorView(errorMessage: errorMessage) | ||
} | ||
} | ||
|
||
func getSuccessView(result: PayPalVaultResult) -> some View { | ||
VStack(spacing: 16) { | ||
HStack { | ||
Text("Vault Success") | ||
.font(.system(size: 20)) | ||
Spacer() | ||
} | ||
LeadingText("ID", weight: .bold) | ||
LeadingText("\(result.tokenID)") | ||
LeadingText("Status", weight: .bold) | ||
LeadingText("APPROVED") | ||
LeadingText("Approval Session ID", weight: .bold) | ||
LeadingText("\(result.approvalSessionID)") | ||
} | ||
.frame(maxWidth: .infinity) | ||
.padding() | ||
.background( | ||
RoundedRectangle(cornerRadius: 10) | ||
.stroke(.gray, lineWidth: 2) | ||
.padding(5) | ||
) | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
Demo/Demo/SwiftUIComponents/PayPalVaultViews/PayPalVaultView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import SwiftUI | ||
|
||
struct PayPalVaultView: View { | ||
|
||
@StateObject var paypalVaultViewModel = PayPalVaultViewModel() | ||
|
||
var body: some View { | ||
ScrollView { | ||
ScrollViewReader { scrollView in | ||
VStack(spacing: 16) { | ||
CreateSetupTokenView( | ||
selectedMerchantIntegration: DemoSettings.merchantIntegration, | ||
vaultViewModel: paypalVaultViewModel, | ||
paymentSourceType: PaymentSourceType.paypal(usageType: "MERCHANT") | ||
) | ||
SetupTokenResultView(vaultViewModel: paypalVaultViewModel) | ||
if let url = paypalVaultViewModel.state.setupToken?.paypalURL { | ||
Button("Vault PayPal") { | ||
Task { | ||
await paypalVaultViewModel.vault(url: url) | ||
} | ||
} | ||
.buttonStyle(RoundedBlueButtonStyle()) | ||
.padding() | ||
} | ||
PayPalVaultResultView(viewModel: paypalVaultViewModel) | ||
if let paypalVaultResult = paypalVaultViewModel.state.paypalVaultToken { | ||
CreatePaymentTokenView( | ||
vaultViewModel: paypalVaultViewModel, | ||
selectedMerchantIntegration: DemoSettings.merchantIntegration, | ||
setupToken: paypalVaultResult.tokenID | ||
) | ||
} | ||
PaymentTokenResultView(vaultViewModel: paypalVaultViewModel) | ||
switch paypalVaultViewModel.state.paymentTokenResponse { | ||
case .loaded, .error: | ||
VStack { | ||
Button("Reset") { | ||
paypalVaultViewModel.resetState() | ||
} | ||
.foregroundColor(.black) | ||
.padding() | ||
.frame(maxWidth: .infinity) | ||
.background(.gray) | ||
.cornerRadius(10) | ||
} | ||
.padding(5) | ||
default: | ||
EmptyView() | ||
} | ||
Text("") | ||
.id("bottomView") | ||
.frame(maxWidth: .infinity, alignment: .top) | ||
.padding(.horizontal, 10) | ||
.onChange(of: paypalVaultViewModel.state) { _ in | ||
withAnimation { | ||
scrollView.scrollTo("bottomView") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.