feat(content): 추천 오디오 탭을 추가한다

This commit is contained in:
Yu Sung
2026-07-06 14:03:09 +09:00
parent f3cbf42328
commit b42ca61ce4
28 changed files with 1841 additions and 460 deletions

View File

@@ -25,7 +25,6 @@ struct BannerCarousel: View {
init(
items: [BannerCarouselItem],
height: CGFloat = 120,
action: @escaping (BannerCarouselItem) -> Void = { _ in }
) {
self.items = Array(items.prefix(BannerCarousel.maxItemCount))
@@ -200,6 +199,49 @@ struct BannerCarousel: View {
}
}
struct BannerCarouselSection<Item>: View {
let items: [Item]
let id: (Item, Int) -> String
let imageUrl: (Item) -> String?
let action: (Item) -> Void
init(
items: [Item],
id: @escaping (Item, Int) -> String,
imageUrl: @escaping (Item) -> String?,
action: @escaping (Item) -> Void
) {
self.items = items
self.id = id
self.imageUrl = imageUrl
self.action = action
}
var body: some View {
if !items.isEmpty {
BannerCarousel(items: carouselItems) { carouselItem in
guard let item = item(for: carouselItem) else { return }
action(item)
}
}
}
private var carouselItems: [BannerCarouselItem] {
items.enumerated().map { index, item in
BannerCarouselItem(
id: id(item, index),
imageUrl: imageUrl(item)
)
}
}
private func item(for carouselItem: BannerCarouselItem) -> Item? {
items.enumerated().first { index, item in
id(item, index) == carouselItem.id
}?.element
}
}
struct BannerCarousel_Previews: PreviewProvider {
static var previews: some View {
BannerCarousel(