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 { ...@@ -37,9 +37,29 @@ public final class MenuController: UIViewController {
public override func viewDidLoad() { public override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
screenView.headerView.set(
username: viewModel.username, let paragraphStyle = NSMutableParagraphStyle()
image: viewModel.avatar 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 { switch currentItem {
...@@ -88,7 +108,7 @@ public final class MenuController: UIViewController { ...@@ -88,7 +108,7 @@ public final class MenuController: UIViewController {
screenView screenView
.headerView .headerView
.nameButton .profileButton
.publisher(for: .touchUpInside) .publisher(for: .touchUpInside)
.receive(on: DispatchQueue.main) .receive(on: DispatchQueue.main)
.sink { [unowned self] in .sink { [unowned self] in
......
...@@ -3,52 +3,50 @@ import Shared ...@@ -3,52 +3,50 @@ import Shared
import AppResources import AppResources
final class MenuHeaderView: UIView { final class MenuHeaderView: UIView {
let nameButton = UIButton() let textLabel = UILabel()
let scanButton = UIButton() let scanButton = UIButton()
let stackView = UIStackView()
let avatarView = AvatarView() let avatarView = AvatarView()
let verticalStackView = UIStackView() let profileButton = UIControl()
init() { init() {
super.init(frame: .zero) super.init(frame: .zero)
let helloLabel = UILabel() textLabel.numberOfLines = 0
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.layer.cornerRadius = 14
scanButton.snp.makeConstraints { $0.width.height.equalTo(40) } avatarView.isUserInteractionEnabled = false
scanButton.setImage(Asset.menuScan.image, for: .normal)
scanButton.backgroundColor = Asset.neutralBody.color scanButton.backgroundColor = Asset.neutralBody.color
scanButton.setImage(Asset.menuScan.image, for: .normal)
stackView.spacing = 15 addSubview(scanButton)
stackView.addArrangedSubview(avatarView) addSubview(profileButton)
stackView.addArrangedSubview(verticalStackView) profileButton.addSubview(avatarView)
stackView.addArrangedSubview(scanButton.pinning(at: .top(0))) profileButton.addSubview(textLabel)
addSubview(stackView)
avatarView.snp.makeConstraints { $0.width.height.equalTo(70) } profileButton.snp.makeConstraints {
stackView.snp.makeConstraints { $0.edges.equalToSuperview() } $0.top.equalToSuperview()
$0.left.equalToSuperview()
$0.bottom.equalToSuperview()
$0.right.lessThanOrEqualTo(scanButton.snp.left)
}
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 } 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)
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment