parent
2268b0c1bc
commit
0a96509b35
|
@ -9,6 +9,7 @@ import Foundation
|
||||||
|
|
||||||
struct CreateCommunityPostRequest: Encodable {
|
struct CreateCommunityPostRequest: Encodable {
|
||||||
let content: String
|
let content: String
|
||||||
|
let price: Int
|
||||||
let isAdult: Bool
|
let isAdult: Bool
|
||||||
let isCommentAvailable: Bool
|
let isCommentAvailable: Bool
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ struct CreatorCommunityWriteView: View {
|
||||||
VStack(spacing: 0) {
|
VStack(spacing: 0) {
|
||||||
Text("이미지")
|
Text("이미지")
|
||||||
.font(.custom(Font.bold.rawValue, size: 16.7))
|
.font(.custom(Font.bold.rawValue, size: 16.7))
|
||||||
.foregroundColor(Color(hex: "eeeeee"))
|
.foregroundColor(Color.grayee)
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
|
||||||
ZStack {
|
ZStack {
|
||||||
|
@ -45,14 +45,14 @@ struct CreatorCommunityWriteView: View {
|
||||||
.scaledToFit()
|
.scaledToFit()
|
||||||
.padding(13.3)
|
.padding(13.3)
|
||||||
.frame(width: 107, height: 107)
|
.frame(width: 107, height: 107)
|
||||||
.background(Color(hex: "13181B"))
|
.background(Color.bg)
|
||||||
.cornerRadius(8)
|
.cornerRadius(8)
|
||||||
.clipped()
|
.clipped()
|
||||||
}
|
}
|
||||||
|
|
||||||
Image("ic_camera")
|
Image("ic_camera")
|
||||||
.padding(10)
|
.padding(10)
|
||||||
.background(Color(hex: "3BB9F1"))
|
.background(Color.button)
|
||||||
.cornerRadius(30)
|
.cornerRadius(30)
|
||||||
.offset(x: 50, y: 36)
|
.offset(x: 50, y: 36)
|
||||||
}
|
}
|
||||||
|
@ -63,28 +63,28 @@ struct CreatorCommunityWriteView: View {
|
||||||
HStack(alignment: .top, spacing: 0) {
|
HStack(alignment: .top, spacing: 0) {
|
||||||
Text("※ ")
|
Text("※ ")
|
||||||
.font(.custom(Font.medium.rawValue, size: 13.3))
|
.font(.custom(Font.medium.rawValue, size: 13.3))
|
||||||
.foregroundColor(Color(hex: "777777"))
|
.foregroundColor(Color.gray77)
|
||||||
|
|
||||||
Text("등록할 이미지가 없으면 이미지 없이 게시글만 등록 하셔도 됩니다.")
|
Text("등록할 이미지가 없으면 이미지 없이 게시글만 등록 하셔도 됩니다.")
|
||||||
.font(.custom(Font.medium.rawValue, size: 13.3))
|
.font(.custom(Font.medium.rawValue, size: 13.3))
|
||||||
.foregroundColor(Color(hex: "777777"))
|
.foregroundColor(Color.gray77)
|
||||||
}
|
}
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.frame(maxWidth: .infinity)
|
||||||
.padding(.top, 24)
|
.padding(.top, 24)
|
||||||
|
|
||||||
HStack(spacing: 0) {
|
HStack(spacing: 0) {
|
||||||
Text("내용")
|
Text("내용")
|
||||||
.font(.custom(Font.bold.rawValue, size: 16.7))
|
.font(.custom(Font.bold.rawValue, size: 16.7))
|
||||||
.foregroundColor(Color(hex: "eeeeee"))
|
.foregroundColor(Color.grayee)
|
||||||
|
|
||||||
Spacer()
|
Spacer()
|
||||||
|
|
||||||
Text("\(viewModel.content.count)자")
|
Text("\(viewModel.content.count)자")
|
||||||
.font(.custom(Font.medium.rawValue, size: 13.3))
|
.font(.custom(Font.medium.rawValue, size: 13.3))
|
||||||
.foregroundColor(Color(hex: "ff5c49")) +
|
.foregroundColor(Color.mainRed) +
|
||||||
Text(" / 최대 500자")
|
Text(" / 최대 500자")
|
||||||
.font(.custom(Font.medium.rawValue, size: 13.3))
|
.font(.custom(Font.medium.rawValue, size: 13.3))
|
||||||
.foregroundColor(Color(hex: "777777"))
|
.foregroundColor(Color.gray77)
|
||||||
}
|
}
|
||||||
.padding(.top, 26.7)
|
.padding(.top, 26.7)
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ struct CreatorCommunityWriteView: View {
|
||||||
VStack(spacing: 13.3) {
|
VStack(spacing: 13.3) {
|
||||||
Text("댓글 가능 여부")
|
Text("댓글 가능 여부")
|
||||||
.font(.custom(Font.bold.rawValue, size: 16.7))
|
.font(.custom(Font.bold.rawValue, size: 16.7))
|
||||||
.foregroundColor(Color(hex: "eeeeee"))
|
.foregroundColor(Color.grayee)
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
|
||||||
HStack(spacing: 13.3) {
|
HStack(spacing: 13.3) {
|
||||||
|
@ -126,33 +126,92 @@ struct CreatorCommunityWriteView: View {
|
||||||
}
|
}
|
||||||
.padding(.top, 26.7)
|
.padding(.top, 26.7)
|
||||||
|
|
||||||
VStack(spacing: 13.3) {
|
if UserDefaults.bool(forKey: .auth) {
|
||||||
Text("연령 제한")
|
VStack(spacing: 13.3) {
|
||||||
.font(.custom(Font.bold.rawValue, size: 16.7))
|
Text("연령 제한")
|
||||||
.foregroundColor(Color(hex: "eeeeee"))
|
.font(.custom(Font.bold.rawValue, size: 16.7))
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.foregroundColor(Color.grayee)
|
||||||
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
HStack(spacing: 13.3) {
|
|
||||||
SelectButtonView(
|
|
||||||
title: "전체 연령",
|
|
||||||
isChecked: !viewModel.isAdult
|
|
||||||
) {
|
|
||||||
if viewModel.isAdult {
|
|
||||||
viewModel.isAdult = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SelectButtonView(
|
HStack(spacing: 13.3) {
|
||||||
title: "19세 이상",
|
SelectButtonView(
|
||||||
isChecked: viewModel.isAdult
|
title: "전체 연령",
|
||||||
) {
|
isChecked: !viewModel.isAdult
|
||||||
if !viewModel.isAdult {
|
) {
|
||||||
viewModel.isAdult = true
|
if viewModel.isAdult {
|
||||||
|
viewModel.isAdult = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectButtonView(
|
||||||
|
title: "19세 이상",
|
||||||
|
isChecked: viewModel.isAdult
|
||||||
|
) {
|
||||||
|
if !viewModel.isAdult {
|
||||||
|
viewModel.isAdult = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.padding(.top, 26.7)
|
||||||
|
}
|
||||||
|
|
||||||
|
if let _ = viewModel.postImage {
|
||||||
|
VStack(spacing: 13.3) {
|
||||||
|
Text("가격 설정")
|
||||||
|
.font(.custom(Font.bold.rawValue, size: 16.7))
|
||||||
|
.foregroundColor(Color.grayee)
|
||||||
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
|
||||||
|
HStack(spacing: 13.3) {
|
||||||
|
SelectButtonView(
|
||||||
|
title: "무료",
|
||||||
|
isChecked: viewModel.isPriceFree
|
||||||
|
) {
|
||||||
|
if !viewModel.isPriceFree {
|
||||||
|
viewModel.isPriceFree = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectButtonView(
|
||||||
|
title: "유료",
|
||||||
|
isChecked: !viewModel.isPriceFree
|
||||||
|
) {
|
||||||
|
if viewModel.isPriceFree {
|
||||||
|
viewModel.isPriceFree = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !viewModel.isPriceFree {
|
||||||
|
HStack(spacing: 0) {
|
||||||
|
TextField("", text: $viewModel.priceString)
|
||||||
|
.autocapitalization(.none)
|
||||||
|
.disableAutocorrection(true)
|
||||||
|
.multilineTextAlignment(.center)
|
||||||
|
.font(.custom(Font.bold.rawValue, size: 13.3))
|
||||||
|
.foregroundColor(Color.button)
|
||||||
|
.accentColor(Color.button)
|
||||||
|
.keyboardType(.numberPad)
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
|
||||||
|
Text("캔")
|
||||||
|
.font(.custom(Font.medium.rawValue, size: 14.7))
|
||||||
|
.foregroundColor(Color.button)
|
||||||
|
}
|
||||||
|
.padding(.horizontal, 13.3)
|
||||||
|
.padding(.vertical, 16.7)
|
||||||
|
.frame(maxWidth: .infinity)
|
||||||
|
.overlay(
|
||||||
|
RoundedRectangle(cornerRadius: 6.7)
|
||||||
|
.stroke(Color.gray77, lineWidth: 1)
|
||||||
|
)
|
||||||
|
.background(Color.gray23)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.padding(.top, 26.7)
|
||||||
}
|
}
|
||||||
.padding(.top, 26.7)
|
|
||||||
}
|
}
|
||||||
.padding(13.3)
|
.padding(13.3)
|
||||||
|
|
||||||
|
@ -160,14 +219,14 @@ struct CreatorCommunityWriteView: View {
|
||||||
HStack(spacing: 13.3) {
|
HStack(spacing: 13.3) {
|
||||||
Text("닫기")
|
Text("닫기")
|
||||||
.font(.custom(Font.bold.rawValue, size: 18.3))
|
.font(.custom(Font.bold.rawValue, size: 18.3))
|
||||||
.foregroundColor(Color(hex: "3BB9F1"))
|
.foregroundColor(Color.button)
|
||||||
.frame(maxWidth: .infinity)
|
.frame(maxWidth: .infinity)
|
||||||
.frame(height: 50)
|
.frame(height: 50)
|
||||||
.background(Color(hex: "13181B"))
|
.background(Color.bg)
|
||||||
.cornerRadius(10)
|
.cornerRadius(10)
|
||||||
.overlay(
|
.overlay(
|
||||||
RoundedRectangle(cornerRadius: 8)
|
RoundedRectangle(cornerRadius: 8)
|
||||||
.stroke(Color(hex: "3BB9F1"), lineWidth: 1)
|
.stroke(Color.button, lineWidth: 1)
|
||||||
)
|
)
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
hideKeyboard()
|
hideKeyboard()
|
||||||
|
@ -179,7 +238,7 @@ struct CreatorCommunityWriteView: View {
|
||||||
.foregroundColor(Color.white)
|
.foregroundColor(Color.white)
|
||||||
.frame(maxWidth: .infinity)
|
.frame(maxWidth: .infinity)
|
||||||
.frame(height: 50)
|
.frame(height: 50)
|
||||||
.background(Color(hex: "3BB9F1"))
|
.background(Color.button)
|
||||||
.cornerRadius(10)
|
.cornerRadius(10)
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
hideKeyboard()
|
hideKeyboard()
|
||||||
|
@ -194,17 +253,17 @@ struct CreatorCommunityWriteView: View {
|
||||||
}
|
}
|
||||||
.padding(13.3)
|
.padding(13.3)
|
||||||
.frame(maxWidth: .infinity)
|
.frame(maxWidth: .infinity)
|
||||||
.background(Color(hex: "222222"))
|
.background(Color.gray22)
|
||||||
.cornerRadius(16.7, corners: [.topLeft, .topRight])
|
.cornerRadius(16.7, corners: [.topLeft, .topRight])
|
||||||
|
|
||||||
Rectangle()
|
Rectangle()
|
||||||
.foregroundColor(Color(hex: "222222"))
|
.foregroundColor(Color.gray22)
|
||||||
.frame(height: keyboardHandler.keyboardHeight)
|
.frame(height: keyboardHandler.keyboardHeight)
|
||||||
.frame(maxWidth: .infinity)
|
.frame(maxWidth: .infinity)
|
||||||
|
|
||||||
if proxy.safeAreaInsets.bottom > 0 {
|
if proxy.safeAreaInsets.bottom > 0 {
|
||||||
Rectangle()
|
Rectangle()
|
||||||
.foregroundColor(Color(hex: "222222"))
|
.foregroundColor(Color.gray22)
|
||||||
.frame(height: 15.3)
|
.frame(height: 15.3)
|
||||||
.frame(maxWidth: .infinity)
|
.frame(maxWidth: .infinity)
|
||||||
}
|
}
|
||||||
|
@ -232,7 +291,7 @@ struct CreatorCommunityWriteView: View {
|
||||||
.padding(.vertical, 13.3)
|
.padding(.vertical, 13.3)
|
||||||
.frame(width: screenSize().width - 66.7, alignment: .center)
|
.frame(width: screenSize().width - 66.7, alignment: .center)
|
||||||
.font(.custom(Font.medium.rawValue, size: 12))
|
.font(.custom(Font.medium.rawValue, size: 12))
|
||||||
.background(Color(hex: "9970ff"))
|
.background(Color.button)
|
||||||
.foregroundColor(Color.white)
|
.foregroundColor(Color.white)
|
||||||
.multilineTextAlignment(.center)
|
.multilineTextAlignment(.center)
|
||||||
.cornerRadius(20)
|
.cornerRadius(20)
|
||||||
|
|
|
@ -20,16 +20,38 @@ final class CreatorCommunityWriteViewModel: ObservableObject {
|
||||||
|
|
||||||
@Published var content = ""
|
@Published var content = ""
|
||||||
@Published var isAdult = false
|
@Published var isAdult = false
|
||||||
|
@Published var isPriceFree = true {
|
||||||
|
didSet {
|
||||||
|
if isPriceFree {
|
||||||
|
priceString = "0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@Published var isAvailableComment = true
|
@Published var isAvailableComment = true
|
||||||
@Published var postImage: UIImage? = nil
|
@Published var postImage: UIImage? = nil
|
||||||
|
|
||||||
|
@Published var priceString = "0" {
|
||||||
|
didSet {
|
||||||
|
if priceString.count > 5 {
|
||||||
|
priceString = String(priceString.prefix(5))
|
||||||
|
} else {
|
||||||
|
if let price = Int(priceString) {
|
||||||
|
self.price = price
|
||||||
|
} else {
|
||||||
|
self.price = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Published var price = 0
|
||||||
|
|
||||||
var placeholder = "내용을 입력하세요"
|
var placeholder = "내용을 입력하세요"
|
||||||
|
|
||||||
func createCommunityPost(onSuccess: @escaping () -> Void) {
|
func createCommunityPost(onSuccess: @escaping () -> Void) {
|
||||||
if !isLoading && validateData() {
|
if !isLoading && validateData() {
|
||||||
isLoading = true
|
isLoading = true
|
||||||
|
|
||||||
let request = CreateCommunityPostRequest(content: content, isAdult: isAdult, isCommentAvailable: isAvailableComment)
|
let request = CreateCommunityPostRequest(content: content, price: price, isAdult: isAdult, isCommentAvailable: isAvailableComment)
|
||||||
var multipartData = [MultipartFormData]()
|
var multipartData = [MultipartFormData]()
|
||||||
|
|
||||||
let encoder = JSONEncoder()
|
let encoder = JSONEncoder()
|
||||||
|
@ -103,6 +125,12 @@ final class CreatorCommunityWriteViewModel: ObservableObject {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !isPriceFree && price < 5 {
|
||||||
|
errorMessage = "최소금액은 5캔 입니다."
|
||||||
|
isShowPopup = true
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue