Compare commits

...

4 Commits

Author SHA1 Message Date
Yu Sung 27b87c9cbe 라이브 상세
- 크리에이터는 예약자(참여자) 표시
2024-02-14 17:02:22 +09:00
Yu Sung 20cce36c16 콘텐츠 리스트 - 가격, 시간 추가 2024-02-14 16:11:06 +09:00
Yu Sung 7d0c472885 콘텐츠 메인 - 숏플, 라이브 다시 듣기 추가 2024-02-14 15:49:13 +09:00
Yu Sung c787027dcc 큐레이션, 새로운 콘텐츠 - 아이템 개수 2개에서 3개로 변경 2024-02-14 12:56:16 +09:00
23 changed files with 530 additions and 11 deletions

View File

@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_card_can_gray.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 552 B

View File

@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_card_time_small_gray.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 543 B

View File

@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_short_play.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_thumb_play_blue.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -119,4 +119,6 @@ enum AppStep {
case creatorCommunityModify(postId: Int, onSuccess: () -> Void)
case canCoupon
case contentAllByTheme(themeId: Int)
}

View File

@ -0,0 +1,111 @@
//
// ContentAllByThemeView.swift
// SodaLive
//
// Created by klaus on 2/14/24.
//
import SwiftUI
struct ContentAllByThemeView: View {
@StateObject var viewModel = ContentAllByThemeViewModel()
let themeId: Int
let columns = [
GridItem(.flexible(), alignment: .top),
GridItem(.flexible(), alignment: .top),
GridItem(.flexible(), alignment: .top)
]
var body: some View {
NavigationView {
BaseView(isLoading: $viewModel.isLoading) {
VStack(alignment: .leading, spacing: 0) {
DetailNavigationBar(title: viewModel.theme)
HStack(spacing: 13.3) {
Spacer()
Text("최신순")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(
Color(hex: "e2e2e2")
.opacity(viewModel.sort == .NEWEST ? 1 : 0.5)
)
.onTapGesture {
if viewModel.sort != .NEWEST {
viewModel.sort = .NEWEST
}
}
Text("높은 가격순")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(
Color(hex: "e2e2e2")
.opacity(viewModel.sort == .PRICE_HIGH ? 1 : 0.5)
)
.onTapGesture {
if viewModel.sort != .PRICE_HIGH {
viewModel.sort = .PRICE_HIGH
}
}
Text("낮은 가격순")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(
Color(hex: "e2e2e2")
.opacity(viewModel.sort == .PRICE_LOW ? 1 : 0.5)
)
.onTapGesture {
if viewModel.sort != .PRICE_LOW {
viewModel.sort = .PRICE_LOW
}
}
}
.padding(.vertical, 13.3)
.padding(.horizontal, 20)
.background(Color(hex: "161616"))
.padding(.top, 13.3)
HStack(spacing: 0) {
Text("전체")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "e2e2e2"))
Text("\(viewModel.totalCount)")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "ff5c49"))
.padding(.leading, 8)
Text("")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "e2e2e2"))
.padding(.leading, 2)
Spacer()
}
.padding(.vertical, 13.3)
.padding(.horizontal, 20)
ScrollView(.vertical, showsIndicators: false) {
LazyVGrid(columns: columns, spacing: 13.3) {
ForEach(0..<viewModel.contentList.count, id: \.self) { index in
ContentNewAllItemView(item: viewModel.contentList[index])
.onAppear {
if index == viewModel.contentList.count - 1 {
viewModel.getContentList()
}
}
}
}
}
}
.onAppear {
viewModel.themeId = themeId
viewModel.getContentList()
}
}
}
}
}

View File

