Digital PCT265 story ONEAPP-6389 - Button group size updates, title lockup like views font updates, label font updates
This commit is contained in:
parent
9b831bfa35
commit
5c414a0e40
@ -9,17 +9,23 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import UIKit
|
import UIKit
|
||||||
import VDS
|
import VDS
|
||||||
|
import Combine
|
||||||
|
|
||||||
@objcMembers open class ButtonGroup: VDS.ButtonGroup, VDSMoleculeViewProtocol {
|
open class ButtonGroup: VDS.ButtonGroup, VDSMoleculeViewProtocol {
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
public var model: MoleculeModelProtocol?
|
||||||
open var viewModel: ButtonGroupModel!
|
open var viewModel: ButtonGroupModel!
|
||||||
open var delegateObject: MVMCoreUIDelegateObject?
|
open var delegateObject: MVMCoreUIDelegateObject?
|
||||||
open var additionalData: [AnyHashable : Any]?
|
open var additionalData: [AnyHashable : Any]?
|
||||||
open var previousModel: ButtonGroupModel?
|
open var previousModel: ButtonGroupModel?
|
||||||
|
|
||||||
|
/// For notifying the delegate of layout updates.
|
||||||
|
private var contentSizeObservation: Cancellable?
|
||||||
|
private var previousSize: CGSize?
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - MoleculeViewProtocol
|
// MARK: - MoleculeViewProtocol
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -74,6 +80,15 @@ import VDS
|
|||||||
// force redraw
|
// force redraw
|
||||||
setNeedsUpdate()
|
setNeedsUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Notify the delegate of a size change.
|
||||||
|
previousSize = bounds.size
|
||||||
|
contentSizeObservation = contentSizePublisher.sink { [weak self] size in
|
||||||
|
guard let self = self,
|
||||||
|
!MVMCoreGetterUtility.fequal(a: Float(size.height), b: Float(self.previousSize?.height ?? Self.estimatedHeight(with: self.viewModel, self.delegateObject) ?? VDS.Button.Size.large.height)) else { return }
|
||||||
|
self.previousSize = size
|
||||||
|
self.delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -31,7 +31,7 @@ open class HeaderView: Container {
|
|||||||
(molecule as? MVMCoreViewProtocol)?.updateView(size)
|
(molecule as? MVMCoreViewProtocol)?.updateView(size)
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func setupView() {
|
open override func setupView() {
|
||||||
super.setupView()
|
super.setupView()
|
||||||
line.setStyle(.none)
|
line.setStyle(.none)
|
||||||
addSubview(line)
|
addSubview(line)
|
||||||
|
|||||||
@ -7,9 +7,9 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
@objcMembers public class HeaderModel: ContainerModel {
|
open class HeaderModel: ContainerModel {
|
||||||
public var backgroundColor: Color?
|
open var backgroundColor: Color?
|
||||||
public var line: LineModel?
|
open var line: LineModel?
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
case line
|
case line
|
||||||
@ -17,7 +17,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Defaults to set
|
/// Defaults to set
|
||||||
public override func setDefaults() {
|
open override func setDefaults() {
|
||||||
if useHorizontalMargins == nil {
|
if useHorizontalMargins == nil {
|
||||||
useHorizontalMargins = true
|
useHorizontalMargins = true
|
||||||
}
|
}
|
||||||
@ -43,7 +43,7 @@
|
|||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func encode(to encoder: Encoder) throws {
|
open override func encode(to encoder: Encoder) throws {
|
||||||
try super.encode(to: encoder)
|
try super.encode(to: encoder)
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encode(line, forKey: .line)
|
try container.encode(line, forKey: .line)
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
public let stack = Stack<StackModel>(frame: .zero)
|
public let stack = Stack<StackModel>(frame: .zero)
|
||||||
public let eyebrow = Label(fontStyle: .RegularMicro)
|
public let eyebrow = Label(fontStyle: .RegularMicro)
|
||||||
public let headline = Label(fontStyle: .BoldBodySmall)
|
public let headline = Label(fontStyle: .RegularTitleSmall)
|
||||||
public let body = Label(fontStyle: .RegularBodySmall, true)
|
public let body = Label(fontStyle: .RegularBodySmall, true)
|
||||||
public let link = Link()
|
public let link = Link()
|
||||||
|
|
||||||
@ -58,7 +58,7 @@
|
|||||||
super.reset()
|
super.reset()
|
||||||
stack.reset()
|
stack.reset()
|
||||||
eyebrow.setFontStyle(.RegularMicro)
|
eyebrow.setFontStyle(.RegularMicro)
|
||||||
headline.setFontStyle(.BoldBodySmall)
|
headline.setFontStyle(.RegularTitleSmall)
|
||||||
body.setFontStyle(.RegularBodySmall)
|
body.setFontStyle(.RegularBodySmall)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -60,9 +60,9 @@ open class HeadlineBody: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func stylePageHeader() {
|
public func stylePageHeader() {
|
||||||
headlineLabel.setFontStyle(.RegularTitleLarge)
|
headlineLabel.setFontStyle(.RegularTitleXLarge)
|
||||||
messageLabel.setFontStyle(.RegularBodyLarge)
|
messageLabel.setFontStyle(.RegularTitleMedium)
|
||||||
spaceBetweenLabelsConstant = Padding.Two
|
spaceBetweenLabelsConstant = Padding.Four
|
||||||
}
|
}
|
||||||
|
|
||||||
public func styleListItem() {
|
public func styleListItem() {
|
||||||
@ -72,8 +72,8 @@ open class HeadlineBody: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func styleListItemDivider() {
|
public func styleListItemDivider() {
|
||||||
headlineLabel.setFontStyle(.BoldTitleSmall)
|
headlineLabel.setFontStyle(.BoldTitleLarge)
|
||||||
messageLabel.setFontStyle(.RegularBodySmall)
|
messageLabel.setFontStyle(.RegularBodyLarge)
|
||||||
spaceBetweenLabelsConstant = Padding.Two
|
spaceBetweenLabelsConstant = Padding.Two
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,9 @@ public protocol VDSMoleculeViewProtocol: MoleculeViewProtocol, MVMCoreViewProtoc
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension VDSMoleculeViewProtocol {
|
extension VDSMoleculeViewProtocol {
|
||||||
|
|
||||||
public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||||
|
self.model = model
|
||||||
guard let castedModel = model as? ViewModel else { return }
|
guard let castedModel = model as? ViewModel else { return }
|
||||||
self.delegateObject = delegateObject
|
self.delegateObject = delegateObject
|
||||||
self.additionalData = additionalData
|
self.additionalData = additionalData
|
||||||
|
|||||||
@ -198,7 +198,29 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
|
|||||||
|
|
||||||
open override func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) {
|
open override func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) {
|
||||||
guard let tableView = tableView else { return }
|
guard let tableView = tableView else { return }
|
||||||
|
let id = molecule.model?.id
|
||||||
|
|
||||||
|
// Check for header
|
||||||
|
var inHeaderOrFooter = false
|
||||||
|
if let _ = templateModel?.header?.findFirstMolecule(by: { compareModel in id == compareModel.id }) {
|
||||||
|
showHeader(nil)
|
||||||
|
inHeaderOrFooter = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for footer
|
||||||
|
if let _ = templateModel?.footer?.findFirstMolecule(by: { compareModel in id == compareModel.id }) {
|
||||||
|
showFooter(nil)
|
||||||
|
inHeaderOrFooter = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the view is in a header or footer, need to update the constraints.
|
||||||
|
if inHeaderOrFooter {
|
||||||
|
view.setNeedsUpdateConstraints()
|
||||||
|
view.updateConstraintsIfNeeded()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the view is in a cell, refresh the table ui.
|
||||||
let point = molecule.convert(molecule.bounds.origin, to: tableView)
|
let point = molecule.convert(molecule.bounds.origin, to: tableView)
|
||||||
if let indexPath = tableView.indexPathForRow(at: point), tableView.indexPathsForVisibleRows?.contains(indexPath) ?? false {
|
if let indexPath = tableView.indexPathForRow(at: point), tableView.indexPathsForVisibleRows?.contains(indexPath) ?? false {
|
||||||
refreshTable()
|
refreshTable()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user