-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Title stack #395
Title stack #395
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// | ||
// TitleHeaderFooterView.swift | ||
// | ||
// Made with β€οΈ by Novum | ||
// | ||
// Copyright Β© Telefonica. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
public class TitleHeaderFooterView: UITableViewHeaderFooterView { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the original component. It inherits from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know it's a breaking change but I think it should be.... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMHO I prefer the breaking change and fix in the project, should be no problem There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I rather prefer the breaking change too.This won't be to difficult to update. |
||
public typealias Style = TitleView.Style | ||
|
||
private lazy var titleView = TitleView() | ||
|
||
public var onLinkLabelTapped: (() -> Void)? { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the get first and more consise version :
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done! thx! |
||
get { | ||
titleView.onLinkLabelTapped | ||
} | ||
set { | ||
titleView.onLinkLabelTapped = newValue | ||
} | ||
} | ||
|
||
public var style: Style { | ||
set { | ||
titleView.style = newValue | ||
} | ||
get { | ||
titleView.style | ||
} | ||
} | ||
|
||
public var title: String? { | ||
get { | ||
titleView.title | ||
} | ||
set { | ||
titleView.title = newValue | ||
} | ||
} | ||
|
||
public var linkTitle: String? { | ||
get { | ||
titleView.linkTitle | ||
} | ||
set { | ||
titleView.linkTitle = newValue | ||
} | ||
} | ||
|
||
override public init(reuseIdentifier: String?) { | ||
super.init(reuseIdentifier: reuseIdentifier) | ||
|
||
commonInit() | ||
} | ||
|
||
public required init?(coder: NSCoder) { | ||
super.init(coder: coder) | ||
|
||
commonInit() | ||
} | ||
|
||
public init(style: Style, reuseIdentifier: String? = nil) { | ||
super.init(reuseIdentifier: reuseIdentifier) | ||
self.style = style | ||
|
||
commonInit() | ||
} | ||
} | ||
|
||
// MARK: - Accessibility | ||
|
||
public extension TitleHeaderFooterView { | ||
var titleAccessibilityTraits: UIAccessibilityTraits { | ||
get { | ||
titleView.accessibilityTraits | ||
} | ||
set { | ||
titleView.accessibilityTraits = newValue | ||
} | ||
} | ||
} | ||
|
||
// MARK: - Private methods | ||
|
||
private extension TitleHeaderFooterView { | ||
func commonInit() { | ||
contentView.addSubview(withDefaultConstraints: titleView) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ private enum ViewStyles { | |
static let minimumHeight: CGFloat = 40 | ||
} | ||
|
||
public class TitleView: UITableViewHeaderFooterView { | ||
public class TitleView: UIView { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what we need! |
||
public enum Style { | ||
case title1 | ||
case title2 | ||
|
@@ -82,8 +82,8 @@ public class TitleView: UITableViewHeaderFooterView { | |
} | ||
} | ||
|
||
override public init(reuseIdentifier: String?) { | ||
super.init(reuseIdentifier: reuseIdentifier) | ||
override public init(frame: CGRect) { | ||
super.init(frame: frame) | ||
|
||
commonInit() | ||
} | ||
|
@@ -93,13 +93,6 @@ public class TitleView: UITableViewHeaderFooterView { | |
|
||
commonInit() | ||
} | ||
|
||
public init(style: Style, reuseIdentifier: String? = nil) { | ||
super.init(reuseIdentifier: reuseIdentifier) | ||
self.style = style | ||
|
||
commonInit() | ||
} | ||
} | ||
|
||
// MARK: - Accessibility | ||
|
@@ -124,7 +117,7 @@ private extension TitleView { | |
} | ||
|
||
func updateStyle() { | ||
contentView.backgroundColor = .background | ||
backgroundColor = .background | ||
|
||
titleLabel.text = style.format(text: unformattedTitle) | ||
titleLabel.font = style.font | ||
|
@@ -139,6 +132,7 @@ private extension TitleView { | |
func layoutViews() { | ||
linkLabel.setContentHuggingPriority(.required, for: .horizontal) | ||
linkLabel.setContentCompressionResistancePriority(.required, for: .horizontal) | ||
linkLabel.isUserInteractionEnabled = true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the link didn't work!!!!!! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess that if it is working for them it is because they are using
directly on the |
||
linkLabel.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(linkLabelTapped))) | ||
|
||
let stackView = UIStackView(arrangedSubviews: [ | ||
|
@@ -149,9 +143,8 @@ private extension TitleView { | |
stackView.alignment = .firstBaseline | ||
|
||
preservesSuperviewLayoutMargins = false | ||
contentView.preservesSuperviewLayoutMargins = false | ||
contentView.addSubview(constrainedToLayoutMarginsGuideOf: stackView) | ||
contentView.directionalLayoutMargins = NSDirectionalEdgeInsets( | ||
addSubview(constrainedToLayoutMarginsGuideOf: stackView) | ||
directionalLayoutMargins = NSDirectionalEdgeInsets( | ||
top: ViewStyles.topMargin, | ||
leading: ViewStyles.horizontalMargin, | ||
bottom: ViewStyles.bottomMargin, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just to verify it's not broken