Skip to content

Commit

Permalink
[feat] 쪽지 작성 창 글자수 라벨 100자 초과시 붉은 색으로 변경 #164
Browse files Browse the repository at this point in the history
  • Loading branch information
skkimeo committed Apr 14, 2022
1 parent d735530 commit be65aa8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Happiggy-bank/Happiggy-bank/Utils/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ extension NewNoteTextViewModel {
static let textViewNote = "textViewNote"

/// 글자수 라벨 텍스트를 반환
static let letterCountText = " \\ \(NewNoteTextViewController.Metric.noteTextMaxLength)"
static let letterCountText = " / \(NewNoteTextViewController.Metric.noteTextMaxLength)"
}

/// NewNoteTextViewModel 에서 사용하는 폰트 크기
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ final class NewNoteTextViewController: UIViewController {
self.yearLabel.textColor = self.viewModel.labelColor
self.monthAndDayLabel.textColor = self.viewModel.labelColor
self.letterCountLabel.textColor = self.viewModel.labelColor
self.letterCountLabel.attributedText = self.viewModel.attributedLetterCountString(
count: self.textView.text.count
)
}

/// 새로운 노트 엔티티를 생성
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,13 @@ final class NewNoteTextViewModel {

/// 색깔 적용한 글자수 라벨 텍스트
func attributedLetterCountString(count: Int) -> NSMutableAttributedString {
let color = (count > NewNoteTextViewController.Metric.noteTextMaxLength) ?
UIColor.customWarningLabel : .noteHighlight(for: self.newNote.color)

let countString = "\(count)"
.nsMutableAttributedStringify()
.bold(fontSize: Font.letterCountLabel)
.color(color: .noteHighlight(for: self.newNote.color))
.color(color: color)

countString.append(StringLiteral.letterCountText.nsMutableAttributedStringify())

Expand Down

0 comments on commit be65aa8

Please sign in to comment.