Compare commits

...

13 Commits

Author SHA1 Message Date
Matt Bruce
5b4358e9e9 ensuring the range passed in is valid.
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
2024-03-20 15:23:34 -05:00
Pfeil, Scott Robert
b021e14030 Merge branch 'revert-51315abf' into 'release/11_4_0'
Revert "Merge branch 'bugfix/PRODDEF-24073' into 'release/11_4_0'"

### Summary
Revert another miss merge.

See merge request https://gitlab.verizon.com/BPHV_MIPS/mvm_core_ui/-/merge_requests/1076
2024-03-15 21:09:25 +00:00
Pfeil, Scott Robert
e1f248875e Revert "Merge branch 'bugfix/PRODDEF-24073' into 'release/11_4_0'"
This reverts merge request !1062
2024-03-15 21:08:11 +00:00
Pfeil, Scott Robert
51315abf49 Merge branch 'bugfix/PRODDEF-24073' into 'release/11_4_0'
Added customActions to checkBoxLabel

### Summary
CheckBoxLabel will be receiving the single focus with no clause. Implemented customActions for the label embedded with actions.

### JIRA Ticket
https://onejira.verizon.com/browse/PRODDEF-24073

Co-authored-by: Keerthy <keerthy.marakanti@verizon.com>
Co-authored-by: Matt Bruce <matt.bruce@verizon.com>

See merge request https://gitlab.verizon.com/BPHV_MIPS/mvm_core_ui/-/merge_requests/1062
2024-03-15 21:07:37 +00:00
Pfeil, Scott Robert
59ea9ca2bd Merge branch 'bugfix/CXTDT-531370' into 'release/11_4_0'
doing extra guards for actionMap and actionText range to ensure a valid...

### Summary
nil ActionMap being sent to the Label which caused a range issue. Guards were put in place to ensure this can't happen. 

### JIRA Ticket
https://onejira.verizon.com/browse/CXTDT-531370

Co-authored-by: Matt Bruce <matt.bruce@verizon.com>

See merge request https://gitlab.verizon.com/BPHV_MIPS/mvm_core_ui/-/merge_requests/1075
2024-03-15 20:49:57 +00:00
Matt Bruce
3219d9f351 doing extra guards for actionMap and actionText range to ensure a valid ActionLabelAttribute gets created.
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
2024-03-15 14:35:23 -05:00
Keerthy
6ab685d906 Merge branch 'develop' into bugfix/PRODDEF-24073 2024-03-15 22:43:39 +05:30
Pfeil, Scott Robert
37fadb9a29 Merge branch 'revert-8f166223' into 'release/11_4_0'
Revert "Merge branch 'feature/vds_header_mapping' into 'release/11_4_0'"

### Summary
Reverting mistaken merge

See merge request https://gitlab.verizon.com/BPHV_MIPS/mvm_core_ui/-/merge_requests/1072
2024-03-14 14:16:15 +00:00
Pfeil, Scott Robert
054a70d41b Revert "Merge branch 'feature/vds_header_mapping' into 'release/11_4_0'"
This reverts merge request !1071
2024-03-14 14:14:49 +00:00
Pfeil, Scott Robert
8f166223d0 Merge branch 'feature/vds_header_mapping' into 'release/11_4_0'
Sizing fixes and font updates

### Summary
Sizing fixes for templates when using button group and font updates.

### JIRA Ticket
https://onejira.verizon.com/browse/ONEAPP-6389

Co-authored-by: Scott Pfeil <Scott.Pfeil3@verizonwireless.com>

See merge request https://gitlab.verizon.com/BPHV_MIPS/mvm_core_ui/-/merge_requests/1071
2024-03-13 17:47:56 +00:00
Keerthy
d99a7ee546 Updated logic
Updated access to children instead of parent
2024-03-06 23:55:15 +05:30
Keerthy
5f15d630e1 Merge branch 'develop' into bugfix/PRODDEF-24073 2024-03-06 12:05:55 +05:30
Keerthy
1b10c21100 Added customActions to checkBoxLabel 2024-02-26 23:48:28 +05:30
24 changed files with 175 additions and 269 deletions

View File

@ -9,23 +9,17 @@
import Foundation
import UIKit
import VDS
import Combine
open class ButtonGroup: VDS.ButtonGroup, VDSMoleculeViewProtocol {
@objcMembers open class ButtonGroup: VDS.ButtonGroup, VDSMoleculeViewProtocol {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public var model: MoleculeModelProtocol?
open var viewModel: ButtonGroupModel!
open var delegateObject: MVMCoreUIDelegateObject?
open var additionalData: [AnyHashable : Any]?
open var previousModel: ButtonGroupModel?
/// For notifying the delegate of layout updates.
private var contentSizeObservation: Cancellable?
private var previousSize: CGSize?
//--------------------------------------------------
// MARK: - MoleculeViewProtocol
//--------------------------------------------------
@ -80,15 +74,6 @@ open class ButtonGroup: VDS.ButtonGroup, VDSMoleculeViewProtocol {
// force redraw
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)
}
}
//--------------------------------------------------

View File

@ -209,9 +209,6 @@ public typealias ActionBlock = () -> ()
if let newFont = UIFont(name: fontName, size: fontSize ?? standardFontSize) {
font = newFont
}
} else if let fontSize = viewModel.fontSize {
standardFontSize = fontSize
font = textStyle.font.withSize(fontSize)
}
if let color = viewModel.textColor {
@ -421,6 +418,8 @@ extension Label {
/// Underlines the tappable region and stores the tap logic for interation.
private func setTextLinkState(range: NSRange, actionBlock: @escaping ActionBlock) {
guard let text, text.isValid(range: range) else { return }
var textLink = ActionLabelAttribute(location: range.location, length: range.length)
textLink.subscriber = textLink
.action
@ -440,6 +439,8 @@ extension Label {
}
public func createActionBlockFor(actionMap: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) -> ActionBlock? {
guard let actionMap else { return nil }
return { [weak self] in
guard let self = self else { return }

View File

@ -21,10 +21,10 @@ extension Styler.Font {
case .TitleXLarge: actualFont = .RegularTitleXLarge
case .H1: actualFont = .RegularTitle2XLarge
case .H32: actualFont = .RegularTitleXLarge
case .H2: actualFont = .RegularTitleXLarge
case .H2: actualFont = .RegularTitleLarge
case .B20: actualFont = .RegularBodyLarge
case .H3: actualFont = .BoldTitleMedium
case .B1: actualFont = .RegularTitleSmall
case .B1: actualFont = .BoldBodySmall
case .B2: actualFont = .RegularBodySmall
case .B3: actualFont = .RegularMicro
default: break

View File

@ -8,14 +8,14 @@
import Foundation
open class HeadersH1Button: HeaderView {
@objcMembers open class HeadersH1Button: HeaderView {
//--------------------------------------------------
// MARK: - Outlets
//--------------------------------------------------
public let titleLockup = TitleLockup()
public let headlineBody = HeadlineBody()
public let buttons = TwoButtonView()
public lazy var stack: Stack<StackModel> = {
Stack<StackModel>.createStack(with: [titleLockup, buttons], spacing: Padding.Eighteen)
Stack<StackModel>.createStack(with: [headlineBody, buttons], spacing: Padding.Eighteen)
}()
//-------------------------------------------------------
@ -23,6 +23,7 @@ open class HeadersH1Button: HeaderView {
//-------------------------------------------------------
open override func setupView() {
super.setupView()
headlineBody.styleLandingPageHeader()
addMolecule(stack)
stack.restack()
}
@ -34,9 +35,14 @@ open class HeadersH1Button: HeaderView {
super.set(with: model, delegateObject, additionalData)
guard let model = model as? HeadersH1ButtonModel else { return }
titleLockup.set(with: model.titleLockup, delegateObject, additionalData)
headlineBody.set(with: model.headlineBody, delegateObject, additionalData)
buttons.set(with: model.buttons, delegateObject, additionalData)
}
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { 121 }
open override func reset() {
super.reset()
headlineBody.styleLandingPageHeader()
}
}

View File

@ -13,16 +13,15 @@ public class HeadersH1ButtonModel: HeaderModel, MoleculeModelProtocol, ParentMol
// MARK: - Properties
//--------------------------------------------------
public static var identifier: String = "headerH1Btn"
public var titleLockup: TitleLockupModel
public var headlineBody: HeadlineBodyModel
public var buttons: TwoButtonViewModel
private var helper = DeprecatedHeadlineBodyHelper()
public var children: [MoleculeModelProtocol] {
[titleLockup, buttons]
[headlineBody, buttons]
}
public func replaceChildMolecule(with molecule: MoleculeModelProtocol) throws -> Bool {
return try replaceChildMolecule(at: &titleLockup, with: molecule)
return try replaceChildMolecule(at: &headlineBody, with: molecule)
|| replaceChildMolecule(at: &buttons, with: molecule)
}
@ -30,8 +29,8 @@ public class HeadersH1ButtonModel: HeaderModel, MoleculeModelProtocol, ParentMol
// MARK: - Initializer
//--------------------------------------------------
public init(titleLockup: TitleLockupModel, buttons: TwoButtonViewModel) {
self.titleLockup = titleLockup
public init(headlineBody: HeadlineBodyModel, buttons: TwoButtonViewModel) {
self.headlineBody = headlineBody
self.buttons = buttons
super.init()
}
@ -41,13 +40,10 @@ public class HeadersH1ButtonModel: HeaderModel, MoleculeModelProtocol, ParentMol
//--------------------------------------------------
public override func setDefaults() {
if headlineBody.headline?.accessibilityTraits == nil {
headlineBody.headline?.accessibilityTraits = .header
}
super.setDefaults()
if titleLockup.title.fontStyle == nil {
titleLockup.title.fontStyle = Styler.Font.RegularTitle2XLarge
}
if titleLockup.subTitle?.fontStyle == nil {
titleLockup.subTitle?.fontStyle = Styler.Font.RegularTitleMedium
}
}
//--------------------------------------------------
@ -56,7 +52,7 @@ public class HeadersH1ButtonModel: HeaderModel, MoleculeModelProtocol, ParentMol
private enum CodingKeys: String, CodingKey {
case moleculeName
case titleLockup
case headlineBody
case buttons
}
@ -65,7 +61,7 @@ public class HeadersH1ButtonModel: HeaderModel, MoleculeModelProtocol, ParentMol
//--------------------------------------------------
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
titleLockup = try helper.deprecatedCreate(from: decoder) ?? typeContainer.decodeMolecule(codingKey: .titleLockup)
headlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .headlineBody)
buttons = try typeContainer.decode(TwoButtonViewModel.self, forKey: .buttons)
try super.init(from: decoder)
}
@ -74,8 +70,7 @@ public class HeadersH1ButtonModel: HeaderModel, MoleculeModelProtocol, ParentMol
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(moleculeName, forKey: .moleculeName)
try container.encode(headlineBody, forKey: .headlineBody)
try container.encode(buttons, forKey: .buttons)
guard try !helper.deprecatedEncode(to: encoder) else { return }
try container.encode(titleLockup, forKey: .titleLockup)
}
}

View File

@ -8,19 +8,20 @@
import Foundation
open class HeadersH1NoButtonsBodyText: HeaderView {
@objcMembers open class HeadersH1NoButtonsBodyText: HeaderView {
//--------------------------------------------------
// MARK: - Outlets
//--------------------------------------------------
public let titleLockup = TitleLockup()
public let headlineBody = HeadlineBody()
//-------------------------------------------------------
// MARK: - View Lifecycle
//-------------------------------------------------------
open override func setupView() {
super.setupView()
addMolecule(titleLockup)
headlineBody.styleLandingPageHeader()
addMolecule(headlineBody)
}
//----------------------------------------------------
@ -30,8 +31,13 @@ open class HeadersH1NoButtonsBodyText: HeaderView {
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
super.set(with: model, delegateObject, additionalData)
guard let model = model as? HeadersH1NoButtonsBodyTextModel else { return }
titleLockup.set(with: model.titleLockup, delegateObject, additionalData)
headlineBody.set(with: model.headlineBody, delegateObject, additionalData)
}
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { 121 }
open override func reset() {
super.reset()
headlineBody.styleLandingPageHeader()
}
}

View File

@ -6,48 +6,50 @@
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
public class HeadersH1NoButtonsBodyTextModel: HeaderModel, MoleculeModelProtocol, ParentMoleculeModelProtocol {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public static var identifier: String = "headerH1"
public var titleLockup: TitleLockupModel
private var helper = DeprecatedHeadlineBodyHelper()
public var headlineBody: HeadlineBodyModel
public var children: [MoleculeModelProtocol] {
[titleLockup]
[headlineBody]
}
public func replaceChildMolecule(with molecule: MoleculeModelProtocol) throws -> Bool {
return try replaceChildMolecule(at: &titleLockup, with: molecule)
}
public override func setDefaults() {
super.setDefaults()
if titleLockup.title.fontStyle == nil {
titleLockup.title.fontStyle = Styler.Font.RegularTitle2XLarge
}
if titleLockup.subTitle?.fontStyle == nil {
titleLockup.subTitle?.fontStyle = Styler.Font.RegularTitleMedium
}
return try replaceChildMolecule(at: &headlineBody, with: molecule)
}
//--------------------------------------------------
// MARK: - Initializer
//--------------------------------------------------
public init(titleLockup: TitleLockupModel) {
self.titleLockup = titleLockup
public init(headlineBody: HeadlineBodyModel) {
self.headlineBody = headlineBody
super.init()
}
//--------------------------------------------------
// MARK: - Subclass
//--------------------------------------------------
public override func setDefaults() {
if headlineBody.headline?.accessibilityTraits == nil {
headlineBody.headline?.accessibilityTraits = .header
}
super.setDefaults()
}
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
private enum CodingKeys: String, CodingKey {
case moleculeName
case titleLockup
case headlineBody
}
//--------------------------------------------------
@ -55,7 +57,7 @@ public class HeadersH1NoButtonsBodyTextModel: HeaderModel, MoleculeModelProtocol
//--------------------------------------------------
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
titleLockup = try helper.deprecatedCreate(from: decoder) ?? typeContainer.decodeMolecule(codingKey: .titleLockup)
headlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .headlineBody)
try super.init(from: decoder)
}
@ -63,55 +65,6 @@ public class HeadersH1NoButtonsBodyTextModel: HeaderModel, MoleculeModelProtocol
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(moleculeName, forKey: .moleculeName)
guard try !helper.deprecatedEncode(to: encoder) else { return }
try container.encode(titleLockup, forKey: .titleLockup)
}
}
public struct DeprecatedHeadlineBodyHelper {
var headlineBody: HeadlineBodyModel?
private enum DeprecatedCodingKeys: String, CodingKey {
case headlineBody
}
public mutating func deprecatedCreate(from decoder: Decoder) throws -> TitleLockupModel? {
let typeContainer = try decoder.container(keyedBy: DeprecatedCodingKeys.self)
headlineBody = try typeContainer.decodeIfPresent(HeadlineBodyModel.self, forKey: .headlineBody)
guard let headlineBody = headlineBody else { return nil }
return try createTitleLockupModel(headlineBody: headlineBody)
}
public func deprecatedEncode(to encoder: Encoder) throws -> Bool {
guard let headlineBody = headlineBody else { return false }
var container = encoder.container(keyedBy: DeprecatedCodingKeys.self)
try container.encode(headlineBody, forKey: DeprecatedCodingKeys.headlineBody)
return true
}
public func createTitleLockupModel(defaultStyle: HeadlineBodyModel.Style = .header, headlineBody: HeadlineBodyModel) throws -> TitleLockupModel {
guard let headline = headlineBody.headline else { throw ModelRegistry.Error.decoderOther(message: "headline is required for this use case.") }
var body = headlineBody.body
switch headlineBody.style ?? defaultStyle {
case .landingHeader:
headline.fontStyle = Styler.Font.RegularTitle2XLarge
body?.fontStyle = Styler.Font.RegularTitleMedium
case .itemHeader:
headline.fontStyle = Styler.Font.BoldTitleLarge
body?.fontStyle = Styler.Font.RegularBodyLarge
default:
headline.fontStyle = Styler.Font.RegularTitleXLarge
body?.fontStyle = Styler.Font.RegularTitleMedium
}
let model = try TitleLockupModel(title: headline, subTitle: body)
model.id = headlineBody.id
return model
}
public func createHeadlineBodyModel(titleLockup: TitleLockupModel) -> HeadlineBodyModel {
var headlineBody = HeadlineBodyModel(headline: titleLockup.title)
headlineBody.body = titleLockup.subTitle
headlineBody.id = titleLockup.id
return headlineBody
try container.encode(headlineBody, forKey: .headlineBody)
}
}

View File

@ -9,15 +9,15 @@
import Foundation
open class HeadersH2Buttons: HeaderView {
@objcMembers open class HeadersH2Buttons: HeaderView {
//--------------------------------------------------
// MARK: - Outlets
//--------------------------------------------------
public let titleLockup = TitleLockup()
public let headlineBody = HeadlineBody()
public let buttons = TwoButtonView()
public lazy var stack: Stack<StackModel> = {
return Stack<StackModel>.createStack(with: [titleLockup, buttons], spacing: PaddingDefaultVerticalSpacing3)
return Stack<StackModel>.createStack(with: [headlineBody, buttons], spacing: PaddingDefaultVerticalSpacing3)
}()
//-------------------------------------------------------
@ -26,6 +26,7 @@ open class HeadersH2Buttons: HeaderView {
open override func setupView() {
super.setupView()
headlineBody.stylePageHeader()
addMolecule(stack)
stack.restack()
}
@ -39,11 +40,16 @@ open class HeadersH2Buttons: HeaderView {
guard let model = model as? HeadersH2ButtonsModel else { return }
titleLockup.set(with: model.titleLockup, delegateObject, additionalData)
headlineBody.set(with: model.headlineBody, delegateObject, additionalData)
buttons.set(with: model.buttons, delegateObject, additionalData)
}
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return 121
}
open override func reset() {
super.reset()
headlineBody.stylePageHeader()
}
}

View File

@ -15,16 +15,15 @@ public class HeadersH2ButtonsModel: HeaderModel, MoleculeModelProtocol, ParentMo
//--------------------------------------------------
public static var identifier: String = "headerH2Btns"
public var titleLockup: TitleLockupModel
public var headlineBody: HeadlineBodyModel
public var buttons: TwoButtonViewModel
private var helper = DeprecatedHeadlineBodyHelper()
public var children: [MoleculeModelProtocol] {
[titleLockup, buttons]
[headlineBody, buttons]
}
public func replaceChildMolecule(with molecule: MoleculeModelProtocol) throws -> Bool {
return try replaceChildMolecule(at: &titleLockup, with: molecule)
return try replaceChildMolecule(at: &headlineBody, with: molecule)
|| replaceChildMolecule(at: &buttons, with: molecule)
}
@ -32,8 +31,8 @@ public class HeadersH2ButtonsModel: HeaderModel, MoleculeModelProtocol, ParentMo
// MARK: - Initializer
//--------------------------------------------------
public init(titleLockup: TitleLockupModel, buttons: TwoButtonViewModel) {
self.titleLockup = titleLockup
public init(headlineBody: HeadlineBodyModel, buttons: TwoButtonViewModel) {
self.headlineBody = headlineBody
self.buttons = buttons
super.init()
}
@ -49,11 +48,8 @@ public class HeadersH2ButtonsModel: HeaderModel, MoleculeModelProtocol, ParentMo
if bottomPadding == nil {
bottomPadding = Padding.Component.VerticalMarginSpacing
}
if titleLockup.title.fontStyle == nil {
titleLockup.title.fontStyle = Styler.Font.RegularTitleXLarge
}
if titleLockup.subTitle?.fontStyle == nil {
titleLockup.subTitle?.fontStyle = Styler.Font.RegularTitleMedium
if headlineBody.headline?.accessibilityTraits == nil {
headlineBody.headline?.accessibilityTraits = .header
}
super.setDefaults()
}
@ -64,7 +60,7 @@ public class HeadersH2ButtonsModel: HeaderModel, MoleculeModelProtocol, ParentMo
private enum CodingKeys: String, CodingKey {
case moleculeName
case titleLockup
case headlineBody
case buttons
}
@ -74,7 +70,7 @@ public class HeadersH2ButtonsModel: HeaderModel, MoleculeModelProtocol, ParentMo
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
titleLockup = try typeContainer.decodeMolecule(codingKey: .titleLockup)
headlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .headlineBody)
buttons = try typeContainer.decode(TwoButtonViewModel.self, forKey: .buttons)
try super.init(from: decoder)
}
@ -83,8 +79,7 @@ public class HeadersH2ButtonsModel: HeaderModel, MoleculeModelProtocol, ParentMo
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(moleculeName, forKey: .moleculeName)
try container.encode(headlineBody, forKey: .headlineBody)
try container.encode(buttons, forKey: .buttons)
guard try !helper.deprecatedEncode(to: encoder) else { return }
try container.encode(titleLockup, forKey: .titleLockup)
}
}

View File

@ -7,14 +7,14 @@
//
import Foundation
open class HeadersH2CaretLink: HeaderView {
@objcMembers open class HeadersH2CaretLink: HeaderView {
//--------------------------------------------------
// MARK: - Outlets
//--------------------------------------------------
public let titleLockup = TitleLockup()
public let headlineBody = HeadlineBody()
public let caretLink = CaretLink()
public lazy var stack: Stack<StackModel> = {
return Stack<StackModel>.createStack(with: [titleLockup, caretLink])
return Stack<StackModel>.createStack(with: [headlineBody, caretLink])
}()
//-------------------------------------------------------
@ -22,6 +22,7 @@ open class HeadersH2CaretLink: HeaderView {
//-------------------------------------------------------
open override func setupView() {
super.setupView()
headlineBody.stylePageHeader()
addMolecule(stack)
stack.restack()
}
@ -32,11 +33,16 @@ open class HeadersH2CaretLink: HeaderView {
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
super.set(with: model, delegateObject, additionalData)
guard let model = model as? HeadersH2CaretLinkModel else { return }
titleLockup.set(with: model.titleLockup, delegateObject, additionalData)
headlineBody.set(with: model.headlineBody, delegateObject, additionalData)
caretLink.set(with: model.caretLink, delegateObject, additionalData)
}
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return 121
}
open override func reset() {
super.reset()
headlineBody.stylePageHeader()
}
}

View File

@ -12,24 +12,23 @@ public class HeadersH2CaretLinkModel: HeaderModel, MoleculeModelProtocol, Parent
// MARK: - Properties
//--------------------------------------------------
public static var identifier: String = "headerH2CrtBtn"
public var titleLockup: TitleLockupModel
public var headlineBody: HeadlineBodyModel
public var caretLink: CaretLinkModel
private var helper = DeprecatedHeadlineBodyHelper()
public var children: [MoleculeModelProtocol] {
[titleLockup, caretLink]
[headlineBody, caretLink]
}
public func replaceChildMolecule(with molecule: MoleculeModelProtocol) throws -> Bool {
return try replaceChildMolecule(at: &titleLockup, with: molecule)
return try replaceChildMolecule(at: &headlineBody, with: molecule)
|| replaceChildMolecule(at: &caretLink, with: molecule)
}
//--------------------------------------------------
// MARK: - Initializer
//--------------------------------------------------
public init(titleLockup: TitleLockupModel, caretLink: CaretLinkModel) {
self.titleLockup = titleLockup
public init(headlineBody: HeadlineBodyModel, caretLink: CaretLinkModel) {
self.headlineBody = headlineBody
self.caretLink = caretLink
super.init()
}
@ -44,11 +43,8 @@ public class HeadersH2CaretLinkModel: HeaderModel, MoleculeModelProtocol, Parent
if bottomPadding == nil {
bottomPadding = Padding.Component.VerticalMarginSpacing
}
if titleLockup.title.fontStyle == nil {
titleLockup.title.fontStyle = Styler.Font.RegularTitleXLarge
}
if titleLockup.subTitle?.fontStyle == nil {
titleLockup.subTitle?.fontStyle = Styler.Font.RegularTitleMedium
if headlineBody.headline?.accessibilityTraits == nil {
headlineBody.headline?.accessibilityTraits = .header
}
super.setDefaults()
}
@ -58,7 +54,7 @@ public class HeadersH2CaretLinkModel: HeaderModel, MoleculeModelProtocol, Parent
//--------------------------------------------------
private enum CodingKeys: String, CodingKey {
case moleculeName
case titleLockup
case headlineBody
case caretLink
}
@ -67,7 +63,7 @@ public class HeadersH2CaretLinkModel: HeaderModel, MoleculeModelProtocol, Parent
//--------------------------------------------------
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
titleLockup = try typeContainer.decodeMolecule(codingKey: .titleLockup)
headlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .headlineBody)
caretLink = try typeContainer.decode(CaretLinkModel.self, forKey: .caretLink)
try super.init(from: decoder)
}
@ -76,8 +72,7 @@ public class HeadersH2CaretLinkModel: HeaderModel, MoleculeModelProtocol, Parent
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(moleculeName, forKey: .moleculeName)
try container.encode(headlineBody, forKey: .headlineBody)
try container.encode(caretLink, forKey: .caretLink)
guard try !helper.deprecatedEncode(to: encoder) else { return }
try container.encode(titleLockup, forKey: .titleLockup)
}
}

