hero stuff.
This commit is contained in:
parent
6d52663b4f
commit
f067a20ba9
@ -56,6 +56,7 @@ import UIKit
|
|||||||
open override func layoutSubviews() {
|
open override func layoutSubviews() {
|
||||||
super.layoutSubviews()
|
super.layoutSubviews()
|
||||||
|
|
||||||
|
// Ensures accessory view aligns to the center y derived from the
|
||||||
if let center = heroAccessoryCenter {
|
if let center = heroAccessoryCenter {
|
||||||
accessoryView?.center.y = center.y
|
accessoryView?.center.y = center.y
|
||||||
}
|
}
|
||||||
@ -83,6 +84,11 @@ import UIKit
|
|||||||
bottomSeparatorView?.hide()
|
bottomSeparatorView?.hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func willDisplay() {
|
||||||
|
|
||||||
|
alignAccessoryToHero()
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Inits
|
// MARK: - Inits
|
||||||
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
||||||
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
||||||
@ -126,7 +132,7 @@ import UIKit
|
|||||||
/// NOTE: Should only be called when displayed or about to be displayed.
|
/// NOTE: Should only be called when displayed or about to be displayed.
|
||||||
public func alignAccessoryToHero() {
|
public func alignAccessoryToHero() {
|
||||||
|
|
||||||
// Layout call required to force draw in memory to get dinmensions of subviews.
|
// Layout call required to force draw in memory to get dimensions of subviews.
|
||||||
layoutIfNeeded()
|
layoutIfNeeded()
|
||||||
guard let heroLabel = findHeroLabel(views: contentView.subviews), let hero = heroLabel.hero else { return }
|
guard let heroLabel = findHeroLabel(views: contentView.subviews), let hero = heroLabel.hero else { return }
|
||||||
let rect = Label.boundingRect(forCharacterRange: NSRange(location: hero, length: 1), in: heroLabel)
|
let rect = Label.boundingRect(forCharacterRange: NSRange(location: hero, length: 1), in: heroLabel)
|
||||||
@ -240,7 +246,7 @@ import UIKit
|
|||||||
|
|
||||||
// MARK: - Arrow
|
// MARK: - Arrow
|
||||||
/// Adds the standard mvm style caret to the accessory view
|
/// Adds the standard mvm style caret to the accessory view
|
||||||
public func addCaretViewAccessory() {
|
@objc public func addCaretViewAccessory() {
|
||||||
guard accessoryView == nil else { return }
|
guard accessoryView == nil else { return }
|
||||||
let width: CGFloat = 6
|
let width: CGFloat = 6
|
||||||
let height: CGFloat = 10
|
let height: CGFloat = 10
|
||||||
|
|||||||
@ -24,9 +24,6 @@
|
|||||||
/// Resets to default state before set with json is called again.
|
/// Resets to default state before set with json is called again.
|
||||||
- (void)reset;
|
- (void)reset;
|
||||||
|
|
||||||
/// Currently designed for UITableViewCell. Aligns the accessory view with the center of a character in a line of text.
|
|
||||||
- (void)alignAccessoryToHero;
|
|
||||||
|
|
||||||
/// For the molecule list to load more efficiently.
|
/// For the molecule list to load more efficiently.
|
||||||
+ (CGFloat)estimatedHeightForRow:(nullable NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject;
|
+ (CGFloat)estimatedHeightForRow:(nullable NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject;
|
||||||
|
|
||||||
|
|||||||
@ -17,4 +17,7 @@
|
|||||||
/// Handle action
|
/// Handle action
|
||||||
- (void)didSelectCellAtIndex:(nonnull NSIndexPath *)indexPath delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData;
|
- (void)didSelectCellAtIndex:(nonnull NSIndexPath *)indexPath delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject additionalData:(nullable NSDictionary *)additionalData;
|
||||||
|
|
||||||
|
/// Currently designed for UITableViewCell. Aligns the accessory view with the center of a character in a line of text.
|
||||||
|
- (void)willDisplay;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@ -89,8 +89,8 @@ open class MoleculeListTemplate: ThreeLayerTableViewController {
|
|||||||
|
|
||||||
open override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
|
open override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
|
||||||
|
|
||||||
if cell.accessoryView != nil, let protocolCell = cell as? (MoleculeTableViewCell & MVMCoreUIMoleculeViewProtocol) {
|
if let protocolCell = cell as? MoleculeListCellProtocol {
|
||||||
protocolCell.alignAccessoryToHero()
|
protocolCell.willDisplay?()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user