feat(auth): 인증 후 콘텐츠 설정과 개발용 모의 인증을 추가한다
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import SwiftUI
|
||||
|
||||
import Bootpay
|
||||
#if !AUTH_VERIFICATION_MOCK
|
||||
import BootpayUI
|
||||
#endif
|
||||
|
||||
struct AuthVerificationView: View {
|
||||
let payload: Payload
|
||||
let onCancel: () -> Void
|
||||
let onError: () -> Void
|
||||
let onDone: ([String: Any]) -> Void
|
||||
let onClose: () -> Void
|
||||
|
||||
#if AUTH_VERIFICATION_MOCK
|
||||
@State private var hasCompleted = false
|
||||
#endif
|
||||
|
||||
var body: some View {
|
||||
#if AUTH_VERIFICATION_MOCK
|
||||
LoadingView()
|
||||
.background(Color.white.ignoresSafeArea())
|
||||
.task {
|
||||
guard !hasCompleted else { return }
|
||||
do {
|
||||
try await Task.sleep(nanoseconds: 500_000_000)
|
||||
} catch is CancellationError {
|
||||
return
|
||||
} catch {
|
||||
onError()
|
||||
return
|
||||
}
|
||||
guard !Task.isCancelled, !hasCompleted else { return }
|
||||
hasCompleted = true
|
||||
onDone(["data": ["receipt_id": "dev-mock-auth-receipt"]])
|
||||
}
|
||||
#else
|
||||
BootpayUI(payload: payload, requestType: BootpayRequest.TYPE_AUTHENTICATION)
|
||||
.onConfirm { _ in true }
|
||||
.onCancel { _ in onCancel() }
|
||||
.onError { _ in onError() }
|
||||
.onDone(onDone)
|
||||
.onClose(onClose)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user