Add TextField and TableView (#540)

tableView is green for now, cell's are coming next
This commit is contained in:
Nathan Mattes 2022-11-11 18:46:06 +01:00
parent 08302cf2fa
commit cc6ec42c5c
2 changed files with 34 additions and 0 deletions

View File

@ -16,6 +16,8 @@ class MastodonLoginView: UIView {
let titleLabel: UILabel
let subtitleLabel: UILabel
private let headerStackView: UIStackView
let searchTextField: UITextField
let tableView: UITableView
let navigationActionView: NavigationActionView
override init(frame: CGRect) {
@ -37,12 +39,27 @@ class MastodonLoginView: UIView {
headerStackView.spacing = 16
headerStackView.translatesAutoresizingMaskIntoConstraints = false
searchTextField = UITextField()
searchTextField.translatesAutoresizingMaskIntoConstraints = false
searchTextField.backgroundColor = Asset.Scene.Onboarding.textFieldBackground.color
searchTextField.layer.cornerRadius = 10 //TODO: Change mask for
searchTextField.placeholder = "Search for your server"
searchTextField.leftView = UIImageView(image: UIImage(systemName: "magnifyingglass"))
searchTextField.leftViewMode = .always
tableView = UITableView()
tableView.translatesAutoresizingMaskIntoConstraints = false
tableView.backgroundColor = .green
//TODO: @zeitchlag Cell
navigationActionView = NavigationActionView()
navigationActionView.translatesAutoresizingMaskIntoConstraints = false
super.init(frame: frame)
addSubview(headerStackView)
addSubview(searchTextField)
addSubview(tableView)
addSubview(navigationActionView)
backgroundColor = .systemBackground
@ -60,6 +77,16 @@ class MastodonLoginView: UIView {
headerStackView.leadingAnchor.constraint(equalTo: readableContentGuide.leadingAnchor),
headerStackView.trailingAnchor.constraint(equalTo: readableContentGuide.trailingAnchor),
searchTextField.topAnchor.constraint(equalTo: headerStackView.bottomAnchor, constant: 32),
searchTextField.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 16),
searchTextField.heightAnchor.constraint(equalToConstant: 55),
trailingAnchor.constraint(equalTo: searchTextField.trailingAnchor, constant: 16),
tableView.topAnchor.constraint(equalTo: searchTextField.bottomAnchor),
tableView.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 16),
trailingAnchor.constraint(equalTo: tableView.trailingAnchor, constant: 16),
tableView.bottomAnchor.constraint(equalTo: navigationActionView.topAnchor),
navigationActionView.leadingAnchor.constraint(equalTo: leadingAnchor),
navigationActionView.trailingAnchor.constraint(equalTo: trailingAnchor),
bottomAnchor.constraint(equalTo: navigationActionView.bottomAnchor),

View File

@ -36,6 +36,9 @@ class MastodonLoginViewController: UIViewController {
loginView.navigationActionView.nextButton.addTarget(self, action: #selector(MastodonLoginViewController.nextButtonPressed(_:)), for: .touchUpInside)
loginView.navigationActionView.backButton.addTarget(self, action: #selector(MastodonLoginViewController.backButtonPressed(_:)), for: .touchUpInside)
loginView.searchTextField.addTarget(self, action: #selector(MastodonLoginViewController.textfieldDidChange(_:)), for: .editingChanged)
//TODO: Set tableView.delegate and tableView.dataSource
view = loginView
}
@ -102,6 +105,10 @@ class MastodonLoginViewController: UIViewController {
// }
// .store(in: &disposeBag)
}
@objc func textfieldDidChange(_ textField: UITextField) {
print(textField.text ?? "---")
}
}
// MARK: - OnboardingViewControllerAppearance