Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions Wable-iOS/Presentation/Home/View/HomeDetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ extension HomeDetailViewController {

extension HomeDetailViewController: UITextViewDelegate {
func textViewDidEndEditing(_ textView: UITextView) {
placeholderLabel.isHidden = !textView.text.isEmpty
updatePlaceholderVisibility(textView)
}

func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
Expand All @@ -875,14 +875,13 @@ extension HomeDetailViewController: UITextViewDelegate {

let newText = oldText.replacingCharacters(in: stringRange, with: text)

placeholderLabel.isHidden = !newText.isEmpty

return newText.count <= 500
}

func textViewDidChange(_ textView: UITextView) {
placeholderLabel.isHidden = !textView.text.isEmpty
createCommentButton.isEnabled = !textView.text.isEmpty
updatePlaceholderVisibility(textView)

createCommentButton.isEnabled = !textView.text.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty

let size = CGSize(width: textView.frame.width, height: .infinity)
let estimatedSize = textView.sizeThatFits(size)
Expand All @@ -895,6 +894,13 @@ extension HomeDetailViewController: UITextViewDelegate {

textView.superview?.layoutIfNeeded()
}

private func updatePlaceholderVisibility(_ textView: UITextView) {
let hasText = !textView.text.isEmpty
let hasMarkedText = textView.markedTextRange != nil

placeholderLabel.isHidden = hasText || hasMarkedText
}
}

// MARK: - Constant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ extension CommentCollectionViewCell {
}

func configurePostStatus(info: CommentInfo) {
WableLogger.log("\(info.status)", for: .error)
switch info.status {
case .normal:
ghostCell(opacity: info.opacity.alpha)
Expand All @@ -286,8 +285,8 @@ extension CommentCollectionViewCell {
$0.top.equalTo(infoView.snp.bottom).offset(12)
$0.leading.equalTo(likeButton)
$0.trailing.equalToSuperview().inset(16)
$0.bottom.equalTo(ghostButton.snp.top).offset(-12)
$0.adjustedHeightEqualTo(50)
$0.bottom.lessThanOrEqualTo(ghostButton.snp.top).offset(-12)
$0.adjustedHeightEqualTo(50).priority(.high)
}

DispatchQueue.main.async {
Expand Down