라이브 전체보기 - 성인 라이브 입장에 본인인증 흐름 추가
This commit is contained in:
@@ -7,14 +7,25 @@
|
|||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
import RefreshableScrollView
|
import RefreshableScrollView
|
||||||
|
import Bootpay
|
||||||
|
import BootpayUI
|
||||||
|
|
||||||
struct LiveNowAllView: View {
|
struct LiveNowAllView: View {
|
||||||
|
|
||||||
@StateObject var viewModel = LiveViewModel()
|
@StateObject var viewModel = LiveViewModel()
|
||||||
@StateObject var liveAllViewModel = LiveAllViewModel()
|
@StateObject var liveAllViewModel = LiveAllViewModel()
|
||||||
|
@StateObject var mypageViewModel = MyPageViewModel()
|
||||||
|
|
||||||
let spacing: CGFloat = 16
|
let spacing: CGFloat = 16
|
||||||
|
|
||||||
|
@AppStorage("token") private var token: String = UserDefaults.string(forKey: UserDefaultsKey.token)
|
||||||
|
@AppStorage("auth") private var auth: Bool = UserDefaults.bool(forKey: UserDefaultsKey.auth)
|
||||||
|
|
||||||
|
@State private var isShowAuthView = false
|
||||||
|
@State private var isShowAuthConfirmView = false
|
||||||
|
@State private var pendingAction: (() -> Void)? = nil
|
||||||
|
@State private var payload = Payload()
|
||||||
|
|
||||||
var columns: [GridItem] {
|
var columns: [GridItem] {
|
||||||
[
|
[
|
||||||
GridItem(.flexible(), spacing: spacing, alignment: .top),
|
GridItem(.flexible(), spacing: spacing, alignment: .top),
|
||||||
@@ -26,73 +37,150 @@ struct LiveNowAllView: View {
|
|||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
BaseView(isLoading: $viewModel.isLoading) {
|
BaseView(isLoading: $viewModel.isLoading) {
|
||||||
GeometryReader { proxy in
|
ZStack {
|
||||||
VStack(spacing: 0) {
|
GeometryReader { proxy in
|
||||||
DetailNavigationBar(title: I18n.LiveNow.allTitle)
|
VStack(spacing: 0) {
|
||||||
|
DetailNavigationBar(title: I18n.LiveNow.allTitle)
|
||||||
RefreshableScrollView(
|
|
||||||
refreshing: $viewModel.isRefresh,
|
RefreshableScrollView(
|
||||||
action: {
|
refreshing: $viewModel.isRefresh,
|
||||||
viewModel.page = 1
|
action: {
|
||||||
viewModel.isLast = false
|
viewModel.page = 1
|
||||||
viewModel.getLiveNowList()
|
viewModel.isLast = false
|
||||||
},
|
viewModel.getLiveNowList()
|
||||||
content: {
|
},
|
||||||
let itemWidth = (proxy.size.width - (spacing * 3)) / 2
|
content: {
|
||||||
|
let itemWidth = (proxy.size.width - (spacing * 3)) / 2
|
||||||
LazyVGrid(columns: columns, spacing: spacing) {
|
|
||||||
ForEach(0..<viewModel.liveNowItems.count, id: \.self) { index in
|
LazyVGrid(columns: columns, spacing: spacing) {
|
||||||
let item = viewModel.liveNowItems[index]
|
ForEach(0..<viewModel.liveNowItems.count, id: \.self) { index in
|
||||||
|
let item = viewModel.liveNowItems[index]
|
||||||
LiveNowItemView(item: item, itemWidth: itemWidth)
|
|
||||||
.contentShape(Rectangle())
|
LiveNowItemView(item: item, itemWidth: itemWidth)
|
||||||
.onTapGesture {
|
.contentShape(Rectangle())
|
||||||
self.liveAllViewModel.selectedRoomId = item.roomId
|
.onTapGesture {
|
||||||
withAnimation {
|
handleLiveNowItemTap(
|
||||||
self.liveAllViewModel.isShowLiveDetail = true
|
roomId: item.roomId,
|
||||||
|
isAdult: item.isAdult
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
.onAppear {
|
||||||
.onAppear {
|
if index == viewModel.liveNowItems.count - 1 {
|
||||||
if index == viewModel.liveNowItems.count - 1 {
|
viewModel.getLiveNowList()
|
||||||
viewModel.getLiveNowList()
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.padding(.horizontal, spacing)
|
||||||
|
.padding(.top, spacing)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
if proxy.safeAreaInsets.bottom > 0 {
|
||||||
|
Rectangle()
|
||||||
|
.foregroundColor(Color.black.opacity(0))
|
||||||
|
.frame(width: screenSize().width, height: 15.3)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.edgesIgnoringSafeArea(.bottom)
|
||||||
|
}
|
||||||
|
|
||||||
|
if liveAllViewModel.isShowLiveDetail {
|
||||||
|
LiveDetailView(
|
||||||
|
roomId: liveAllViewModel.selectedRoomId,
|
||||||
|
onClickParticipant: {
|
||||||
|
AppState.shared.isShowPlayer = false
|
||||||
|
onClickParticipant(liveAllViewModel.selectedRoomId)
|
||||||
|
},
|
||||||
|
onClickReservation: {},
|
||||||
|
onClickStart: {},
|
||||||
|
onClickCancel: {},
|
||||||
|
onClickClose: {
|
||||||
|
withAnimation {
|
||||||
|
liveAllViewModel.isShowLiveDetail = false
|
||||||
}
|
}
|
||||||
.padding(.horizontal, spacing)
|
|
||||||
.padding(.top, spacing)
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
if proxy.safeAreaInsets.bottom > 0 {
|
|
||||||
Rectangle()
|
|
||||||
.foregroundColor(Color.black.opacity(0))
|
|
||||||
.frame(width: screenSize().width, height: 15.3)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.edgesIgnoringSafeArea(.bottom)
|
|
||||||
}
|
if isShowAuthConfirmView {
|
||||||
|
SodaDialog(
|
||||||
if liveAllViewModel.isShowLiveDetail {
|
title: "본인인증",
|
||||||
LiveDetailView(
|
desc: "청소년 보호를 위해\n본인인증을 완료한\n성인만 라이브 입장이 가능합니다.\n" +
|
||||||
roomId: liveAllViewModel.selectedRoomId,
|
"라이브 입장을 위해\n본인인증을 진행해 주세요.",
|
||||||
onClickParticipant: {
|
confirmButtonTitle: "본인인증 하러가기",
|
||||||
AppState.shared.isShowPlayer = false
|
confirmButtonAction: {
|
||||||
onClickParticipant(liveAllViewModel.selectedRoomId)
|
isShowAuthConfirmView = false
|
||||||
},
|
isShowAuthView = true
|
||||||
onClickReservation: {},
|
},
|
||||||
onClickStart: {},
|
cancelButtonTitle: "취소",
|
||||||
onClickCancel: {},
|
cancelButtonAction: {
|
||||||
onClickClose: {
|
isShowAuthConfirmView = false
|
||||||
withAnimation {
|
pendingAction = nil
|
||||||
liveAllViewModel.isShowLiveDetail = false
|
},
|
||||||
}
|
textAlignment: .center
|
||||||
}
|
)
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onAppear {
|
.onAppear {
|
||||||
|
payload.applicationId = BOOTPAY_APP_ID
|
||||||
|
payload.price = 0
|
||||||
|
payload.pg = "다날"
|
||||||
|
payload.method = "본인인증"
|
||||||
|
payload.orderName = "본인인증"
|
||||||
|
payload.authenticationId = "\(UserDefaults.string(forKey: .nickname))__\(String(NSTimeIntervalSince1970))"
|
||||||
|
|
||||||
viewModel.getLiveNowList()
|
viewModel.getLiveNowList()
|
||||||
}
|
}
|
||||||
|
.fullScreenCover(isPresented: $isShowAuthView) {
|
||||||
|
BootpayUI(payload: payload, requestType: BootpayRequest.TYPE_AUTHENTICATION)
|
||||||
|
.onConfirm { _ in
|
||||||
|
true
|
||||||
|
}
|
||||||
|
.onCancel { _ in
|
||||||
|
isShowAuthView = false
|
||||||
|
}
|
||||||
|
.onError { _ in
|
||||||
|
AppState.shared.errorMessage = "본인인증 중 오류가 발생했습니다."
|
||||||
|
AppState.shared.isShowErrorPopup = true
|
||||||
|
isShowAuthView = false
|
||||||
|
}
|
||||||
|
.onDone {
|
||||||
|
DEBUG_LOG("onDone: \($0)")
|
||||||
|
mypageViewModel.authVerify($0) {
|
||||||
|
auth = true
|
||||||
|
isShowAuthView = false
|
||||||
|
if let action = pendingAction {
|
||||||
|
pendingAction = nil
|
||||||
|
action()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.onClose {
|
||||||
|
isShowAuthView = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func handleLiveNowItemTap(roomId: Int, isAdult: Bool) {
|
||||||
|
let trimmed = token.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
|
guard !trimmed.isEmpty else {
|
||||||
|
AppState.shared.setAppStep(step: .login)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if isAdult && auth == false {
|
||||||
|
pendingAction = { openLiveDetail(roomId: roomId) }
|
||||||
|
isShowAuthConfirmView = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
openLiveDetail(roomId: roomId)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func openLiveDetail(roomId: Int) {
|
||||||
|
liveAllViewModel.selectedRoomId = roomId
|
||||||
|
withAnimation {
|
||||||
|
liveAllViewModel.isShowLiveDetail = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -202,8 +202,8 @@ struct HomeView: View {
|
|||||||
if isShowAuthConfirmView {
|
if isShowAuthConfirmView {
|
||||||
SodaDialog(
|
SodaDialog(
|
||||||
title: "본인인증",
|
title: "본인인증",
|
||||||
desc: "보이스온의 오픈월드 캐릭터톡은\n청소년 보호를 위해 본인인증한\n성인만 이용이 가능합니다.\n" +
|
desc: "청소년 보호를 위해\n본인인증을 완료한\n성인만 라이브 입장이 가능합니다.\n" +
|
||||||
"캐릭터톡 서비스를 이용하시려면\n본인인증을 하고 이용해주세요.",
|
"라이브 입장을 위해\n본인인증을 진행해 주세요.",
|
||||||
confirmButtonTitle: "본인인증 하러가기",
|
confirmButtonTitle: "본인인증 하러가기",
|
||||||
confirmButtonAction: {
|
confirmButtonAction: {
|
||||||
isShowAuthConfirmView = false
|
isShowAuthConfirmView = false
|
||||||
|
|||||||
Reference in New Issue
Block a user