diff options
author | Nicholas Tay <nick@windblume.net> | 2022-03-24 15:46:13 +1100 |
---|---|---|
committer | Nicholas Tay <nick@windblume.net> | 2022-03-24 15:46:13 +1100 |
commit | abb8f691fe6f276205d1cea655ee9938194d1e67 (patch) | |
tree | 752610821eb4862aad72b823efda7934793e0b1a /foray/ForayDetailViewController.swift | |
parent | dac7f928d2a1ed555aeedd97ec9433e266f47cf1 (diff) | |
download | forayios-abb8f691fe6f276205d1cea655ee9938194d1e67.tar.gz forayios-abb8f691fe6f276205d1cea655ee9938194d1e67.tar.bz2 forayios-abb8f691fe6f276205d1cea655ee9938194d1e67.zip |
Split details view into separate View and VC
Also fixed the scrollview margins while I was at it - it looked weird
being so inside
Diffstat (limited to '')
-rw-r--r-- | foray/ForayDetailViewController.swift | 78 |
1 files changed, 6 insertions, 72 deletions
diff --git a/foray/ForayDetailViewController.swift b/foray/ForayDetailViewController.swift index f87e4b0..c676df6 100644 --- a/foray/ForayDetailViewController.swift +++ b/foray/ForayDetailViewController.swift @@ -7,89 +7,23 @@ import UIKit -class ForayDetailViewController: UIViewController, ForayCoordinated { +class ForayDetailViewController: UIViewController, HasCustomView, ForayCoordinated { - var coordinator: ForayCoordinator? - - let scrollView: UIScrollView = { - let sv = UIScrollView() - sv.alwaysBounceVertical = true // just for fun - return sv - }() - let container = UIView() - - let nameLabel: UILabel = { - let l = UILabel() - l.font = UIFont.preferredFont(forTextStyle: .largeTitle) - l.adjustsFontForContentSizeCategory = true - l.numberOfLines = 3 - l.textAlignment = .center - return l - }() - - let itemImageView: UIImageView = { - let iv = UIImageView() - iv.contentMode = .scaleAspectFit - return iv - }() + typealias CustomView = ForayDetailView - let descLabel: UILabel = { - let l = UILabel() - l.font = UIFont.preferredFont(forTextStyle: .body) - l.adjustsFontForContentSizeCategory = true - l.numberOfLines = 10 - return l - }() + var coordinator: ForayCoordinator? override func viewDidLoad() { super.viewDidLoad() - self.title = "Details" - self.view.backgroundColor = .systemBackground - - initialiseViews() - } - - private func initialiseViews() { - self.view.addSubview(scrollView) - scrollView.addSubview(container) - - container.addSubview(nameLabel) - container.addSubview(itemImageView) - container.addSubview(descLabel) - - setupConstraints() } - private func setupConstraints() { - scrollView.snp.makeConstraints { (make) in - make.edges.equalTo(self.view.snp.margins) - } - container.snp.makeConstraints { (make) in - make.edges.equalToSuperview() - make.width.equalTo(scrollView.snp.width) - } - - nameLabel.snp.makeConstraints { (make) in - make.top.equalToSuperview().inset(16) - make.leading.trailing.equalToSuperview().inset(8) - } - itemImageView.snp.makeConstraints { (make) in - make.top.equalTo(nameLabel.snp.bottom).offset(32) - make.leading.trailing.equalToSuperview() - make.height.equalTo(150) - } - descLabel.snp.makeConstraints { (make) in - make.top.equalTo(itemImageView.snp.bottom).offset(32) - make.leading.trailing.equalToSuperview() - make.bottom.equalTo(container.snp.bottom).inset(16) - } + override func loadView() { + view = ForayDetailView() } public func setDetails(name: String, description: String, image: UIImage) { - nameLabel.text = name - descLabel.text = description - itemImageView.image = image + self.customView.setDetails(name: name, description: description, image: image) } } |