Files
comaps/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCTextReviewCell.swift
Konstantin Pastbin e3e4a1985a Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run:
  git remote add om-historic [om-historic.git repo url]
  git fetch --tags om-historic
  git replace squashed-history historic-commits
2025-05-08 21:10:51 +07:00

39 lines
1.1 KiB
Swift

@objc(MWMUGCTextReviewDelegate)
protocol UGCTextReviewDelegate: NSObjectProtocol {
func changeReviewText(_ text: String)
}
@objc(MWMUGCTextReviewCell)
final class UGCTextReviewCell: MWMTableViewCell, UITextViewDelegate {
private enum Consts {
static let kMaxNumberOfSymbols = 400
}
@IBOutlet private weak var textView: MWMTextView!
@IBOutlet private weak var countLabel: UILabel!
private weak var delegate: UGCTextReviewDelegate?
private var indexPath: NSIndexPath = NSIndexPath()
@objc func configWith(delegate: UGCTextReviewDelegate?) {
self.delegate = delegate
setCount(textView.text.characters.count)
}
private func setCount(_ count: Int) {
countLabel.text = "\(count)/\(Consts.kMaxNumberOfSymbols)"
}
// MARK: UITextViewDelegate
func textView(_ textView: UITextView, shouldChangeTextIn _: NSRange, replacementText _: String) -> Bool {
return textView.text.characters.count <= Consts.kMaxNumberOfSymbols
}
func textViewDidChange(_ textView: UITextView) {
setCount(textView.text.characters.count)
}
func textViewDidEndEditing(_ textView: UITextView) {
delegate?.changeReviewText(textView.text)
}
}