diff options
author | Nicholas Tay <nick@windblume.net> | 2022-07-18 00:07:21 +1000 |
---|---|---|
committer | Nicholas Tay <nick@windblume.net> | 2022-07-18 00:07:21 +1000 |
commit | 8b255702c674bf1bfeca96697711f6e4f088dfdb (patch) | |
tree | 98a3ee132dd02973ca1e5c02136b3fe539b22275 /foray/Scenes/ForayDetailView.swift | |
parent | bd7761216a065b0dd859cb19d709996739a240cd (diff) | |
download | forayios-8b255702c674bf1bfeca96697711f6e4f088dfdb.tar.gz forayios-8b255702c674bf1bfeca96697711f6e4f088dfdb.tar.bz2 forayios-8b255702c674bf1bfeca96697711f6e4f088dfdb.zip |
Try out 'share' aka UIActivityViewController
Diffstat (limited to '')
-rw-r--r-- | foray/Scenes/ForayDetailView.swift | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/foray/Scenes/ForayDetailView.swift b/foray/Scenes/ForayDetailView.swift index 5997016..cd70ffc 100644 --- a/foray/Scenes/ForayDetailView.swift +++ b/foray/Scenes/ForayDetailView.swift @@ -38,6 +38,21 @@ class ForayDetailView: UIView { l.numberOfLines = 10 return l }() + + private lazy var shareButton: UIButton = { + let b = UIButton() + b.addTarget(self, action: #selector(onShareButton), for: .touchUpInside) + b.setTitle("Share", for: .normal) + b.setTitleColor(UIColor.systemBlue, for: .normal) + b.backgroundColor = UIColor.clear + return b + }() + + enum ActionType { + case onShare + } + + var onAction: ((ActionType) -> Void)? override init(frame: CGRect) { super.init(frame: frame) @@ -56,6 +71,7 @@ class ForayDetailView: UIView { container.addSubview(nameLabel) container.addSubview(itemImageView) + container.addSubview(shareButton) container.addSubview(descLabel) setupConstraints() @@ -80,8 +96,14 @@ class ForayDetailView: UIView { make.leading.trailing.equalToSuperview() make.height.equalTo(150) } + shareButton.snp.makeConstraints { (make) in + make.top.equalTo(itemImageView.snp.bottom).offset(16) + make.width.equalTo(50) + make.height.equalTo(25) + make.centerX.equalToSuperview() + } descLabel.snp.makeConstraints { (make) in - make.top.equalTo(itemImageView.snp.bottom).offset(32) + make.top.equalTo(shareButton.snp.bottom).offset(32) make.leading.trailing.equalToSuperview() make.bottom.equalTo(container.snp.bottom).inset(16) } @@ -93,4 +115,9 @@ class ForayDetailView: UIView { itemImageView.image = image } + @objc + private func onShareButton() { + onAction?(.onShare) + } + } |