Merge branch 'feature/equatable' into 'develop'

added equatable to structs

See merge request BPHV_MIPS/vds_ios!295
This commit is contained in:
Bruce, Matt R 2024-08-26 14:04:28 +00:00
commit b0d48568a0
25 changed files with 154 additions and 27 deletions

View File

@ -8,8 +8,7 @@
import Foundation import Foundation
extension Breadcrumbs { extension Breadcrumbs {
public struct BreadcrumbItemModel { public struct BreadcrumbItemModel: Equatable {
///Text that goes in the breadcrumb item ///Text that goes in the breadcrumb item
public var text: String public var text: String
@ -24,5 +23,10 @@ extension Breadcrumbs {
self.selected = selected self.selected = selected
self.onClick = onClick self.onClick = onClick
} }
public static func == (lhs: Breadcrumbs.BreadcrumbItemModel, rhs: Breadcrumbs.BreadcrumbItemModel) -> Bool {
lhs.text == rhs.text
&& lhs.selected == rhs.selected
}
} }
} }

View File

@ -9,7 +9,7 @@ import Foundation
/// Custom data type for indicators prop /// Custom data type for indicators prop
extension CalendarBase { extension CalendarBase {
public struct CalendarIndicatorModel { public struct CalendarIndicatorModel: Equatable {
/// Text that shown to an indicator for legend /// Text that shown to an indicator for legend
public var label: String public var label: String

View File

@ -10,7 +10,7 @@ import UIKit
/// Custom data type for pagination prop for 'Carousel' component. /// Custom data type for pagination prop for 'Carousel' component.
extension Carousel { extension Carousel {
public struct CarouselPaginationModel { public struct CarouselPaginationModel: Equatable {
/// Pagination supports Button icon property 'kind'. /// Pagination supports Button icon property 'kind'.
public var kind: ButtonIcon.Kind public var kind: ButtonIcon.Kind

View File

@ -11,7 +11,7 @@ import Foundation
extension Carousel { extension Carousel {
/// Used only when slot content have different heights or widths. /// Used only when slot content have different heights or widths.
public struct CarouselSlotAlignmentModel { public struct CarouselSlotAlignmentModel: Equatable {
/// Used for vertical alignment of slot alignment. /// Used for vertical alignment of slot alignment.
public var vertical: Carousel.Vertical public var vertical: Carousel.Vertical

View File

@ -108,8 +108,8 @@ open class CheckboxGroup: SelectorGroupBase<CheckboxItem>, SelectorGroupMultiSel
} }
extension CheckboxGroup { extension CheckboxGroup {
public struct CheckboxItemModel : Surfaceable, Initable, Errorable { public struct CheckboxItemModel : Surfaceable, Initable, Errorable, Equatable {
/// Whether this object is enabled or not /// Whether this object is enabled or not
public var enabled: Bool public var enabled: Bool
/// Current Surface and this is used to pass down to child objects that implement Surfacable /// Current Surface and this is used to pass down to child objects that implement Surfacable
@ -146,6 +146,21 @@ extension CheckboxGroup {
public init() { public init() {
self.init(enabled: true) self.init(enabled: true)
} }
public static func == (lhs: CheckboxGroup.CheckboxItemModel, rhs: CheckboxGroup.CheckboxItemModel) -> Bool {
lhs.enabled == rhs.enabled
&& lhs.surface == rhs.surface
&& lhs.inputId == rhs.inputId
&& lhs.value == rhs.value
&& lhs.accessibileText == rhs.accessibileText
&& lhs.labelText == rhs.labelText
&& lhs.labelTextAttributes == rhs.labelTextAttributes
&& lhs.childText == rhs.childText
&& lhs.childTextAttributes == rhs.childTextAttributes
&& lhs.selected == rhs.selected
&& lhs.showError == rhs.showError
&& lhs.errorText == rhs.errorText
}
} }
} }

View File

@ -9,7 +9,7 @@ import Foundation
import UIKit import UIKit
extension DatePicker { extension DatePicker {
public struct CalendarModel { public struct CalendarModel: Equatable {
/// If set to true, the calendar will not have a border. /// If set to true, the calendar will not have a border.
public let hideContainerBorder: Bool public let hideContainerBorder: Bool

View File

@ -8,7 +8,7 @@
import Foundation import Foundation
extension DropdownSelect { extension DropdownSelect {
public struct DropdownOptionModel { public struct DropdownOptionModel: Equatable {
/// Text that goes as option to DropdownSelect /// Text that goes as option to DropdownSelect
public var text: String public var text: String

View File

@ -10,7 +10,7 @@ import Foundation
extension ButtonIcon { extension ButtonIcon {
//Model that represents the options available for the Badge Indicator //Model that represents the options available for the Badge Indicator
public struct BadgeIndicatorModel { public struct BadgeIndicatorModel: Equatable {
/// Enum used to describe the badge indicator direction of icon button determining the expand direction. /// Enum used to describe the badge indicator direction of icon button determining the expand direction.
public enum ExpandDirection: String, CaseIterable { public enum ExpandDirection: String, CaseIterable {
case right, center, left case right, center, left

View File

@ -24,7 +24,7 @@ extension Icon {
/// let icon = Icon() /// let icon = Icon()
/// icon.name = .foo /// icon.name = .foo
/// ``` /// ```
public struct Name: RawRepresentable { public struct Name: RawRepresentable, Equatable {
public typealias RawValue = String public typealias RawValue = String
public var rawValue: String public var rawValue: String

View File

@ -8,12 +8,16 @@
import Foundation import Foundation
extension Notification { extension Notification {
public struct ButtonModel { public struct ButtonModel: Equatable {
public var text: String public var text: String
public var onClick: (Button) -> () public var onClick: (Button) -> ()
public init(text: String, onClick: @escaping (Button) -> Void) { public init(text: String, onClick: @escaping (Button) -> Void) {
self.text = text self.text = text
self.onClick = onClick self.onClick = onClick
} }
public static func == (lhs: Notification.ButtonModel, rhs: Notification.ButtonModel) -> Bool {
lhs.text == rhs.text
}
} }
} }

View File

@ -113,7 +113,7 @@ open class RadioBoxGroup: SelectorGroupBase<RadioBoxItem>, SelectorGroupSingleSe
} }
extension RadioBoxGroup { extension RadioBoxGroup {
public struct RadioBoxItemModel: Surfaceable, Initable, FormFieldable { public struct RadioBoxItemModel: Surfaceable, Initable, FormFieldable, Equatable {
/// Whether this object is enabled or not /// Whether this object is enabled or not
public var enabled: Bool public var enabled: Bool
/// Current Surface and this is used to pass down to child objects that implement Surfacable /// Current Surface and this is used to pass down to child objects that implement Surfacable
@ -158,5 +158,22 @@ extension RadioBoxGroup {
public init() { public init() {
self.init(enabled: true) self.init(enabled: true)
} }
public static func == (lhs: RadioBoxGroup.RadioBoxItemModel, rhs: RadioBoxGroup.RadioBoxItemModel) -> Bool {
lhs.enabled == rhs.enabled
&& lhs.surface == rhs.surface
&& lhs.inputId == rhs.inputId
&& lhs.value == rhs.value
&& lhs.accessibileText == rhs.accessibileText
&& lhs.text == rhs.text
&& lhs.textAttributes == rhs.textAttributes
&& lhs.subText == rhs.subText
&& lhs.subTextAttributes == rhs.subTextAttributes
&& lhs.subTextRight == rhs.subTextRight
&& lhs.subTextRightAttributes == rhs.subTextRightAttributes
&& lhs.selected == rhs.selected
&& lhs.strikethrough == rhs.strikethrough
&& lhs.strikethroughAccessibileText == rhs.strikethroughAccessibileText
}
} }
} }

View File

@ -103,7 +103,7 @@ open class RadioButtonGroup: SelectorGroupBase<RadioButtonItem>, SelectorGroupSi
} }
extension RadioButtonGroup { extension RadioButtonGroup {
public struct RadioButtonItemModel: Surfaceable, Initable, FormFieldable, Errorable { public struct RadioButtonItemModel: Surfaceable, Initable, FormFieldable, Errorable, Equatable {
/// Whether this object is enabled or not /// Whether this object is enabled or not
public var enabled: Bool public var enabled: Bool
@ -141,5 +141,20 @@ extension RadioButtonGroup {
public init() { public init() {
self.init(enabled: true) self.init(enabled: true)
} }
public static func == (lhs: RadioButtonGroup.RadioButtonItemModel, rhs: RadioButtonGroup.RadioButtonItemModel) -> Bool {
lhs.enabled == rhs.enabled
&& lhs.surface == rhs.surface
&& lhs.inputId == rhs.inputId
&& lhs.value == rhs.value
&& lhs.accessibileText == rhs.accessibileText
&& lhs.labelText == rhs.labelText
&& lhs.labelTextAttributes == rhs.labelTextAttributes
&& lhs.childText == rhs.childText
&& lhs.childTextAttributes == rhs.childTextAttributes
&& lhs.selected == rhs.selected
&& lhs.showError == rhs.showError
&& lhs.errorText == rhs.errorText
}
} }
} }

View File

@ -10,7 +10,7 @@ import UIKit
import VDSCoreTokens import VDSCoreTokens
/// Model that represent the content of each cell of Table component /// Model that represent the content of each cell of Table component
public struct TableItemModel { public struct TableItemModel: Equatable {
public let defaultHeight: CGFloat = 50.0 public let defaultHeight: CGFloat = 50.0

View File

@ -7,7 +7,7 @@
import Foundation import Foundation
public struct TableRowModel { public struct TableRowModel: Equatable {
public var columns: [TableItemModel] public var columns: [TableItemModel]

View File

@ -8,7 +8,7 @@
import Foundation import Foundation
extension Tabs { extension Tabs {
public struct TabModel { public struct TabModel: Equatable {
///Text that goes in the Tab ///Text that goes in the Tab
public var text: String public var text: String
@ -24,5 +24,10 @@ extension Tabs {
self.onClick = onClick self.onClick = onClick
self.width = width self.width = width
} }
public static func == (lhs: Tabs.TabModel, rhs: Tabs.TabModel) -> Bool {
lhs.text == rhs.text
&& lhs.width == rhs.width
}
} }
} }

View File

@ -82,10 +82,25 @@ open class TileContainerBase<PaddingType: DefaultValuing & Valuing>: View where
} }
/// Enum used to describe the background effect choices used for this component. /// Enum used to describe the background effect choices used for this component.
public enum BackgroundEffect { public enum BackgroundEffect: Equatable {
case transparency case transparency
case gradient(UIColor, UIColor) case gradient(UIColor, UIColor)
case none case none
public static func == (lhs: TileContainerBase.BackgroundEffect, rhs: TileContainerBase.BackgroundEffect) -> Bool {
lhs.description == lhs.description
}
public var description: String {
switch self {
case .transparency:
"transparency"
case .gradient(let first, let second):
"gradient(\(first), \(second)"
case .none:
"none"
}
}
} }
/// Enum used to describe the aspect ratios used for this component. /// Enum used to describe the aspect ratios used for this component.

View File

@ -11,7 +11,7 @@ import UIKit
extension Tilelet { extension Tilelet {
/// Model that represents the options available for the badge. /// Model that represents the options available for the badge.
public struct BadgeModel { public struct BadgeModel: Equatable {
/// Text that will be used for the badge. /// Text that will be used for the badge.
public var text: String = "" public var text: String = ""

View File

@ -32,7 +32,7 @@ extension Tilelet {
} }
/// Model that represents the options available for the descriptive icon. /// Model that represents the options available for the descriptive icon.
public struct DescriptiveIcon { public struct DescriptiveIcon: Equatable {
/// A representation that will be used to render the icon with corresponding name. /// A representation that will be used to render the icon with corresponding name.
public var name: Icon.Name public var name: Icon.Name
@ -58,7 +58,7 @@ extension Tilelet {
} }
/// Model that represents the options available for the directional icon. /// Model that represents the options available for the directional icon.
public struct DirectionalIcon { public struct DirectionalIcon: Equatable {
public enum IconType: String, CaseIterable { public enum IconType: String, CaseIterable {
case rightArrow case rightArrow
case externalLink case externalLink

View File

@ -10,7 +10,7 @@ import UIKit
extension Tilelet { extension Tilelet {
/// Model that represents the options available for the sub title label. /// Model that represents the options available for the sub title label.
public struct SubTitleModel { public struct SubTitleModel: Equatable {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Enums // MARK: - Enums
//-------------------------------------------------- //--------------------------------------------------
@ -67,5 +67,13 @@ extension Tilelet {
textAttributes: textAttributes, textAttributes: textAttributes,
lineBreakMode: lineBreakMode) lineBreakMode: lineBreakMode)
} }
public static func == (lhs: Tilelet.SubTitleModel, rhs: Tilelet.SubTitleModel) -> Bool {
lhs.text == rhs.text
&& lhs.textColor == rhs.textColor
&& lhs.otherStandardStyle == rhs.otherStandardStyle
&& lhs.textAttributes == rhs.textAttributes
&& lhs.lineBreakMode == rhs.lineBreakMode
}
} }
} }

View File

@ -10,7 +10,7 @@ import UIKit
extension Tilelet { extension Tilelet {
/// Model that represents the options available for the title label. /// Model that represents the options available for the title label.
public struct TitleModel { public struct TitleModel: Equatable {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Enums // MARK: - Enums
//-------------------------------------------------- //--------------------------------------------------
@ -75,5 +75,14 @@ extension Tilelet {
standardStyle: standardStyle.value, standardStyle: standardStyle.value,
lineBreakMode: lineBreakMode) lineBreakMode: lineBreakMode)
} }
public static func == (lhs: Tilelet.TitleModel, rhs: Tilelet.TitleModel) -> Bool {
lhs.text == rhs.text
&& lhs.textColor == rhs.textColor
&& lhs.isBold == rhs.isBold
&& lhs.textAttributes == rhs.textAttributes
&& lhs.standardStyle == rhs.standardStyle
&& lhs.lineBreakMode == rhs.lineBreakMode
}
} }
} }

View File

@ -11,7 +11,7 @@ import UIKit
extension Tilelet { extension Tilelet {
/// Model that represents the options available for the eyebrow label. /// Model that represents the options available for the eyebrow label.
public struct EyebrowModel { public struct EyebrowModel: Equatable {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Public Properties // MARK: - Public Properties
//-------------------------------------------------- //--------------------------------------------------
@ -60,5 +60,14 @@ extension Tilelet {
standardStyle: standardStyle.value, standardStyle: standardStyle.value,
textAttributes: textAttributes) textAttributes: textAttributes)
} }
public static func == (lhs: Tilelet.EyebrowModel, rhs: Tilelet.EyebrowModel) -> Bool {
lhs.text == rhs.text
&& lhs.textColor == rhs.textColor
&& lhs.isBold == rhs.isBold
&& lhs.textAttributes == rhs.textAttributes
&& lhs.standardStyle == rhs.standardStyle
&& lhs.lineBreakMode == rhs.lineBreakMode
}
} }
} }

View File

@ -9,7 +9,7 @@ import Foundation
extension TitleLockup { extension TitleLockup {
/// Model that represents the options available for the eyebrow label. /// Model that represents the options available for the eyebrow label.
public struct EyebrowModel { public struct EyebrowModel: Equatable {
/// Text that will be used for the eyebrow label. /// Text that will be used for the eyebrow label.
public var text: String public var text: String
@ -44,6 +44,15 @@ extension TitleLockup {
/// Text style that will be used for the eyebrow label. /// Text style that will be used for the eyebrow label.
public var textStyle: TextStyle { isBold ? standardStyle.value.bold : standardStyle.value.regular } public var textStyle: TextStyle { isBold ? standardStyle.value.bold : standardStyle.value.regular }
public static func == (lhs: TitleLockup.EyebrowModel, rhs: TitleLockup.EyebrowModel) -> Bool {
lhs.text == rhs.text
&& lhs.textColor == rhs.textColor
&& lhs.isBold == rhs.isBold
&& lhs.standardStyle == rhs.standardStyle
&& lhs.textAttributes == rhs.textAttributes
&& lhs.numberOfLines == rhs.numberOfLines
}
} }
} }

View File

@ -46,6 +46,14 @@ extension TitleLockup {
/// TextStyle used to render the text. /// TextStyle used to render the text.
public var textStyle: TextStyle { otherStandardStyle.value.regular } public var textStyle: TextStyle { otherStandardStyle.value.regular }
public static func == (lhs: TitleLockup.SubTitleModel, rhs: TitleLockup.SubTitleModel) -> Bool {
lhs.text == rhs.text
&& lhs.textColor == rhs.textColor
&& lhs.otherStandardStyle == rhs.otherStandardStyle
&& lhs.textAttributes == rhs.textAttributes
&& lhs.lineBreakMode == rhs.lineBreakMode
&& lhs.numberOfLines == rhs.numberOfLines
}
} }
} }

View File

@ -10,7 +10,7 @@ import UIKit
extension TitleLockup { extension TitleLockup {
/// Model that represents the options available for the sub title label. /// Model that represents the options available for the sub title label.
public struct TitleModel { public struct TitleModel: Equatable {
/// Text that will be used for the title label. /// Text that will be used for the title label.
public var text: String public var text: String
@ -51,5 +51,14 @@ extension TitleLockup {
/// TextStyle used to render the text. /// TextStyle used to render the text.
public var textStyle: TextStyle { isBold ? standardStyle.value.bold : standardStyle.value.regular } public var textStyle: TextStyle { isBold ? standardStyle.value.bold : standardStyle.value.regular }
public static func == (lhs: TitleLockup.TitleModel, rhs: TitleLockup.TitleModel) -> Bool {
lhs.text == rhs.text
&& lhs.textColor == rhs.textColor
&& lhs.isBold == rhs.isBold
&& lhs.standardStyle == rhs.standardStyle
&& lhs.textAttributes == rhs.textAttributes
&& lhs.numberOfLines == rhs.numberOfLines
&& lhs.lineBreakMode == rhs.lineBreakMode
}
} }
} }

View File

@ -11,7 +11,7 @@ import UIKit
extension Tooltip { extension Tooltip {
/// Model used to represent the tooltip. /// Model used to represent the tooltip.
public struct TooltipModel { public struct TooltipModel: Equatable {
/// Current Surface and this is used to pass down to child objects that implement Surfacable /// Current Surface and this is used to pass down to child objects that implement Surfacable
public var closeButtonText: String public var closeButtonText: String
public var title: String? public var title: String?