feat(fantalk): 쓰기 입력 제한을 적용한다
This commit is contained in:
@@ -3551,6 +3551,7 @@ If you block this user, the following features will be restricted.
|
||||
)
|
||||
}
|
||||
static var writeAction: String { pick(ko: "응원남기기", en: "Send a fan letter", ja: "ファンレターを送る") }
|
||||
static var writePlaceholder: String { pick(ko: "응원 메시지를 입력해 주세요.", en: "Enter a message of support.", ja: "応援メッセージを入力してください。") }
|
||||
static var send: String { pick(ko: "보내기", en: "Send", ja: "送信") }
|
||||
static var exitModalTitle: String { pick(ko: "입력 종료", en: "Discard input", ja: "入力終了") }
|
||||
static var exitModalMessage: String { pick(ko: "입력을 종료할까요?\n지금 나가면 입력한 내용이 저장되지 않아요.", en: "Discard your input?\nIf you leave now, your input will not be saved.", ja: "入力を終了しますか?\n終了すると、入力内容は保存されません。") }
|
||||
|
||||
@@ -25,12 +25,27 @@ struct CreatorChannelFanTalkWriteView: View {
|
||||
VStack(spacing: 0) {
|
||||
navigationBar
|
||||
|
||||
TextEditor(text: $viewModel.content)
|
||||
TextEditor(text: Binding(
|
||||
get: { viewModel.content },
|
||||
set: { newValue in
|
||||
viewModel.content = String(newValue.prefix(viewModel.maxContentCount))
|
||||
}
|
||||
))
|
||||
.appFont(size: 16, weight: .regular)
|
||||
.foregroundColor(Color.white)
|
||||
.foregroundColor(viewModel.isContentOverLimit ? Color.red400 : Color.white)
|
||||
.accentColor(Color.soda400)
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(Color.black)
|
||||
.overlay(alignment: .topLeading) {
|
||||
if viewModel.content.isEmpty {
|
||||
Text(I18n.CreatorChannelFanTalk.writePlaceholder)
|
||||
.appFont(size: 16, weight: .regular)
|
||||
.foregroundColor(Color.gray500)
|
||||
.padding(.horizontal, SodaSpacing.s4)
|
||||
.padding(.vertical, SodaSpacing.s8)
|
||||
.allowsHitTesting(false)
|
||||
}
|
||||
}
|
||||
.focused($isFocused)
|
||||
.padding(.horizontal, SodaSpacing.s14)
|
||||
.padding(.top, SodaSpacing.s20)
|
||||
@@ -56,7 +71,6 @@ struct CreatorChannelFanTalkWriteView: View {
|
||||
Text(I18n.Common.cancel)
|
||||
.appFont(size: 16, weight: .regular)
|
||||
.foregroundColor(Color.white)
|
||||
.frame(width: 64, height: 56, alignment: .leading)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
|
||||
@@ -85,8 +99,8 @@ struct CreatorChannelFanTalkWriteView: View {
|
||||
|
||||
Text("\(viewModel.content.count)")
|
||||
.appFont(size: 16, weight: .medium)
|
||||
.foregroundColor(Color.white)
|
||||
Text("/\(viewModel.maxContentCount)자")
|
||||
.foregroundColor(viewModel.isContentOverLimit ? Color.red400 : Color.white)
|
||||
Text("/\(viewModel.maxContentCount)")
|
||||
.appFont(size: 16, weight: .medium)
|
||||
.foregroundColor(Color.gray500)
|
||||
}
|
||||
|
||||
@@ -29,7 +29,15 @@ final class CreatorChannelFanTalkWriteViewModel: ObservableObject {
|
||||
|
||||
let maxContentCount = 500
|
||||
|
||||
var isContentOverLimit: Bool {
|
||||
content.count > maxContentCount
|
||||
}
|
||||
|
||||
var canSend: Bool {
|
||||
hasContent && isContentOverLimit == false
|
||||
}
|
||||
|
||||
private var hasContent: Bool {
|
||||
content.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty == false
|
||||
}
|
||||
|
||||
@@ -40,7 +48,7 @@ final class CreatorChannelFanTalkWriteViewModel: ObservableObject {
|
||||
}
|
||||
|
||||
func handleCancel() -> Bool {
|
||||
guard canSend else { return true }
|
||||
guard hasContent else { return true }
|
||||
|
||||
shouldShowExitModal = true
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user