@ -0,0 +1,96 @@
//
// ContentAllByThemeViewModel.swift
// SodaLive
//
// Created by klaus on 2/14/24.
//
import Foundation
import Combine
final class ContentAllByThemeViewModel: ObservableObject {
enum Sort: String {
case NEWEST, PRICE_HIGH, PRICE_LOW
}
private let repository = ContentRepository()
private var subscription = Set<AnyCancellable>()
@Published var errorMessage = ""
@Published var isShowPopup = false
@Published var isLoading = false
@Published var theme = ""
@Published var totalCount = 0
@Published var sort = Sort.NEWEST {
didSet {
page = 1
isLast = false
getContentList()
}
}
@Published var contentList: [GetAudioContentMainItem] = []
var themeId = 0
var page = 1
var isLast = false
private let pageSize = 10
func getContentList() {
if (!isLast && !isLoading) {
isLoading = true
repository.getAudioContentByTheme(
themeId: themeId,
page: page,
size: pageSize,
sort: sort
)
.sink { result in
switch result {
case .finished:
DEBUG_LOG("finish")
case .failure(let error):
ERROR_LOG(error.localizedDescription)
}
} receiveValue: { [unowned self] response in
let responseData = response.data
do {
let jsonDecoder = JSONDecoder()
let decoded = try jsonDecoder.decode(ApiResponse<GetContentByThemeResponse>.self, from: responseData)
if let data = decoded.data, decoded.success {
if page == 1 {
self.contentList.removeAll()
}
if !data.items.isEmpty {
page += 1
self.theme = data.theme
self.totalCount = data.totalCount
self.contentList.append(contentsOf: data.items)
} else {
isLast = true
}
} else {
if let message = decoded.message {
self.errorMessage = message
} else {
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
}
self.isShowPopup = true
}
} catch {
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
self.isShowPopup = true
}
self.isLoading = false
}
.store(in: &subscription)
}
}
}

View File

@ -0,0 +1,14 @@
//
// GetContentByThemeResponse.swift
// SodaLive
//
// Created by klaus on 2/14/24.
//
import Foundation
struct GetContentByThemeResponse: Decodable {
let theme: String
let totalCount: Int
let items: [GetAudioContentMainItem]
}

View File

@ -19,11 +19,54 @@ struct ContentNewAllItemView: View {
ContentDetailView(contentId: item.contentId)
} label: {
VStack(alignment: .leading, spacing: 8) {
KFImage(URL(string: item.coverImageUrl))
.resizable()
.scaledToFill()
.frame(width: width, height: width, alignment: .top)
.cornerRadius(2.7)
ZStack(alignment: .bottom) {
KFImage(URL(string: item.coverImageUrl))
.resizable()
.scaledToFill()
.frame(width: width, height: width, alignment: .top)
.cornerRadius(2.7)
VStack(spacing: 0) {
Spacer()
HStack(spacing: 0) {
HStack(spacing: 2) {
if item.price > 0 {
Image("ic_card_can_gray")
Text("\(item.price)")
.font(.custom(Font.medium.rawValue, size: 8.3))
.foregroundColor(Color.white)
} else {
Text("무료")
.font(.custom(Font.medium.rawValue, size: 8.3))
.foregroundColor(Color.white)
}
}
.padding(3)
.background(Color(hex: "333333").opacity(0.7))
.cornerRadius(10)
.padding(.leading, 2.7)
.padding(.bottom, 2.7)
Spacer()
HStack(spacing: 2) {
Image("ic_card_time_small_gray")
Text(item.duration)
.font(.custom(Font.medium.rawValue, size: 8.3))
.foregroundColor(Color.white)
}
.padding(3)
.background(Color(hex: "333333").opacity(0.7))
.cornerRadius(10)
.padding(.trailing, 2.7)
.padding(.bottom, 2.7)
}
}
}
.frame(width: width, height: width)
Text(item.title)
.font(.custom(Font.medium.rawValue, size: 13.3))
@ -50,7 +93,7 @@ struct ContentNewAllItemView: View {
}
.frame(width: width)
.onAppear {
width = (screenSize().width - 40) / 2
width = (screenSize().width - 54) / 3
}
}
}

View File