View File

@ -8,14 +8,14 @@
import Foundation
open class HeadersH2Link: HeaderView {
@objcMembers open class HeadersH2Link: HeaderView {
//--------------------------------------------------
// MARK: - Outlets
//--------------------------------------------------
public let titleLockup = TitleLockup()
public let headlineBody = HeadlineBody()
public let link = Link()
public lazy var stack: Stack<StackModel> = {
return Stack<StackModel>.createStack(with: [titleLockup, link])
return Stack<StackModel>.createStack(with: [headlineBody, link])
}()
//-------------------------------------------------------
@ -23,6 +23,7 @@ open class HeadersH2Link: HeaderView {
//-------------------------------------------------------
open override func setupView() {
super.setupView()
headlineBody.stylePageHeader()
addMolecule(stack)
stack.restack()
}
@ -33,11 +34,16 @@ open class HeadersH2Link: HeaderView {
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
super.set(with: model, delegateObject, additionalData)
guard let model = model as? HeadersH2LinkModel else { return }
titleLockup.set(with: model.titleLockup, delegateObject, additionalData)
headlineBody.set(with: model.headlineBody, delegateObject, additionalData)
link.set(with: model.link, delegateObject, additionalData)
}
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return 121
}
open override func reset() {
super.reset()
headlineBody.stylePageHeader()
}
}

View File

@ -14,16 +14,15 @@ public class HeadersH2LinkModel: HeaderModel, MoleculeModelProtocol, ParentMolec
//--------------------------------------------------
public static var identifier: String = "headerH2Link"
public var titleLockup: TitleLockupModel
public var headlineBody: HeadlineBodyModel
public var link: LinkModel
private var helper = DeprecatedHeadlineBodyHelper()
public var children: [MoleculeModelProtocol] {
[titleLockup, link]
[headlineBody, link]
}
public func replaceChildMolecule(with molecule: MoleculeModelProtocol) throws -> Bool {
return try replaceChildMolecule(at: &titleLockup, with: molecule)
return try replaceChildMolecule(at: &headlineBody, with: molecule)
|| replaceChildMolecule(at: &link, with: molecule)
}
@ -31,8 +30,8 @@ public class HeadersH2LinkModel: HeaderModel, MoleculeModelProtocol, ParentMolec
// MARK: - Initializer
//--------------------------------------------------
public init(titleLockup: TitleLockupModel, link: LinkModel) {
self.titleLockup = titleLockup
public init(headlineBody: HeadlineBodyModel, link: LinkModel) {
self.headlineBody = headlineBody
self.link = link
super.init()
}
@ -48,11 +47,8 @@ public class HeadersH2LinkModel: HeaderModel, MoleculeModelProtocol, ParentMolec
if bottomPadding == nil {
bottomPadding = Padding.Component.VerticalMarginSpacing
}
if titleLockup.title.fontStyle == nil {
titleLockup.title.fontStyle = Styler.Font.RegularTitleXLarge
}
if titleLockup.subTitle?.fontStyle == nil {
titleLockup.subTitle?.fontStyle = Styler.Font.RegularTitleMedium
if headlineBody.headline?.accessibilityTraits == nil {
headlineBody.headline?.accessibilityTraits = .header
}
super.setDefaults()
}
@ -63,7 +59,7 @@ public class HeadersH2LinkModel: HeaderModel, MoleculeModelProtocol, ParentMolec
private enum CodingKeys: String, CodingKey {
case moleculeName
case titleLockup
case headlineBody
case link
}
@ -73,7 +69,7 @@ public class HeadersH2LinkModel: HeaderModel, MoleculeModelProtocol, ParentMolec
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
titleLockup = try typeContainer.decodeMolecule(codingKey: .titleLockup)
headlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .headlineBody)
link = try typeContainer.decode(LinkModel.self, forKey: .link)
try super.init(from: decoder)
}
@ -82,8 +78,7 @@ public class HeadersH2LinkModel: HeaderModel, MoleculeModelProtocol, ParentMolec
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(moleculeName, forKey: .moleculeName)
try container.encode(headlineBody, forKey: .headlineBody)
try container.encode(link, forKey: .link)
guard try !helper.deprecatedEncode(to: encoder) else { return }
try container.encode(titleLockup, forKey: .titleLockup)
}
}

