sodalive-ios/SodaLive/Sources/Live/Room/Dialog/LiveRoomProfileItemTitleVie...

190 lines
6.4 KiB
Swift

//
// LiveRoomProfileItemTitleView.swift
// SodaLive
//
// Created by klaus on 2023/08/14.
//
import SwiftUI
import Kingfisher
struct LiveRoomProfileItemTitleView: View {
let title: String
let count: Int?
let totalCount: Int?
var body: some View {
HStack(spacing: 0) {
Text(title)
.font(.custom(Font.bold.rawValue, size: 13))
.foregroundColor(Color(hex: "eeeeee"))
if let count = count {
Text("\(count)")
.font(.custom(Font.medium.rawValue, size: 13))
.foregroundColor(Color(hex: "9970ff"))
.padding(.leading, 6.7)
}
if let totalCount = totalCount {
Text("/\(totalCount > 9 ? 9 : totalCount - 1)")
.font(.custom(Font.medium.rawValue, size: 13))
.foregroundColor(Color(hex: "bbbbbb"))
}
Spacer()
}
}
}
struct LiveRoomProfileItemMasterView: View {
let id: Int
let nickname: String
let profileUrl: String
let onClickProfile: (Int) -> Void
var body: some View {
VStack(alignment: .leading, spacing: 20) {
HStack(spacing: 0) {
KFImage(URL(string: profileUrl))
.resizable()
.frame(width: 60, height: 60)
.clipShape(Circle())
.onTapGesture { onClickProfile(id) }
Image("ic_crown")
.padding(.leading, 16.7)
Text(nickname)
.font(.custom(Font.medium.rawValue, size: 14))
.foregroundColor(Color(hex: "eeeeee"))
.padding(.leading, 4)
}
.padding(.horizontal, 16.7)
Rectangle()
.frame(height: 1)
.foregroundColor(Color(hex: "909090").opacity(0.3))
}
}
}
struct LiveRoomProfileItemUserView: View {
let isStaff: Bool
let userId: Int
let nickname: String
let profileUrl: String
let role: LiveRoomMemberRole
let onClickChangeListener: (Int) -> Void
let onClickInviteSpeaker: (Int) -> Void
let onClickKickOut: (Int) -> Void
let onClickProfile: (Int) -> Void
var body: some View {
ZStack {
VStack(spacing: 10) {
HStack(spacing: 0) {
KFImage(URL(string: profileUrl))
.resizable()
.frame(width: 46.7, height: 46.7)
.clipShape(Circle())
.onTapGesture { onClickProfile(userId) }
if role == .MANAGER {
Image("ic_badge_manager")
.padding(.leading, 16.7)
Text(nickname)
.font(.custom(Font.medium.rawValue, size: 14))
.foregroundColor(Color(hex: "eeeeee"))
.lineLimit(2)
.multilineTextAlignment(.leading)
.padding(.leading, 4)
.padding(.trailing, 10)
} else {
Text(nickname)
.font(.custom(Font.medium.rawValue, size: 14))
.foregroundColor(Color(hex: "eeeeee"))
.lineLimit(2)
.multilineTextAlignment(.leading)
.padding(.horizontal, 10)
}
Spacer()
if role == .LISTENER && isStaff {
Text("스피커로 초대")
.font(.custom(Font.medium.rawValue, size: 10))
.foregroundColor(Color(hex: "ffffff"))
.padding(.horizontal, 5.5)
.padding(.vertical, 12)
.background(Color(hex: "9970ff").opacity(0.3))
.cornerRadius(6.7)
.overlay(
RoundedRectangle(cornerRadius: 6.7)
.stroke(Color(hex: "9970ff"), lineWidth: 1)
)
.onTapGesture {
onClickInviteSpeaker(userId)
}
}
if role == .SPEAKER && (userId == UserDefaults.int(forKey: .userId) || isStaff) {
Text("리스너로 변경")
.font(.custom(Font.medium.rawValue, size: 10))
.foregroundColor(Color(hex: "ffffff"))
.padding(.horizontal, 5.5)
.padding(.vertical, 12)
.background(Color(hex: "9970ff"))
.cornerRadius(6.7)
.onTapGesture {
onClickChangeListener(userId)
}
}
if role != .MANAGER && isStaff {
Image("ic_kick_out")
.padding(.leading, 10)
.onTapGesture {
onClickKickOut(userId)
}
}
}
Rectangle()
.frame(height: 1)
.foregroundColor(Color(hex: "909090").opacity(0.3))
}
.padding(.horizontal, 16.7)
}
}
}
struct LiveRoomProfileRequestSpeakerView: View {
let onClickRequestSpeaker: () -> Void
var body: some View {
HStack(spacing: 6.7) {
Spacer()
Image("ic_request_speak")
Text("스피커 요청하기")
.font(.custom(Font.bold.rawValue, size: 13.3))
.foregroundColor(.white)
Spacer()
}
.padding(.vertical, 8)
.overlay(
RoundedRectangle(cornerRadius: 5.3)
.stroke(Color(hex: "909090"), lineWidth: 1)
)
.onTapGesture {
onClickRequestSpeaker()
}
.padding(.horizontal, 16.7)
}
}