@ -12,6 +12,7 @@ struct ContentNewAllView: View {
@StateObject var viewModel = ContentNewAllViewModel()
let columns = [
GridItem(.flexible(), alignment: .top),
GridItem(.flexible(), alignment: .top),
GridItem(.flexible(), alignment: .top)
]

View File

@ -36,6 +36,7 @@ enum ContentApi {
case getContentRankingSortType
case pinContent(contentId: Int)
case unpinContent(contentId: Int)
case getAudioContentByTheme(themeId: Int, page: Int, size: Int, sort: ContentAllByThemeViewModel.Sort)
}
extension ContentApi: TargetType {
@ -125,6 +126,9 @@ extension ContentApi: TargetType {
case .unpinContent(let contentId):
return "/audio-content/unpin-at-the-top/\(contentId)"
case .getAudioContentByTheme(let themeId, _, _, _):
return "/audio-content/theme/\(themeId)/content"
}
}
@ -136,7 +140,7 @@ extension ContentApi: TargetType {
.getContentRankingSortType:
return .get
case .getMainBannerList, .getMainOrderList, .getNewContentUploadCreatorList, .getCurationList:
case .getMainBannerList, .getMainOrderList, .getNewContentUploadCreatorList, .getCurationList, .getAudioContentByTheme:
return .get
case .likeContent, .modifyAudioContent, .modifyComment, .unpinContent:
@ -271,6 +275,15 @@ extension ContentApi: TargetType {
case .pinContent, .unpinContent:
return .requestPlain
case .getAudioContentByTheme(_, let page, let size, let sort):
let parameters = [
"page": page - 1,
"size": size,
"sort-type": sort
] as [String : Any]
return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString)
}
}

View File

@ -125,4 +125,8 @@ final class ContentRepository {
func getCategoryList(creatorId: Int) -> AnyPublisher<Response, MoyaError> {
return categoryApi.requestPublisher(.getCategoryList(creatorId: creatorId))
}
func getAudioContentByTheme(themeId: Int, page: Int, size: Int, sort: ContentAllByThemeViewModel.Sort) -> AnyPublisher<Response, MoyaError> {
return api.requestPublisher(.getAudioContentByTheme(themeId: themeId, page: page, size: size, sort: sort))
}
}

View File

@ -15,6 +15,7 @@ struct ContentCurationView: View {
let curationId: Int
let columns = [
GridItem(.flexible(), alignment: .top),
GridItem(.flexible(), alignment: .top),
GridItem(.flexible(), alignment: .top)
]

View File

@ -59,7 +59,9 @@ struct ContentMainItemView_Previews: PreviewProvider {
title: "ㅓ처랴햐햫햐햐",
creatorId: 8,
creatorProfileImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
creatorNickname: "유저2"
creatorNickname: "유저2",
price: 10,
duration: "00:00:30"
)
)
}

View File

