라이브 상세 페이지 추가
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// DateWithWeekDaySymbol.swift
|
||||
// SodaLive
|
||||
//
|
||||
// Created by klaus on 2023/08/14.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
struct DateWithWeekDaySymbol {
|
||||
let date: String
|
||||
let dayOfMonth: String
|
||||
let weekDaySymbol: String
|
||||
}
|
@@ -0,0 +1,91 @@
|
||||
//
|
||||
// LiveReservationAllItemView.swift
|
||||
// SodaLive
|
||||
//
|
||||
// Created by klaus on 2023/08/14.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import Kingfisher
|
||||
|
||||
struct LiveReservationAllItemView: View {
|
||||
|
||||
let item: GetRoomListResponse
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 13.3) {
|
||||
HStack(spacing: 20) {
|
||||
ZStack(alignment: .topLeading) {
|
||||
KFImage(URL(string: item.coverImageUrl))
|
||||
.resizable()
|
||||
.scaledToFill()
|
||||
.frame(width: 80, height: 116.7, alignment: .top)
|
||||
.cornerRadius(4.7)
|
||||
.clipped()
|
||||
|
||||
if item.isAdult {
|
||||
Text("19")
|
||||
.font(.custom(Font.bold.rawValue, size: 11.3))
|
||||
.foregroundColor(Color.white)
|
||||
.padding(4)
|
||||
.background(Color(hex: "e53621"))
|
||||
.cornerRadius(20)
|
||||
.padding(.top, 3.3)
|
||||
.padding(.leading, 3.3)
|
||||
}
|
||||
}
|
||||
|
||||
HStack(alignment: .top, spacing: 0) {
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
Text(item.beginDateTime)
|
||||
.font(.custom(Font.medium.rawValue, size: 9.3))
|
||||
.foregroundColor(Color(hex: "ffd300"))
|
||||
|
||||
Text(item.managerNickname)
|
||||
.font(.custom(Font.medium.rawValue, size: 11.3))
|
||||
.foregroundColor(Color(hex: "bbbbbb"))
|
||||
.padding(.top, 10)
|
||||
|
||||
Text(item.title)
|
||||
.font(.custom(Font.medium.rawValue, size: 15.3))
|
||||
.foregroundColor(Color(hex: "e2e2e2"))
|
||||
.lineLimit(2)
|
||||
.padding(.top, 10)
|
||||
.padding(.trailing, 20)
|
||||
|
||||
Spacer()
|
||||
|
||||
if item.isReservation {
|
||||
Text("예약완료")
|
||||
.font(.custom(Font.medium.rawValue, size: 11.3))
|
||||
.foregroundColor(Color(hex: "d2d2d2"))
|
||||
.padding(.horizontal, 7)
|
||||
.padding(.vertical, 4)
|
||||
.background(Color(hex: "533d89"))
|
||||
.cornerRadius(10)
|
||||
} else {
|
||||
Text(item.price > 0 ? "\(item.price)캔" : "무료")
|
||||
.font(.custom(Font.medium.rawValue, size: 12))
|
||||
.foregroundColor(Color(hex: "e2e2e2").opacity(0.49))
|
||||
.padding(.bottom, 6.7)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
if item.isPrivateRoom {
|
||||
Image("ic_lock")
|
||||
.resizable()
|
||||
.frame(width: 20, height: 20)
|
||||
}
|
||||
}
|
||||
.padding(.vertical, 6.7)
|
||||
}
|
||||
|
||||
Rectangle()
|
||||
.foregroundColor(Color(hex: "909090").opacity(0.5))
|
||||
.frame(width: screenSize().width - 26.7, height: 1)
|
||||
}
|
||||
.frame(width: screenSize().width - 26.7, height: 130, alignment: .center)
|
||||
}
|
||||
}
|
@@ -0,0 +1,125 @@
|
||||
//
|
||||
// LiveReservationAllView.swift
|
||||
// SodaLive
|
||||
//
|
||||
// Created by klaus on 2023/08/14.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct LiveReservationAllView: View {
|
||||
|
||||
@ObservedObject var viewModel = LiveViewModel()
|
||||
@StateObject var liveAllViewModel = LiveAllViewModel()
|
||||
|
||||
let onClickReservation: (Int) -> Void
|
||||
let onClickStart: (Int) -> Void
|
||||
let onClickCancel: () -> Void
|
||||
let onTapCreateLive: () -> Void
|
||||
|
||||
var body: some View {
|
||||
BaseView(isLoading: $viewModel.isLoading) {
|
||||
GeometryReader { proxy in
|
||||
VStack(spacing: 0) {
|
||||
DetailNavigationBar(title: "라이브, 예약 캘린더")
|
||||
|
||||
WeekCalendarView { date in
|
||||
viewModel.selectedDateString = date
|
||||
}
|
||||
.padding(.top, 20)
|
||||
|
||||
if viewModel.liveReservationItems.count > 0 {
|
||||
ScrollView(.vertical, showsIndicators: false) {
|
||||
LazyVStack(spacing: 13.3) {
|
||||
ForEach(0..<viewModel.liveReservationItems.count, id: \.self) { index in
|
||||
let item = viewModel.liveReservationItems[index]
|
||||
|
||||
LiveReservationAllItemView(item: item)
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture {
|
||||
self.liveAllViewModel.selectedRoomId = item.roomId
|
||||
withAnimation {
|
||||
self.liveAllViewModel.isShowLiveDetail = true
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
if index == viewModel.liveNowItems.count - 1 {
|
||||
viewModel.getLiveReservationList()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.vertical, 16.7)
|
||||
} else {
|
||||
VStack(spacing: 0) {
|
||||
Image("ic_no_item")
|
||||
.resizable()
|
||||
.frame(width: 60, height: 60)
|
||||
|
||||
Text("지금 예약중인 라이브가 없습니다.\n직접 라이브를 만들어 보세요!")
|
||||
.font(.custom(Font.medium.rawValue, size: 10.7))
|
||||
.foregroundColor(Color(hex: "bbbbbb"))
|
||||
.multilineTextAlignment(.center)
|
||||
.padding(.top, 8)
|
||||
|
||||
HStack(spacing: 0) {
|
||||
Image("ic_plus_no_bg")
|
||||
.resizable()
|
||||
.frame(width: 33.3, height: 33.3, alignment: .center)
|
||||
|
||||
Text("라이브 만들기")
|
||||
.font(.custom(Font.bold.rawValue, size: 13.3))
|
||||
.foregroundColor(Color.white)
|
||||
}
|
||||
.frame(width: 200, height: 33.3, alignment: .center)
|
||||
.background(Color(hex: "9970ff"))
|
||||
.cornerRadius(4.7)
|
||||
.padding(.top, 10.7)
|
||||
.onTapGesture {
|
||||
AppState.shared.back()
|
||||
onTapCreateLive()
|
||||
}
|
||||
}
|
||||
.padding(.vertical, 16.7)
|
||||
.frame(width: screenSize().width - 26.7)
|
||||
.background(Color(hex: "2b2635"))
|
||||
.cornerRadius(4.7)
|
||||
.padding(.top, 28.3)
|
||||
}
|
||||
|
||||
if proxy.safeAreaInsets.bottom > 0 {
|
||||
Rectangle()
|
||||
.foregroundColor(Color.black.opacity(0))
|
||||
.frame(width: screenSize().width, height: 15.3)
|
||||
}
|
||||
}
|
||||
.edgesIgnoringSafeArea(.bottom)
|
||||
}
|
||||
|
||||
if liveAllViewModel.isShowLiveDetail {
|
||||
LiveDetailView(
|
||||
roomId: liveAllViewModel.selectedRoomId,
|
||||
onClickParticipant: {},
|
||||
onClickReservation: {
|
||||
onClickReservation(liveAllViewModel.selectedRoomId)
|
||||
},
|
||||
onClickStart: {
|
||||
onClickStart(liveAllViewModel.selectedRoomId)
|
||||
},
|
||||
onClickCancel: {
|
||||
viewModel.page = 1
|
||||
viewModel.isLast = false
|
||||
viewModel.getLiveReservationList()
|
||||
onClickCancel()
|
||||
},
|
||||
onClickClose: {
|
||||
withAnimation {
|
||||
liveAllViewModel.isShowLiveDetail = false
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
95
SodaLive/Sources/Live/Reservation/All/WeekCalendarView.swift
Normal file
95
SodaLive/Sources/Live/Reservation/All/WeekCalendarView.swift
Normal file
@@ -0,0 +1,95 @@
|
||||
//
|
||||
// WeekCalendarView.swift
|
||||
// SodaLive
|
||||
//
|
||||
// Created by klaus on 2023/08/14.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct WeekCalendarView: View {
|
||||
|
||||
@State private var selectedIndex = 0
|
||||
let action: (String) -> Void
|
||||
|
||||
@ViewBuilder
|
||||
func DateItemView(index: Int, dateWithWeekDaySymbol: DateWithWeekDaySymbol) -> some View {
|
||||
VStack(spacing: 6.7) {
|
||||
Text(dateWithWeekDaySymbol.weekDaySymbol)
|
||||
.font(.custom(Font.medium.rawValue, size: 11.3))
|
||||
.foregroundColor(
|
||||
self.selectedIndex == index ?
|
||||
.white :
|
||||
Color(hex: "e2e2e2")
|
||||
)
|
||||
|
||||
Text(dateWithWeekDaySymbol.dayOfMonth)
|
||||
.font(.custom(Font.bold.rawValue, size: 15.3))
|
||||
.foregroundColor(
|
||||
self.selectedIndex == index ?
|
||||
.white :
|
||||
Color(hex: "e2e2e2")
|
||||
)
|
||||
}
|
||||
.frame(width: 53.3)
|
||||
.frame(minHeight: 66.7)
|
||||
.background(index == selectedIndex ? Color(hex: "9970ff") : Color.clear)
|
||||
.cornerRadius(6.7)
|
||||
.onTapGesture {
|
||||
if self.selectedIndex != index {
|
||||
self.selectedIndex = index
|
||||
action(dateWithWeekDaySymbol.date)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 16.7) {
|
||||
ScrollView(.horizontal, showsIndicators: false) {
|
||||
HStack(spacing: 6.7) {
|
||||
ForEach(0..<7, id: \.self) { index in
|
||||
let dateWithWeekDaySymbol = getDateFromCurrent(afterDay: index)
|
||||
DateItemView(
|
||||
index: index,
|
||||
dateWithWeekDaySymbol: dateWithWeekDaySymbol
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
.scaledToFit()
|
||||
|
||||
Rectangle()
|
||||
.frame(height: 1)
|
||||
.foregroundColor(Color(hex: "909090").opacity(0.5))
|
||||
}
|
||||
.onAppear {
|
||||
self.selectedIndex = 0
|
||||
action(getDateFromCurrent(afterDay: 0).date)
|
||||
}
|
||||
}
|
||||
|
||||
private func getDateFromCurrent(afterDay: Int) -> DateWithWeekDaySymbol {
|
||||
var calendar = Calendar.current
|
||||
calendar.locale = Locale(identifier: String(Locale.preferredLanguages[0].prefix(2)))
|
||||
|
||||
let currentDate = Date()
|
||||
let futureDate = calendar.date(byAdding: .day, value: afterDay, to: currentDate)!
|
||||
|
||||
let dateFormatter = DateFormatter()
|
||||
dateFormatter.dateFormat = "yyyy-MM-dd"
|
||||
|
||||
let dayOfMonthFormatter = DateFormatter()
|
||||
dayOfMonthFormatter.dateFormat = "d"
|
||||
|
||||
let date = dateFormatter.string(from: futureDate)
|
||||
let dayOfMonth = dayOfMonthFormatter.string(from: futureDate)
|
||||
let day = calendar.component(.weekday, from: futureDate) - 1
|
||||
let weekDaySymbol = calendar.shortWeekdaySymbols[day]
|
||||
|
||||
return DateWithWeekDaySymbol(
|
||||
date: date,
|
||||
dayOfMonth: dayOfMonth,
|
||||
weekDaySymbol: weekDaySymbol
|
||||
)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user