View File

@ -9,12 +9,12 @@
import Foundation
open class HeadersH2NoButtonsBodyText: HeaderView {
@objcMembers open class HeadersH2NoButtonsBodyText: HeaderView {
//--------------------------------------------------
// MARK: - Outlets
//--------------------------------------------------
public let titleLockup = TitleLockup()
public let headlineBody = HeadlineBody()
//-------------------------------------------------------
// MARK: - View Lifecycle
@ -22,7 +22,8 @@ open class HeadersH2NoButtonsBodyText: HeaderView {
open override func setupView() {
super.setupView()
addMolecule(titleLockup)
headlineBody.stylePageHeader()
addMolecule(headlineBody)
}
//----------------------------------------------------
@ -33,10 +34,15 @@ open class HeadersH2NoButtonsBodyText: HeaderView {
guard let model = model as? HeadersH2NoButtonsBodyTextModel else { return }
titleLockup.set(with: model.titleLockup, delegateObject, additionalData)
headlineBody.set(with: model.headlineBody, delegateObject, additionalData)
}
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return 121
}
open override func reset() {
super.reset()
headlineBody.stylePageHeader()
}
}

View File

@ -15,23 +15,22 @@ public class HeadersH2NoButtonsBodyTextModel: HeaderModel, MoleculeModelProtocol
//--------------------------------------------------
public static var identifier: String = "headerH2"
public var titleLockup: TitleLockupModel
private var helper = DeprecatedHeadlineBodyHelper()
public var headlineBody: HeadlineBodyModel
public var children: [MoleculeModelProtocol] {
[titleLockup]
[headlineBody]
}
public func replaceChildMolecule(with molecule: MoleculeModelProtocol) throws -> Bool {
return try replaceChildMolecule(at: &titleLockup, with: molecule)
return try replaceChildMolecule(at: &headlineBody, with: molecule)
}
//--------------------------------------------------
// MARK: - Initializer
//--------------------------------------------------
public init(titleLockup: TitleLockupModel) {
self.titleLockup = titleLockup
public init(headlineBody: HeadlineBodyModel) {
self.headlineBody = headlineBody
super.init()
}
@ -42,11 +41,8 @@ public class HeadersH2NoButtonsBodyTextModel: HeaderModel, MoleculeModelProtocol
if bottomPadding == nil {
bottomPadding = Padding.Component.VerticalMarginSpacing
}
if titleLockup.title.fontStyle == nil {
titleLockup.title.fontStyle = Styler.Font.RegularTitleXLarge
}
if titleLockup.subTitle?.fontStyle == nil {
titleLockup.subTitle?.fontStyle = Styler.Font.RegularTitleMedium
if headlineBody.headline?.accessibilityTraits == nil {
headlineBody.headline?.accessibilityTraits = .header
}
super.setDefaults()
}
@ -57,7 +53,7 @@ public class HeadersH2NoButtonsBodyTextModel: HeaderModel, MoleculeModelProtocol
private enum CodingKeys: String, CodingKey {
case moleculeName
case titleLockup
case headlineBody
}
//--------------------------------------------------
@ -66,7 +62,7 @@ public class HeadersH2NoButtonsBodyTextModel: HeaderModel, MoleculeModelProtocol
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
titleLockup = try helper.deprecatedCreate(from: decoder) ?? typeContainer.decodeMolecule(codingKey: .titleLockup)
headlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .headlineBody)
try super.init(from: decoder)
}
@ -74,7 +70,6 @@ public class HeadersH2NoButtonsBodyTextModel: HeaderModel, MoleculeModelProtocol
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(moleculeName, forKey: .moleculeName)
guard try !helper.deprecatedEncode(to: encoder) else { return }
try container.encode(titleLockup, forKey: .titleLockup)
try container.encode(headlineBody, forKey: .headlineBody)
}
}

