Skip to content
Snippets Groups Projects
Commit 75efb538 authored by Bruno Muniz's avatar Bruno Muniz :apple:
Browse files

Fixes size of tappable area for profile button on menu

parent 7d2cfa24
No related branches found
No related tags found
1 merge request!94Fixes size of tappable area for profile button on menu
......@@ -37,9 +37,29 @@ public final class MenuController: UIViewController {
public override func viewDidLoad() {
super.viewDidLoad()
screenView.headerView.set(
username: viewModel.username,
image: viewModel.avatar
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = 10
let attrString = NSMutableAttributedString(
string: "\(Localized.Menu.title)\n*\(viewModel.username)*",
attributes: [
.paragraphStyle: paragraphStyle,
.foregroundColor: Asset.neutralWeak.color,
.font: Fonts.Mulish.semiBold.font(size: 14.0) as UIFont
]
)
attrString.addAttributes(attributes: [
.foregroundColor: Asset.neutralLine.color,
.font: Fonts.Mulish.bold.font(size: 18.0) as UIFont
], betweenCharacters: "*")
screenView.headerView.textLabel.attributedText = attrString
screenView.headerView.avatarView.setupProfile(
title: viewModel.username,
image: viewModel.avatar,
size: .large
)
switch currentItem {
......@@ -88,7 +108,7 @@ public final class MenuController: UIViewController {
screenView
.headerView
.nameButton
.profileButton
.publisher(for: .touchUpInside)
.receive(on: DispatchQueue.main)
.sink { [unowned self] in
......
......@@ -3,52 +3,50 @@ import Shared
import AppResources
final class MenuHeaderView: UIView {
let nameButton = UIButton()
let scanButton = UIButton()
let stackView = UIStackView()
let avatarView = AvatarView()
let verticalStackView = UIStackView()
init() {
super.init(frame: .zero)
let helloLabel = UILabel()
helloLabel.text = Localized.Menu.title
helloLabel.textColor = Asset.neutralWeak.color
helloLabel.font = Fonts.Mulish.semiBold.font(size: 14.0)
nameButton.titleLabel?.font = Fonts.Mulish.bold.font(size: 18.0)
nameButton.setTitleColor(Asset.neutralLine.color, for: .normal)
let spacingView = UIView()
verticalStackView.axis = .vertical
verticalStackView.addArrangedSubview(spacingView)
verticalStackView.addArrangedSubview(helloLabel)
verticalStackView.addArrangedSubview(nameButton.pinning(at: .left(0)))
verticalStackView.setCustomSpacing(15, after: spacingView)
verticalStackView.setCustomSpacing(5, after: helloLabel)
scanButton.layer.cornerRadius = 14
scanButton.snp.makeConstraints { $0.width.height.equalTo(40) }
scanButton.setImage(Asset.menuScan.image, for: .normal)
scanButton.backgroundColor = Asset.neutralBody.color
stackView.spacing = 15
stackView.addArrangedSubview(avatarView)
stackView.addArrangedSubview(verticalStackView)
stackView.addArrangedSubview(scanButton.pinning(at: .top(0)))
addSubview(stackView)
avatarView.snp.makeConstraints { $0.width.height.equalTo(70) }
stackView.snp.makeConstraints { $0.edges.equalToSuperview() }
let textLabel = UILabel()
let scanButton = UIButton()
let avatarView = AvatarView()
let profileButton = UIControl()
init() {
super.init(frame: .zero)
textLabel.numberOfLines = 0
scanButton.layer.cornerRadius = 14
avatarView.isUserInteractionEnabled = false
scanButton.backgroundColor = Asset.neutralBody.color
scanButton.setImage(Asset.menuScan.image, for: .normal)
addSubview(scanButton)
addSubview(profileButton)
profileButton.addSubview(avatarView)
profileButton.addSubview(textLabel)
profileButton.snp.makeConstraints {
$0.top.equalToSuperview()
$0.left.equalToSuperview()
$0.bottom.equalToSuperview()
$0.right.lessThanOrEqualTo(scanButton.snp.left)
}
required init?(coder: NSCoder) { nil }
func set(username: String, image: Data? = nil) {
nameButton.setTitle(username, for: .normal)
avatarView.setupProfile(title: username, image: image, size: .large)
avatarView.snp.makeConstraints {
$0.top.equalToSuperview()
$0.left.equalToSuperview()
$0.width.equalTo(70)
$0.height.equalTo(70)
$0.bottom.equalToSuperview()
}
scanButton.snp.makeConstraints {
$0.top.equalToSuperview()
$0.right.equalToSuperview()
$0.width.equalTo(40)
$0.height.equalTo(40)
}
textLabel.snp.makeConstraints {
$0.centerY.equalTo(avatarView)
$0.left.equalTo(avatarView.snp.right).offset(20)
$0.right.equalToSuperview()
}
}
required init?(coder: NSCoder) { nil }
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment