메인 라이브 탭 - 커뮤니티 포스트 영역 추가
This commit is contained in:
parent
7bd32f8486
commit
acdacbfb7b
|
@ -120,6 +120,7 @@ struct CreatorCommunityAllItemView_Previews: PreviewProvider {
|
|||
CreatorCommunityAllItemView(
|
||||
item: GetCommunityPostListResponse(
|
||||
postId: 1,
|
||||
creatorId: 1,
|
||||
creatorNickname: "민하나",
|
||||
creatorProfileUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
|
||||
imageUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
|
||||
|
|
|
@ -18,6 +18,7 @@ enum CreatorCommunityApi {
|
|||
case getCommunityPostCommentList(postId: Int, page: Int, size: Int)
|
||||
case getCommentReplyList(commentId: Int, page: Int, size: Int)
|
||||
case modifyComment(request: ModifyCommunityPostCommentRequest)
|
||||
case getLatestPostListFromCreatorsYouFollow
|
||||
}
|
||||
|
||||
extension CreatorCommunityApi: TargetType {
|
||||
|
@ -44,6 +45,9 @@ extension CreatorCommunityApi: TargetType {
|
|||
|
||||
case .getCommunityPostDetail(let postId):
|
||||
return "/creator-community/\(postId)"
|
||||
|
||||
case .getLatestPostListFromCreatorsYouFollow:
|
||||
return "/creator-community/latest"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,7 +56,7 @@ extension CreatorCommunityApi: TargetType {
|
|||
case .createCommunityPost, .communityPostLike, .createCommunityPostComment:
|
||||
return .post
|
||||
|
||||
case .getCommunityPostList, .getCommunityPostCommentList, .getCommentReplyList, .getCommunityPostDetail:
|
||||
case .getCommunityPostList, .getCommunityPostCommentList, .getCommentReplyList, .getCommunityPostDetail, .getLatestPostListFromCreatorsYouFollow:
|
||||
return .get
|
||||
|
||||
case .modifyComment, .modifyCommunityPost:
|
||||
|
@ -107,6 +111,10 @@ extension CreatorCommunityApi: TargetType {
|
|||
case .getCommunityPostDetail:
|
||||
let parameters = ["timezone": TimeZone.current.identifier] as [String: Any]
|
||||
return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString)
|
||||
|
||||
case .getLatestPostListFromCreatorsYouFollow:
|
||||
let parameters = ["timezone": TimeZone.current.identifier] as [String: Any]
|
||||
return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -86,6 +86,7 @@ struct CreatorCommunityItemView_Previews: PreviewProvider {
|
|||
CreatorCommunityItemView(
|
||||
item: GetCommunityPostListResponse(
|
||||
postId: 1,
|
||||
creatorId: 1,
|
||||
creatorNickname: "민하나",
|
||||
creatorProfileUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
|
||||
imageUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
|
||||
|
|
|
@ -48,4 +48,8 @@ class CreatorCommunityRepository {
|
|||
func modifyComment(request: ModifyCommunityPostCommentRequest) -> AnyPublisher<Response, MoyaError> {
|
||||
return api.requestPublisher(.modifyComment(request: request))
|
||||
}
|
||||
|
||||
func getLatestPostListFromCreatorsYouFollow() -> AnyPublisher<Response, MoyaError> {
|
||||
return api.requestPublisher(.getLatestPostListFromCreatorsYouFollow)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
struct GetCommunityPostListResponse: Decodable {
|
||||
let postId: Int
|
||||
let creatorId: Int
|
||||
let creatorNickname: String
|
||||
let creatorProfileUrl: String
|
||||
let imageUrl: String?
|
||||
|
|
|
@ -25,11 +25,10 @@ struct LiveView: View {
|
|||
viewModel.getSummary()
|
||||
}
|
||||
) {
|
||||
VStack(spacing: 0) {
|
||||
LazyVStack(spacing: 40) {
|
||||
if viewModel.recommendLiveItems.count > 0 {
|
||||
SectionRecommendLiveView(items: viewModel.recommendLiveItems)
|
||||
.padding(.top, 13.3)
|
||||
.padding(.bottom, 40)
|
||||
}
|
||||
|
||||
if viewModel.recommendChannelItems.count > 0 {
|
||||
|
@ -50,7 +49,6 @@ struct LiveView: View {
|
|||
AppState.shared.setAppStep(step: .createLive(timeSettingMode: .NOW, onSuccess: onCreateSuccess))
|
||||
}
|
||||
)
|
||||
.padding(.top, 40)
|
||||
|
||||
if viewModel.eventBannerItems.count > 0 {
|
||||
SectionEventBannerView(items: viewModel.eventBannerItems)
|
||||
|
@ -59,7 +57,10 @@ struct LiveView: View {
|
|||
height: viewModel.eventBannerItems.count > 0 ? screenSize().width * 300 / 1000 : 0,
|
||||
alignment: .center
|
||||
)
|
||||
.padding(.top, 40)
|
||||
}
|
||||
|
||||
if viewModel.communityPostItems.count > 0 {
|
||||
SectionCommunityPostView(items: viewModel.communityPostItems)
|
||||
}
|
||||
|
||||
SectionLiveReservationView(
|
||||
|
@ -73,7 +74,6 @@ struct LiveView: View {
|
|||
AppState.shared.setAppStep(step: .createLive(timeSettingMode: .RESERVATION, onSuccess: onCreateSuccess))
|
||||
}
|
||||
)
|
||||
.padding(.top, 40)
|
||||
}
|
||||
}
|
||||
.frame(width: geo.size.width, height: geo.size.height)
|
||||
|
|
|
@ -13,6 +13,7 @@ final class LiveViewModel: ObservableObject {
|
|||
private let repository = LiveRepository()
|
||||
private let eventRepository = EventRepository()
|
||||
private let liveRecommendRepository = LiveRecommendRepository()
|
||||
private let creatorCommunityRepository = CreatorCommunityRepository()
|
||||
private var subscription = Set<AnyCancellable>()
|
||||
|
||||
@Published private(set) var eventBannerItems = [EventItem]()
|
||||
|
@ -21,6 +22,7 @@ final class LiveViewModel: ObservableObject {
|
|||
@Published private(set) var recommendLiveItems: [GetRecommendLiveResponse] = []
|
||||
@Published private(set) var recommendChannelItems: [GetRecommendChannelResponse] = []
|
||||
@Published private(set) var followedChannelItems: [GetRecommendChannelResponse] = []
|
||||
@Published private(set) var communityPostItems: [GetCommunityPostListResponse] = []
|
||||
|
||||
@Published var errorMessage = ""
|
||||
@Published var isShowPopup = false
|
||||
|
@ -80,6 +82,7 @@ final class LiveViewModel: ObservableObject {
|
|||
getFollowedChannelList()
|
||||
getRecommendChannelList()
|
||||
getRecommendLive()
|
||||
getLatestPostListFromCreatorsYouFollow()
|
||||
isLoading = true
|
||||
|
||||
eventBannerItems.removeAll()
|
||||
|
@ -644,4 +647,42 @@ final class LiveViewModel: ObservableObject {
|
|||
}
|
||||
.store(in: &subscription)
|
||||
}
|
||||
|
||||
private func getLatestPostListFromCreatorsYouFollow() {
|
||||
communityPostItems.removeAll()
|
||||
|
||||
creatorCommunityRepository.getLatestPostListFromCreatorsYouFollow()
|
||||
.sink { result in
|
||||
switch result {
|
||||
case .finished:
|
||||
DEBUG_LOG("finish")
|
||||
case .failure(let error):
|
||||
ERROR_LOG(error.localizedDescription)
|
||||
}
|
||||
} receiveValue: { [unowned self] response in
|
||||
self.isRecommendLiveLoading = false
|
||||
let responseData = response.data
|
||||
|
||||
do {
|
||||
let jsonDecoder = JSONDecoder()
|
||||
let decoded = try jsonDecoder.decode(ApiResponse<[GetCommunityPostListResponse]>.self, from: responseData)
|
||||
|
||||
if let data = decoded.data, decoded.success {
|
||||
self.communityPostItems.append(contentsOf: data)
|
||||
} else {
|
||||
if let message = decoded.message {
|
||||
self.errorMessage = message
|
||||
} else {
|
||||
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
|
||||
}
|
||||
self.isShowPopup = true
|
||||
}
|
||||
} catch {
|
||||
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
|
||||
self.isShowPopup = true
|
||||
}
|
||||
}
|
||||
.store(in: &subscription)
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
//
|
||||
// SectionCommunityPostView.swift
|
||||
// SodaLive
|
||||
//
|
||||
// Created by klaus on 2023/12/21.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct SectionCommunityPostView: View {
|
||||
|
||||
let items: [GetCommunityPostListResponse]
|
||||
|
||||
var body: some View {
|
||||
ScrollView(.horizontal, showsIndicators: false) {
|
||||
HStack(spacing: 13.3) {
|
||||
ForEach(0..<items.count, id: \.self) { index in
|
||||
let item = items[index]
|
||||
CreatorCommunityItemView(item: item)
|
||||
.frame(width: 320)
|
||||
.onTapGesture {
|
||||
AppState.shared
|
||||
.setAppStep(step: .creatorCommunityAll(creatorId: item.creatorId))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct SectionCommunityPostView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
SectionCommunityPostView(items: [
|
||||
GetCommunityPostListResponse(
|
||||
postId: 1,
|
||||
creatorId: 1,
|
||||
creatorNickname: "민하나",
|
||||
creatorProfileUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
|
||||
imageUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
|
||||
content: "라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!",
|
||||
date: "3일전",
|
||||
isCommentAvailable: false,
|
||||
isAdult: false,
|
||||
isLike: true,
|
||||
likeCount: 10,
|
||||
commentCount: 0,
|
||||
firstComment: nil
|
||||
),
|
||||
GetCommunityPostListResponse(
|
||||
postId: 2,
|
||||
creatorId: 2,
|
||||
creatorNickname: "닉네임2",
|
||||
creatorProfileUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
|
||||
imageUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
|
||||
content: "너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!너무 조하유 앞으로도 좋은 라이브 많이 들려주세요!",
|
||||
date: "3일전",
|
||||
isCommentAvailable: false,
|
||||
isAdult: false,
|
||||
isLike: true,
|
||||
likeCount: 20,
|
||||
commentCount: 0,
|
||||
firstComment: nil
|
||||
)
|
||||
])
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue