feat(home): 현재 라이브 섹션을 연결한다

This commit is contained in:
Yu Sung
2026-06-29 13:22:00 +09:00
parent e67efeb30f
commit c441fb0b02
8 changed files with 191 additions and 38 deletions

View File

@@ -0,0 +1,83 @@
import SwiftUI
struct MainHomeLiveSection: View {
let items: [HomeLiveItem]
let onTapLive: (Int) -> Void
var body: some View {
if !items.isEmpty {
ScrollView(.horizontal, showsIndicators: false) {
LazyHStack(alignment: .top, spacing: SodaSpacing.s12) {
ForEach(items, id: \.self) { item in
MainHomeLiveItemView(item: item, onTapLive: onTapLive)
}
}
.padding(.horizontal, SodaSpacing.s20)
}
}
}
}
private struct MainHomeLiveItemView: View {
let item: HomeLiveItem
let onTapLive: (Int) -> Void
var body: some View {
Button {
onTapLive(item.roomId)
} label: {
VStack(alignment: .center, spacing: SodaSpacing.s6) {
ZStack(alignment: .bottom) {
DownsampledKFImage(url: URL(string: item.creatorProfileImage), size: CGSize(width: 62, height: 62))
.background(Color.gray800)
.clipShape(Circle())
.padding(SodaSpacing.s4)
.overlay {
Circle()
.strokeBorder(Color.button, lineWidth: 3)
}
Image("img_live")
.resizable()
.frame(width: 50, height: 18)
}
Text(item.creatorNickname)
.appFont(.body4)
.foregroundColor(.white)
.lineLimit(1)
.truncationMode(.tail)
}
.frame(width: 70, height: 102, alignment: .top)
}
.buttonStyle(.plain)
}
}
struct MainHomeLiveSection_Previews: PreviewProvider {
private static let previewImageUrl = "https://placehold.co/500"
static var previews: some View {
Group {
MainHomeLiveItemView(
item: HomeLiveItem(roomId: 1, creatorNickname: "크리에이...", creatorProfileImage: previewImageUrl),
onTapLive: { _ in }
)
.background(Color.black)
.previewLayout(.fixed(width: 70, height: 102))
.previewDisplayName("Live Item")
MainHomeLiveSection(
items: [
HomeLiveItem(roomId: 1, creatorNickname: "설린", creatorProfileImage: previewImageUrl),
HomeLiveItem(roomId: 2, creatorNickname: "크리에이터", creatorProfileImage: previewImageUrl)
],
onTapLive: { _ in }
)
.padding(.vertical, SodaSpacing.s20)
.background(Color.black)
.previewLayout(.sizeThatFits)
.previewDisplayName("Live Section")
}
}
}

View File

@@ -17,6 +17,16 @@ struct MainHomeRecommendationView: View {
if viewModel.isLoading && viewModel.recommendations == nil {
ProgressView()
.progressViewStyle(CircularProgressViewStyle(tint: .white))
} else {
ScrollView(showsIndicators: false) {
VStack(alignment: .leading, spacing: SodaSpacing.s24) {
MainHomeLiveSection(
items: viewModel.recommendations?.lives ?? [],
onTapLive: onTapLive
)
}
.padding(.vertical, SodaSpacing.s20)
}
}
}
.onAppear {

View File

@@ -13,9 +13,9 @@ struct HomeRecommendationResponse: Decodable {
}
struct HomeLiveItem: Decodable, Hashable {
let roomId: Int?
let creatorNickname: String?
let creatorProfileImage: String?
let roomId: Int
let creatorNickname: String
let creatorProfileImage: String
}
struct RecommendationBannerResponse: Decodable, Hashable {
@@ -30,56 +30,56 @@ struct RecommendationBannerResponse: Decodable, Hashable {
}
struct HomeActiveCreatorItem: Decodable, Hashable {
let creatorNickname: String?
let creatorProfileImage: String?
let activityType: RecommendedActivityType?
let activityAt: String?
let creatorNickname: String
let creatorProfileImage: String
let activityType: RecommendedActivityType
let activityAt: String
let targetId: Int?
}
struct HomeCreatorItem: Decodable, Hashable {
let creatorId: Int?
let creatorNickname: String?
let creatorProfileImage: String?
let creatorId: Int
let creatorNickname: String
let creatorProfileImage: String
}
struct HomeFirstAudioContentItem: Decodable, Hashable {
let contentId: Int?
let creatorId: Int?
let creatorNickname: String?
let creatorProfileImage: String?
let title: String?
let price: Int?
let contentId: Int
let creatorId: Int
let creatorNickname: String
let creatorProfileImage: String
let title: String
let price: Int
let coverImage: String?
let isPointAvailable: Bool?
let isPointAvailable: Bool
}
struct HomeAiCharacterItem: Decodable, Hashable {
let characterId: Int?
let creatorId: Int?
let name: String?
let description: String?
let characterId: Int
let creatorId: Int
let name: String
let description: String
let profileImage: String?
let totalChatCount: Int?
let totalChatCount: Int
let originalWorkTitle: String?
}
struct HomeGenreCreatorGroupItem: Decodable, Hashable {
let genreName: String?
let creators: [HomeCreatorItem]?
let genreName: String
let creators: [HomeCreatorItem]
}
struct HomePopularCommunityPostItem: Decodable, Hashable {
let postId: Int?
let creatorId: Int?
let creatorNickname: String?
let postId: Int
let creatorId: Int
let creatorNickname: String
let creatorProfileImage: String?
let content: String?
let content: String
let imageUrl: String?
let audioUrl: String?
let price: Int?
let existOrdered: Bool?
let likeCount: Int?
let commentCount: Int?
let createdAt: String?
let price: Int
let existOrdered: Bool
let likeCount: Int
let commentCount: Int
let createdAt: String
}

View File

@@ -440,7 +440,13 @@ struct MainView: View {
private func handleRecommendationLiveTap(roomId: Int) {
guard roomId > 0 else { return }
performRecommendationDetailAction {
openLiveDetail(roomId: roomId)
handleExternalNavigationRequest(
value: roomId,
navigationAction: {
liveViewModel.enterLiveRoom(roomId: roomId)
},
cancelAction: {}
)
}
}