/
sberpay
/
AgeGate-iOS
Обзор
Документация
Войти
/
sberpay
/
AgeGate-iOS
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
develop
AgeGateExample/Presentation/ConfigModule/Cells/TextViewCell.swift
77 строк
2 KB
SergeyGladkiy
[0.2.0] БДСЧ сценарий
30 июл 2026, 21:57
30 июл 2026, 21:57
cbcdfcb
Код
Авторство
О чём код?
// // TextViewCell.swift // AgeGateExample // // Created by Гладкий Сергей Игоревич on 24.07.2026. // import UIKit final class TextViewCell: UITableViewCell { private var valueChanged: ((String) -> Void)? private lazy var titleLabel: UILabel = { let view = UILabel() view.textColor = .secondaryLabel view.font = .systemFont(ofSize: 13, weight: .medium) return view }() private lazy var textField: UITextField = { let view = UITextField() view.font = .systemFont(ofSize: 15) view.borderStyle = .roundedRect view.clearButtonMode = .whileEditing view.autocorrectionType = .no view.autocapitalizationType = .none view.addTarget(self, action: #selector(textChanged), for: .editingChanged) return view }() private lazy var stackView: UIStackView = { let view = UIStackView(arrangedSubviews: [titleLabel, textField]) view.axis = .vertical view.spacing = 6 view.translatesAutoresizingMaskIntoConstraints = false return view }() override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) selectionStyle = .none setupUI() } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } func config(title: String, value: String?, placeholder: String? = nil, keyboard: UIKeyboardType = .default, valueChanged: @escaping (String) -> Void) { titleLabel.text = title textField.text = value textField.placeholder = placeholder textField.keyboardType = keyboard self.valueChanged = valueChanged } @objc private func textChanged() { valueChanged?(textField.text ?? "") } private func setupUI() { contentView.addSubview(stackView) NSLayoutConstraint.activate([ stackView.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 8), stackView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 16), stackView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -16), stackView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -8) ]) } }