feat(creator): 팬Talk 탭을 추가한다
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import SwiftUI
|
||||
|
||||
struct CreatorChannelFanTalkActionPopup: View {
|
||||
let isMine: Bool
|
||||
let isOwnCreatorChannel: Bool
|
||||
let onTapEdit: () -> Void
|
||||
let onTapDelete: () -> Void
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
if isMine {
|
||||
actionButton(title: "수정하기", action: onTapEdit)
|
||||
}
|
||||
|
||||
if isMine || isOwnCreatorChannel {
|
||||
actionButton(title: "삭제하기", action: onTapDelete)
|
||||
}
|
||||
}
|
||||
.background(Color.gray900)
|
||||
.cornerRadius(14)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 14, style: .continuous)
|
||||
.stroke(Color.gray700, lineWidth: 1)
|
||||
)
|
||||
}
|
||||
|
||||
private func actionButton(title: String, action: @escaping () -> Void) -> some View {
|
||||
Button(action: action) {
|
||||
Text(title)
|
||||
.appFont(size: 14, weight: .medium)
|
||||
.foregroundColor(.white)
|
||||
.lineLimit(1)
|
||||
.frame(minWidth: 80, alignment: .leading)
|
||||
.padding(.horizontal, SodaSpacing.s12)
|
||||
.padding(.vertical, SodaSpacing.s8)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import SwiftUI
|
||||
|
||||
struct CreatorChannelFanTalkCountBar: View {
|
||||
let fanTalkCount: Int
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: SodaSpacing.s4) {
|
||||
Text("전체")
|
||||
.appFont(size: 16, weight: .medium)
|
||||
.foregroundColor(.white)
|
||||
|
||||
Text("\(fanTalkCount)")
|
||||
.appFont(size: 16, weight: .medium)
|
||||
.foregroundColor(Color.gray500)
|
||||
|
||||
Spacer()
|
||||
}
|
||||
.padding(.horizontal, SodaSpacing.s14)
|
||||
.frame(height: 52)
|
||||
.background(Color.black)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import SwiftUI
|
||||
|
||||
struct CreatorChannelFanTalkEmptyView: View {
|
||||
let showsWriteButton: Bool
|
||||
let onTapWrite: () -> Void
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: SodaSpacing.s20) {
|
||||
Text("아직 응원이 없습니다.\n처음으로 크리에이터를 응원해 보세요!")
|
||||
.appFont(size: 16, weight: .medium)
|
||||
.foregroundColor(Color.gray500)
|
||||
.multilineTextAlignment(.center)
|
||||
.lineSpacing(SodaSpacing.s4)
|
||||
|
||||
if showsWriteButton {
|
||||
Button(action: onTapWrite) {
|
||||
HStack(spacing: SodaSpacing.s6) {
|
||||
Image("ic_plus_no_bg")
|
||||
.resizable()
|
||||
.renderingMode(.template)
|
||||
.foregroundColor(.white)
|
||||
.scaledToFit()
|
||||
.frame(width: 20, height: 20)
|
||||
|
||||
Text("응원 남기기")
|
||||
.appFont(size: 16, weight: .medium)
|
||||
.foregroundColor(.white)
|
||||
.lineLimit(1)
|
||||
}
|
||||
.padding(.horizontal, SodaSpacing.s20)
|
||||
.frame(height: 44)
|
||||
.background(Color.soda400)
|
||||
.clipShape(Capsule())
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.vertical, 48)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
import SwiftUI
|
||||
|
||||
struct CreatorChannelFanTalkListItem: View {
|
||||
let fanTalk: CreatorChannelFanTalkItemResponse
|
||||
let isMine: Bool
|
||||
let isOwnCreatorChannel: Bool
|
||||
let onTapReport: () -> Void
|
||||
let onTapMore: () -> Void
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
VStack(alignment: .leading, spacing: SodaSpacing.s12) {
|
||||
header
|
||||
|
||||
Text(fanTalk.content)
|
||||
.appFont(size: 16, weight: .regular)
|
||||
.foregroundColor(.white)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.padding(.leading, 50)
|
||||
|
||||
if fanTalk.creatorReplies.isEmpty == false {
|
||||
replies
|
||||
.padding(.leading, 50)
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, SodaSpacing.s14)
|
||||
.padding(.vertical, SodaSpacing.s16)
|
||||
|
||||
Rectangle()
|
||||
.fill(Color.gray800)
|
||||
.frame(height: 1)
|
||||
}
|
||||
.background(Color.black)
|
||||
}
|
||||
|
||||
private var header: some View {
|
||||
HStack(alignment: .top, spacing: SodaSpacing.s8) {
|
||||
DownsampledKFImage(
|
||||
url: URL(string: fanTalk.writerProfileImageUrl),
|
||||
size: CGSize(width: 42, height: 42)
|
||||
)
|
||||
.background(Color.white.opacity(0.6))
|
||||
.clipShape(Circle())
|
||||
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text(fanTalk.writerNickname)
|
||||
.appFont(size: 14, weight: .medium)
|
||||
.foregroundColor(.white)
|
||||
.lineLimit(1)
|
||||
.truncationMode(.tail)
|
||||
|
||||
Text(fanTalk.relativeTimeText())
|
||||
.appFont(size: 14, weight: .regular)
|
||||
.foregroundColor(Color.gray500)
|
||||
.lineLimit(1)
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
||||
trailingAction
|
||||
}
|
||||
}
|
||||
|
||||
private var trailingAction: some View {
|
||||
Group {
|
||||
if isMine || isOwnCreatorChannel {
|
||||
Button(action: onTapMore) {
|
||||
Image("ic_new_more")
|
||||
.resizable()
|
||||
.frame(width: 24, height: 24)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
} else {
|
||||
Button(action: onTapReport) {
|
||||
Text("신고")
|
||||
.appFont(size: 13, weight: .medium)
|
||||
.foregroundColor(Color.gray500)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var replies: some View {
|
||||
VStack(alignment: .leading, spacing: SodaSpacing.s8) {
|
||||
ForEach(fanTalk.creatorReplies) { reply in
|
||||
HStack(alignment: .top, spacing: SodaSpacing.s8) {
|
||||
Rectangle()
|
||||
.fill(Color.gray800)
|
||||
.frame(width: 2)
|
||||
|
||||
replyCard(reply)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func replyCard(_ reply: CreatorChannelFanTalkReplyResponse) -> some View {
|
||||
VStack(alignment: .leading, spacing: SodaSpacing.s8) {
|
||||
HStack(alignment: .center, spacing: SodaSpacing.s6) {
|
||||
DownsampledKFImage(
|
||||
url: URL(string: reply.writerProfileImageUrl),
|
||||
size: CGSize(width: 20, height: 20)
|
||||
)
|
||||
.background(Color.white.opacity(0.6))
|
||||
.clipShape(Circle())
|
||||
|
||||
Text(reply.writerNickname)
|
||||
.appFont(size: 13, weight: .medium)
|
||||
.foregroundColor(.white)
|
||||
.lineLimit(1)
|
||||
|
||||
Text(reply.relativeTimeText())
|
||||
.appFont(size: 14, weight: .regular)
|
||||
.foregroundColor(Color.gray500)
|
||||
.lineLimit(1)
|
||||
}
|
||||
|
||||
Text(reply.content)
|
||||
.appFont(size: 16, weight: .regular)
|
||||
.foregroundColor(.white)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
.padding(SodaSpacing.s12)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.background(Color.gray900)
|
||||
.clipShape(RoundedRectangle(cornerRadius: SodaSpacing.s14, style: .continuous))
|
||||
}
|
||||
}
|
||||
|
||||
extension CreatorChannelFanTalkItemResponse {
|
||||
func relativeTimeText(now: Date = Date()) -> String {
|
||||
DateParser.relativeTimeText(fromUTC: createdAtUtc, fallback: createdAtUtc, now: now)
|
||||
}
|
||||
}
|
||||
|
||||
extension CreatorChannelFanTalkReplyResponse {
|
||||
func relativeTimeText(now: Date = Date()) -> String {
|
||||
DateParser.relativeTimeText(fromUTC: createdAtUtc, fallback: createdAtUtc, now: now)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user