Skip to content

Commit 3446130

Browse files
Merge pull request #68 from componentskit/refactor/inits
Refactor initializers
2 parents f10b6fe + b3b6050 commit 3446130

File tree

11 files changed

+16
-13
lines changed

11 files changed

+16
-13
lines changed

Sources/ComponentsKit/Components/Alert/Helpers/AlertButtonsOrientationCalculator.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ struct AlertButtonsOrientationCalculator {
66
case horizontal
77
}
88

9-
private static let primaryButton = UKButton()
10-
private static let secondaryButton = UKButton()
9+
private static let primaryButton = UKButton(model: .init())
10+
private static let secondaryButton = UKButton(model: .init())
1111

1212
private init() {}
1313

Sources/ComponentsKit/Components/Alert/UKAlertController.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ public class UKAlertController: UKCenterModalController {
4848
/// The label used to display the subtitle or message of the alert.
4949
public let subtitleLabel = UILabel()
5050
/// The button representing the primary action in the alert.
51-
public let primaryButton = UKButton()
51+
public let primaryButton = UKButton(model: .init())
5252
/// The button representing the secondary action in the alert.
53-
public let secondaryButton = UKButton()
53+
public let secondaryButton = UKButton(model: .init())
5454
/// A stack view that arranges the primary and secondary buttons.
5555
public let buttonsStackView = UIStackView()
5656

Sources/ComponentsKit/Components/Avatar/UIKit/UKAvatar.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ open class UKAvatar: UIImageView, UKComponent {
2626
/// Initializer.
2727
/// - Parameters:
2828
/// - model: A model that defines the appearance properties.
29-
public init(model: AvatarVM = .init()) {
29+
public init(model: AvatarVM) {
3030
self.model = model
3131
self.imageManager = AvatarImageManager(model: model)
3232

Sources/ComponentsKit/Components/AvatarGroup/UIKit/UKAvatarGroup.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ open class UKAvatarGroup: UIView, UKComponent {
2222
/// Initializer.
2323
/// - Parameters:
2424
/// - model: A model that defines the appearance properties.
25-
public init(model: AvatarGroupVM = .init()) {
25+
public init(model: AvatarGroupVM) {
2626
self.model = model
2727

2828
super.init(frame: .zero)

Sources/ComponentsKit/Components/Badge/UKBadge.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ open class UKBadge: UIView, UKComponent {
2929

3030
/// Initializes a new instance of `UKBadge`.
3131
/// - Parameter model: A model that defines the appearance properties for the badge.
32-
public init(model: BadgeVM = .init()) {
32+
public init(model: BadgeVM) {
3333
self.model = model
3434
super.init(frame: .zero)
3535

Sources/ComponentsKit/Components/Button/UKButton.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ open class UKButton: UIView, UKComponent {
4747
/// - model: A model that defines the appearance properties.
4848
/// - action: A closure that is triggered when the button is tapped.
4949
public init(
50-
model: ButtonVM = .init(),
50+
model: ButtonVM,
5151
action: @escaping () -> Void = {}
5252
) {
5353
self.model = model

Sources/ComponentsKit/Components/Card/SUCard.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public struct SUCard<Content: View>: View {
2727
/// - model: A model that defines the appearance properties.
2828
/// - content: The content that is displayed in the card.
2929
public init(
30-
model: CardVM,
30+
model: CardVM = .init(),
3131
content: @escaping () -> Content
3232
) {
3333
self.model = model

Sources/ComponentsKit/Components/Card/UKCard.swift

+4-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ open class UKCard: UIView, UKComponent {
4444
/// - Parameters:
4545
/// - model: A model that defines the appearance properties.
4646
/// - content: The content that is displayed in the card.
47-
public init(model: CardVM, content: @escaping Content) {
47+
public init(
48+
model: CardVM = .init(),
49+
content: @escaping Content
50+
) {
4851
self.model = model
4952
self.content = content()
5053

Sources/ComponentsKit/Components/Countdown/SUCountdown.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public struct SUCountdown: View {
1717
/// Initializer.
1818
/// - Parameters:
1919
/// - model: A model that defines the appearance properties.
20-
public init(model: CountdownVM = .init()) {
20+
public init(model: CountdownVM) {
2121
self.model = model
2222
}
2323

Sources/ComponentsKit/Components/RadioGroup/UIKit/UKRadioGroup.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ open class UKRadioGroup<ID: Hashable>: UIView, UKComponent, UIGestureRecognizerD
4141
/// - onSelectionChange: A closure that is triggered when the selected radio button changes.
4242
public init(
4343
initialSelectedId: ID? = nil,
44-
model: RadioGroupVM<ID> = .init(),
44+
model: RadioGroupVM<ID>,
4545
onSelectionChange: ((ID?) -> Void)? = nil
4646
) {
4747
self.selectedId = initialSelectedId

Sources/ComponentsKit/Components/SegmentedControl/UKSegmentedControl.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ open class UKSegmentedControl<ID: Hashable>: UIView, UKComponent {
5353
/// - onSelectionChange: A closure that is triggered when a selected segment changes.
5454
public init(
5555
selectedId: ID,
56-
model: SegmentedControlVM<ID> = .init(),
56+
model: SegmentedControlVM<ID>,
5757
onSelectionChange: @escaping (ID) -> Void = { _ in }
5858
) {
5959
self.selectedId = selectedId

0 commit comments

Comments
 (0)