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
extension Breadcrumbs {
public struct BreadcrumbItemModel {
public struct BreadcrumbItemModel: Equatable {
///Text that goes in the breadcrumb item
public var text: String
@ -24,5 +23,10 @@ extension Breadcrumbs {
self.selected = selected
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
extension CalendarBase {
public struct CalendarIndicatorModel {
public struct CalendarIndicatorModel: Equatable {
/// Text that shown to an indicator for legend
public var label: String

View File

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

View File

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

View File

@ -108,7 +108,7 @@ open class CheckboxGroup: SelectorGroupBase<CheckboxItem>, SelectorGroupMultiSel
}
extension CheckboxGroup {
public struct CheckboxItemModel : Surfaceable, Initable, Errorable {
public struct CheckboxItemModel : Surfaceable, Initable, Errorable, Equatable {
/// Whether this object is enabled or not
public var enabled: Bool
@ -146,6 +146,21 @@ extension CheckboxGroup {
public init() {
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
extension DatePicker {
public struct CalendarModel {
public struct CalendarModel: Equatable {
/// If set to true, the calendar will not have a border.
public let hideContainerBorder: Bool

View File

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

View File

@ -10,7 +10,7 @@ import Foundation
extension ButtonIcon {
//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.
public enum ExpandDirection: String, CaseIterable {
case right, center, left

View File

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

View File

@ -8,12 +8,16 @@
import Foundation
extension Notification {
public struct ButtonModel {
public struct ButtonModel: Equatable {
public var text: String
public var onClick: (Button) -> ()
public init(text: String, onClick: @escaping (Button) -> Void) {
self.text = text
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 {
public struct RadioBoxItemModel: Surfaceable, Initable, FormFieldable {
public struct RadioBoxItemModel: Surfaceable, Initable, FormFieldable, Equatable {
/// Whether this object is enabled or not
public var enabled: Bool
/// Current Surface and this is used to pass down to child objects that implement Surfacable
@ -158,5 +158,22 @@ extension RadioBoxGroup {
public init() {
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 {
public struct RadioButtonItemModel: Surfaceable, Initable, FormFieldable, Errorable {
public struct RadioButtonItemModel: Surfaceable, Initable, FormFieldable, Errorable, Equatable {
/// Whether this object is enabled or not
public var enabled: Bool
@ -141,5 +141,20 @@ extension RadioButtonGroup {
public init() {
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
/// Model that represent the content of each cell of Table component
public struct TableItemModel {
public struct TableItemModel: Equatable {
public let defaultHeight: CGFloat = 50.0

View File

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

View File

@ -8,7 +8,7 @@
import Foundation
extension Tabs {
public struct TabModel {
public struct TabModel: Equatable {
///Text that goes in the Tab
public var text: String
@ -24,5 +24,10 @@ extension Tabs {
self.onClick = onClick
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.
public enum BackgroundEffect {
public enum BackgroundEffect: Equatable {
case transparency
case gradient(UIColor, UIColor)
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.

View File

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

View File

@ -32,7 +32,7 @@ extension Tilelet {
}
/// 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.
public var name: Icon.Name
@ -58,7 +58,7 @@ extension Tilelet {
}
/// Model that represents the options available for the directional icon.
public struct DirectionalIcon {
public struct DirectionalIcon: Equatable {
public enum IconType: String, CaseIterable {
case rightArrow
case externalLink

View File

@ -10,7 +10,7 @@ import UIKit
extension Tilelet {
/// Model that represents the options available for the sub title label.
public struct SubTitleModel {
public struct SubTitleModel: Equatable {
//--------------------------------------------------
// MARK: - Enums
//--------------------------------------------------
@ -67,5 +67,13 @@ extension Tilelet {
textAttributes: textAttributes,
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 {
/// Model that represents the options available for the title label.
public struct TitleModel {
public struct TitleModel: Equatable {
//--------------------------------------------------
// MARK: - Enums
//--------------------------------------------------
@ -75,5 +75,14 @@ extension Tilelet {
standardStyle: standardStyle.value,
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 {
/// Model that represents the options available for the eyebrow label.
public struct EyebrowModel {
public struct EyebrowModel: Equatable {
//--------------------------------------------------
// MARK: - Public Properties
//--------------------------------------------------
@ -60,5 +60,14 @@ extension Tilelet {
standardStyle: standardStyle.value,
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 {
/// 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.
public var text: String
@ -44,6 +44,15 @@ extension TitleLockup {
/// Text style that will be used for the eyebrow label.
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.
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 {
/// 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.
public var text: String
@ -51,5 +51,14 @@ extension TitleLockup {
/// TextStyle used to render the text.
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 {
/// 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
public var closeButtonText: String
public var title: String?