hero stuff.

This commit is contained in:
Kevin G Christiano 2019-10-18 08:47:14 -04:00
parent 6d52663b4f
commit f067a20ba9
4 changed files with 13 additions and 7 deletions

View File

@ -56,6 +56,7 @@ import UIKit
open override func layoutSubviews() {
super.layoutSubviews()
// Ensures accessory view aligns to the center y derived from the
if let center = heroAccessoryCenter {
accessoryView?.center.y = center.y
}
@ -83,6 +84,11 @@ import UIKit
bottomSeparatorView?.hide()
}
public func willDisplay() {
alignAccessoryToHero()
}
// MARK: - Inits
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
@ -126,7 +132,7 @@ import UIKit
/// NOTE: Should only be called when displayed or about to be displayed.
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()
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)
@ -240,7 +246,7 @@ import UIKit
// MARK: - Arrow
/// Adds the standard mvm style caret to the accessory view
public func addCaretViewAccessory() {
@objc public func addCaretViewAccessory() {
guard accessoryView == nil else { return }
let width: CGFloat = 6
let height: CGFloat = 10

View File

@ -24,9 +24,6 @@
/// Resets to default state before set with json is called again.
- (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.
+ (CGFloat)estimatedHeightForRow:(nullable NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject;

View File

@ -17,4 +17,7 @@
/// Handle action
- (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

View File

@ -89,8 +89,8 @@ open class MoleculeListTemplate: ThreeLayerTableViewController {
open override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if cell.accessoryView != nil, let protocolCell = cell as? (MoleculeTableViewCell & MVMCoreUIMoleculeViewProtocol) {
protocolCell.alignAccessoryToHero()
if let protocolCell = cell as? MoleculeListCellProtocol {
protocolCell.willDisplay?()
}
}