@ -35,11 +35,60 @@ struct ContentMainView: View {
.padding(.horizontal, 13.3)
ContentMainBannerView()
.padding(.bottom, 40)
.padding(.bottom, 26.7)
.padding(.horizontal, 13.3)
HStack(spacing: 13.3) {
VStack(spacing: 2.7) {
HStack(spacing: 2.7) {
Image("ic_short_play")
Text("숏플")
.font(.custom(Font.bold.rawValue, size: 14.7))
.foregroundColor(Color(hex: "dd158d"))
}
Text("짧지만 꼴릿한 이야기")
.font(.custom(Font.light.rawValue, size: 10))
.foregroundColor(Color(hex: "dd158d"))
}
.padding(.vertical, 10)
.frame(maxWidth: .infinity)
.background(Color(hex: "ffecf7"))
.cornerRadius(2.6)
.onTapGesture {
AppState.shared.setAppStep(
step: .contentAllByTheme(themeId: 11)
)
}
VStack(spacing: 2.7) {
HStack(spacing: 2.7) {
Image("ic_thumb_play_blue")
Text("라이브 다시듣기")
.font(.custom(Font.bold.rawValue, size: 14.7))
.foregroundColor(Color(hex: "0057ff"))
}
Text("놓쳤던 라이브 다시듣기")
.font(.custom(Font.light.rawValue, size: 10))
.foregroundColor(Color(hex: "0057ff"))
}
.padding(.vertical, 10)
.frame(maxWidth: .infinity)
.background(Color(hex: "ecf9ff"))
.cornerRadius(2.6)
.onTapGesture {
AppState.shared.setAppStep(
step: .contentAllByTheme(themeId: 7)
)
}
}
.padding(.bottom, 40)
.padding(.horizontal, 13.3)
ContentMainMyStashView()
.padding(.bottom, 40)
.padding(.horizontal, 13.3)
ContentMainNewContentView()

View File

@ -48,6 +48,8 @@ struct GetAudioContentMainItem: Decodable {
let creatorId: Int
let creatorProfileImageUrl: String
let creatorNickname: String
let price: Int
let duration: String
}
struct GetAudioContentCurationResponse: Decodable {

View File

@ -39,6 +39,7 @@ struct ContentMainMyStashView: View {
}
}
}
.padding(.bottom, 40)
}
if viewModel.isLoading {

View File

@ -175,6 +175,9 @@ struct ContentView: View {
case .canCoupon:
CanCouponView()
case .contentAllByTheme(let themeId):
ContentAllByThemeView(themeId: themeId)
default:
EmptyView()
.frame(width: 0, height: 0, alignment: .topLeading)

View File

@ -118,9 +118,20 @@ struct LiveDetailView: View {
.padding(.top, 16.7)
.frame(width: proxy.size.width - 26.7)
if UserDefaults.int(forKey: .userId) == room.manager.id {
Rectangle()
.frame(height: 1)
.foregroundColor(Color.gray90.opacity(0.5))
.padding(.top, 8)
.frame(width: proxy.size.width - 26.7)
ParticipantView(room: room)
.frame(width: proxy.size.width - 26.7)
}
Rectangle()
.frame(height: 1)
.foregroundColor(Color(hex: "909090").opacity(0.5))
.foregroundColor(Color.gray90.opacity(0.5))
.padding(.top, 13.3)
HStack(spacing: 13.3) {
@ -392,6 +403,88 @@ struct LiveDetailView: View {
}
}
@ViewBuilder
private func ParticipantView(room: GetRoomDetailResponse) -> some View {
if isExpandParticipantArea {
HStack(spacing: 0) {
Text(room.channelName.isNullOrBlank() ? "예약자" : "참가자")
.font(.custom(Font.medium.rawValue, size: 12))
.foregroundColor(Color.graybb)
Spacer()
Text("\(room.numberOfParticipants)")
.font(.custom(Font.medium.rawValue, size: 12))
.foregroundColor(Color.button)
Text("/\(room.numberOfParticipantsTotal)")
.font(.custom(Font.medium.rawValue, size: 12))
.foregroundColor(Color.graybb)
}
.padding(.top, 16.7)
LazyVGrid(columns: columns) {
ForEach(room.participatingUsers, id: \.self) { user in
VStack(spacing: 6.7) {
KFImage(URL(string: user.profileImageUrl))
.resizable()
.scaledToFill()
.frame(width: 46.7, height: 46.7, alignment: .top)
.clipShape(Circle())
Text(user.nickname)
.font(.custom(Font.medium.rawValue, size: 12))
.foregroundColor(Color.graybb)
.lineLimit(1)
}
}
}
.padding(.top, 16.7)
} else {
let userCount = room.numberOfParticipants > 10 ? 10 : room.numberOfParticipants
HStack(spacing: -13.3) {
ForEach(0..<userCount, id: \.self) { index in
let user = room.participatingUsers[index]
KFImage(URL(string: user.profileImageUrl))
.resizable()
.scaledToFill()
.frame(width: 33.3, height: 33.3, alignment: .top)
.clipShape(Circle())
}
Spacer()
HStack(spacing: 0) {
Text("\(room.numberOfParticipants)")
.font(.custom(Font.medium.rawValue, size: 12))
.foregroundColor(Color.button)
Text("/\(room.numberOfParticipantsTotal)")
.font(.custom(Font.medium.rawValue, size: 12))
.foregroundColor(Color.graybb)
}
}
.padding(.top, 22)
}
if room.numberOfParticipants > 0 {
HStack(spacing: 6.7) {
Image(isExpandParticipantArea ? "ic_live_detail_top" : "ic_live_detail_bottom")
.resizable()
.frame(width: 20, height: 20)
Text(isExpandParticipantArea ? "닫기" : "펼쳐보기")
.font(.custom(Font.medium.rawValue, size: 12))
.foregroundColor(Color.graybb)
}
.padding(.top, 13.3)
.onTapGesture {
isExpandParticipantArea.toggle()
}
}
}
private func hideView() {
if let close = onClickClose {
close()