-
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.
Created individual views for each step of order process
- Loading branch information
Showing
6 changed files
with
89 additions
and
14 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
30 changes: 30 additions & 0 deletions
30
Demo/Demo/PayPalWebPayments/PayPalWebPaymentsView/PayPalApprovalResultView.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,30 @@ | ||
import SwiftUI | ||
|
||
struct PayPalApprovalResultView: View { | ||
@ObservedObject var payPalWebViewModel: PayPalWebViewModel | ||
|
||
var body: some View { | ||
switch payPalWebViewModel.state.approveResultResponse { | ||
case .idle, .loading: | ||
EmptyView() | ||
case .error(let message): | ||
ErrorView(errorMessage: message) | ||
case .loaded(let approvalResult): | ||
getApprovalSuccessView(approvalResult: approvalResult) | ||
} | ||
} | ||
|
||
func getApprovalSuccessView(approvalResult: PayPalPaymentState.ApprovalResult) -> some View { | ||
VStack(spacing: 16) { | ||
Text("Approval Result") | ||
.font(.headline) | ||
LeadingText("Approval ID", weight: .bold) | ||
|
||
LeadingText(approvalResult.id) | ||
if let status = approvalResult.status { | ||
LeadingText("Status", weight: .bold) | ||
LeadingText(status) | ||
} | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
Demo/Demo/PayPalWebPayments/PayPalWebPaymentsView/PayPalOrderCompletionResultView.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,28 @@ | ||
import SwiftUI | ||
|
||
struct PayPalOrderCompletionResultView: View { | ||
@ObservedObject var payPalWebViewModel: PayPalWebViewModel | ||
|
||
var body: some View { | ||
VStack { | ||
if case .loaded(let authorizedOrder) = payPalWebViewModel.state.authorizedOrderResponse { | ||
getCompletionSuccessView(order: authorizedOrder, intent: "Authorized") | ||
} | ||
if case .loaded(let capturedOrder) = payPalWebViewModel.state.capturedOrderResponse { | ||
getCompletionSuccessView(order: capturedOrder, intent: "Captured") | ||
} | ||
} | ||
} | ||
|
||
func getCompletionSuccessView(order: Order, intent: String) -> some View { | ||
VStack(spacing: 16) { | ||
Text("Order \(intent) Successfully") | ||
.font(.headline) | ||
|
||
LeadingText("Order ID", weight: .bold) | ||
LeadingText(order.id) | ||
LeadingText("Status", weight: .bold) | ||
LeadingText(order.status) | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...WebPaymentsView/PayPalWebResultView.swift → ...ntsView/PayPalOrderCreateResultView.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
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