성인 라이브 입장에 본인인증 흐름 추가

라이브 지금 항목 탭을 상위에서 처리 가능하도록 노출
This commit is contained in:
Yu Sung
2026-02-02 11:48:12 +09:00
parent 9e97c301b8
commit b985af4497
4 changed files with 130 additions and 43 deletions

View File

@@ -26,7 +26,16 @@ struct HomeTabView: View {
@State private var pendingUnfollowCreatorId: Int? = nil @State private var pendingUnfollowCreatorId: Int? = nil
@State private var pendingUnfollowCreatorName = "" @State private var pendingUnfollowCreatorName = ""
var onTapPopularCharacterAllView: (() -> Void)? = nil let onTapPopularCharacterAllView: (() -> Void)?
let onTapLiveNowItem: ((Int, Bool) -> Void)?
init(
onTapPopularCharacterAllView: (() -> Void)? = nil,
onTapLiveNowItem: ((Int, Bool) -> Void)? = nil
) {
self.onTapPopularCharacterAllView = onTapPopularCharacterAllView
self.onTapLiveNowItem = onTapLiveNowItem
}
// CharacterView // CharacterView
private func handleCharacterSelection(_ characterId: Int) { private func handleCharacterSelection(_ characterId: Int) {
@@ -46,6 +55,10 @@ struct HomeTabView: View {
AppState.shared.setAppStep(step: .characterDetail(characterId: characterId)) AppState.shared.setAppStep(step: .characterDetail(characterId: characterId))
} }
private func handleLiveNowItemTap(roomId: Int, isAdult: Bool) {
onTapLiveNowItem?(roomId, isAdult)
}
var body: some View { var body: some View {
BaseView(isLoading: $viewModel.isLoading) { BaseView(isLoading: $viewModel.isLoading) {
ZStack(alignment: .bottomTrailing) { ZStack(alignment: .bottomTrailing) {
@@ -93,23 +106,12 @@ struct HomeTabView: View {
ScrollView(.horizontal, showsIndicators: false) { ScrollView(.horizontal, showsIndicators: false) {
LazyHStack(spacing: 16) { LazyHStack(spacing: 16) {
ForEach(0..<viewModel.liveList.count, id: \.self) { index in ForEach(0..<viewModel.liveList.count, id: \.self) { index in
HomeLiveItemView(item: viewModel.liveList[index]) { roomId in let item = viewModel.liveList[index]
if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty { HomeLiveItemView(item: item) { roomId in
AppState.shared.setAppStep( handleLiveNowItemTap(
step: .liveDetail( roomId: roomId,
roomId: roomId, isAdult: item.isAdult
onClickParticipant: { )
AppState.shared.isShowPlayer = false
liveViewModel.enterLiveRoom(roomId: roomId)
},
onClickReservation: {},
onClickStart: {},
onClickCancel: {}
)
)
} else {
AppState.shared.setAppStep(step: .login)
}
} }
} }
} }

View File

@@ -15,6 +15,12 @@ struct LiveView: View {
@AppStorage("token") private var token: String = UserDefaults.string(forKey: UserDefaultsKey.token) @AppStorage("token") private var token: String = UserDefaults.string(forKey: UserDefaultsKey.token)
@AppStorage("role") private var role: String = UserDefaults.string(forKey: UserDefaultsKey.role) @AppStorage("role") private var role: String = UserDefaults.string(forKey: UserDefaultsKey.role)
let onTapLiveNowItem: (Int, Bool) -> Void
init(onTapLiveNowItem: @escaping (Int, Bool) -> Void = { _, _ in }) {
self.onTapLiveNowItem = onTapLiveNowItem
}
var body: some View { var body: some View {
ZStack { ZStack {
Color.black.ignoresSafeArea() Color.black.ignoresSafeArea()
@@ -61,6 +67,9 @@ struct LiveView: View {
AppState.shared.setAppStep(step: .login) AppState.shared.setAppStep(step: .login)
} }
}, },
onTapItem: { item in
onTapLiveNowItem(item.roomId, item.isAdult)
},
onTapCreateLive: { onTapCreateLive: {
if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty { if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
AppState.shared.setAppStep(step: .createLive(timeSettingMode: .NOW, onSuccess: onCreateSuccess)) AppState.shared.setAppStep(step: .createLive(timeSettingMode: .NOW, onSuccess: onCreateSuccess))

View File

@@ -12,11 +12,10 @@ struct SectionLiveNowView: View {
let items: [GetRoomListResponse] let items: [GetRoomListResponse]
let onClickParticipant: (Int) -> Void let onClickParticipant: (Int) -> Void
let onTapItem: (GetRoomListResponse) -> Void
let onTapCreateLive: () -> Void let onTapCreateLive: () -> Void
let onClickRefresh: () -> Void let onClickRefresh: () -> Void
@AppStorage("token") private var token: String = UserDefaults.string(forKey: UserDefaultsKey.token)
var body: some View { var body: some View {
LazyVStack(spacing: 13.3) { LazyVStack(spacing: 13.3) {
HStack(spacing: 0) { HStack(spacing: 0) {
@@ -43,24 +42,7 @@ struct SectionLiveNowView: View {
LiveNowItemView(item: item, itemWidth: nil) LiveNowItemView(item: item, itemWidth: nil)
.contentShape(Rectangle()) .contentShape(Rectangle())
.onTapGesture { .onTapGesture {
if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty { onTapItem(item)
AppState.shared.setAppStep(
step: .liveDetail(
roomId: item.roomId,
onClickParticipant: {
AppState.shared.isShowPlayer = false
onClickParticipant(item.roomId)
},
onClickReservation: {},
onClickStart: {
},
onClickCancel: {
}
)
)
} else {
AppState.shared.setAppStep(step: .login)
}
} }
} }
} }
@@ -114,6 +96,7 @@ struct SectionLiveNowView_Previews: PreviewProvider {
SectionLiveNowView( SectionLiveNowView(
items: [], items: [],
onClickParticipant: { _ in }, onClickParticipant: { _ in },
onTapItem: { _ in },
onTapCreateLive: {}, onTapCreateLive: {},
onClickRefresh: {} onClickRefresh: {}
) )

View File

@@ -9,6 +9,8 @@ import SwiftUI
import Firebase import Firebase
import Kingfisher import Kingfisher
import Bootpay
import BootpayUI
struct HomeView: View { struct HomeView: View {
@StateObject var viewModel = HomeViewModel() @StateObject var viewModel = HomeViewModel()
@@ -16,13 +18,25 @@ struct HomeView: View {
@StateObject var appState = AppState.shared @StateObject var appState = AppState.shared
@StateObject var contentPlayManager = ContentPlayManager.shared @StateObject var contentPlayManager = ContentPlayManager.shared
@StateObject var contentPlayerPlayManager = ContentPlayerPlayManager.shared @StateObject var contentPlayerPlayManager = ContentPlayerPlayManager.shared
@StateObject var mypageViewModel = MyPageViewModel()
private let liveView = LiveView() private var liveView: LiveView { LiveView(onTapLiveNowItem: handleLiveNowItemTap) }
@State var homeTabView = HomeTabView() private var homeTabView: HomeTabView {
HomeTabView(
onTapPopularCharacterAllView: { viewModel.currentTab = .chat },
onTapLiveNowItem: handleLiveNowItemTap
)
}
private let chatTabView = ChatTabView() private let chatTabView = ChatTabView()
@State private var isShowPlayer = false @State private var isShowPlayer = false
@AppStorage("token") private var token: String = UserDefaults.string(forKey: UserDefaultsKey.token) @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: Bool = false
@State private var isShowAuthConfirmView: Bool = false
@State private var pendingAction: (() -> Void)? = nil
@State private var payload = Payload()
var body: some View { var body: some View {
GeometryReader { proxy in GeometryReader { proxy in
@@ -166,9 +180,12 @@ struct HomeView: View {
} }
} }
.onAppear { .onAppear {
homeTabView.onTapPopularCharacterAllView = { payload.applicationId = BOOTPAY_APP_ID
viewModel.currentTab = .chat payload.price = 0
} payload.pg = "다날"
payload.method = "본인인증"
payload.orderName = "본인인증"
payload.authenticationId = "\(UserDefaults.string(forKey: .nickname))__\(String(NSTimeIntervalSince1970))"
if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty { if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
pushTokenUpdate() pushTokenUpdate()
@@ -182,6 +199,25 @@ struct HomeView: View {
NotificationSettingsDialog() NotificationSettingsDialog()
} }
if isShowAuthConfirmView {
SodaDialog(
title: "본인인증",
desc: "보이스온의 오픈월드 캐릭터톡은\n청소년 보호를 위해 본인인증한\n성인만 이용이 가능합니다.\n" +
"캐릭터톡 서비스를 이용하시려면\n본인인증을 하고 이용해주세요.",
confirmButtonTitle: "본인인증 하러가기",
confirmButtonAction: {
isShowAuthConfirmView = false
isShowAuthView = true
},
cancelButtonTitle: "취소",
cancelButtonAction: {
isShowAuthConfirmView = false
pendingAction = nil
},
textAlignment: .center
)
}
if liveViewModel.isShowPaymentDialog { if liveViewModel.isShowPaymentDialog {
LivePaymentDialog( LivePaymentDialog(
title: liveViewModel.paymentDialogTitle, title: liveViewModel.paymentDialogTitle,
@@ -231,6 +267,34 @@ struct HomeView: View {
} }
} }
.edgesIgnoringSafeArea(.bottom) .edgesIgnoringSafeArea(.bottom)
.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
}
}
.valueChanged(value: appState.pushRoomId) { value in .valueChanged(value: appState.pushRoomId) { value in
DispatchQueue.main.async { DispatchQueue.main.async {
appState.setAppStep(step: .main) appState.setAppStep(step: .main)
@@ -285,6 +349,35 @@ struct HomeView: View {
} }
} }
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) {
AppState.shared.setAppStep(
step: .liveDetail(
roomId: roomId,
onClickParticipant: {
AppState.shared.isShowPlayer = false
liveViewModel.enterLiveRoom(roomId: roomId)
},
onClickReservation: {},
onClickStart: {},
onClickCancel: {}
)
)
}
private func pushTokenUpdate() { private func pushTokenUpdate() {
let pushToken = UserDefaults.string(forKey: .pushToken) let pushToken = UserDefaults.string(forKey: .pushToken)
if !pushToken.trimmingCharacters(in: .whitespaces).isEmpty { if !pushToken.trimmingCharacters(in: .whitespaces).isEmpty {