feat: 메인 홈 - 라이브 중

- 터치 액션 추가
This commit is contained in:
Yu Sung
2025-07-14 19:52:16 +09:00
parent 4c3fa0fbb5
commit 87b43bd2c2
2 changed files with 25 additions and 3 deletions

View File

@@ -11,6 +11,7 @@ import Kingfisher
struct HomeLiveItemView: View { struct HomeLiveItemView: View {
let item: GetRoomListResponse let item: GetRoomListResponse
let onClickItem: (Int) -> Void
var body: some View { var body: some View {
HStack(spacing: 16) { HStack(spacing: 16) {
@@ -65,6 +66,8 @@ struct HomeLiveItemView: View {
lineWidth: 1 lineWidth: 1
) )
) )
.contentShape(Rectangle())
.onTapGesture { onClickItem(item.roomId) }
} }
} }
@@ -88,5 +91,5 @@ struct HomeLiveItemView: View {
isReservation: false, isReservation: false,
isPrivateRoom: false isPrivateRoom: false
) )
) ) { _ in }
} }

View File

@@ -9,6 +9,8 @@ import SwiftUI
struct HomeTabView: View { struct HomeTabView: View {
@StateObject var viewModel = HomeTabViewModel() @StateObject var viewModel = HomeTabViewModel()
@StateObject var liveViewModel = LiveViewModel()
@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)
@@ -50,8 +52,25 @@ struct HomeTabView: View {
ScrollView(.horizontal, showsIndicators: false) { ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 16) { HStack(spacing: 16) {
ForEach(0..<viewModel.liveList.count, id: \.self) { ForEach(0..<viewModel.liveList.count, id: \.self) { index in
HomeLiveItemView(item: viewModel.liveList[$0]) HomeLiveItemView(item: viewModel.liveList[index]) { roomId in
if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
AppState.shared.setAppStep(
step: .liveDetail(
roomId: roomId,
onClickParticipant: {
AppState.shared.isShowPlayer = false
liveViewModel.enterLiveRoom(roomId: roomId)
},
onClickReservation: {},
onClickStart: {},
onClickCancel: {}
)
)
} else {
AppState.shared.setAppStep(step: .login)
}
}
} }
} }
.padding(.horizontal, 24) .padding(.horizontal, 24)