diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index 52ade755..641d995c 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -11,12 +11,14 @@ import UIKit public typealias FacadeElements = (fill: UIColor?, text: UIColor?, border: UIColor?) -public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWatcherFieldProtocol, EnableableModelProtocol { +open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWatcherFieldProtocol, EnableableModelProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - - public static var identifier: String = "button" + //Making static property as class property so that subclasses can override getter function of the property + open class var identifier: String { + "button" + } public var backgroundColor: Color? public var accessibilityIdentifier: String? public var title: String @@ -247,7 +249,7 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupW } } - public func encode(to encoder: Encoder) throws { + open func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) try container.encode(title, forKey: .title) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/Item Dropdown/MultiItemDropdownEntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/Item Dropdown/MultiItemDropdownEntryField.swift index 2c509bb3..8bed3996 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/Item Dropdown/MultiItemDropdownEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/Item Dropdown/MultiItemDropdownEntryField.swift @@ -71,6 +71,10 @@ open class MultiItemDropdownEntryField: BaseItemPickerEntryField { } } + func pickerHasComponent(_ index: Int) -> Bool { + !pickerComponents.isEmpty && !pickerComponents[index].isEmpty + } + //-------------------------------------------------- // MARK: - TextField Observation //-------------------------------------------------- @@ -122,18 +126,14 @@ open class MultiItemDropdownEntryField: BaseItemPickerEntryField { @objc public func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { - guard !pickerComponents.isEmpty, - !pickerComponents[component].isEmpty - else { return nil } + guard pickerHasComponent(component) else { return nil } return pickerComponents[component][row] } @objc public func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { - guard !pickerComponents.isEmpty, - !pickerComponents[component].isEmpty - else { return } + guard pickerHasComponent(component) else { return } let oldText = text ?? "" dropdownModel?.selectedIndexes[component] = row diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/Item Dropdown/MultiItemDropdownEntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/Item Dropdown/MultiItemDropdownEntryFieldModel.swift index fbdde6f3..8799f6aa 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/Item Dropdown/MultiItemDropdownEntryFieldModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/Item Dropdown/MultiItemDropdownEntryFieldModel.swift @@ -18,7 +18,7 @@ import Foundation public var components: [[String]] = [[]] public var selectedIndexes: [Int: Int] = [:] - public var delimiters: [String]? + public var delimiters: [Int: String] = [:] //-------------------------------------------------- // MARK: - Validation @@ -31,12 +31,17 @@ import Foundation return selectedRowText } + //-------------------------------------------------- + // MARK: - Methods + //-------------------------------------------------- + + /// - parameter index: The index of the delimiter. + /// - returns: The delimiter for a given index. Defaults to whitespace for valid index if no delimiters is provided. If invalid index, empty string. public func delimiter(for index: Int) -> String { - - guard let delimiters = delimiters else { return " " } + guard index != components.count - 1 else { return "" } - return delimiters[index] + return delimiters[index, default: " "] } /// A string of the picker row concatenated by whitespace or delimiters if provided. @@ -64,6 +69,18 @@ import Foundation return indexArray } + public var delimiterArray: [String] { + + var array: [String] = [] + + for i in 0.. () } else if !MVMCoreGetterUtility.fequal(a: Float(standardFontSize), b: 0.0), let sizeObject = sizeObject ?? MFStyler.sizeObjectGeneric(forCurrentDevice: standardFontSize) { font = font.updateSize(sizeObject.getValueBased(onSize: size)) } + + // Provide the label additional size information to help calculate its intrinsic content. + preferredMaxLayoutWidth = Styler.maxAvailableLayoutWidth(size: size) } @objc public func setFont(_ font: UIFont, scale: Bool) { diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableRightCaretAlltextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableRightCaretAlltextAndLinks.swift index 3b6a5b76..3a342b6a 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableRightCaretAlltextAndLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableRightCaretAlltextAndLinks.swift @@ -22,7 +22,7 @@ public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { // Fill for left vertical alignment because bottom constraint was breaking with leading. CXTDT-145456 - stack = Stack.createStack(with: [(view: eyebrowHeadlineBodyLink, model: StackItemModel(horizontalAlignment: .leading, verticalAlignment: .fill)), (view: rightLabel, model: StackItemModel(horizontalAlignment:.fill, verticalAlignment: .leading))], axis: .horizontal) + stack = Stack.createStack(with: [(view: eyebrowHeadlineBodyLink, model: StackItemModel(horizontalAlignment: .leading, verticalAlignment: .fill)), (view: rightLabel, model: StackItemModel(horizontalAlignment: .trailing, verticalAlignment: .leading))], axis: .horizontal) super.init(style: style, reuseIdentifier: reuseIdentifier) } @@ -37,6 +37,8 @@ open override func setupView() { super.setupView() rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) + rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal) + rightLabel.numberOfLines = 1 addMolecule(stack) stack.restack() } diff --git a/MVMCoreUI/Styles/Padding.swift b/MVMCoreUI/Styles/Padding.swift index 0dd9ff6e..480896a0 100644 --- a/MVMCoreUI/Styles/Padding.swift +++ b/MVMCoreUI/Styles/Padding.swift @@ -6,8 +6,6 @@ // Copyright © 2020 Verizon Wireless. All rights reserved. // -import Foundation - /// Padding is a multiple based on the number 4. public struct Padding { @@ -30,19 +28,19 @@ public struct Padding { public static let VerticalMarginSpacing: CGFloat = 24 public static var horizontalPaddingForApplicationWidth: CGFloat { - return MFSizeObject(scalingStandardSize: HorizontalMarginSpacing)?.getValueBasedOnApplicationWidth() ?? HorizontalMarginSpacing + MFSizeObject(scalingStandardSize: HorizontalMarginSpacing)?.getValueBasedOnApplicationWidth() ?? HorizontalMarginSpacing } public static var verticalPaddingForApplicationWidth: CGFloat { - return MFSizeObject(scalingStandardSize: VerticalMarginSpacing)?.getValueBasedOnApplicationWidth() ?? VerticalMarginSpacing + MFSizeObject(scalingStandardSize: VerticalMarginSpacing)?.getValueBasedOnApplicationWidth() ?? VerticalMarginSpacing } public static func horizontalPaddingForSize(_ size: CGFloat) -> CGFloat { - return MFSizeObject(scalingStandardSize: HorizontalMarginSpacing)?.getValueBased(onSize: size) ?? HorizontalMarginSpacing + MFSizeObject(scalingStandardSize: HorizontalMarginSpacing)?.getValueBased(onSize: size) ?? HorizontalMarginSpacing } public static func verticalPaddingForSize(_ size: CGFloat) -> CGFloat { - return MFSizeObject(scalingStandardSize: VerticalMarginSpacing)?.getValueBased(onSize: size) ?? VerticalMarginSpacing + MFSizeObject(scalingStandardSize: VerticalMarginSpacing)?.getValueBased(onSize: size) ?? VerticalMarginSpacing } } } diff --git a/MVMCoreUI/Styles/Styler.swift b/MVMCoreUI/Styles/Styler.swift index c0dd6792..77402295 100644 --- a/MVMCoreUI/Styles/Styler.swift +++ b/MVMCoreUI/Styles/Styler.swift @@ -209,7 +209,14 @@ open class Styler { } open class func sizeFontGeneric(forCurrentDevice size: CGFloat) -> CGFloat { - return sizeObjectGeneric(forCurrentDevice: size)?.getValueBasedOnApplicationWidth() ?? size + sizeObjectGeneric(forCurrentDevice: size)?.getValueBasedOnApplicationWidth() ?? size + } + + /// Provide additional size information to help calculate its intrinsic height. + /// - Returns: The available spacing that can be used for intrinsic content width. + open class func maxAvailableLayoutWidth(size: CGFloat) -> CGFloat { + // The 2 is the product of both sides of padding. + size - (Padding.Component.horizontalPaddingForSize(size) * 2) } //--------------------------------------------------