View File

@ -9,15 +9,15 @@
import Foundation
open class HeadersH2TinyButton: HeaderView {
@objcMembers open class HeadersH2TinyButton: HeaderView {
//--------------------------------------------------
// MARK: - Outlets
//--------------------------------------------------
public let titleLockup = TitleLockup()
public let headlineBody = HeadlineBody()
public let button = PillButton()
public lazy var stack: Stack<StackModel> = {
return Stack<StackModel>.createStack(with: [(view: titleLockup, model: StackItemModel(horizontalAlignment: .fill)),
return Stack<StackModel>.createStack(with: [(view: headlineBody, model: StackItemModel(horizontalAlignment: .fill)),
(view: button, model: StackItemModel(spacing: spacingBetwenHeadlineBodyAndButton, horizontalAlignment: .leading))],
axis: .vertical)
}()
@ -34,6 +34,7 @@ open class HeadersH2TinyButton: HeaderView {
open override func setupView() {
super.setupView()
headlineBody.stylePageHeader()
addMolecule(stack)
stack.restack()
}
@ -47,11 +48,16 @@ open class HeadersH2TinyButton: HeaderView {
guard let model = model as? HeadersH2TinyButtonModel else { return }
titleLockup.set(with: model.titleLockup, delegateObject, additionalData)
headlineBody.set(with: model.headlineBody, delegateObject, additionalData)
button.set(with: model.button, delegateObject, additionalData)
}
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return 121
}
open override func reset() {
super.reset()
headlineBody.stylePageHeader()
}
}

View File

@ -15,16 +15,15 @@ public class HeadersH2TinyButtonModel: HeaderModel, MoleculeModelProtocol, Paren
//--------------------------------------------------
public static var identifier: String = "headerH2BtnTny"
public var titleLockup: TitleLockupModel
public var headlineBody: HeadlineBodyModel
public var button: ButtonModel
private var helper = DeprecatedHeadlineBodyHelper()
public var children: [MoleculeModelProtocol] {
[titleLockup, button]
[headlineBody, button]
}
public func replaceChildMolecule(with molecule: MoleculeModelProtocol) throws -> Bool {
return try replaceChildMolecule(at: &titleLockup, with: molecule)
return try replaceChildMolecule(at: &headlineBody, with: molecule)
|| replaceChildMolecule(at: &button, with: molecule)
}
@ -32,8 +31,8 @@ public class HeadersH2TinyButtonModel: HeaderModel, MoleculeModelProtocol, Paren
// MARK: - Initializer
//--------------------------------------------------
public init(titleLockup: TitleLockupModel, button: ButtonModel) {
self.titleLockup = titleLockup
public init(headlineBody: HeadlineBodyModel, button: ButtonModel) {
self.headlineBody = headlineBody
self.button = button
super.init()
}
@ -49,11 +48,8 @@ public class HeadersH2TinyButtonModel: HeaderModel, MoleculeModelProtocol, Paren
if bottomPadding == nil {
bottomPadding = Padding.Component.VerticalMarginSpacing
}
if titleLockup.title.fontStyle == nil {
titleLockup.title.fontStyle = Styler.Font.RegularTitleXLarge
}
if titleLockup.subTitle?.fontStyle == nil {
titleLockup.subTitle?.fontStyle = Styler.Font.RegularTitleMedium
if headlineBody.headline?.accessibilityTraits == nil {
headlineBody.headline?.accessibilityTraits = .header
}
super.setDefaults()
button.style = .secondary
@ -66,7 +62,7 @@ public class HeadersH2TinyButtonModel: HeaderModel, MoleculeModelProtocol, Paren
private enum CodingKeys: String, CodingKey {
case moleculeName
case titleLockup
case headlineBody
case button
}
@ -76,7 +72,7 @@ public class HeadersH2TinyButtonModel: HeaderModel, MoleculeModelProtocol, Paren
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
titleLockup = try typeContainer.decodeMolecule(codingKey: .titleLockup)
headlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .headlineBody)
button = try typeContainer.decode(ButtonModel.self, forKey: .button)
try super.init(from: decoder)
}
@ -85,8 +81,7 @@ public class HeadersH2TinyButtonModel: HeaderModel, MoleculeModelProtocol, Paren
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(moleculeName, forKey: .moleculeName)
try container.encode(headlineBody, forKey: .headlineBody)
try container.encode(button, forKey: .button)
guard try !helper.deprecatedEncode(to: encoder) else { return }
try container.encode(titleLockup, forKey: .titleLockup)
}
}

View File

@ -31,7 +31,7 @@ open class HeaderView: Container {
(molecule as? MVMCoreViewProtocol)?.updateView(size)
}
open override func setupView() {
public override func setupView() {
super.setupView()
line.setStyle(.none)
addSubview(line)

View File

@ -7,9 +7,9 @@
//
open class HeaderModel: ContainerModel {
open var backgroundColor: Color?
open var line: LineModel?
@objcMembers public class HeaderModel: ContainerModel {
public var backgroundColor: Color?
public var line: LineModel?
private enum CodingKeys: String, CodingKey {
case line
@ -17,7 +17,7 @@ open class HeaderModel: ContainerModel {
}
/// Defaults to set
open override func setDefaults() {
public override func setDefaults() {
if useHorizontalMargins == nil {
useHorizontalMargins = true
}
@ -43,7 +43,7 @@ open class HeaderModel: ContainerModel {
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
}
open override func encode(to encoder: Encoder) throws {
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(line, forKey: .line)

View File

@ -14,7 +14,7 @@
public let stack = Stack<StackModel>(frame: .zero)
public let eyebrow = Label(fontStyle: .RegularMicro)
public let headline = Label(fontStyle: .RegularTitleSmall)
public let headline = Label(fontStyle: .BoldBodySmall)
public let body = Label(fontStyle: .RegularBodySmall, true)
public let link = Link()
@ -58,7 +58,7 @@
super.reset()
stack.reset()
eyebrow.setFontStyle(.RegularMicro)
headline.setFontStyle(.RegularTitleSmall)
headline.setFontStyle(.BoldBodySmall)
body.setFontStyle(.RegularBodySmall)
}

View File

@ -60,9 +60,9 @@ open class HeadlineBody: View {
}
public func stylePageHeader() {
headlineLabel.setFontStyle(.RegularTitleXLarge)
messageLabel.setFontStyle(.RegularTitleMedium)
spaceBetweenLabelsConstant = Padding.Four
headlineLabel.setFontStyle(.RegularTitleLarge)
messageLabel.setFontStyle(.RegularBodyLarge)
spaceBetweenLabelsConstant = Padding.Two
}
public func styleListItem() {
@ -72,8 +72,8 @@ open class HeadlineBody: View {
}
public func styleListItemDivider() {
headlineLabel.setFontStyle(.BoldTitleLarge)
messageLabel.setFontStyle(.RegularBodyLarge)
headlineLabel.setFontStyle(.BoldTitleSmall)
messageLabel.setFontStyle(.RegularBodySmall)
spaceBetweenLabelsConstant = Padding.Two
}

View File

@ -6,8 +6,8 @@
// Copyright © 2019 Suresh, Kamlesh. All rights reserved.
//
import MVMCore
open class HeadlineBodyModel: ParentMoleculeModelProtocol {
@objcMembers open class HeadlineBodyModel: ParentMoleculeModelProtocol {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
@ -90,24 +90,3 @@ open class HeadlineBodyModel: ParentMoleculeModelProtocol {
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
}
}
public extension HeadlineBodyModel {
func createHeaderTitleLockupModel(defaultStyle: Style = .header) throws -> TitleLockupModel {
guard let headline = headline else { throw ModelRegistry.Error.decoderOther(message: "headline is required for this use case.") }
var body = self.body
switch style ?? defaultStyle {
case .landingHeader:
headline.fontStyle = Styler.Font.RegularTitle2XLarge
body?.fontStyle = Styler.Font.RegularTitleMedium
case .itemHeader:
headline.fontStyle = Styler.Font.BoldTitleLarge
body?.fontStyle = Styler.Font.RegularBodyLarge
default:
headline.fontStyle = Styler.Font.RegularTitleXLarge
body?.fontStyle = Styler.Font.RegularTitleMedium
}
let model = try TitleLockupModel(title: headline, subTitle: body)
model.id = id
return model
}
}

View File

@ -21,9 +21,7 @@ public protocol VDSMoleculeViewProtocol: MoleculeViewProtocol, MVMCoreViewProtoc
}
extension VDSMoleculeViewProtocol {
public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
self.model = model
guard let castedModel = model as? ViewModel else { return }
self.delegateObject = delegateObject
self.additionalData = additionalData

View File

@ -203,29 +203,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
open override func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) {
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)
if let indexPath = tableView.indexPathForRow(at: point), tableView.indexPathsForVisibleRows?.contains(indexPath) ?? false {
refreshTable()