라이브 방 추가

This commit is contained in:
Yu Sung
2023-08-15 01:22:15 +09:00
parent 634f50d4f2
commit 0f8b740469
92 changed files with 5213 additions and 20 deletions

View File

@@ -0,0 +1,42 @@
//
// LiveRoomChat.swift
// SodaLive
//
// Created by klaus on 2023/08/14.
//
import Foundation
enum LiveRoomChatType: String {
case CHAT, DONATION, JOIN
}
protocol LiveRoomChat {
var type: LiveRoomChatType { get set }
}
struct LiveRoomNormalChat: LiveRoomChat {
let userId: Int
let profileUrl: String
let nickname: String
let rank: Int
let chat: String
var type: LiveRoomChatType = .CHAT
}
struct LiveRoomDonationChat: LiveRoomChat {
let profileUrl: String
let nickname: String
let chat: String
let can: Int
let donationMessage: String
var type: LiveRoomChatType = .DONATION
}
struct LiveRoomJoinChat: LiveRoomChat {
let nickname: String
var type: LiveRoomChatType = .JOIN
}

View File

@@ -0,0 +1,130 @@
//
// LiveRoomChatItemView.swift
// SodaLive
//
// Created by klaus on 2023/08/14.
//
import SwiftUI
import Kingfisher
struct LiveRoomChatItemView: View {
let chatMessage: LiveRoomNormalChat
let onClickProfile: () -> Void
var body: some View {
HStack(alignment: .top, spacing: 13.3) {
ZStack {
switch chatMessage.rank + 1 {
case -2:
Color(hex: "4999e3")
.frame(width: 33.3, height: 33.3, alignment: .top)
.clipShape(Circle())
case -1:
Color(hex: "6f3dec")
.frame(width: 33.3, height: 33.3, alignment: .top)
.clipShape(Circle())
case 1:
Color(hex: "fdca2f")
.frame(width: 33.3, height: 33.3, alignment: .top)
.clipShape(Circle())
case 2:
Color(hex: "dcdcdc")
.frame(width: 33.3, height: 33.3, alignment: .top)
.clipShape(Circle())
case 3:
Color(hex: "c67e4a")
.frame(width: 33.3, height: 33.3, alignment: .top)
.clipShape(Circle())
default:
Color(hex: "bbbbbb")
.frame(width: 33.3, height: 33.3, alignment: .top)
.clipShape(Circle())
}
KFImage(URL(string: chatMessage.profileUrl))
.resizable()
.scaledToFill()
.frame(width: 30, height: 30, alignment: .top)
.clipShape(Circle())
VStack(alignment: .trailing, spacing: 0) {
Spacer()
switch chatMessage.rank + 1 {
case -2:
Image("ic_badge_manager")
.resizable()
.frame(width: 16.7, height: 16.7)
case -1:
Image("ic_crown")
.resizable()
.frame(width: 16.7, height: 16.7)
case 1:
Image("ic_crown_1")
.resizable()
.frame(width: 16.7, height: 16.7)
case 2:
Image("ic_crown_2")
.resizable()
.frame(width: 16.7, height: 16.7)
case 3:
Image("ic_crown_3")
.resizable()
.frame(width: 16.7, height: 16.7)
default:
EmptyView()
}
}
.frame(width: 33.3, height: 33.3, alignment: .trailing)
}
.onTapGesture { onClickProfile() }
VStack(alignment: .leading, spacing: 6.7) {
HStack(spacing: 5) {
if chatMessage.rank == -3 {
Text("스탭")
.font(.custom(Font.medium.rawValue, size: 10))
.foregroundColor(.white)
.padding(2)
.background(Color(hex: "4999e3"))
.cornerRadius(2)
}
Text(chatMessage.nickname)
.font(.custom(Font.light.rawValue, size: 12))
.foregroundColor(.white)
}
Text(chatMessage.chat)
.font(.custom(Font.medium.rawValue, size: 14))
.foregroundColor(.white)
.multilineTextAlignment(.leading)
.lineLimit(nil)
.lineSpacing(6)
.fixedSize(horizontal: false, vertical: true)
}
.padding(.horizontal, 8)
.padding(.vertical, 5.3)
.background(
UserDefaults.int(forKey: .userId) == chatMessage.userId ?
Color(hex: "9970ff").opacity(0.6) :
Color.black.opacity(0.6)
)
.cornerRadius(3.3)
}
.frame(width: screenSize().width - 86, alignment: .leading)
.padding(.leading, 20)
}
}

View File

@@ -0,0 +1,19 @@
//
// LiveRoomChatRawMessage.swift
// SodaLive
//
// Created by klaus on 2023/08/14.
//
import Foundation
struct LiveRoomChatRawMessage: Codable {
enum LiveRoomChatRawMessageType: String, Codable {
case DONATION, EDIT_ROOM_INFO, SET_MANAGER
}
let type: LiveRoomChatRawMessageType
let message: String
let can: Int
let donationMessage: String?
}

View File

@@ -0,0 +1,70 @@
//
// LiveRoomDonationChatItemView.swift
// SodaLive
//
// Created by klaus on 2023/08/14.
//
import SwiftUI
import Kingfisher
struct LiveRoomDonationChatItemView: View {
let chatMessage: LiveRoomDonationChat
var body: some View {
HStack(spacing: 13.3) {
ZStack(alignment: .bottomTrailing) {
KFImage(URL(string: chatMessage.profileUrl))
.resizable()
.scaledToFill()
.frame(width: 33.3, height: 33.3, alignment: .top)
.clipped()
.cornerRadius(23.3)
Image("ic_can")
}
VStack(alignment: .leading, spacing: 6.7) {
HStack(spacing: 0) {
Text(chatMessage.nickname)
.font(.custom(Font.medium.rawValue, size: 12))
.foregroundColor(.white)
Text("님이")
.font(.custom(Font.light.rawValue, size: 12))
.foregroundColor(.white)
}
HStack(spacing: 0) {
Text("\(chatMessage.can)")
.font(.custom(Font.medium.rawValue, size: 13))
.foregroundColor(Color(hex: "fdca2f"))
Text("을 후원하셨습니다.")
.font(.custom(Font.medium.rawValue, size: 13))
.foregroundColor(.white)
}
if !chatMessage.donationMessage.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
Text("\"\(chatMessage.donationMessage)\"")
.font(.custom(Font.medium.rawValue, size: 13))
.foregroundColor(.white)
}
}
}
.padding(13)
.frame(width: screenSize().width - 86, alignment: .leading)
.background(
chatMessage.can >= 100000 ? Color(hex: "c25264") :
chatMessage.can >= 50000 ? Color(hex: "d85e37").opacity(0.9) :
chatMessage.can >= 10000 ? Color(hex: "d38c38").opacity(0.9) :
chatMessage.can >= 5000 ? Color(hex: "59548f").opacity(0.9) :
chatMessage.can >= 1000 ? Color(hex: "4d6aa4").opacity(0.9) :
chatMessage.can >= 500 ? Color(hex: "2d7390").opacity(0.9) :
Color(hex: "548f7d").opacity(0.9)
)
.cornerRadius(10)
.padding(.leading, 20)
}
}

View File

@@ -0,0 +1,34 @@
//
// LiveRoomJoinChatItemView.swift
// SodaLive
//
// Created by klaus on 2023/08/14.
//
import SwiftUI
struct LiveRoomJoinChatItemView: View {
let chatMessage: LiveRoomJoinChat
var body: some View {
HStack(spacing: 0) {
Text("'")
.font(.custom(Font.medium.rawValue, size: 12))
.foregroundColor(Color(hex: "eeeeee"))
Text(chatMessage.nickname)
.font(.custom(Font.bold.rawValue, size: 12))
.foregroundColor(Color(hex: "ffdc00"))
Text("'님이 입장하셨습니다.")
.font(.custom(Font.medium.rawValue, size: 12))
.foregroundColor(Color(hex: "eeeeee"))
}
.padding(.vertical, 6.7)
.frame(width: screenSize().width - 86)
.background(Color(hex: "3d2a6c"))
.cornerRadius(4.7)
.padding(.leading, 20)
}
}