From 13ed5c04eec6ca78d24ed030bbdb7a8ed5cb13ba Mon Sep 17 00:00:00 2001 From: Michael Zimmermann Date: Thu, 20 Jun 2024 19:51:36 +0200 Subject: [PATCH] Swiftlint all files. --- .swiftlint.yml | 18 +++-- .../Global/Publisher+SubscribeExtension.swift | 4 +- .../ControlPropertyStateTests.swift | 4 +- .../ControlPropertyStatesTests.swift | 26 +++---- .../Control/SwiftUI/ControlStateText.swift | 2 +- .../SwiftUI/ControlStateTextTests.swift | 2 +- .../UIView/UIControlStateImageView.swift | 2 +- .../Enum/DisplayedTextTypeTests.swift | 4 +- .../Model/DisplayedTextTests.swift | 4 +- .../GetDidDisplayedTextChangeUseCase.swift | 2 +- ...etDidDisplayedTextChangeUseCaseTests.swift | 2 +- .../DisplayedTextViewModelTests.swift | 7 +- .../CGFloat+ScaledMetricExtension.swift | 2 +- .../Foundation/Extension/CGRect-Center.swift | 4 +- .../Extension/Optional+ExtensionTests.swift | 6 +- .../Foundation/Extension/UIView-Closest.swift | 2 +- .../Extension/UIViewClosestTests.swift | 2 +- ...LayoutConstraint+MultiplierExtension.swift | 2 +- .../UITraitCollection-SizeAppearance.swift | 1 - .../UIView+AccessibilityExtension.swift | 2 +- .../NSLayoutConstraint+Extension.swift | 1 - .../BadgeAccessibilityIdentifier.swift | 1 - .../BadgeGetIntentColorsUseCase.swift | 4 +- .../Badge/View/SwiftUI/BadgeView.swift | 2 +- .../Badge/View/UIKit/BadgeUIView.swift | 12 ++-- .../Badge/ViewModel/BadgeViewModel.swift | 2 +- .../Badge/ViewModel/BadgeViewModelTests.swift | 28 ++++---- ...ntationController-customHeightDetent.swift | 8 +-- .../GetColors/ButtonGetColorsUseCase.swift | 2 +- .../ButtonGetSpacingsUseCaseTests.swift | 2 +- .../Common/ButtonScenarioSnapshotTests.swift | 2 +- .../IconButtonScenarioSnapshotTests.swift | 8 +-- .../SwiftUI/Public/Button/ButtonView.swift | 2 +- .../SwiftUI/Public/Icon/IconButtonView.swift | 1 - .../View/UIKit/Button/ButtonUIView.swift | 4 +- .../ViewModel/Button/ButtonViewModel.swift | 2 +- .../ViewModel/Main/ButtonMainViewModel.swift | 2 +- .../Main/ButtonMainViewModelTests.swift | 6 +- .../Model/CheckboxGroupViewModel.swift | 3 +- .../Model/CheckboxGroupViewModelTests.swift | 4 +- .../Checkbox/Model/CheckboxViewModel.swift | 6 +- .../Model/CheckboxViewModelTests.swift | 9 ++- .../CheckboxGroupScenarioSnapshotTests.swift | 2 +- .../CheckboxScenarioSnapshotTests.swift | 2 +- .../CheckboxGetSpacingUseCaseTests.swift | 8 +-- .../View/CheckboxGroupItemDefault.swift | 2 +- .../View/SwiftUI/CheckboxGroupView.swift | 3 +- .../Checkbox/View/SwiftUI/CheckboxView.swift | 6 +- .../View/UIKit/CheckboxControlUIView.swift | 11 ++- .../View/UIKit/CheckboxGroupUIView.swift | 14 ++-- .../CheckboxGroupUIViewActionTests.swift | 8 ++- .../Checkbox/View/UIKit/CheckboxUIView.swift | 15 ++-- .../UIKit/CheckboxUIViewSnapshotTests.swift | 2 +- .../Chip/Model/ChipIntentColors.swift | 2 +- .../Chip/Model/ChipStateColors.swift | 2 +- .../ChipGetOutlinedIntentColorsUseCase.swift | 18 ++--- .../Chip/View/ChipViewModelTests.swift | 51 ++++++++------ .../ChipScenarioSnapshotTests.swift | 2 +- .../CommonTests/ChipStateSnapshotTests.swift | 2 +- .../Chip/View/SwiftUI/ChipView.swift | 11 +-- .../Chip/View/UIKit/ChipUIView.swift | 16 ++--- .../Model/FormFieldViewModelTests.swift | 8 +-- .../UseCase/FormfieldTitleUseCase.swift | 2 +- .../View/UIKit/FormFieldUIView.swift | 6 +- .../UIKit/FormFieldUIViewSnapshotTests.swift | 9 +-- .../Icon/UseCase/IconGetColorUseCase.swift | 2 +- .../Icon/View/Model/IconViewModelTests.swift | 12 ++-- .../View/UIKit/IconUIViewSnapshotTests.swift | 2 +- ...ssBarIndeterminateAnimationTypeTests.swift | 2 +- .../Colors/Single/ProgressBarColors.swift | 2 +- .../Internal/ProgressBarContentView.swift | 2 +- .../Public/ProgressBarIndeterminateView.swift | 3 +- .../View/SwiftUI/Public/ProgressBarView.swift | 18 ++--- .../ProgressBarIndeterminateViewModel.swift | 2 +- ...ogressBarIndeterminateViewModelTests.swift | 4 +- .../Main/ProgressBarMainViewModel.swift | 2 +- .../Main/ProgressBarMainViewModelTests.swift | 3 +- .../Model/ProgressTrackerColors.swift | 2 +- .../Model/ProgressTrackerContent.swift | 4 +- .../Model/ProgressTrackerContentTests.swift | 4 +- .../Model/ProgressTrackerTintedColors.swift | 1 - ...rogressTrackerGetTintedColorsUseCase.swift | 2 +- ...ssTrackerGetTintedColorsUseCaseTests.swift | 1 - ...essTrackerConfigurationSnapshotTests.swift | 1 - ...ProgressTrackerScenarioSnapshotTests.swift | 2 +- .../ProgressTrackerIndicatorViewModel.swift | 2 +- ...ogressTrackerIndicatorViewModelTests.swift | 50 ++++++++------ .../View/ProgressTrackerTrackViewModel.swift | 2 +- .../ProgressTrackerTrackViewModelTests.swift | 1 - .../View/ProgressTrackerViewModel.swift | 4 +- .../View/ProgressTrackerViewModelTests.swift | 15 ++-- ...TrackerContinuousGestureHandlerTests.swift | 3 +- ...ssTrackerDiscreteGestureHandlerTests.swift | 2 +- .../ProgressTrackerGestureHandler.swift | 13 ++-- .../ProgressTrackerHorizontalView.swift | 10 +-- ...rackerIndependentGestureHandlerTests.swift | 2 +- .../ProgressTrackerIndicatorView.swift | 8 +-- .../SwiftUI/ProgressTrackerTrackView.swift | 6 +- .../SwiftUI/ProgressTrackerVerticalView.swift | 12 ++-- .../View/SwiftUI/ProgressTrackerView.swift | 12 ++-- ...TrackerContinuousUITouchHandlerTests.swift | 18 ++--- ...ssTrackerDiscreteUITouchHandlerTests.swift | 16 ++--- ...rackerIndependentUITouchHandlerTests.swift | 15 ++-- .../ProgressTrackerIndicatorUIControl.swift | 8 +-- .../View/UIKit/ProgressTrackerUIControl.swift | 34 ++++----- ...rogressTrackerUIControlSnapshotTests.swift | 2 +- .../UIKit/ProgressTrackerUITouchHandler.swift | 15 ++-- ...ssTrackerUITouchHandlerCreationTests.swift | 4 +- .../Internal/RadioButtonConstants.swift | 2 +- .../Properties/Public/RadioButtonItem.swift | 4 +- .../Properties/Public/RadioButtonUIItem.swift | 4 +- .../RadioButtonGetColorsUseCase.swift | 2 +- .../RadioButtonGetGroupColorUseCase.swift | 2 +- .../View/RadioButtonGroupViewModel.swift | 2 +- .../View/RadioButtonGroupViewModelTests.swift | 26 +++---- .../View/RadioButtonViewModel.swift | 2 +- .../View/RadioButtonViewModelTests.swift | 24 ++++--- .../View/SwiftUI/RadioButtonGroupView.swift | 4 +- .../View/UIKit/RadioButtonToggleUIView.swift | 16 ++--- .../View/UIKit/RadioButtonUIGroupView.swift | 15 ++-- .../RadioButtonUIGroupViewDelegate.swift | 2 +- .../View/UIKit/RadioButtonUIView.swift | 5 +- .../Rating/Cache/CGLayerCache.swift | 2 +- .../Components/Rating/Enum/StarFillMode.swift | 2 +- .../Rating/Graphics/ShapeLayer.swift | 2 +- .../Components/Rating/Graphics/Star.swift | 18 ++--- .../Rating/Model/StarConfiguration.swift | 4 +- ...ingDisplayConfigurationSnapshotTests.swift | 2 +- .../RatingInputScenarioSnapshotTests.swift | 3 +- .../UseCases/RatingGetColorsUseCase.swift | 8 ++- .../Rating/View/RatingDisplayViewModel.swift | 1 - .../View/RatingDisplayViewModelTests.swift | 1 - .../RatingDisplayViewSnapshotTests.swift | 1 - .../View/UIKit/RatingDisplayUIView.swift | 11 ++- .../Rating/View/UIKit/RatingInputUIView.swift | 6 +- .../Rating/View/UIKit/StarUIView.swift | 9 ++- .../SliderCreateStepsUseCase.swift | 2 +- ...SliderGetClosestValueInBoundsUseCase.swift | 2 +- ...rGetClosestValueUseCasableMock+Tests.swift | 3 +- .../GetColors/SliderGetColorsUseCase.swift | 2 +- ...epValuesInBoundsUseCasableMock+Tests.swift | 4 +- .../Slider/View/UIKit/SliderUIControl.swift | 2 +- .../ViewModel/Base/SliderViewModel.swift | 6 +- .../Single/SingleSliderViewModel.swift | 3 +- .../Spinner/SpinnerViewModelTests.swift | 2 +- .../Spinner/UIKit/SpinnerUIView.swift | 7 +- .../GetColor/SwitchGetColorUseCaseTests.swift | 4 +- .../SwitchGetPositionUseCase.swift | 2 +- .../Switch/View/SwiftUI/SwitchView.swift | 2 +- .../ViewModel/SwitchViewModelTests.swift | 4 +- .../Tab/Properties/TabItemColors.swift | 4 +- .../Tab/Properties/TabItemContent.swift | 2 +- .../Tab/Properties/TabItemSpacings.swift | 4 +- .../Components/Tab/Properties/TabState.swift | 2 +- .../Tab/Properties/TabStateAttributes.swift | 2 +- .../TabGetIntentColorUseCaseTests.swift | 8 +-- .../TabGetStateAttributesUseCase.swift | 2 +- .../TabGetStateAttributesUseCaseTests.swift | 20 +++--- .../TabsGetAttributesUseCaseTests.swift | 1 - .../View/SwiftUI/TabApportionsSizeView.swift | 7 +- .../Tab/View/SwiftUI/TabEqualSizeView.swift | 6 +- .../Tab/View/SwiftUI/TabItemView.swift | 8 +-- .../SwiftUI/TabItemViewSnapshotTests.swift | 34 ++++----- .../Components/Tab/View/SwiftUI/TabView.swift | 4 +- .../Tab/View/UIKit/TabItemUIView.swift | 12 ++-- .../UIKit/TabItemUIViewSnapshotTests.swift | 1 + .../Tab/View/UIKit/TabItemUIViewTests.swift | 2 +- .../Components/Tab/View/UIKit/TabUIView.swift | 32 ++++----- .../Tab/View/UIKit/TabUIViewDelegate.swift | 2 +- .../Tab/View/UIKit/TabUIViewTests.swift | 11 +-- .../Tab/ViewModel/TabItemViewModel.swift | 8 +-- .../Tab/ViewModel/TabItemViewModelTests.swift | 69 +++++++++---------- .../Tab/ViewModel/TabViewModelTests.swift | 28 ++++---- .../Tag/ViewModel/TagViewModelTests.swift | 6 +- .../Addons/View/SwiftUI/TextFieldAddon.swift | 2 +- .../Addons/View/SwiftUI/TextFieldAddons.swift | 2 +- .../View/UIKit/TextFieldAddonsUIView.swift | 6 +- .../View/SwiftUI/TextFieldView.swift | 2 +- .../View/UIKit/TextFieldUIView.swift | 12 ++-- .../ViewModel/TextFieldViewModel.swift | 2 +- .../ViewModel/TextFieldViewModelTests.swift | 2 +- .../Enum/Public/TextLinkTypography.swift | 2 +- .../GetColor/TextLinkGetColorUseCase.swift | 16 ++--- .../TextLinkGetColorUseCaseTests.swift | 2 +- .../TextLink/View/SwiftUI/TextLinkView.swift | 2 +- .../UIKit/TextLinkUIViewSnapshotTests.swift | 2 +- .../ViewModel/TextLinkViewModel.swift | 2 +- .../ViewModel/TextLinkViewModelTests.swift | 6 +- .../PropertyWrapper/ScaledUIMetric.swift | 2 +- .../PropertyWrapper/ScaledUIMetricTests.swift | 1 + .../ColorsGeneratedMock+ExtensionTests.swift | 2 +- ...lorsBaseGeneratedMock+ExtensionTests.swift | 2 +- ...sSupportGeneratedMock+ExtensionTests.swift | 2 +- .../Drop/ElevationDropShadowsDefault.swift | 2 +- .../Shadow/ElevationShadowDefault.swift | 1 - .../Typography/TypographyDefault.swift | 2 +- ...pographyGeneratedMock+ExtensionTests.swift | 2 +- .../ThemeGeneratedMock+ExtensionTests.swift | 2 +- .../Classes/Publisher/PublisherMock.swift | 5 +- .../SwiftUIComponentSnapshotTestCase.swift | 10 +-- .../ComponentSnapshotTestCase.swift | 2 +- .../TestCase/SnapshotTestCaseTracker.swift | 1 + spark/Demo/Classes/Enum/UIComponent.swift | 1 - .../Tabbar/SparkTabbarController.swift | 8 +-- .../View/ComponentVersionViewController.swift | 3 +- .../UIKit/BadgeComponentUIViewModel.swift | 1 - .../UIKit/BadgeComponentViewController.swift | 7 +- .../UIKit/BottomSheetDemoView.swift | 1 - ...ottomSheetPresentingUIViewController.swift | 1 - .../UIKit/ButtonComponentViewController.swift | 7 +- .../CheckboxComponentUIViewController.swift | 7 +- ...eckboxGroupComponentUIViewController.swift | 7 +- .../ChipComponentViewRepresentable.swift | 1 - .../Chip/UIKit/ChipComponentUIView.swift | 10 ++- .../UIKit/ChipComponentUIViewController.swift | 7 +- .../Components/ComponentsViewController.swift | 3 +- .../UIKit/FormFieldComponentUIView.swift | 15 ++-- .../FormFieldComponentUIViewController.swift | 7 +- .../Icon/UIKit/IconComponentUIView.swift | 1 - .../UIKit/IconComponentUIViewController.swift | 7 +- .../IconButtonComponentViewController.swift | 7 +- .../ComponentsConfigurationItemView.swift | 16 ++--- ...determinateComponentUIViewController.swift | 7 +- ...ProgressBarComponentUIViewController.swift | 7 +- .../ProgressTrackerComponentUIView.swift | 1 - ...ressTrackerComponentUIViewController.swift | 8 +-- .../ProgressTrackerComponentUIViewModel.swift | 1 - .../UIKit/RadioButtonComponentUIView.swift | 3 +- ...RadioButtonComponentUIViewController.swift | 7 +- .../RadioButtonComponentUIViewModel.swift | 1 - .../UIKit/RatingDisplayComponentUIView.swift | 3 +- ...RatingDisplayComponentViewController.swift | 7 +- .../UIKit/RatingInputComponentUIView.swift | 3 +- .../RatingInputComponentUIViewModel.swift | 1 - .../RatingInputComponentViewController.swift | 7 +- .../Rating/UIKit/StarComponentUIView.swift | 4 +- .../UIKit/StarComponentViewController.swift | 3 +- .../SliderComponentUIViewController.swift | 7 +- .../UIKit/SliderComponentUIViewModel.swift | 1 - .../UIKit/SpinnerComponentUIView.swift | 1 - .../SpinnerComponentUIViewController.swift | 7 +- .../SwitchComponentUIViewController.swift | 7 +- .../Tab/UIKit/TabComponentUIView.swift | 5 +- .../UIKit/TabComponentUIViewController.swift | 7 +- .../UIKit/TagComponentUIViewController.swift | 7 +- .../TextFieldAddonsComponentView.swift | 1 - .../TextFieldAddonsComponentUIView.swift | 3 +- ...FieldAddonsComponentUIViewController.swift | 7 +- .../TextFieldComponentUIViewController.swift | 7 +- .../TextLinkComponentUIViewController.swift | 7 +- .../ListView/Cells/BadgeCell/BadgeCell.swift | 3 +- .../Cells/ButtonCell/ButtonCell.swift | 3 +- .../Cells/CheckboxCell/CheckboxCell.swift | 3 +- .../CheckboxGroupCell/CheckboxGroupCell.swift | 3 +- .../ListView/Cells/ChipCell/ChipCell.swift | 3 +- .../ListView/Cells/IconCell/IconCell.swift | 3 +- .../ProgressBarIndeterminateCell.swift | 3 +- .../ProgressBarSingleCell.swift | 3 +- .../RadioButtonCell/RadioButtonCell.swift | 3 +- .../RadioButtonGroupCell.swift | 3 +- .../RatingDisplayCell/RatingDisplayCell.swift | 3 +- .../RatingInputCell/RatingInputCell.swift | 3 +- .../Cells/SpinnerCell/SpinnerCell.swift | 3 +- .../ListView/Cells/StarCell/StarCell.swift | 3 +- .../SwitchButtonCell/SwitchButtonCell.swift | 3 +- .../View/ListView/Cells/TabCell/TabCell.swift | 3 +- .../View/ListView/Cells/TagCell/TagCell.swift | 3 +- .../Controllers/RadioCheckboxView.swift | 1 - .../ListComponentsViewController.swift | 3 +- .../View/ListView/ListViewDatasource.swift | 1 - .../Classes/View/SettingsViewController.swift | 3 +- .../Content/SparkTypographyTests.swift | 1 - 272 files changed, 786 insertions(+), 853 deletions(-) diff --git a/.swiftlint.yml b/.swiftlint.yml index ce0b688fa..0910e0682 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -1,10 +1,8 @@ -included: - - SparkCore - - SparkCoreTests - - Spark - - SparkTests +excluded: + - "**/*.generated.swift" # Enabled rules for CI linting +# List of all the rules: https://realm.github.io/SwiftLint/rule-directory.html only_rules: - colon - comment_spacing @@ -18,6 +16,7 @@ only_rules: - private_subject - unneeded_parentheses_in_closure_argument - multiline_arguments + - multiline_parameters - lower_acl_than_parent - syntactic_sugar - unneeded_break_in_switch @@ -27,10 +26,19 @@ only_rules: - statement_position - explicit_self - empty_count + - empty_string - force_cast - force_try - force_unwrapping - empty_collection_literal + - vertical_whitespace + - direct_return + # - file_name + - file_name_no_space + # - file_header + # - missing_docs + - toggle_bool + - yoda_condition # Rules triggering ERROR diff --git a/core/Sources/Common/Combine/Global/Publisher+SubscribeExtension.swift b/core/Sources/Common/Combine/Global/Publisher+SubscribeExtension.swift index 0bc30b1a0..3fceb62a1 100644 --- a/core/Sources/Common/Combine/Global/Publisher+SubscribeExtension.swift +++ b/core/Sources/Common/Combine/Global/Publisher+SubscribeExtension.swift @@ -16,9 +16,9 @@ extension Publisher where Failure == Never { action: @escaping (Self.Output) -> Void ) where S: Scheduler { self .receive(on: scheduler) - .sink { value in + .sink(receiveValue: { value in action(value) - } + }) .store(in: &subscriptions) } } diff --git a/core/Sources/Common/Control/PropertyState/ControlPropertyStateTests.swift b/core/Sources/Common/Control/PropertyState/ControlPropertyStateTests.swift index a0edb27aa..731ddea94 100644 --- a/core/Sources/Common/Control/PropertyState/ControlPropertyStateTests.swift +++ b/core/Sources/Common/Control/PropertyState/ControlPropertyStateTests.swift @@ -11,9 +11,9 @@ import SwiftUI @testable import SparkCore final class ControlPropertyStateTests: XCTestCase { - + // MARK: - Tests - + func test_default_value() { // GIVEN / WHEN let state = ControlPropertyState(for: .normal) diff --git a/core/Sources/Common/Control/PropertyStates/ControlPropertyStatesTests.swift b/core/Sources/Common/Control/PropertyStates/ControlPropertyStatesTests.swift index 8c7d8707c..22c75ddcb 100644 --- a/core/Sources/Common/Control/PropertyStates/ControlPropertyStatesTests.swift +++ b/core/Sources/Common/Control/PropertyStates/ControlPropertyStatesTests.swift @@ -11,22 +11,22 @@ import SwiftUI @testable import SparkCore final class ControlPropertyStatesTests: XCTestCase { - + // MARK: - Value for States - Tests - + func test_value_for_all_states_when_value_is_set() { // GIVEN let expectedValue = "Value" - + let states = ControlState.allCases - + for state in states { let states = ControlPropertyStates() states.setValue(expectedValue, for: state) - + // WHEN let value = states.value(for: state) - + // THEN XCTAssertEqual( value, @@ -35,18 +35,18 @@ final class ControlPropertyStatesTests: XCTestCase { ) } } - + func test_value_for_all_states_when_value_is_nil() { // GIVEN let states = ControlState.allCases - + for state in states { let states = ControlPropertyStates() states.setValue(nil, for: state) - + // WHEN let value = states.value(for: state) - + // THEN XCTAssertNil( value, @@ -54,9 +54,9 @@ final class ControlPropertyStatesTests: XCTestCase { ) } } - + // MARK: - Value for Status - Tests - + func test_all_values_when_status_isHighlighted() { // GIVEN let normalStateValue = "normal" @@ -116,7 +116,7 @@ final class ControlPropertyStatesTests: XCTestCase { ) // ** } - + func test_all_values_when_status_isDisabled() { // GIVEN let normalStateValue = "normal" diff --git a/core/Sources/Common/Control/SwiftUI/ControlStateText.swift b/core/Sources/Common/Control/SwiftUI/ControlStateText.swift index 3488b4772..ae3a396c6 100644 --- a/core/Sources/Common/Control/SwiftUI/ControlStateText.swift +++ b/core/Sources/Common/Control/SwiftUI/ControlStateText.swift @@ -43,7 +43,7 @@ final class ControlStateText: ObservableObject { /// Set the attributed text for a state. /// - parameter text: new attributed text /// - parameter state: state of the attributed text - /// - parameter status: the status of the parent control + /// - parameter status: the status of the parent control func setAttributedText( _ attributedText: AttributedString?, for state: ControlState, diff --git a/core/Sources/Common/Control/SwiftUI/ControlStateTextTests.swift b/core/Sources/Common/Control/SwiftUI/ControlStateTextTests.swift index fc47edbde..3f972044f 100644 --- a/core/Sources/Common/Control/SwiftUI/ControlStateTextTests.swift +++ b/core/Sources/Common/Control/SwiftUI/ControlStateTextTests.swift @@ -63,7 +63,7 @@ final class ControlStateTextTests: XCTestCase { ) // WHEN - + // Check when a text is nil for an another state, // The text text for the normal state should be returned diff --git a/core/Sources/Common/Control/UIView/UIControlStateImageView.swift b/core/Sources/Common/Control/UIView/UIControlStateImageView.swift index 3f7d744ae..58a8e3ae7 100644 --- a/core/Sources/Common/Control/UIView/UIControlStateImageView.swift +++ b/core/Sources/Common/Control/UIView/UIControlStateImageView.swift @@ -55,7 +55,7 @@ final class UIControlStateImageView: UIImageView { /// Set the image for a state. /// - parameter image: new image /// - parameter state: state of the image - /// - parameter control: the parent control + /// - parameter control: the parent control func setImage( _ image: UIImage?, for state: ControlState, diff --git a/core/Sources/Common/DisplayedText/Enum/DisplayedTextTypeTests.swift b/core/Sources/Common/DisplayedText/Enum/DisplayedTextTypeTests.swift index 1c9b62b02..906c84de9 100644 --- a/core/Sources/Common/DisplayedText/Enum/DisplayedTextTypeTests.swift +++ b/core/Sources/Common/DisplayedText/Enum/DisplayedTextTypeTests.swift @@ -16,10 +16,10 @@ final class DisplayedTextTypeTests: XCTestCase { func test_containsText_when_type_is_none() { // GIVEN let type: DisplayedTextType = .none - + // WHEN let containsText = type.containsText - + // THEN XCTAssertFalse(containsText) } diff --git a/core/Sources/Common/DisplayedText/Model/DisplayedTextTests.swift b/core/Sources/Common/DisplayedText/Model/DisplayedTextTests.swift index 84ddffa34..8bf884590 100644 --- a/core/Sources/Common/DisplayedText/Model/DisplayedTextTests.swift +++ b/core/Sources/Common/DisplayedText/Model/DisplayedTextTests.swift @@ -10,9 +10,9 @@ import XCTest @testable import SparkCore final class DisplayedTextTests: XCTestCase { - + // MARK: - Optional Init - + func test_optional_init_with_only_text() { // GIVEN let textMock = "My text" diff --git a/core/Sources/Common/DisplayedText/UseCase/GetDidDisplayedTextChange/GetDidDisplayedTextChangeUseCase.swift b/core/Sources/Common/DisplayedText/UseCase/GetDidDisplayedTextChange/GetDidDisplayedTextChangeUseCase.swift index 11efc9129..19abf0f3f 100644 --- a/core/Sources/Common/DisplayedText/UseCase/GetDidDisplayedTextChange/GetDidDisplayedTextChangeUseCase.swift +++ b/core/Sources/Common/DisplayedText/UseCase/GetDidDisplayedTextChange/GetDidDisplayedTextChangeUseCase.swift @@ -11,7 +11,7 @@ protocol GetDidDisplayedTextChangeUseCaseable { func execute(currentText: String?, newText: String?, displayedTextType: DisplayedTextType) -> Bool - + func execute(currentAttributedText: AttributedStringEither?, newAttributedText: AttributedStringEither?, displayedTextType: DisplayedTextType) -> Bool diff --git a/core/Sources/Common/DisplayedText/UseCase/GetDidDisplayedTextChange/GetDidDisplayedTextChangeUseCaseTests.swift b/core/Sources/Common/DisplayedText/UseCase/GetDidDisplayedTextChange/GetDidDisplayedTextChangeUseCaseTests.swift index 3a963e150..1c2a9cd1c 100644 --- a/core/Sources/Common/DisplayedText/UseCase/GetDidDisplayedTextChange/GetDidDisplayedTextChangeUseCaseTests.swift +++ b/core/Sources/Common/DisplayedText/UseCase/GetDidDisplayedTextChange/GetDidDisplayedTextChangeUseCaseTests.swift @@ -147,7 +147,7 @@ final class GetDidDisplayedTextChangeUseCaseTests: XCTestCase { // THEN XCTAssertFalse(isChanged) } - + // MARK: - Tests Execute with attributed text func test_execute_when_currentAttributedText_is_equal_to_newAttributedText_and_displayedTextType_is_none() { diff --git a/core/Sources/Common/DisplayedText/ViewModel/DisplayedTextViewModelTests.swift b/core/Sources/Common/DisplayedText/ViewModel/DisplayedTextViewModelTests.swift index 91989b995..ff72e0d6a 100644 --- a/core/Sources/Common/DisplayedText/ViewModel/DisplayedTextViewModelTests.swift +++ b/core/Sources/Common/DisplayedText/ViewModel/DisplayedTextViewModelTests.swift @@ -10,9 +10,9 @@ import XCTest @testable import SparkCore final class DisplayedTextViewModelTests: XCTestCase { - + // MARK: - Tests Init - + func test_properties_after_init() { // GIVEN let textMock = "Hello" @@ -28,7 +28,7 @@ final class DisplayedTextViewModelTests: XCTestCase { attributedText: attributedTextMock, getDisplayedTextTypeUseCase: getDisplayedTextTypeUseCaseMock ) - + // THEN XCTAssertEqual(viewModel.displayedTextType, displayedTextTypeMock, @@ -42,7 +42,6 @@ final class DisplayedTextViewModelTests: XCTestCase { XCTAssertEqual(viewModel.containsText, displayedTextTypeMock.containsText, "Wrong containsText value") - // ** // GetDisplayedTextTypeUseCase diff --git a/core/Sources/Common/Foundation/Extension/CGFloat+ScaledMetricExtension.swift b/core/Sources/Common/Foundation/Extension/CGFloat+ScaledMetricExtension.swift index 5aee37fa0..ce40364ac 100644 --- a/core/Sources/Common/Foundation/Extension/CGFloat+ScaledMetricExtension.swift +++ b/core/Sources/Common/Foundation/Extension/CGFloat+ScaledMetricExtension.swift @@ -14,7 +14,7 @@ extension CGFloat { /// we add this the scaled metric multiplier value. /// This value must be multiplied with you want to make dynamic (width, height, padding, ...) /// - note: - Please use this value only for @ScaledMetric on SwiftUI - /// + /// /// **Example** /// This example shows how to create view this multiplier on SwiftUI View /// ```swift diff --git a/core/Sources/Common/Foundation/Extension/CGRect-Center.swift b/core/Sources/Common/Foundation/Extension/CGRect-Center.swift index 2cd9410bd..42f5bd647 100644 --- a/core/Sources/Common/Foundation/Extension/CGRect-Center.swift +++ b/core/Sources/Common/Foundation/Extension/CGRect-Center.swift @@ -11,12 +11,12 @@ import Foundation extension CGRect { /// Returns the center of the x-coordinate of the rect var centerX: CGFloat { - return (self.minX + self.maxX)/2 + return (self.minX + self.maxX) / 2 } /// Returns the center of the y-coordinate of the rect var centerY: CGFloat { - return (self.minY + self.maxY)/2 + return (self.minY + self.maxY) / 2 } /// The center point of the rect diff --git a/core/Sources/Common/Foundation/Extension/Optional+ExtensionTests.swift b/core/Sources/Common/Foundation/Extension/Optional+ExtensionTests.swift index dc567d00e..ff91c335b 100644 --- a/core/Sources/Common/Foundation/Extension/Optional+ExtensionTests.swift +++ b/core/Sources/Common/Foundation/Extension/Optional+ExtensionTests.swift @@ -50,7 +50,7 @@ final class OptionalExtensionTests: XCTestCase { func test_nil_array() { // GIVEN - let array: Array? = nil + let array: [Int]? = nil // WHEN let isEmptyOrNil = array.isEmptyOrNil @@ -61,7 +61,7 @@ final class OptionalExtensionTests: XCTestCase { func test_empty_array() { // GIVEN - let array: Array? = [] + let array: [Int]? = [] // WHEN let isEmptyOrNil = array.isEmptyOrNil @@ -72,7 +72,7 @@ final class OptionalExtensionTests: XCTestCase { func test_array() { // GIVEN - let array: Array? = [10, 22, 3] + let array: [Int]? = [10, 22, 3] // WHEN let isEmptyOrNil = array.isEmptyOrNil diff --git a/core/Sources/Common/Foundation/Extension/UIView-Closest.swift b/core/Sources/Common/Foundation/Extension/UIView-Closest.swift index 617fd3bc0..d425ad0d8 100644 --- a/core/Sources/Common/Foundation/Extension/UIView-Closest.swift +++ b/core/Sources/Common/Foundation/Extension/UIView-Closest.swift @@ -23,7 +23,7 @@ extension Array where Element == CGRect { let distances = self.map{ rect in rect.center.distance(to: location) } - let nearest = distances.enumerated().min { (left, right) in + let nearest = distances.enumerated().min { left, right in return left.element < right.element } return nearest?.offset diff --git a/core/Sources/Common/Foundation/Extension/UIViewClosestTests.swift b/core/Sources/Common/Foundation/Extension/UIViewClosestTests.swift index 98fd1eb6f..fec87177a 100644 --- a/core/Sources/Common/Foundation/Extension/UIViewClosestTests.swift +++ b/core/Sources/Common/Foundation/Extension/UIViewClosestTests.swift @@ -16,7 +16,7 @@ final class UIViewClosestTests: XCTestCase { let views = positions.map{ CGRect(x: $0, y: 10, width: 50, height: 50) }.map(UIView.init(frame:)) for (index, position) in positions.enumerated() { - let closestIndex = views.index(closestTo: CGPoint(x: position+50, y: 100)) + let closestIndex = views.index(closestTo: CGPoint(x: position + 50, y: 100)) XCTAssertEqual(closestIndex, index, "Expected \(String(describing: closestIndex)) to be equal to \(index)") } } diff --git a/core/Sources/Common/UIKit/Extension/NSLayoutConstraint/NSLayoutConstraint+MultiplierExtension.swift b/core/Sources/Common/UIKit/Extension/NSLayoutConstraint/NSLayoutConstraint+MultiplierExtension.swift index 1e50413e2..0e8018ddc 100644 --- a/core/Sources/Common/UIKit/Extension/NSLayoutConstraint/NSLayoutConstraint+MultiplierExtension.swift +++ b/core/Sources/Common/UIKit/Extension/NSLayoutConstraint/NSLayoutConstraint+MultiplierExtension.swift @@ -9,7 +9,7 @@ import UIKit extension NSLayoutConstraint { - + /// There is no native possibility to update the multiplier /// So we need to recreate the constraint with the new multiplier static func updateMultiplier( diff --git a/core/Sources/Common/UIKit/Extension/UITraitCollection/UITraitCollection-SizeAppearance.swift b/core/Sources/Common/UIKit/Extension/UITraitCollection/UITraitCollection-SizeAppearance.swift index f4bc645fe..87fefc727 100644 --- a/core/Sources/Common/UIKit/Extension/UITraitCollection/UITraitCollection-SizeAppearance.swift +++ b/core/Sources/Common/UIKit/Extension/UITraitCollection/UITraitCollection-SizeAppearance.swift @@ -8,7 +8,6 @@ import UIKit - extension UITraitCollection { func hasDifferentSizeCategory(comparedTo traitCollection: UITraitCollection?) -> Bool { self.preferredContentSizeCategory != traitCollection?.preferredContentSizeCategory diff --git a/core/Sources/Common/UIKit/Extension/UIView/UIView+AccessibilityExtension.swift b/core/Sources/Common/UIKit/Extension/UIView/UIView+AccessibilityExtension.swift index 485f667e5..75293e97f 100644 --- a/core/Sources/Common/UIKit/Extension/UIView/UIView+AccessibilityExtension.swift +++ b/core/Sources/Common/UIKit/Extension/UIView/UIView+AccessibilityExtension.swift @@ -9,7 +9,7 @@ import UIKit extension UIView { - + /// Insert or remove the trait on the current accessibilityTraits func accessibilityTraits(manage trait: UIAccessibilityTraits, insert: Bool) { if insert { diff --git a/core/Sources/Common/UIKit/GlobalExtension/NSLayoutConstraint/NSLayoutConstraint+Extension.swift b/core/Sources/Common/UIKit/GlobalExtension/NSLayoutConstraint/NSLayoutConstraint+Extension.swift index 1cf1acab1..be4bca941 100644 --- a/core/Sources/Common/UIKit/GlobalExtension/NSLayoutConstraint/NSLayoutConstraint+Extension.swift +++ b/core/Sources/Common/UIKit/GlobalExtension/NSLayoutConstraint/NSLayoutConstraint+Extension.swift @@ -51,7 +51,6 @@ extension NSLayoutConstraint { constraints.append(from.trailingAnchor.constraint(equalTo: to.trailingAnchor, constant: -insets.right)) } - return constraints } diff --git a/core/Sources/Components/Badge/AccessibilityIdentifier/BadgeAccessibilityIdentifier.swift b/core/Sources/Components/Badge/AccessibilityIdentifier/BadgeAccessibilityIdentifier.swift index 674395518..b074f5df1 100644 --- a/core/Sources/Components/Badge/AccessibilityIdentifier/BadgeAccessibilityIdentifier.swift +++ b/core/Sources/Components/Badge/AccessibilityIdentifier/BadgeAccessibilityIdentifier.swift @@ -8,7 +8,6 @@ import Foundation - public enum BadgeAccessibilityIdentifier { // MARK: - Properties diff --git a/core/Sources/Components/Badge/UseCase/GetIntentColors/BadgeGetIntentColorsUseCase.swift b/core/Sources/Components/Badge/UseCase/GetIntentColors/BadgeGetIntentColorsUseCase.swift index f73b8fb98..d4de0f39a 100644 --- a/core/Sources/Components/Badge/UseCase/GetIntentColors/BadgeGetIntentColorsUseCase.swift +++ b/core/Sources/Components/Badge/UseCase/GetIntentColors/BadgeGetIntentColorsUseCase.swift @@ -15,7 +15,7 @@ protocol BadgeGetIntentColorsUseCaseable { } final class BadgeGetIntentColorsUseCase: BadgeGetIntentColorsUseCaseable { - + // MARK: - Methods func execute(intentType: BadgeIntentType, @@ -77,7 +77,7 @@ final class BadgeGetIntentColorsUseCase: BadgeGetIntentColorsUseCaseable { borderColor: surfaceColor, foregroundColor: colors.feedback.onSuccess ) - + } } } diff --git a/core/Sources/Components/Badge/View/SwiftUI/BadgeView.swift b/core/Sources/Components/Badge/View/SwiftUI/BadgeView.swift index 3f2e9fa7f..4b1569527 100644 --- a/core/Sources/Components/Badge/View/SwiftUI/BadgeView.swift +++ b/core/Sources/Components/Badge/View/SwiftUI/BadgeView.swift @@ -11,7 +11,7 @@ import SwiftUI /// This is SwiftUI badge view to show notifications count /// /// Badge border and offsets of it's text are **@ScaledMetric** variables and alligned to user's **Accessibility** -/// +/// /// **Example** /// This example shows how to create view with horizontal alignment of Badge /// ```swift diff --git a/core/Sources/Components/Badge/View/UIKit/BadgeUIView.swift b/core/Sources/Components/Badge/View/UIKit/BadgeUIView.swift index 21f193721..cf1768178 100644 --- a/core/Sources/Components/Badge/View/UIKit/BadgeUIView.swift +++ b/core/Sources/Components/Badge/View/UIKit/BadgeUIView.swift @@ -161,10 +161,8 @@ public class BadgeUIView: UIView { private func setupBadgeText() { self.addSubview(textLabel) - self.textLabel.setContentCompressionResistancePriority(.required, - for: .vertical) - self.textLabel.setContentCompressionResistancePriority(.required, - for: .horizontal) + self.textLabel.setContentCompressionResistancePriority(.required, for: .vertical) + self.textLabel.setContentCompressionResistancePriority(.required, for: .horizontal) self.textLabel.accessibilityIdentifier = BadgeAccessibilityIdentifier.text self.textLabel.adjustsFontForContentSizeCategory = true self.textLabel.textAlignment = .center @@ -392,14 +390,12 @@ extension BadgeUIView { public extension BadgeUIView { func setLabelContentCompressionResistancePriority(_ priority: UILayoutPriority, for axis: NSLayoutConstraint.Axis) { - self.textLabel.setContentCompressionResistancePriority(priority, - for: axis) + self.textLabel.setContentCompressionResistancePriority(priority, for: axis) } func setLabelContentHuggingPriority(_ priority: UILayoutPriority, for axis: NSLayoutConstraint.Axis) { - self.textLabel.setContentHuggingPriority(priority, - for: axis) + self.textLabel.setContentHuggingPriority(priority, for: axis) } } diff --git a/core/Sources/Components/Badge/ViewModel/BadgeViewModel.swift b/core/Sources/Components/Badge/ViewModel/BadgeViewModel.swift index baf4dd739..2a903df1e 100644 --- a/core/Sources/Components/Badge/ViewModel/BadgeViewModel.swift +++ b/core/Sources/Components/Badge/ViewModel/BadgeViewModel.swift @@ -29,7 +29,7 @@ import SwiftUI final class BadgeViewModel: ObservableObject { // MARK: - Badge Configuration Public Properties - var value: Int? = nil { + var value: Int? { didSet { self.updateText() } diff --git a/core/Sources/Components/Badge/ViewModel/BadgeViewModelTests.swift b/core/Sources/Components/Badge/ViewModel/BadgeViewModelTests.swift index bf9967121..663785bf4 100644 --- a/core/Sources/Components/Badge/ViewModel/BadgeViewModelTests.swift +++ b/core/Sources/Components/Badge/ViewModel/BadgeViewModelTests.swift @@ -106,9 +106,10 @@ final class BadgeViewModelTests: XCTestCase { let allPublishers = Publishers.Zip(publishers, sut.$textFont) - allPublishers.sink { _ in + allPublishers.sink(receiveValue: { _ in updateExpectation.fulfill() - }.store(in: &self.subscriptions) + }) + .store(in: &self.subscriptions) // When sut.theme = ThemeGeneratedMock.mocked() @@ -127,9 +128,10 @@ final class BadgeViewModelTests: XCTestCase { sut.$badgeHeight, sut.$offset) - publishers.sink { _ in + publishers.sink(receiveValue: { _ in updateExpectation.fulfill() - }.store(in: &self.subscriptions) + }) + .store(in: &self.subscriptions) // When sut.size = .small @@ -144,12 +146,12 @@ final class BadgeViewModelTests: XCTestCase { let updateExpectation = expectation(description: "Attributes updated") updateExpectation.expectedFulfillmentCount = 2 - let publishers = Publishers.Zip(sut.$textColor, - sut.$backgroundColor) + let publishers = Publishers.Zip(sut.$textColor, sut.$backgroundColor) - publishers.sink { _ in + publishers.sink(receiveValue: { _ in updateExpectation.fulfill() - }.store(in: &self.subscriptions) + }) + .store(in: &self.subscriptions) // When sut.intent = .alert @@ -164,9 +166,10 @@ final class BadgeViewModelTests: XCTestCase { let updateExpectation = expectation(description: "Attributes updated") updateExpectation.expectedFulfillmentCount = 2 - sut.$text.sink { _ in + sut.$text.sink(receiveValue: { _ in updateExpectation.fulfill() - }.store(in: &self.subscriptions) + }) + .store(in: &self.subscriptions) // When sut.value = 99 @@ -181,9 +184,10 @@ final class BadgeViewModelTests: XCTestCase { let updateExpectation = expectation(description: "Attributes updated") updateExpectation.expectedFulfillmentCount = 2 - sut.$text.sink { _ in + sut.$text.sink(receiveValue: { _ in updateExpectation.fulfill() - }.store(in: &self.subscriptions) + }) + .store(in: &self.subscriptions) // When sut.format = .overflowCounter(maxValue: 99) diff --git a/core/Sources/Components/BottomSheet/UIKit/UISheetPresentationController-customHeightDetent.swift b/core/Sources/Components/BottomSheet/UIKit/UISheetPresentationController-customHeightDetent.swift index 69136fb65..f13359331 100644 --- a/core/Sources/Components/BottomSheet/UIKit/UISheetPresentationController-customHeightDetent.swift +++ b/core/Sources/Components/BottomSheet/UIKit/UISheetPresentationController-customHeightDetent.swift @@ -22,11 +22,9 @@ public extension UISheetPresentationController.Detent { @available(iOS 16.0, *) static func expandedHeight(of view: UIView) -> UISheetPresentationController.Detent { return .custom { context in - let height = min( + return min( view.systemLayoutSizeFitting(UIView.layoutFittingExpandedSize).height, context.maximumDetentValue - 1) - - return height } } @@ -43,11 +41,9 @@ public extension UISheetPresentationController.Detent { @available(iOS 16.0, *) static func compressedHeight(of view: UIView) -> UISheetPresentationController.Detent { return .custom { context in - let height = min( + return min( view.systemLayoutSizeFitting(UIView.layoutFittingCompressedSize).height, context.maximumDetentValue - 1) - - return height } } diff --git a/core/Sources/Components/Button/UseCase/GetColors/ButtonGetColorsUseCase.swift b/core/Sources/Components/Button/UseCase/GetColors/ButtonGetColorsUseCase.swift index 3883cd2f8..46f262ab7 100644 --- a/core/Sources/Components/Button/UseCase/GetColors/ButtonGetColorsUseCase.swift +++ b/core/Sources/Components/Button/UseCase/GetColors/ButtonGetColorsUseCase.swift @@ -62,7 +62,7 @@ struct ButtonGetColorsUseCase: ButtonGetColorsUseCaseable { case .tinted: useCase = self.getTintedUseCase } - + return useCase.execute( intent: intent, colors: colors, diff --git a/core/Sources/Components/Button/UseCase/GetSpacings/ButtonGetSpacingsUseCaseTests.swift b/core/Sources/Components/Button/UseCase/GetSpacings/ButtonGetSpacingsUseCaseTests.swift index 679443e9e..8d5b67fcf 100644 --- a/core/Sources/Components/Button/UseCase/GetSpacings/ButtonGetSpacingsUseCaseTests.swift +++ b/core/Sources/Components/Button/UseCase/GetSpacings/ButtonGetSpacingsUseCaseTests.swift @@ -17,7 +17,7 @@ final class ButtonGetSpacingsUseCaseTests: XCTestCase { func test_execute() { // GIVEN let spacingMock = LayoutSpacingGeneratedMock.mocked() - + let useCase = ButtonGetSpacingsUseCase() // WHEN diff --git a/core/Sources/Components/Button/View/Common/ButtonScenarioSnapshotTests.swift b/core/Sources/Components/Button/View/Common/ButtonScenarioSnapshotTests.swift index 9d6046cb4..2651f3069 100644 --- a/core/Sources/Components/Button/View/Common/ButtonScenarioSnapshotTests.swift +++ b/core/Sources/Components/Button/View/Common/ButtonScenarioSnapshotTests.swift @@ -92,7 +92,7 @@ enum ButtonScenarioSnapshotTests: String, CaseIterable { return alignments.map { alignment -> ButtonConfigurationSnapshotTests in .init( scenario: self, - alignment: alignment, + alignment: alignment, content: .titleAndImage( "My Title", .mock(isSwiftUIComponent: isSwiftUIComponent) diff --git a/core/Sources/Components/Button/View/Common/IconButtonScenarioSnapshotTests.swift b/core/Sources/Components/Button/View/Common/IconButtonScenarioSnapshotTests.swift index a010af8ee..a14915545 100644 --- a/core/Sources/Components/Button/View/Common/IconButtonScenarioSnapshotTests.swift +++ b/core/Sources/Components/Button/View/Common/IconButtonScenarioSnapshotTests.swift @@ -58,7 +58,7 @@ enum IconButtonScenarioSnapshotTests: String, CaseIterable { let intents = ButtonIntent.allCases return intents.compactMap { intent -> IconButtonConfigurationSnapshotTests? in - guard let image = ImageEither.mock( + guard let image = ImageEither.mock( isSwiftUIComponent: isSwiftUIComponent, for: .normal ) else { @@ -92,7 +92,7 @@ enum IconButtonScenarioSnapshotTests: String, CaseIterable { let shapes = ButtonShape.allCases return shapes.compactMap { shape -> IconButtonConfigurationSnapshotTests? in - guard let image = ImageEither.mock( + guard let image = ImageEither.mock( isSwiftUIComponent: isSwiftUIComponent, for: .normal ) else { @@ -126,7 +126,7 @@ enum IconButtonScenarioSnapshotTests: String, CaseIterable { let sizes = ButtonSize.allCases return sizes.compactMap { size -> IconButtonConfigurationSnapshotTests? in - guard let image = ImageEither.mock( + guard let image = ImageEither.mock( isSwiftUIComponent: isSwiftUIComponent, for: .normal ) else { @@ -160,7 +160,7 @@ enum IconButtonScenarioSnapshotTests: String, CaseIterable { let variants = ButtonVariant.allCases return variants.compactMap { variant -> IconButtonConfigurationSnapshotTests? in - guard let image = ImageEither.mock( + guard let image = ImageEither.mock( isSwiftUIComponent: isSwiftUIComponent, for: .normal ) else { diff --git a/core/Sources/Components/Button/View/SwiftUI/Public/Button/ButtonView.swift b/core/Sources/Components/Button/View/SwiftUI/Public/Button/ButtonView.swift index 9d5cf7999..bfc31b8a6 100644 --- a/core/Sources/Components/Button/View/SwiftUI/Public/Button/ButtonView.swift +++ b/core/Sources/Components/Button/View/SwiftUI/Public/Button/ButtonView.swift @@ -30,7 +30,7 @@ public struct ButtonView: View { /// - size: The size of the button. /// - shape: The shape of the button. /// - alignment: The alignment of the button. - /// - action: The action of the button. + /// - action: The action of the button. public init( theme: Theme, intent: ButtonIntent, diff --git a/core/Sources/Components/Button/View/SwiftUI/Public/Icon/IconButtonView.swift b/core/Sources/Components/Button/View/SwiftUI/Public/Icon/IconButtonView.swift index 3423726ed..af2ab3ea2 100644 --- a/core/Sources/Components/Button/View/SwiftUI/Public/Icon/IconButtonView.swift +++ b/core/Sources/Components/Button/View/SwiftUI/Public/Icon/IconButtonView.swift @@ -6,7 +6,6 @@ // Copyright © 2023 Adevinta. All rights reserved. // - import SwiftUI import Foundation diff --git a/core/Sources/Components/Button/View/UIKit/Button/ButtonUIView.swift b/core/Sources/Components/Button/View/UIKit/Button/ButtonUIView.swift index fb8175f04..6e953b650 100644 --- a/core/Sources/Components/Button/View/UIKit/Button/ButtonUIView.swift +++ b/core/Sources/Components/Button/View/UIKit/Button/ButtonUIView.swift @@ -22,7 +22,7 @@ public final class ButtonUIView: ButtonMainUIView { let stackView = UIStackView( arrangedSubviews: [ - + self.imageContentView, self.titleLabel ] @@ -322,7 +322,7 @@ public final class ButtonUIView: ButtonMainUIView { internal override func isImageOnStateViewDidUpdate(_ isImage: Bool) { super.isImageOnStateViewDidUpdate(isImage) - self.imageContentView.isHidden = !isImage + self.imageContentView.isHidden = !isImage } private func updateAccessibilityLabel() { diff --git a/core/Sources/Components/Button/ViewModel/Button/ButtonViewModel.swift b/core/Sources/Components/Button/ViewModel/Button/ButtonViewModel.swift index 3a39a0b39..8ddcc74a6 100644 --- a/core/Sources/Components/Button/ViewModel/Button/ButtonViewModel.swift +++ b/core/Sources/Components/Button/ViewModel/Button/ButtonViewModel.swift @@ -61,7 +61,7 @@ class ButtonViewModel: ButtonMainViewModel { override func updateAll() { super.updateAll() - + self.alignmentDidUpdate() self.spacingsDidUpdate() self.titleFontDidUpdate() diff --git a/core/Sources/Components/Button/ViewModel/Main/ButtonMainViewModel.swift b/core/Sources/Components/Button/ViewModel/Main/ButtonMainViewModel.swift index 6b72b4800..4a598a9c4 100644 --- a/core/Sources/Components/Button/ViewModel/Main/ButtonMainViewModel.swift +++ b/core/Sources/Components/Button/ViewModel/Main/ButtonMainViewModel.swift @@ -106,7 +106,7 @@ class ButtonMainViewModel: ObservableObject { self.variant = variant self.size = size self.shape = shape - + self.getBorderUseCase = getBorderUseCase self.getColorsUseCase = getColorsUseCase self.getCurrentColorsUseCase = getCurrentColorsUseCase diff --git a/core/Sources/Components/Button/ViewModel/Main/ButtonMainViewModelTests.swift b/core/Sources/Components/Button/ViewModel/Main/ButtonMainViewModelTests.swift index 20a1e0115..949e29237 100644 --- a/core/Sources/Components/Button/ViewModel/Main/ButtonMainViewModelTests.swift +++ b/core/Sources/Components/Button/ViewModel/Main/ButtonMainViewModelTests.swift @@ -801,9 +801,9 @@ private final class Stub: ButtonMainViewModelStub { for frameworkType: FrameworkType = .uiKit, type: ButtonType = .button, intent: ButtonIntent = .main, - variant: ButtonVariant = .tinted, - size: ButtonSize = .medium, - shape: ButtonShape = .rounded + variant: ButtonVariant = .tinted, + size: ButtonSize = .medium, + shape: ButtonShape = .rounded ) { // ** // Use Cases diff --git a/core/Sources/Components/Checkbox/Model/CheckboxGroupViewModel.swift b/core/Sources/Components/Checkbox/Model/CheckboxGroupViewModel.swift index 5bff7906d..cb38f024d 100644 --- a/core/Sources/Components/Checkbox/Model/CheckboxGroupViewModel.swift +++ b/core/Sources/Components/Checkbox/Model/CheckboxGroupViewModel.swift @@ -48,8 +48,7 @@ final class CheckboxGroupViewModel: ObservableObject { let textWidth: CGFloat = string?.widthOfString(usingFont: font) ?? 0 let spacing: CGFloat = CheckboxGetSpacingUseCase().execute(layoutSpacing: self.theme.layout.spacing, alignment: self.alignment) let checkboxControlSize: CGFloat = CheckboxView.Constants.checkboxSize - let width: CGFloat = checkboxControlSize + spacing + textWidth - return width + return checkboxControlSize + spacing + textWidth as CGFloat } } diff --git a/core/Sources/Components/Checkbox/Model/CheckboxGroupViewModelTests.swift b/core/Sources/Components/Checkbox/Model/CheckboxGroupViewModelTests.swift index 88280339c..cfa6affaf 100644 --- a/core/Sources/Components/Checkbox/Model/CheckboxGroupViewModelTests.swift +++ b/core/Sources/Components/Checkbox/Model/CheckboxGroupViewModelTests.swift @@ -69,7 +69,7 @@ final class CheckboxGroupViewModelTests: XCTestCase { let spacing: CGFloat = checkboxViewModel.spacing let checkboxControlSize: CGFloat = CheckboxView.Constants.checkboxSize let font: UIFont = checkboxViewModel.font.uiFont - let fontAttributes: [NSAttributedString.Key: Any] = [NSAttributedString.Key.font: font] + let fontAttributes: [NSAttributedString.Key: Any] = [NSAttributedString.Key.font: font] let textSize: CGSize? = (string as? NSString)?.size(withAttributes: fontAttributes) let textWidth: CGFloat = textSize?.width ?? 0 return checkboxControlSize + spacing + textWidth @@ -80,7 +80,7 @@ private extension Theme where Self == ThemeGeneratedMock { static var mock: Self { let theme = ThemeGeneratedMock() - theme.colors = ColorsGeneratedMock.mocked() + theme.colors = ColorsGeneratedMock.mocked() theme.layout = LayoutGeneratedMock.mocked() theme.dims = DimsGeneratedMock.mocked() theme.border = BorderGeneratedMock.mocked() diff --git a/core/Sources/Components/Checkbox/Model/CheckboxViewModel.swift b/core/Sources/Components/Checkbox/Model/CheckboxViewModel.swift index 28c20103f..7740b7ccc 100644 --- a/core/Sources/Components/Checkbox/Model/CheckboxViewModel.swift +++ b/core/Sources/Components/Checkbox/Model/CheckboxViewModel.swift @@ -11,7 +11,7 @@ import SwiftUI import UIKit final class CheckboxViewModel: ObservableObject { - + // MARK: - Internal properties @Published var text: Either @Published var checkedImage: Either @@ -21,7 +21,7 @@ final class CheckboxViewModel: ObservableObject { self.updateSpacing() } } - + @Published var selectionState: CheckboxSelectionState @Published var opacity: CGFloat @Published var spacing: CGFloat @@ -97,7 +97,7 @@ final class CheckboxViewModel: ObservableObject { private func updateOpacity() { self.opacity = self.isEnabled ? self.theme.dims.none : self.theme.dims.dim3 } - + private func updateSpacing() { self.spacing = spacingUseCase.execute(layoutSpacing: self.theme.layout.spacing, alignment: self.alignment) } diff --git a/core/Sources/Components/Checkbox/Model/CheckboxViewModelTests.swift b/core/Sources/Components/Checkbox/Model/CheckboxViewModelTests.swift index 5fd1a4929..69ed9f210 100644 --- a/core/Sources/Components/Checkbox/Model/CheckboxViewModelTests.swift +++ b/core/Sources/Components/Checkbox/Model/CheckboxViewModelTests.swift @@ -11,6 +11,7 @@ import SwiftUI import XCTest @testable import SparkCore +// swiftlint:disable force_unwrapping final class CheckboxViewModelTests: XCTestCase { var theme: ThemeGeneratedMock! @@ -98,10 +99,11 @@ final class CheckboxViewModelTests: XCTestCase { let expectation = expectation(description: "Colors are updates") - sut.$colors.sink { _ in + sut.$colors.sink(receiveValue: { _ in isColorsUpdated = true expectation.fulfill() - }.store(in: &cancellable) + }) + .store(in: &cancellable) await fulfillment(of: [expectation], timeout: 2.0) @@ -123,7 +125,8 @@ final class CheckboxViewModelTests: XCTestCase { return CheckboxViewModel( text: attributeText == nil ? .left(NSAttributedString("Text")) : .left(attributeText!), checkedImage: .left(self.checkedImage), - theme: self.theme, isEnabled: isEnabled, + theme: self.theme, + isEnabled: isEnabled, selectionState: .unselected ) } diff --git a/core/Sources/Components/Checkbox/TestHelper/CheckboxGroupScenarioSnapshotTests.swift b/core/Sources/Components/Checkbox/TestHelper/CheckboxGroupScenarioSnapshotTests.swift index 727da5a44..4d15c47d8 100644 --- a/core/Sources/Components/Checkbox/TestHelper/CheckboxGroupScenarioSnapshotTests.swift +++ b/core/Sources/Components/Checkbox/TestHelper/CheckboxGroupScenarioSnapshotTests.swift @@ -181,7 +181,7 @@ enum CheckboxGroupScenarioSnapshotTests: String, CaseIterable { } } } - + /// Test 5 /// /// Description: To test a11y sizes diff --git a/core/Sources/Components/Checkbox/TestHelper/CheckboxScenarioSnapshotTests.swift b/core/Sources/Components/Checkbox/TestHelper/CheckboxScenarioSnapshotTests.swift index f558ca616..5c7860199 100644 --- a/core/Sources/Components/Checkbox/TestHelper/CheckboxScenarioSnapshotTests.swift +++ b/core/Sources/Components/Checkbox/TestHelper/CheckboxScenarioSnapshotTests.swift @@ -59,7 +59,7 @@ enum CheckboxScenarioSnapshotTests: String, CaseIterable { selectionState: .selected, state: .enabled, alignment: .left, - text: "Hello World", + text: "Hello World", image: UIImage.mock, modes: Constants.Modes.all, sizes: Constants.Sizes.default diff --git a/core/Sources/Components/Checkbox/UseCase/CheckboxGetSpacingUseCaseTests.swift b/core/Sources/Components/Checkbox/UseCase/CheckboxGetSpacingUseCaseTests.swift index 26667dcb4..769feb868 100644 --- a/core/Sources/Components/Checkbox/UseCase/CheckboxGetSpacingUseCaseTests.swift +++ b/core/Sources/Components/Checkbox/UseCase/CheckboxGetSpacingUseCaseTests.swift @@ -14,21 +14,21 @@ final class CheckboxGetSpacingUseCaseTests: XCTestCase { var sut: CheckboxGetSpacingUseCase! var layoutSpacing: LayoutSpacingGeneratedMock! - + override func setUp() { self.layoutSpacing = LayoutSpacingGeneratedMock.mocked() self.sut = CheckboxGetSpacingUseCase() } - + func test_left_alignment_spacing() { let spacing = sut.execute(layoutSpacing: self.layoutSpacing, alignment: .left) - + XCTAssertEqual(spacing, self.layoutSpacing.medium) } func test_right_alignment_spacing() { let spacing = sut.execute(layoutSpacing: self.layoutSpacing, alignment: .right) - + XCTAssertEqual(spacing, self.layoutSpacing.xxxLarge) } } diff --git a/core/Sources/Components/Checkbox/View/CheckboxGroupItemDefault.swift b/core/Sources/Components/Checkbox/View/CheckboxGroupItemDefault.swift index 92ced2d03..766418e74 100644 --- a/core/Sources/Components/Checkbox/View/CheckboxGroupItemDefault.swift +++ b/core/Sources/Components/Checkbox/View/CheckboxGroupItemDefault.swift @@ -68,7 +68,7 @@ public struct CheckboxGroupItemDefault: CheckboxGroupItemProtocol, Hashable { self.isEnabled = isEnabled self.state = isEnabled ? .enabled : .disabled } - + public static func == (lhs: CheckboxGroupItemDefault, rhs: CheckboxGroupItemDefault) -> Bool { lhs.id == rhs.id } diff --git a/core/Sources/Components/Checkbox/View/SwiftUI/CheckboxGroupView.swift b/core/Sources/Components/Checkbox/View/SwiftUI/CheckboxGroupView.swift index 9b3e535d7..9673baf2d 100644 --- a/core/Sources/Components/Checkbox/View/SwiftUI/CheckboxGroupView.swift +++ b/core/Sources/Components/Checkbox/View/SwiftUI/CheckboxGroupView.swift @@ -22,11 +22,10 @@ public struct CheckboxGroupView: View { @ScaledMetric private var spacingSmall: CGFloat @ScaledMetric private var spacingLarge: CGFloat @ScaledMetric private var checkboxSelectedBorderWidth: CGFloat - + @State private var viewWidth: CGFloat = 0 @State private var isScrollableHStack: Bool = true - // MARK: - Initialization /// Initialize a group of one or multiple checkboxes. diff --git a/core/Sources/Components/Checkbox/View/SwiftUI/CheckboxView.swift b/core/Sources/Components/Checkbox/View/SwiftUI/CheckboxView.swift index cfd5d343e..23179bf91 100644 --- a/core/Sources/Components/Checkbox/View/SwiftUI/CheckboxView.swift +++ b/core/Sources/Components/Checkbox/View/SwiftUI/CheckboxView.swift @@ -42,7 +42,7 @@ public struct CheckboxView: View { @ObservedObject var viewModel: CheckboxViewModel // MARK: - Private Properties - + @Namespace private var namespace @ScaledMetric var checkboxSize: CGFloat = Constants.checkboxSize @@ -124,7 +124,7 @@ public struct CheckboxView: View { } } - @ViewBuilder + @ViewBuilder private var checkboxView: some View { if self.selectionState == .selected { self.checkbox().accessibilityAddTraits(.isSelected) @@ -192,7 +192,7 @@ public struct CheckboxView: View { } } - @ViewBuilder + @ViewBuilder private var contentView: some View { HStack(spacing: 0) { switch self.viewModel.alignment { diff --git a/core/Sources/Components/Checkbox/View/UIKit/CheckboxControlUIView.swift b/core/Sources/Components/Checkbox/View/UIKit/CheckboxControlUIView.swift index f97681b72..edac1007a 100644 --- a/core/Sources/Components/Checkbox/View/UIKit/CheckboxControlUIView.swift +++ b/core/Sources/Components/Checkbox/View/UIKit/CheckboxControlUIView.swift @@ -55,7 +55,6 @@ class CheckboxControlUIView: UIView { } } - // MARK: - Private Properties. @ScaledUIMetric private var cornerRadius: CGFloat = Constants.cornerRadius @ScaledUIMetric private var cornerRadiusPressed: CGFloat = Constants.cornerRadiusPressed @@ -105,8 +104,8 @@ class CheckboxControlUIView: UIView { view.frame = CGRect( x: -self.lineWidthPressed, y: -self.lineWidthPressed, - width: self.controlSize + 2*self.lineWidthPressed, - height: self.controlSize + 2*self.lineWidthPressed + width: self.controlSize + 2 * self.lineWidthPressed, + height: self.controlSize + 2 * self.lineWidthPressed ) view.layer.borderWidth = self.lineWidthPressed view.layer.borderColor = self.colors.pressedBorderColor.uiColor.cgColor @@ -115,7 +114,7 @@ class CheckboxControlUIView: UIView { override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { super.traitCollectionDidChange(previousTraitCollection) - + if traitCollection.preferredContentSizeCategory != previousTraitCollection?.preferredContentSizeCategory { let traitCollection = self.traitCollection self._cornerRadius.update(traitCollection: traitCollection) @@ -151,7 +150,7 @@ class CheckboxControlUIView: UIView { if self.isHighlighted { let path = UIBezierPath(roundedRect: rect, cornerRadius: self.cornerRadius) let color = self.colors.pressedBorderColor.uiColor - path.lineWidth = self.lineWidth/2 + path.lineWidth = self.lineWidth / 2 color.setStroke() ctx.setStrokeColor(color.cgColor) path.stroke() @@ -159,7 +158,7 @@ class CheckboxControlUIView: UIView { switch self.selectionState { case .unselected: - let strokeRectangle = rect.insetBy(dx: self.lineWidth/2, dy: self.lineWidth/2) + let strokeRectangle = rect.insetBy(dx: self.lineWidth / 2, dy: self.lineWidth / 2) let strokePath = UIBezierPath(roundedRect: strokeRectangle, cornerRadius: self.cornerRadius) let strokeColor = self.colors.borderColor.uiColor strokePath.lineWidth = self.lineWidth diff --git a/core/Sources/Components/Checkbox/View/UIKit/CheckboxGroupUIView.swift b/core/Sources/Components/Checkbox/View/UIKit/CheckboxGroupUIView.swift index a893ffae9..fb8a4999a 100644 --- a/core/Sources/Components/Checkbox/View/UIKit/CheckboxGroupUIView.swift +++ b/core/Sources/Components/Checkbox/View/UIKit/CheckboxGroupUIView.swift @@ -236,7 +236,7 @@ public final class CheckboxGroupUIView: UIControl { private func setupItemsStackView() { self.updateLayout() - + for item in self.items { var content: Either @@ -244,7 +244,7 @@ public final class CheckboxGroupUIView: UIControl { if let text = item.title { content = .left(NSAttributedString(string: text)) } else { - content = .left(item.attributedTitle) + content = .left(item.attributedTitle) } let checkbox = CheckboxUIView( @@ -258,7 +258,7 @@ public final class CheckboxGroupUIView: UIControl { ) checkbox.accessibilityIdentifier = CheckboxAccessibilityIdentifier.checkboxGroupItem(item.id) - checkbox.publisher.sink { [weak self] in + checkbox.publisher.sink(receiveValue: { [weak self] in guard let self, let index = self.items.firstIndex(where: { $0.id == item.id}) @@ -270,7 +270,7 @@ public final class CheckboxGroupUIView: UIControl { self.delegate?.checkboxGroup(self, didChangeSelection: self.items) self.subject.send(self.items) self.sendActions(for: .valueChanged) - } + }) .store(in: &self.subscriptions) self.itemsStackView.addArrangedSubview(checkbox) @@ -304,7 +304,7 @@ public final class CheckboxGroupUIView: UIControl { self.spacingView.heightAnchor.constraint(equalToConstant: self.spacingSmall), - self.itemsStackView.heightAnchor.constraint(equalTo: self.scrollView.heightAnchor, constant: -2*self.padding), + self.itemsStackView.heightAnchor.constraint(equalTo: self.scrollView.heightAnchor, constant: -2 * self.padding), constraint, self.scrollView.topAnchor.constraint(equalTo: self.titleStackView.bottomAnchor, constant: -self.padding), @@ -315,7 +315,7 @@ public final class CheckboxGroupUIView: UIControl { } } -//MARK: - Updates +// MARK: - Updates extension CheckboxGroupUIView { public func updateItems(_ items: [any CheckboxGroupItemProtocol]) { @@ -338,7 +338,7 @@ extension CheckboxGroupUIView { private func updateTitle() { if let title = self.title, !title.isEmpty { self.titleLabel.text = title - self.spacingView.isHidden = false + self.spacingView.isHidden = false self.titleLabel.isHidden = false } else { self.spacingView.isHidden = true diff --git a/core/Sources/Components/Checkbox/View/UIKit/CheckboxGroupUIViewActionTests.swift b/core/Sources/Components/Checkbox/View/UIKit/CheckboxGroupUIViewActionTests.swift index eed3c1753..847ee1d1b 100644 --- a/core/Sources/Components/Checkbox/View/UIKit/CheckboxGroupUIViewActionTests.swift +++ b/core/Sources/Components/Checkbox/View/UIKit/CheckboxGroupUIViewActionTests.swift @@ -15,9 +15,10 @@ final class CheckboxGroupUIViewActionTests: TestCase { // MARK: Private Properties private var theme: Theme! private var subscriptions: Set! + // swiftlint:disable weak_delegate private var delegate: CheckboxGroupUIViewDelegateGeneratedMock! private var items: [any CheckboxGroupItemProtocol] = [ - CheckboxGroupItemDefault(title: "Apple", id: "1", selectionState: .selected, isEnabled: true), + CheckboxGroupItemDefault(title: "Apple", id: "1", selectionState: .selected, isEnabled: true), CheckboxGroupItemDefault(title: "Cake", id: "2", selectionState: .indeterminate, isEnabled: true), CheckboxGroupItemDefault(title: "Fish", id: "3", selectionState: .unselected, isEnabled: true), CheckboxGroupItemDefault(title: "Fruit", id: "4", selectionState: .unselected, isEnabled: true), @@ -40,10 +41,11 @@ final class CheckboxGroupUIViewActionTests: TestCase { var selectionState: CheckboxSelectionState = .indeterminate - sut.publisher.sink { items in + sut.publisher.sink(receiveValue: { items in selectionState = items[0].selectionState exp.fulfill() - }.store(in: &self.subscriptions) + }) + .store(in: &self.subscriptions) sut.checkboxes[0].sendActions(for: .touchUpInside) diff --git a/core/Sources/Components/Checkbox/View/UIKit/CheckboxUIView.swift b/core/Sources/Components/Checkbox/View/UIKit/CheckboxUIView.swift index 1cdab5dda..c6c2abc3f 100644 --- a/core/Sources/Components/Checkbox/View/UIKit/CheckboxUIView.swift +++ b/core/Sources/Components/Checkbox/View/UIKit/CheckboxUIView.swift @@ -51,11 +51,11 @@ public final class CheckboxUIView: UIControl { private var checkboxSelectionStateSubject = PassthroughSubject() @ScaledUIMetric private var checkboxSize: CGFloat = CheckboxControlUIView.Constants.size @ScaledUIMetric private var spacing: CGFloat - + private var checkboxSizeConstraint: NSLayoutConstraint? private var textObserver: NSKeyValueObservation? private var attributedTextObserver: NSKeyValueObservation? - + // MARK: - Public properties. /// Changes to the checbox state are published to the publisher. @@ -159,8 +159,7 @@ public final class CheckboxUIView: UIControl { set { if newValue == true { self.selectionState = .selected - } - else { + } else { self.selectionState = .unselected } } @@ -266,7 +265,7 @@ public final class CheckboxUIView: UIControl { self.addActions() self.addObservers() } - + // MARK: - Methods private func addActions() { let toggleAction = UIAction { [weak self] _ in @@ -284,7 +283,7 @@ public final class CheckboxUIView: UIControl { } private func addObservers() { - self.textObserver = textLabel.observe(\UILabel.text, options: [.new, .old]) { [weak self] (label, observedChange) in + self.textObserver = textLabel.observe(\UILabel.text, options: [.new, .old]) { [weak self] label, observedChange in if let newText = observedChange.newValue, let oldText = observedChange.oldValue, newText != oldText { @@ -292,7 +291,7 @@ public final class CheckboxUIView: UIControl { } } - self.attributedTextObserver = textLabel.observe(\UILabel.attributedText, options: [.new, .old]) { [weak self] (label, observedChange) in + self.attributedTextObserver = textLabel.observe(\UILabel.attributedText, options: [.new, .old]) { [weak self] label, observedChange in if let newText = observedChange.newValue, let oldText = observedChange.oldValue, newText != oldText { @@ -365,7 +364,7 @@ public final class CheckboxUIView: UIControl { guard let self else { return } self.controlView.selectionIcon = icon.leftValue } - + self.viewModel.$spacing.subscribe(in: &self.cancellables) { [weak self] spacing in guard let self = self else { return } self._spacing.wrappedValue = spacing diff --git a/core/Sources/Components/Checkbox/View/UIKit/CheckboxUIViewSnapshotTests.swift b/core/Sources/Components/Checkbox/View/UIKit/CheckboxUIViewSnapshotTests.swift index 71bbb4ec9..88ec57020 100644 --- a/core/Sources/Components/Checkbox/View/UIKit/CheckboxUIViewSnapshotTests.swift +++ b/core/Sources/Components/Checkbox/View/UIKit/CheckboxUIViewSnapshotTests.swift @@ -23,7 +23,7 @@ final class CheckboxUIViewSnapshotTests: UIKitComponentSnapshotTestCase { for scenario in scenarios { let configurations = scenario.configuration() - + for configuration in configurations { let view = CheckboxUIView( diff --git a/core/Sources/Components/Chip/Model/ChipIntentColors.swift b/core/Sources/Components/Chip/Model/ChipIntentColors.swift index f7bff83f3..147689472 100644 --- a/core/Sources/Components/Chip/Model/ChipIntentColors.swift +++ b/core/Sources/Components/Chip/Model/ChipIntentColors.swift @@ -12,7 +12,7 @@ import Foundation struct ChipIntentColors { // MARK: - Properties - + let border: any ColorToken let text: any ColorToken let selectedText: any ColorToken diff --git a/core/Sources/Components/Chip/Model/ChipStateColors.swift b/core/Sources/Components/Chip/Model/ChipStateColors.swift index d9643f9be..378e85f01 100644 --- a/core/Sources/Components/Chip/Model/ChipStateColors.swift +++ b/core/Sources/Components/Chip/Model/ChipStateColors.swift @@ -24,7 +24,7 @@ struct ChipStateColors { self.foreground = foreground self.opacity = opacity } - + } extension ChipStateColors: Equatable { diff --git a/core/Sources/Components/Chip/UseCase/ChipGetOutlinedIntentColorsUseCase.swift b/core/Sources/Components/Chip/UseCase/ChipGetOutlinedIntentColorsUseCase.swift index 734679a98..afd14617e 100644 --- a/core/Sources/Components/Chip/UseCase/ChipGetOutlinedIntentColorsUseCase.swift +++ b/core/Sources/Components/Chip/UseCase/ChipGetOutlinedIntentColorsUseCase.swift @@ -36,7 +36,7 @@ struct ChipGetOutlinedIntentColorsUseCase: ChipGetIntentColorsUseCasable { pressedBackground: colors.main.main.opacity(opacity), selectedBackground: colors.main.mainContainer ) - + case .support: return .init( border: colors.support.support, text: colors.support.support, @@ -45,7 +45,7 @@ struct ChipGetOutlinedIntentColorsUseCase: ChipGetIntentColorsUseCasable { pressedBackground: colors.support.support.opacity(opacity), selectedBackground: colors.support.supportContainer ) - + case .surface: return .init( border: colors.base.surface, text: colors.base.surface, @@ -54,7 +54,7 @@ struct ChipGetOutlinedIntentColorsUseCase: ChipGetIntentColorsUseCasable { pressedBackground: colors.base.surface.opacity(opacity), selectedBackground: colors.base.surface ) - + case .neutral: return .init( border: colors.feedback.neutral, text: colors.feedback.neutral, @@ -63,7 +63,7 @@ struct ChipGetOutlinedIntentColorsUseCase: ChipGetIntentColorsUseCasable { pressedBackground: colors.feedback.neutral.opacity(opacity), selectedBackground: colors.feedback.neutralContainer ) - + case .info: return .init( border: colors.feedback.info, text: colors.feedback.info, @@ -72,7 +72,7 @@ struct ChipGetOutlinedIntentColorsUseCase: ChipGetIntentColorsUseCasable { pressedBackground: colors.feedback.info.opacity(opacity), selectedBackground: colors.feedback.infoContainer ) - + case .success: return .init( border: colors.feedback.success, text: colors.feedback.success, @@ -81,7 +81,7 @@ struct ChipGetOutlinedIntentColorsUseCase: ChipGetIntentColorsUseCasable { pressedBackground: colors.feedback.success.opacity(opacity), selectedBackground: colors.feedback.successContainer ) - + case .alert: return .init( border: colors.feedback.alert, text: colors.feedback.onAlertContainer, @@ -90,7 +90,7 @@ struct ChipGetOutlinedIntentColorsUseCase: ChipGetIntentColorsUseCasable { pressedBackground: colors.feedback.alert.opacity(opacity), selectedBackground: colors.feedback.alertContainer ) - + case .danger: return .init( border: colors.feedback.error, text: colors.feedback.error, @@ -99,7 +99,7 @@ struct ChipGetOutlinedIntentColorsUseCase: ChipGetIntentColorsUseCasable { pressedBackground: colors.feedback.error.opacity(opacity), selectedBackground: colors.feedback.errorContainer ) - + case .accent: return .init( border: colors.accent.accent, text: colors.accent.accent, @@ -108,7 +108,7 @@ struct ChipGetOutlinedIntentColorsUseCase: ChipGetIntentColorsUseCasable { pressedBackground: colors.accent.accent.opacity(opacity), selectedBackground: colors.accent.accentContainer ) - + case .basic: return .init( border: colors.basic.basic, text: colors.basic.basic, diff --git a/core/Sources/Components/Chip/View/ChipViewModelTests.swift b/core/Sources/Components/Chip/View/ChipViewModelTests.swift index b2c98d36e..02d15096a 100644 --- a/core/Sources/Components/Chip/View/ChipViewModelTests.swift +++ b/core/Sources/Components/Chip/View/ChipViewModelTests.swift @@ -49,9 +49,10 @@ final class ChipViewModelTests: XCTestCase { let updateExpectation = expectation(description: "Colors and border status updated") updateExpectation.expectedFulfillmentCount = 2 - self.sut.$colors.sink { _ in + self.sut.$colors.sink(receiveValue: { _ in updateExpectation.fulfill() - }.store(in: &self.subscriptions) + }) + .store(in: &self.subscriptions) // When self.sut.set(variant: .dashed) @@ -66,14 +67,15 @@ final class ChipViewModelTests: XCTestCase { updateExpectation.expectedFulfillmentCount = 2 let publishers = Publishers.Zip4(self.sut.$padding, - self.sut.$spacing, - self.sut.$borderRadius, - self.sut.$font) + self.sut.$spacing, + self.sut.$borderRadius, + self.sut.$font) Publishers.Zip(self.sut.$colors, publishers) - .sink { _ in - updateExpectation.fulfill() - }.store(in: &self.subscriptions) + .sink(receiveValue: { _ in + updateExpectation.fulfill() + }) + .store(in: &self.subscriptions) // When self.sut.set(theme: ThemeGeneratedMock.mocked()) @@ -87,9 +89,10 @@ final class ChipViewModelTests: XCTestCase { let updateExpectation = expectation(description: "Colors updated") updateExpectation.expectedFulfillmentCount = 2 - self.sut.$colors.sink { _ in + self.sut.$colors.sink(receiveValue: { _ in updateExpectation.fulfill() - }.store(in: &self.subscriptions) + }) + .store(in: &self.subscriptions) // When self.sut.set(intent: .alert) @@ -105,10 +108,11 @@ final class ChipViewModelTests: XCTestCase { var spacings = [CGFloat]() - self.sut.$spacing.sink { spacing in + self.sut.$spacing.sink(receiveValue: { spacing in updateExpectation.fulfill() spacings.append(spacing) - }.store(in: &self.subscriptions) + }) + .store(in: &self.subscriptions) // When let newTheme = ThemeGeneratedMock.mocked() @@ -133,10 +137,11 @@ final class ChipViewModelTests: XCTestCase { var paddings = [CGFloat]() - self.sut.$padding.sink { padding in + self.sut.$padding.sink(receiveValue: { padding in updateExpectation.fulfill() paddings.append(padding) - }.store(in: &self.subscriptions) + }) + .store(in: &self.subscriptions) // When let newTheme = ThemeGeneratedMock.mocked() @@ -161,10 +166,11 @@ final class ChipViewModelTests: XCTestCase { var borderRadii = [CGFloat]() - self.sut.$borderRadius.sink { radius in + self.sut.$borderRadius.sink(receiveValue: { radius in updateExpectation.fulfill() borderRadii.append(radius) - }.store(in: &self.subscriptions) + }) + .store(in: &self.subscriptions) // When let newTheme = ThemeGeneratedMock.mocked() @@ -189,10 +195,11 @@ final class ChipViewModelTests: XCTestCase { var fonts = [TypographyFontToken]() - self.sut.$font.sink { font in + self.sut.$font.sink(receiveValue: { font in updateExpectation.fulfill() fonts.append(font) - }.store(in: &self.subscriptions) + }) + .store(in: &self.subscriptions) // When let newTheme = ThemeGeneratedMock.mocked() @@ -213,9 +220,10 @@ final class ChipViewModelTests: XCTestCase { let updateExpectation = expectation(description: "Colors updated") updateExpectation.expectedFulfillmentCount = 2 - self.sut.$colors.sink { font in + self.sut.$colors.sink(receiveValue: { font in updateExpectation.fulfill() - }.store(in: &self.subscriptions) + }) + .store(in: &self.subscriptions) // When let newTheme = ThemeGeneratedMock.mocked() @@ -240,7 +248,7 @@ final class ChipViewModelTests: XCTestCase { func test_not_bordered() throws { // When self.sut.set(variant: .tinted) - + // Then XCTAssertEqual(self.sut.isBordered, false) } @@ -254,5 +262,4 @@ final class ChipViewModelTests: XCTestCase { XCTAssertEqual(self.sut.isBordered, true) } } - } diff --git a/core/Sources/Components/Chip/View/CommonTests/ChipScenarioSnapshotTests.swift b/core/Sources/Components/Chip/View/CommonTests/ChipScenarioSnapshotTests.swift index 8771c753e..fcca9eeba 100644 --- a/core/Sources/Components/Chip/View/CommonTests/ChipScenarioSnapshotTests.swift +++ b/core/Sources/Components/Chip/View/CommonTests/ChipScenarioSnapshotTests.swift @@ -119,7 +119,7 @@ enum ChipScenarioSnapshotTests: String, CaseIterable { intent: .main, variant: variant, icon: .mock(isSwiftUIComponent: isSwiftUIComponent), - text: "Label", + text: "Label", badge: nil, state: state, modes: Constants.Modes.default, diff --git a/core/Sources/Components/Chip/View/CommonTests/ChipStateSnapshotTests.swift b/core/Sources/Components/Chip/View/CommonTests/ChipStateSnapshotTests.swift index ccca713cd..150f2494a 100644 --- a/core/Sources/Components/Chip/View/CommonTests/ChipStateSnapshotTests.swift +++ b/core/Sources/Components/Chip/View/CommonTests/ChipStateSnapshotTests.swift @@ -12,7 +12,7 @@ import Foundation extension ChipState { static let all: [ChipState] = - [ + [ .init(isEnabled: true, isPressed: false, isSelected: true), .init(isEnabled: false, isPressed: false, isSelected: true), .init(isEnabled: false, isPressed: false, isSelected: false), diff --git a/core/Sources/Components/Chip/View/SwiftUI/ChipView.swift b/core/Sources/Components/Chip/View/SwiftUI/ChipView.swift index f91afb51b..b90184107 100644 --- a/core/Sources/Components/Chip/View/SwiftUI/ChipView.swift +++ b/core/Sources/Components/Chip/View/SwiftUI/ChipView.swift @@ -128,13 +128,14 @@ public struct ChipView: View { } } - @ViewBuilder + @ViewBuilder private func borderedChipView() -> some View { if self.viewModel.isBordered { - self.chipView().chipBorder(width: self.borderWidth, - radius: self.borderRadius, - dashLength: self.borderDashLength(), - colorToken: self.viewModel.colors.border) + self.chipView().chipBorder( + width: self.borderWidth, + radius: self.borderRadius, + dashLength: self.borderDashLength(), + colorToken: self.viewModel.colors.border) } else { self.chipView() } diff --git a/core/Sources/Components/Chip/View/UIKit/ChipUIView.swift b/core/Sources/Components/Chip/View/UIKit/ChipUIView.swift index 9d02d8352..1bd07344c 100644 --- a/core/Sources/Components/Chip/View/UIKit/ChipUIView.swift +++ b/core/Sources/Components/Chip/View/UIKit/ChipUIView.swift @@ -16,7 +16,7 @@ public final class ChipUIView: UIControl { static let touchAreaTolerance: CGFloat = 100 } - //MARK: - Public properties + // MARK: - Public properties /// An optional icon on the Chip. The icon is always rendered to the left of the text public var icon: UIImage? { set { @@ -162,7 +162,7 @@ public final class ChipUIView: UIControl { return CGSize(width: width, height: self.height) } - //MARK: - Private properties + // MARK: - Private properties var hasAction: Bool { return self.allControlEvents == .touchUpInside @@ -226,10 +226,10 @@ public final class ChipUIView: UIControl { private var heightConstraint: NSLayoutConstraint? private var subscriptions = Set() - //MARK: - Initializers + // MARK: - Initializers /// Initializer of a chip containing only an icon. - /// + /// /// - Parameters: /// - theme: The theme. /// - intent: The intent of the chip, e.g. main, support @@ -287,7 +287,7 @@ public final class ChipUIView: UIControl { intent: intent, variant: variant, alignment: alignment, - optionalLabel: label , + optionalLabel: label, optionalIconImage: iconImage) } @@ -358,7 +358,7 @@ public final class ChipUIView: UIControl { self.viewModel.isPressed = false } - //MARK: - Private functions + // MARK: - Private functions /// Update all colors used private func setChipColors(_ chipColors: ChipStateColors) { self.stackView.backgroundColor = chipColors.background.uiColor @@ -390,7 +390,7 @@ public final class ChipUIView: UIControl { self._borderWidth.update(traitCollection: self.traitCollection) self._dashLength.update(traitCollection: self.traitCollection) } - + private func setupView() { self.translatesAutoresizingMaskIntoConstraints = false @@ -497,7 +497,7 @@ public final class ChipUIView: UIControl { self.padding = padding self.updateLayoutMargins() } - + self.viewModel.$borderRadius.subscribe(in: &self.subscriptions) { [weak self] borderRadius in guard let self else { return } self.borderRadius = borderRadius diff --git a/core/Sources/Components/FormField/Model/FormFieldViewModelTests.swift b/core/Sources/Components/FormField/Model/FormFieldViewModelTests.swift index 25737c155..c4e03a52f 100644 --- a/core/Sources/Components/FormField/Model/FormFieldViewModelTests.swift +++ b/core/Sources/Components/FormField/Model/FormFieldViewModelTests.swift @@ -79,11 +79,11 @@ final class FormFieldViewModelTests: XCTestCase { expectation.expectedFulfillmentCount = 2 var isTitleUpdated = false - - viewModel.$title.sink { title in + viewModel.$title.sink(receiveValue: { title in isTitleUpdated = title?.string.contains("*") ?? false expectation.fulfill() - }.store(in: &cancellable) + }) + .store(in: &cancellable) // When viewModel.isTitleRequired = true @@ -120,7 +120,7 @@ final class FormFieldViewModelTests: XCTestCase { description: NSAttributedString("Description"), isTitleRequired: false ) - + // When viewModel.feedbackState = .error diff --git a/core/Sources/Components/FormField/UseCase/FormfieldTitleUseCase.swift b/core/Sources/Components/FormField/UseCase/FormfieldTitleUseCase.swift index 5e36c91cc..d4c4d3d91 100644 --- a/core/Sources/Components/FormField/UseCase/FormfieldTitleUseCase.swift +++ b/core/Sources/Components/FormField/UseCase/FormfieldTitleUseCase.swift @@ -21,7 +21,7 @@ struct FormFieldTitleUseCase: FormFieldTitleUseCaseable { string: " *", attributes: [ NSAttributedString.Key.foregroundColor: colors.asterisk.uiColor, - NSAttributedString.Key.font : typography.caption.uiFont + NSAttributedString.Key.font: typography.caption.uiFont ] ) diff --git a/core/Sources/Components/FormField/View/UIKit/FormFieldUIView.swift b/core/Sources/Components/FormField/View/UIKit/FormFieldUIView.swift index d19baf481..32ceb415c 100644 --- a/core/Sources/Components/FormField/View/UIKit/FormFieldUIView.swift +++ b/core/Sources/Components/FormField/View/UIKit/FormFieldUIView.swift @@ -275,7 +275,8 @@ public final class FormFieldUIView: UIControl { self.viewModel.$title, self.viewModel.$titleFont, self.viewModel.$titleColor - ).subscribe(in: &self.cancellables) { [weak self] title, font, color in + ) + .subscribe(in: &self.cancellables) { [weak self] title, font, color in guard let self else { return } let labelHidden: Bool = (title?.string ?? "").isEmpty self.titleLabel.isHidden = labelHidden @@ -288,7 +289,8 @@ public final class FormFieldUIView: UIControl { self.viewModel.$description, self.viewModel.$descriptionFont, self.viewModel.$descriptionColor - ).subscribe(in: &self.cancellables) { [weak self] title, font, color in + ) + .subscribe(in: &self.cancellables) { [weak self] title, font, color in guard let self else { return } let labelHidden: Bool = (title?.string ?? "").isEmpty self.descriptionLabel.isHidden = labelHidden diff --git a/core/Sources/Components/FormField/View/UIKit/FormFieldUIViewSnapshotTests.swift b/core/Sources/Components/FormField/View/UIKit/FormFieldUIViewSnapshotTests.swift index 68a864929..99fda55fc 100644 --- a/core/Sources/Components/FormField/View/UIKit/FormFieldUIViewSnapshotTests.swift +++ b/core/Sources/Components/FormField/View/UIKit/FormFieldUIViewSnapshotTests.swift @@ -56,14 +56,13 @@ final class FormFieldUIViewSnapshotTests: UIKitComponentSnapshotTestCase { } static func makeSingleCheckbox() -> UIControl { - let view = CheckboxUIView( + return CheckboxUIView( theme: SparkTheme.shared, text: "Hello World", checkedImage: UIImage.mock, selectionState: .unselected, alignment: .left ) - return view } static func makeVerticalCheckbox() -> UIControl { @@ -82,18 +81,17 @@ final class FormFieldUIViewSnapshotTests: UIKitComponentSnapshotTestCase { } static func makeSingleRadioButton() -> UIControl { - let view = RadioButtonUIView( + return RadioButtonUIView( theme: SparkTheme.shared, intent: .info, id: "radiobutton", label: NSAttributedString(string: "Hello World"), isSelected: true ) - return view } static func makeVerticalRadioButton() -> UIControl { - let view = RadioButtonUIGroupView( + return RadioButtonUIGroupView( theme: SparkTheme.shared, intent: .danger, selectedID: "radiobutton", @@ -103,7 +101,6 @@ final class FormFieldUIViewSnapshotTests: UIKitComponentSnapshotTestCase { ], groupLayout: .vertical ) - return view } } diff --git a/core/Sources/Components/Icon/UseCase/IconGetColorUseCase.swift b/core/Sources/Components/Icon/UseCase/IconGetColorUseCase.swift index f0d626ef3..226145a9b 100644 --- a/core/Sources/Components/Icon/UseCase/IconGetColorUseCase.swift +++ b/core/Sources/Components/Icon/UseCase/IconGetColorUseCase.swift @@ -23,7 +23,7 @@ struct IconGetColorUseCase: IconGetColorUseCaseable { return colors.accent.accent case .basic: return colors.basic.basic - case .alert : + case .alert: return colors.feedback.alert case .error: return colors.feedback.error diff --git a/core/Sources/Components/Icon/View/Model/IconViewModelTests.swift b/core/Sources/Components/Icon/View/Model/IconViewModelTests.swift index f415ad808..51f34b904 100644 --- a/core/Sources/Components/Icon/View/Model/IconViewModelTests.swift +++ b/core/Sources/Components/Icon/View/Model/IconViewModelTests.swift @@ -114,7 +114,7 @@ final class IconViewModelTests: XCTestCase { self.getColorUseCase.executeWithIntentAndColorsCallsCount = 0 // THEN - + XCTAssertEqual(self.sut.intent, iconIntent, "Icon intent doesn't match the given intent") self.testGetColorUseCaseExecute( expectedCallsCount: 0 @@ -161,9 +161,10 @@ final class IconViewModelTests: XCTestCase { getColorUseCase: self.getColorUseCase ) - self.sut.$color.sink { _ in + self.sut.$color.sink(receiveValue: { _ in expectation.fulfill() - }.store(in: &self.cancellables) + }) + .store(in: &self.cancellables) // WHEN self.sut.set(intent: .support) @@ -183,9 +184,10 @@ final class IconViewModelTests: XCTestCase { getColorUseCase: self.getColorUseCase ) - self.sut.$size.sink { _ in + self.sut.$size.sink(receiveValue: { _ in expectation.fulfill() - }.store(in: &self.cancellables) + }) + .store(in: &self.cancellables) // WHEN self.sut.set(size: .extraLarge) diff --git a/core/Sources/Components/Icon/View/UIKit/IconUIViewSnapshotTests.swift b/core/Sources/Components/Icon/View/UIKit/IconUIViewSnapshotTests.swift index bb4344d33..e06d68625 100644 --- a/core/Sources/Components/Icon/View/UIKit/IconUIViewSnapshotTests.swift +++ b/core/Sources/Components/Icon/View/UIKit/IconUIViewSnapshotTests.swift @@ -12,7 +12,7 @@ import XCTest final class IconUIViewSnapshotTests: UIKitComponentSnapshotTestCase { - //MARK: Tests + // MARK: Tests func test_icon_intent() { for intent in IconIntent.allCases { let iconView = IconUIView( diff --git a/core/Sources/Components/ProgressBar/Enum/Indeterminate/ProgressBarIndeterminateAnimationTypeTests.swift b/core/Sources/Components/ProgressBar/Enum/Indeterminate/ProgressBarIndeterminateAnimationTypeTests.swift index b9dc351ee..bd42f515c 100644 --- a/core/Sources/Components/ProgressBar/Enum/Indeterminate/ProgressBarIndeterminateAnimationTypeTests.swift +++ b/core/Sources/Components/ProgressBar/Enum/Indeterminate/ProgressBarIndeterminateAnimationTypeTests.swift @@ -13,7 +13,7 @@ import SwiftUI final class ProgressBarIndeterminateAnimationTypeTests: XCTestCase { // MARK: - Tests - + func test_next() throws { // GIVEN let items: [( diff --git a/core/Sources/Components/ProgressBar/Model/Internal/Colors/Single/ProgressBarColors.swift b/core/Sources/Components/ProgressBar/Model/Internal/Colors/Single/ProgressBarColors.swift index 96e40f153..3fa9e9bc7 100644 --- a/core/Sources/Components/ProgressBar/Model/Internal/Colors/Single/ProgressBarColors.swift +++ b/core/Sources/Components/ProgressBar/Model/Internal/Colors/Single/ProgressBarColors.swift @@ -7,7 +7,7 @@ // struct ProgressBarColors: ProgressBarMainColors { - + // MARK: - Properties let trackBackgroundColorToken: any ColorToken diff --git a/core/Sources/Components/ProgressBar/View/SwiftUI/Internal/ProgressBarContentView.swift b/core/Sources/Components/ProgressBar/View/SwiftUI/Internal/ProgressBarContentView.swift index 656f10442..35de63944 100644 --- a/core/Sources/Components/ProgressBar/View/SwiftUI/Internal/ProgressBarContentView.swift +++ b/core/Sources/Components/ProgressBar/View/SwiftUI/Internal/ProgressBarContentView.swift @@ -40,7 +40,7 @@ struct ProgressBarContentView: View { // MARK: - View - public var body: some View { + var body: some View { ZStack() { // Track RoundedRectangle(cornerRadius: self.trackCornerRadius ?? 0) diff --git a/core/Sources/Components/ProgressBar/View/SwiftUI/Public/ProgressBarIndeterminateView.swift b/core/Sources/Components/ProgressBar/View/SwiftUI/Public/ProgressBarIndeterminateView.swift index feacca272..1e696dd9f 100644 --- a/core/Sources/Components/ProgressBar/View/SwiftUI/Public/ProgressBarIndeterminateView.swift +++ b/core/Sources/Components/ProgressBar/View/SwiftUI/Public/ProgressBarIndeterminateView.swift @@ -106,6 +106,7 @@ public struct ProgressBarIndeterminateView: View { every: Constants.Animation.duration, on: .main, in: .common - ).autoconnect() + ) + .autoconnect() } } diff --git a/core/Sources/Components/ProgressBar/View/SwiftUI/Public/ProgressBarView.swift b/core/Sources/Components/ProgressBar/View/SwiftUI/Public/ProgressBarView.swift index 6f49ae93f..fc853b6cb 100644 --- a/core/Sources/Components/ProgressBar/View/SwiftUI/Public/ProgressBarView.swift +++ b/core/Sources/Components/ProgressBar/View/SwiftUI/Public/ProgressBarView.swift @@ -9,20 +9,20 @@ import SwiftUI public struct ProgressBarView: View { - + // MARK: - Type alias - + private typealias AccessibilityIdentifier = ProgressBarAccessibilityIdentifier private typealias Constants = ProgressBarConstants - + // MARK: - Properties - + @ObservedObject var viewModel: ProgressBarViewModel - + private let value: CGFloat - + // MARK: - Initialization - + /// Initialize a new progress bar view /// - Parameters: /// - theme: The spark theme of the progress bar. @@ -43,9 +43,9 @@ public struct ProgressBarView: View { ) self.value = value } - + // MARK: - View - + public var body: some View { ProgressBarContentView( trackCornerRadius: self.viewModel.cornerRadius, diff --git a/core/Sources/Components/ProgressBar/ViewModel/Indeterminate/ProgressBarIndeterminateViewModel.swift b/core/Sources/Components/ProgressBar/ViewModel/Indeterminate/ProgressBarIndeterminateViewModel.swift index 86b189fd2..14e9346a3 100644 --- a/core/Sources/Components/ProgressBar/ViewModel/Indeterminate/ProgressBarIndeterminateViewModel.swift +++ b/core/Sources/Components/ProgressBar/ViewModel/Indeterminate/ProgressBarIndeterminateViewModel.swift @@ -54,7 +54,7 @@ final class ProgressBarIndeterminateViewModel: ProgressBarMainViewModel: ObservableObject { - + // MARK: - Properties private let frameworkType: FrameworkType diff --git a/core/Sources/Components/ProgressBar/ViewModel/Main/ProgressBarMainViewModelTests.swift b/core/Sources/Components/ProgressBar/ViewModel/Main/ProgressBarMainViewModelTests.swift index 07dcab671..1d8d20ff3 100644 --- a/core/Sources/Components/ProgressBar/ViewModel/Main/ProgressBarMainViewModelTests.swift +++ b/core/Sources/Components/ProgressBar/ViewModel/Main/ProgressBarMainViewModelTests.swift @@ -223,7 +223,8 @@ final class ProgressBarMainViewModelTests: XCTestCase { // ** // Use Cases - ProgressBarMainGetColorsUseCaseableMockTest.XCTAssert( stub.getColorsUseCaseMock, + ProgressBarMainGetColorsUseCaseableMockTest.XCTAssert( + stub.getColorsUseCaseMock, expectedNumberOfCalls: 1, givenIntent: intentMock, givenColors: newTheme.colors as? ColorsGeneratedMock, diff --git a/core/Sources/Components/ProgressTracker/Model/ProgressTrackerColors.swift b/core/Sources/Components/ProgressTracker/Model/ProgressTrackerColors.swift index b2e7b7de3..8338c4901 100644 --- a/core/Sources/Components/ProgressTracker/Model/ProgressTrackerColors.swift +++ b/core/Sources/Components/ProgressTracker/Model/ProgressTrackerColors.swift @@ -17,6 +17,6 @@ struct ProgressTrackerColors: Equatable { static func == (lhs: ProgressTrackerColors, rhs: ProgressTrackerColors) -> Bool { return lhs.background.equals(rhs.background) && lhs.outline.equals(rhs.outline) && - lhs.content.equals(rhs.content) + lhs.content.equals(rhs.content) } } diff --git a/core/Sources/Components/ProgressTracker/Model/ProgressTrackerContent.swift b/core/Sources/Components/ProgressTracker/Model/ProgressTrackerContent.swift index 64f9de4ad..f1d663df9 100644 --- a/core/Sources/Components/ProgressTracker/Model/ProgressTrackerContent.swift +++ b/core/Sources/Components/ProgressTracker/Model/ProgressTrackerContent.swift @@ -51,7 +51,7 @@ struct ProgressTrackerContent ProgressTrackerTintedColors { switch intent { - case .accent: + case .accent: return .init( background: colors.accent.accentContainer, content: colors.accent.onAccentContainer) diff --git a/core/Sources/Components/ProgressTracker/UseCase/ProgressTrackerGetTintedColorsUseCaseTests.swift b/core/Sources/Components/ProgressTracker/UseCase/ProgressTrackerGetTintedColorsUseCaseTests.swift index d7b7c6ba9..c332221fb 100644 --- a/core/Sources/Components/ProgressTracker/UseCase/ProgressTrackerGetTintedColorsUseCaseTests.swift +++ b/core/Sources/Components/ProgressTracker/UseCase/ProgressTrackerGetTintedColorsUseCaseTests.swift @@ -63,7 +63,6 @@ final class ProgressTrackerGetTintedColorsUseCaseTests: XCTestCase { } } - func test_colors_disabled() { // GIVEN diff --git a/core/Sources/Components/ProgressTracker/View/CommonTests/ProgressTrackerConfigurationSnapshotTests.swift b/core/Sources/Components/ProgressTracker/View/CommonTests/ProgressTrackerConfigurationSnapshotTests.swift index 4320330ec..a8f336f33 100644 --- a/core/Sources/Components/ProgressTracker/View/CommonTests/ProgressTrackerConfigurationSnapshotTests.swift +++ b/core/Sources/Components/ProgressTracker/View/CommonTests/ProgressTrackerConfigurationSnapshotTests.swift @@ -28,7 +28,6 @@ struct ProgressTrackerConfigurationSnapshotTests { let frame: CGRect? - init(scenario: ProgressTrackerScenarioSnapshotTests, intent: ProgressTrackerIntent, variant: ProgressTrackerVariant, diff --git a/core/Sources/Components/ProgressTracker/View/CommonTests/ProgressTrackerScenarioSnapshotTests.swift b/core/Sources/Components/ProgressTracker/View/CommonTests/ProgressTrackerScenarioSnapshotTests.swift index b43f7d830..e2092a613 100644 --- a/core/Sources/Components/ProgressTracker/View/CommonTests/ProgressTrackerScenarioSnapshotTests.swift +++ b/core/Sources/Components/ProgressTracker/View/CommonTests/ProgressTrackerScenarioSnapshotTests.swift @@ -75,7 +75,7 @@ enum ProgressTrackerScenarioSnapshotTests: String, CaseIterable { variant: .outlined, state: .normal, contentType: .icon, - size: .medium, + size: .medium, orientation: .horizontal, labels: [], modes: Constants.Modes.all, diff --git a/core/Sources/Components/ProgressTracker/View/ProgressTrackerIndicatorViewModel.swift b/core/Sources/Components/ProgressTracker/View/ProgressTrackerIndicatorViewModel.swift index 2decd7d5a..0fd96b133 100644 --- a/core/Sources/Components/ProgressTracker/View/ProgressTrackerIndicatorViewModel.swift +++ b/core/Sources/Components/ProgressTracker/View/ProgressTrackerIndicatorViewModel.swift @@ -9,7 +9,7 @@ import Foundation import SwiftUI -/// A view model for a single Progress Tracker Indicator +/// A view model for a single Progress Tracker Indicator final class ProgressTrackerIndicatorViewModel: ObservableObject { var theme: Theme { diff --git a/core/Sources/Components/ProgressTracker/View/ProgressTrackerIndicatorViewModelTests.swift b/core/Sources/Components/ProgressTracker/View/ProgressTrackerIndicatorViewModelTests.swift index 8fa48ba08..1bbb284df 100644 --- a/core/Sources/Components/ProgressTracker/View/ProgressTrackerIndicatorViewModelTests.swift +++ b/core/Sources/Components/ProgressTracker/View/ProgressTrackerIndicatorViewModelTests.swift @@ -52,9 +52,10 @@ final class ProgressTrackerIndicatorViewModelTests: XCTestCase { let expectation = expectation(description: "Expect colors to have been triggered") expectation.expectedFulfillmentCount = 2 - sut.$colors.sink { _ in + sut.$colors.sink(receiveValue: { _ in expectation.fulfill() - }.store(in: &self.cancellables) + }) + .store(in: &self.cancellables) // When sut.theme = self.theme @@ -69,9 +70,10 @@ final class ProgressTrackerIndicatorViewModelTests: XCTestCase { let expectation = expectation(description: "Expect colors to have been triggered twice") expectation.expectedFulfillmentCount = 2 - sut.$colors.sink { _ in + sut.$colors.sink(receiveValue: { _ in expectation.fulfill() - }.store(in: &self.cancellables) + }) + .store(in: &self.cancellables) // When sut.intent = .danger @@ -86,9 +88,10 @@ final class ProgressTrackerIndicatorViewModelTests: XCTestCase { let expectation = expectation(description: "Expect colors to have been triggered once") expectation.expectedFulfillmentCount = 1 - sut.$colors.sink { _ in + sut.$colors.sink(receiveValue: { _ in expectation.fulfill() - }.store(in: &self.cancellables) + }) + .store(in: &self.cancellables) // When sut.intent = .basic @@ -103,9 +106,10 @@ final class ProgressTrackerIndicatorViewModelTests: XCTestCase { let expectation = expectation(description: "Expect colors to have been triggered twice") expectation.expectedFulfillmentCount = 2 - sut.$colors.sink { _ in + sut.$colors.sink(receiveValue: { _ in expectation.fulfill() - }.store(in: &self.cancellables) + }) + .store(in: &self.cancellables) // When sut.variant = .tinted @@ -120,9 +124,10 @@ final class ProgressTrackerIndicatorViewModelTests: XCTestCase { let expectation = expectation(description: "Expect colors to have been triggered once") expectation.expectedFulfillmentCount = 1 - sut.$colors.sink { _ in + sut.$colors.sink(receiveValue: { _ in expectation.fulfill() - }.store(in: &self.cancellables) + }) + .store(in: &self.cancellables) // When sut.variant = .outlined @@ -137,9 +142,10 @@ final class ProgressTrackerIndicatorViewModelTests: XCTestCase { let expectation = expectation(description: "Expect colors to have been triggered twice") expectation.expectedFulfillmentCount = 2 - sut.$colors.sink { _ in + sut.$colors.sink(receiveValue: { _ in expectation.fulfill() - }.store(in: &self.cancellables) + }) + .store(in: &self.cancellables) // When sut.state = .pressed @@ -154,9 +160,10 @@ final class ProgressTrackerIndicatorViewModelTests: XCTestCase { let expectation = expectation(description: "Expect colors to have been triggered once") expectation.expectedFulfillmentCount = 1 - sut.$colors.sink { _ in + sut.$colors.sink(receiveValue: { _ in expectation.fulfill() - }.store(in: &self.cancellables) + }) + .store(in: &self.cancellables) // When sut.state = .pressed @@ -171,9 +178,10 @@ final class ProgressTrackerIndicatorViewModelTests: XCTestCase { let expectation = expectation(description: "Expect colors to have been triggered twice") expectation.expectedFulfillmentCount = 2 - sut.$colors.sink { _ in + sut.$colors.sink(receiveValue: { _ in expectation.fulfill() - }.store(in: &self.cancellables) + }) + .store(in: &self.cancellables) // When sut.set(selected: true) @@ -188,9 +196,10 @@ final class ProgressTrackerIndicatorViewModelTests: XCTestCase { let expectation = expectation(description: "Expect colors to have been triggered twice") expectation.expectedFulfillmentCount = 2 - sut.$colors.sink { _ in + sut.$colors.sink(receiveValue: { _ in expectation.fulfill() - }.store(in: &self.cancellables) + }) + .store(in: &self.cancellables) // When sut.set(enabled: false) @@ -205,9 +214,10 @@ final class ProgressTrackerIndicatorViewModelTests: XCTestCase { let expectation = expectation(description: "Expect colors to have been triggered twice") expectation.expectedFulfillmentCount = 2 - sut.$colors.sink { _ in + sut.$colors.sink(receiveValue: { _ in expectation.fulfill() - }.store(in: &self.cancellables) + }) + .store(in: &self.cancellables) // When sut.set(highlighted: true) diff --git a/core/Sources/Components/ProgressTracker/View/ProgressTrackerTrackViewModel.swift b/core/Sources/Components/ProgressTracker/View/ProgressTrackerTrackViewModel.swift index 2f04b1c0b..8a67ff7c5 100644 --- a/core/Sources/Components/ProgressTracker/View/ProgressTrackerTrackViewModel.swift +++ b/core/Sources/Components/ProgressTracker/View/ProgressTrackerTrackViewModel.swift @@ -10,7 +10,7 @@ import Foundation /// A view model for the Progress Tracker Track final class ProgressTrackerTrackViewModel: ObservableObject { - + var theme: Theme { didSet { self.updateLineColor() diff --git a/core/Sources/Components/ProgressTracker/View/ProgressTrackerTrackViewModelTests.swift b/core/Sources/Components/ProgressTracker/View/ProgressTrackerTrackViewModelTests.swift index 1497d2828..be58f4f4b 100644 --- a/core/Sources/Components/ProgressTracker/View/ProgressTrackerTrackViewModelTests.swift +++ b/core/Sources/Components/ProgressTracker/View/ProgressTrackerTrackViewModelTests.swift @@ -144,7 +144,6 @@ final class ProgressTrackerTrackViewModelTests: XCTestCase { wait(for: [expect], timeout: 1) } - private func sut( intent: ProgressTrackerIntent = .basic, isEnabled: Bool = true) -> ProgressTrackerTrackViewModel { diff --git a/core/Sources/Components/ProgressTracker/View/ProgressTrackerViewModel.swift b/core/Sources/Components/ProgressTracker/View/ProgressTrackerViewModel.swift index aef1582cd..056c28aab 100644 --- a/core/Sources/Components/ProgressTracker/View/ProgressTrackerViewModel.swift +++ b/core/Sources/Components/ProgressTracker/View/ProgressTrackerViewModel.swift @@ -70,7 +70,7 @@ final class ProgressTrackerViewModel, + content: ProgressTrackerContent, spacingUseCase: ProgressTrackerGetSpacingsUseCaseable = ProgressTrackerGetSpacingsUseCase() ) { self.orientation = orientation diff --git a/core/Sources/Components/ProgressTracker/View/ProgressTrackerViewModelTests.swift b/core/Sources/Components/ProgressTracker/View/ProgressTrackerViewModelTests.swift index 7108764b5..f7e6fa196 100644 --- a/core/Sources/Components/ProgressTracker/View/ProgressTrackerViewModelTests.swift +++ b/core/Sources/Components/ProgressTracker/View/ProgressTrackerViewModelTests.swift @@ -58,9 +58,11 @@ final class ProgressTrackerViewModelTests: XCTestCase { let expectation = expectation(description: "Wait for spacing & font change") expectation.expectedFulfillmentCount = 2 - Publishers.Zip(sut.$spacings, sut.$font).sink { _ in - expectation.fulfill() - }.store(in: &self.cancellables) + Publishers.Zip(sut.$spacings, sut.$font) + .sink(receiveValue: { _ in + expectation.fulfill() + }) + .store(in: &self.cancellables) // WHEN sut.theme = ThemeGeneratedMock.mocked() @@ -75,9 +77,10 @@ final class ProgressTrackerViewModelTests: XCTestCase { let expectation = expectation(description: "Wait for spacings to be change") expectation.expectedFulfillmentCount = 2 - sut.$spacings.sink { _ in + sut.$spacings.sink(receiveValue: { _ in expectation.fulfill() - }.store(in: &self.cancellables) + }) + .store(in: &self.cancellables) // WHEN sut.orientation = .horizontal @@ -174,7 +177,7 @@ final class ProgressTrackerViewModelTests: XCTestCase { sut.setIsEnabled(isEnabled: true, forIndex: 0) // THEN - XCTAssertEqual(sut.disabledIndices, Set(arrayLiteral: 1,2,3)) + XCTAssertEqual(sut.disabledIndices, Set(arrayLiteral: 1, 2, 3)) } func test_set_disabled_single_item() { diff --git a/core/Sources/Components/ProgressTracker/View/SwiftUI/ProgressTrackerContinuousGestureHandlerTests.swift b/core/Sources/Components/ProgressTracker/View/SwiftUI/ProgressTrackerContinuousGestureHandlerTests.swift index 7f84cc3ff..7e540a8d3 100644 --- a/core/Sources/Components/ProgressTracker/View/SwiftUI/ProgressTrackerContinuousGestureHandlerTests.swift +++ b/core/Sources/Components/ProgressTracker/View/SwiftUI/ProgressTrackerContinuousGestureHandlerTests.swift @@ -8,7 +8,6 @@ import Foundation - import SwiftUI import XCTest @@ -23,7 +22,7 @@ final class ProgressTrackerContinuousGestureHandlerTests: XCTestCase { set: { self._currentPageIndex = $0 } ) - private var _currentTouchedPageIndex: Int? = nil + private var _currentTouchedPageIndex: Int? lazy var currentTouchedPageIndex = Binding( get: { return self._currentTouchedPageIndex }, diff --git a/core/Sources/Components/ProgressTracker/View/SwiftUI/ProgressTrackerDiscreteGestureHandlerTests.swift b/core/Sources/Components/ProgressTracker/View/SwiftUI/ProgressTrackerDiscreteGestureHandlerTests.swift index 5f5ce3d92..9e9a22480 100644 --- a/core/Sources/Components/ProgressTracker/View/SwiftUI/ProgressTrackerDiscreteGestureHandlerTests.swift +++ b/core/Sources/Components/ProgressTracker/View/SwiftUI/ProgressTrackerDiscreteGestureHandlerTests.swift @@ -20,7 +20,7 @@ final class ProgressTrackerDiscreteGestureHandlerTests: XCTestCase { set: { self._currentPageIndex = $0 } ) - private var _currentTouchedPageIndex: Int? = nil + private var _currentTouchedPageIndex: Int? lazy var currentTouchedPageIndex = Binding( get: { return self._currentTouchedPageIndex }, diff --git a/core/Sources/Components/ProgressTracker/View/SwiftUI/ProgressTrackerGestureHandler.swift b/core/Sources/Components/ProgressTracker/View/SwiftUI/ProgressTrackerGestureHandler.swift index b0fee023a..fd8b664b3 100644 --- a/core/Sources/Components/ProgressTracker/View/SwiftUI/ProgressTrackerGestureHandler.swift +++ b/core/Sources/Components/ProgressTracker/View/SwiftUI/ProgressTrackerGestureHandler.swift @@ -32,7 +32,8 @@ class ProgressTrackerGestureHandler: ProgressTrackerGestureHandling { let frame: CGRect let disabledIndeces: Set - init(currentPageIndex: Binding, currentTouchedPageIndex: Binding, + init(currentPageIndex: Binding, + currentTouchedPageIndex: Binding, indicators: [CGRect], frame: CGRect, disabledIndices: Set @@ -59,14 +60,14 @@ final class ProgressTrackerIndependentGestureHandler: ProgressTrackerGestureHand } let index = self.indicators.index(closestTo: location) - if let index, + if let index, self.currentTouchedPageIndex == nil, !self.disabledIndeces.contains(index) { self.currentTouchedPageIndex = index } } - + override func onEnded(location: CGPoint) { guard self.frame.contains(location) else { self.currentTouchedPageIndex = nil @@ -79,7 +80,7 @@ final class ProgressTrackerIndependentGestureHandler: ProgressTrackerGestureHand self.currentPageIndex = currentTouchedPageIndex self.currentTouchedPageIndex = nil } - + override func onCancelled() { self.currentTouchedPageIndex = nil } @@ -114,7 +115,7 @@ final class ProgressTrackerDiscreteGestureHandler: ProgressTrackerGestureHandler self.currentTouchedPageIndex = currentPressedPageIndex } } - + override func onEnded(location: CGPoint) { guard self.frame.contains(location) else { self.currentTouchedPageIndex = nil @@ -126,7 +127,7 @@ final class ProgressTrackerDiscreteGestureHandler: ProgressTrackerGestureHandler self.currentPageIndex = currentTouchedPageIndex self.currentTouchedPageIndex = nil } - + override func onCancelled() { self.currentTouchedPageIndex = nil } diff --git a/core/Sources/Components/ProgressTracker/View/SwiftUI/ProgressTrackerHorizontalView.swift b/core/Sources/Components/ProgressTracker/View/SwiftUI/ProgressTrackerHorizontalView.swift index 5cde7c2eb..ac3e3086e 100644 --- a/core/Sources/Components/ProgressTracker/View/SwiftUI/ProgressTrackerHorizontalView.swift +++ b/core/Sources/Components/ProgressTracker/View/SwiftUI/ProgressTrackerHorizontalView.swift @@ -32,7 +32,7 @@ struct ProgressTrackerHorizontalView: View { return self.viewModel.spacings.trackIndicatorSpacing * self.scaleFactor } - //MARK: - Initialization + // MARK: - Initialization init( intent: ProgressTrackerIntent, variant: ProgressTrackerVariant, @@ -47,7 +47,7 @@ struct ProgressTrackerHorizontalView: View { self._currentPageIndex = currentPageIndex } - //MARK: - Body + // MARK: - Body var body: some View { ZStack(alignment: .topLeading) { self.horizontalLayout() @@ -58,13 +58,13 @@ struct ProgressTrackerHorizontalView: View { } } - //MARK: - Private functions + // MARK: - Private functions @ViewBuilder private func horizontalLayout() -> some View { HStack(alignment: .top, spacing: self.spacing) { ForEach((0..( get: { return self._currentTouchedPageIndex }, diff --git a/core/Sources/Components/ProgressTracker/View/SwiftUI/ProgressTrackerIndicatorView.swift b/core/Sources/Components/ProgressTracker/View/SwiftUI/ProgressTrackerIndicatorView.swift index 2a609b27c..68465a628 100644 --- a/core/Sources/Components/ProgressTracker/View/SwiftUI/ProgressTrackerIndicatorView.swift +++ b/core/Sources/Components/ProgressTracker/View/SwiftUI/ProgressTrackerIndicatorView.swift @@ -22,7 +22,7 @@ struct ProgressTrackerIndicatorView: View { return self.scaleFactor * ProgressTrackerConstants.borderWidth } - //MARK: - Initialization + // MARK: - Initialization init( theme: Theme, intent: ProgressTrackerIntent, @@ -41,8 +41,8 @@ struct ProgressTrackerIndicatorView: View { self.viewModel = viewModel } - - //MARK: - Body + + // MARK: - Body var body: some View { ZStack(alignment: .center) { @@ -77,7 +77,7 @@ struct ProgressTrackerIndicatorView: View { .opacity(self.viewModel.opacity) } - //MARK: Modifiers + // MARK: Modifiers func highlighted(_ isHighlighted: Bool) -> Self { self.viewModel.set(highlighted: isHighlighted) return self diff --git a/core/Sources/Components/ProgressTracker/View/SwiftUI/ProgressTrackerTrackView.swift b/core/Sources/Components/ProgressTracker/View/SwiftUI/ProgressTrackerTrackView.swift index 62da96a8b..d25013f50 100644 --- a/core/Sources/Components/ProgressTracker/View/SwiftUI/ProgressTrackerTrackView.swift +++ b/core/Sources/Components/ProgressTracker/View/SwiftUI/ProgressTrackerTrackView.swift @@ -19,7 +19,7 @@ struct ProgressTrackerTrackView: View { return self.scaleFactor * ProgressTrackerConstants.trackSize } - //MARK: - Initialization + // MARK: - Initialization init(theme: Theme, intent: ProgressTrackerIntent, orientation: ProgressTrackerOrientation) { @@ -27,7 +27,7 @@ struct ProgressTrackerTrackView: View { self.viewModel = ProgressTrackerTrackViewModel(theme: theme, intent: intent) } - //MARK: - Body + // MARK: - Body var body: some View { if self.orientation == .horizontal { self.line() @@ -47,7 +47,7 @@ struct ProgressTrackerTrackView: View { .opacity(self.viewModel.opacity) } - //MARK: - View Modifiers + // MARK: - View Modifiers func disabled(_ isDisabled: Bool) -> some View { self.viewModel.isEnabled = !isDisabled return self diff --git a/core/Sources/Components/ProgressTracker/View/SwiftUI/ProgressTrackerVerticalView.swift b/core/Sources/Components/ProgressTracker/View/SwiftUI/ProgressTrackerVerticalView.swift index 7b1d6c35f..456f34211 100644 --- a/core/Sources/Components/ProgressTracker/View/SwiftUI/ProgressTrackerVerticalView.swift +++ b/core/Sources/Components/ProgressTracker/View/SwiftUI/ProgressTrackerVerticalView.swift @@ -36,7 +36,7 @@ struct ProgressTrackerVerticalView: View { return self.viewModel.spacings.trackIndicatorSpacing * self.scaleFactor } - //MARK: - Initialization + // MARK: - Initialization init( intent: ProgressTrackerIntent, variant: ProgressTrackerVariant, @@ -51,7 +51,7 @@ struct ProgressTrackerVerticalView: View { self._currentPageIndex = currentPageIndex } - //MARK: - Body + // MARK: - Body var body: some View { ZStack(alignment: .topLeading) { self.verticalLayout() @@ -62,7 +62,7 @@ struct ProgressTrackerVerticalView: View { } } - //MARK: - Private functions + // MARK: - Private functions @ViewBuilder private func verticalLayout() -> some View { VStack(alignment: .leading, spacing: self.verticalStackSpacing) { @@ -70,7 +70,7 @@ struct ProgressTrackerVerticalView: View { self.pageContent(at: index) .frame(maxHeight: .infinity) .disabled(!self.viewModel.isEnabled(at: index)) - .accessibilityAttributes(viewModel: self.viewModel, index: index) + .accessibilityAttributes(viewModel: self.viewModel, index: index) } } } @@ -100,7 +100,7 @@ struct ProgressTrackerVerticalView: View { .disabled(!self.viewModel.isEnabled(at: key)) .frame(height: height) .offset( - x: rect.width/2, + x: rect.width / 2, y: previousRect.maxY + trackSpacing ) } else { @@ -164,7 +164,7 @@ private extension View { /// Alignment guide for the label and the indicator. The first line of the label is to be aligned centrally with the indicator. private extension VerticalAlignment { - private enum XAlignment : AlignmentID { + private enum XAlignment: AlignmentID { static func defaultValue(in dimension: ViewDimensions) -> CGFloat { return dimension[VerticalAlignment.top] } diff --git a/core/Sources/Components/ProgressTracker/View/SwiftUI/ProgressTrackerView.swift b/core/Sources/Components/ProgressTracker/View/SwiftUI/ProgressTrackerView.swift index e679bf603..034a87049 100644 --- a/core/Sources/Components/ProgressTracker/View/SwiftUI/ProgressTrackerView.swift +++ b/core/Sources/Components/ProgressTracker/View/SwiftUI/ProgressTrackerView.swift @@ -13,7 +13,7 @@ public struct ProgressTrackerView: View { typealias Content = ProgressTrackerContent typealias AccessibilityIdentifier = ProgressTrackerAccessibilityIdentifier - //MARK: - Private properties + // MARK: - Private properties @ObservedObject private var viewModel: ProgressTrackerViewModel private let intent: ProgressTrackerIntent private let variant: ProgressTrackerVariant @@ -21,7 +21,7 @@ public struct ProgressTrackerView: View { @Binding var currentPageIndex: Int @Environment(\.isEnabled) private var isEnabled: Bool - //MARK: - Initialization + // MARK: - Initialization /// Initializer /// - Parameters: /// - theme: the general theme @@ -94,7 +94,7 @@ public struct ProgressTrackerView: View { self._currentPageIndex = currentPageIndex } - //MARK: - Body + // MARK: - Body public var body: some View { self.progressTrackerView .accessibilityElement(children: .contain) @@ -110,7 +110,7 @@ public struct ProgressTrackerView: View { } } - //MARK: - Private functions + // MARK: - Private functions private func dragGesture(bounds: CGRect?, preferences: [Int: CGRect]) -> some Gesture { let indicators = preferences.sorted { $0.key < $1.key }.map(\.value) @@ -146,7 +146,7 @@ public struct ProgressTrackerView: View { return ProgressTrackerDiscreteGestureHandler( currentPageIndex: self._currentPageIndex, currentTouchedPageIndex: self.$viewModel.currentPressedIndicator, - indicators: indicators, + indicators: indicators, frame: frame, disabledIndices: self.viewModel.disabledIndices ) @@ -154,7 +154,7 @@ public struct ProgressTrackerView: View { return ProgressTrackerContinuousGestureHandler( currentPageIndex: self._currentPageIndex, currentTouchedPageIndex: self.$viewModel.currentPressedIndicator, - indicators: indicators, + indicators: indicators, frame: frame, disabledIndices: self.viewModel.disabledIndices ) diff --git a/core/Sources/Components/ProgressTracker/View/UIKit/ProgressTrackerContinuousUITouchHandlerTests.swift b/core/Sources/Components/ProgressTracker/View/UIKit/ProgressTrackerContinuousUITouchHandlerTests.swift index bfc6a4304..88dbe8164 100644 --- a/core/Sources/Components/ProgressTracker/View/UIKit/ProgressTrackerContinuousUITouchHandlerTests.swift +++ b/core/Sources/Components/ProgressTracker/View/UIKit/ProgressTrackerContinuousUITouchHandlerTests.swift @@ -20,7 +20,7 @@ final class ProgressTrackerContinuousUITouchHandlerTests: XCTestCase { var sut: ProgressTrackerContinuousUITouchHandler! var cancellables = Set() - //MARK: - Setup + // MARK: - Setup override func setUp() { super.setUp() self.controls = (0...4) @@ -87,7 +87,7 @@ final class ProgressTrackerContinuousUITouchHandlerTests: XCTestCase { self.sut.beginTracking(location: CGPoint(x: 51, y: 10)) // WHEN - self.sut.continueTracking(location: CGPoint(x: 301, y:10)) + self.sut.continueTracking(location: CGPoint(x: 301, y: 10)) // THEN XCTAssertEqual(self.sut.trackingPageIndex, 2) @@ -99,7 +99,7 @@ final class ProgressTrackerContinuousUITouchHandlerTests: XCTestCase { self.sut.beginTracking(location: CGPoint(x: 51, y: 10)) // WHEN - self.sut.continueTracking(location: CGPoint(x: 101, y:10)) + self.sut.continueTracking(location: CGPoint(x: 101, y: 10)) // THEN XCTAssertNil(self.sut.trackingPageIndex) @@ -109,10 +109,10 @@ final class ProgressTrackerContinuousUITouchHandlerTests: XCTestCase { // GIVEN self.sut.currentPageIndex = 2 self.sut.beginTracking(location: CGPoint(x: 51, y: 10)) - self.sut.continueTracking(location: CGPoint(x: 101, y:10)) + self.sut.continueTracking(location: CGPoint(x: 101, y: 10)) // WHEN - self.sut.continueTracking(location: CGPoint(x: 1, y:10)) + self.sut.continueTracking(location: CGPoint(x: 1, y: 10)) // THEN XCTAssertEqual(self.sut.trackingPageIndex, 1) @@ -128,7 +128,7 @@ final class ProgressTrackerContinuousUITouchHandlerTests: XCTestCase { expect.fulfill() } // WHEN - self.sut.endTracking(location: CGPoint(x: 251, y:10)) + self.sut.endTracking(location: CGPoint(x: 251, y: 10)) // THEN wait(for: [expect]) @@ -147,7 +147,7 @@ final class ProgressTrackerContinuousUITouchHandlerTests: XCTestCase { expect.fulfill() } // WHEN - self.sut.endTracking(location: CGPoint(x: 251, y:10)) + self.sut.endTracking(location: CGPoint(x: 251, y: 10)) // THEN wait(for: [expect], timeout: 0.01) @@ -171,12 +171,12 @@ final class ProgressTrackerContinuousUITouchHandlerTests: XCTestCase { self.sut.continueTracking(location: CGPoint(x: 101, y: 10)) self.sut.continueTracking(location: CGPoint(x: 151, y: 10)) self.sut.continueTracking(location: CGPoint(x: 201, y: 10)) - self.sut.endTracking(location: CGPoint(x: 251, y:10)) + self.sut.endTracking(location: CGPoint(x: 251, y: 10)) // THEN wait(for: [expect]) - XCTAssertEqual(pages, [1,2,3,4]) + XCTAssertEqual(pages, [1, 2, 3, 4]) } func test_highlighted_onmove_tracking() { diff --git a/core/Sources/Components/ProgressTracker/View/UIKit/ProgressTrackerDiscreteUITouchHandlerTests.swift b/core/Sources/Components/ProgressTracker/View/UIKit/ProgressTrackerDiscreteUITouchHandlerTests.swift index 0a4d6da40..3f4896f4a 100644 --- a/core/Sources/Components/ProgressTracker/View/UIKit/ProgressTrackerDiscreteUITouchHandlerTests.swift +++ b/core/Sources/Components/ProgressTracker/View/UIKit/ProgressTrackerDiscreteUITouchHandlerTests.swift @@ -18,7 +18,7 @@ final class ProgressTrackerDiscreteUITouchHandlerTests: XCTestCase { var sut: ProgressTrackerDiscreteUITouchHandler! var cancellables = Set() - //MARK: - Setup + // MARK: - Setup override func setUp() { super.setUp() self.controls = (0...4) @@ -85,7 +85,7 @@ final class ProgressTrackerDiscreteUITouchHandlerTests: XCTestCase { self.sut.beginTracking(location: CGPoint(x: 51, y: 10)) // WHEN - self.sut.continueTracking(location: CGPoint(x: 301, y:10)) + self.sut.continueTracking(location: CGPoint(x: 301, y: 10)) // THEN XCTAssertEqual(self.sut.trackingPageIndex, 1) @@ -97,7 +97,7 @@ final class ProgressTrackerDiscreteUITouchHandlerTests: XCTestCase { self.sut.beginTracking(location: CGPoint(x: 51, y: 10)) // WHEN - self.sut.continueTracking(location: CGPoint(x: 101, y:10)) + self.sut.continueTracking(location: CGPoint(x: 101, y: 10)) // THEN XCTAssertNil(self.sut.trackingPageIndex) @@ -107,10 +107,10 @@ final class ProgressTrackerDiscreteUITouchHandlerTests: XCTestCase { // GIVEN self.sut.currentPageIndex = 2 self.sut.beginTracking(location: CGPoint(x: 51, y: 10)) - self.sut.continueTracking(location: CGPoint(x: 101, y:10)) + self.sut.continueTracking(location: CGPoint(x: 101, y: 10)) // WHEN - self.sut.continueTracking(location: CGPoint(x: 1, y:10)) + self.sut.continueTracking(location: CGPoint(x: 1, y: 10)) // THEN XCTAssertEqual(self.sut.trackingPageIndex, 1) @@ -126,11 +126,11 @@ final class ProgressTrackerDiscreteUITouchHandlerTests: XCTestCase { expect.fulfill() } // WHEN - self.sut.endTracking(location: CGPoint(x: 251, y:10)) + self.sut.endTracking(location: CGPoint(x: 251, y: 10)) // THEN wait(for: [expect]) - + XCTAssertNil(self.sut.trackingPageIndex) } @@ -145,7 +145,7 @@ final class ProgressTrackerDiscreteUITouchHandlerTests: XCTestCase { expect.fulfill() } // WHEN - self.sut.endTracking(location: CGPoint(x: 251, y:10)) + self.sut.endTracking(location: CGPoint(x: 251, y: 10)) // THEN wait(for: [expect], timeout: 0.01) diff --git a/core/Sources/Components/ProgressTracker/View/UIKit/ProgressTrackerIndependentUITouchHandlerTests.swift b/core/Sources/Components/ProgressTracker/View/UIKit/ProgressTrackerIndependentUITouchHandlerTests.swift index 1873399db..dcaa43223 100644 --- a/core/Sources/Components/ProgressTracker/View/UIKit/ProgressTrackerIndependentUITouchHandlerTests.swift +++ b/core/Sources/Components/ProgressTracker/View/UIKit/ProgressTrackerIndependentUITouchHandlerTests.swift @@ -6,7 +6,6 @@ // Copyright © 2024 Adevinta. All rights reserved. // - import Combine import XCTest @@ -19,7 +18,7 @@ final class ProgressTrackerIndependentUITouchHandlerTests: XCTestCase { var sut: ProgressTrackerIndependentUITouchHandler! var cancellables = Set() - //MARK: - Setup + // MARK: - Setup override func setUp() { super.setUp() self.controls = (0...4) @@ -86,7 +85,7 @@ final class ProgressTrackerIndependentUITouchHandlerTests: XCTestCase { self.sut.beginTracking(location: CGPoint(x: 51, y: 10)) // WHEN - self.sut.continueTracking(location: CGPoint(x: 301, y:10)) + self.sut.continueTracking(location: CGPoint(x: 301, y: 10)) // THEN XCTAssertEqual(self.sut.trackingPageIndex, 1) @@ -98,7 +97,7 @@ final class ProgressTrackerIndependentUITouchHandlerTests: XCTestCase { self.sut.beginTracking(location: CGPoint(x: 51, y: 10)) // WHEN - self.sut.continueTracking(location: CGPoint(x: 101, y:10)) + self.sut.continueTracking(location: CGPoint(x: 101, y: 10)) // THEN XCTAssertEqual(self.sut.trackingPageIndex, 1) @@ -108,10 +107,10 @@ final class ProgressTrackerIndependentUITouchHandlerTests: XCTestCase { // GIVEN self.sut.currentPageIndex = 2 self.sut.beginTracking(location: CGPoint(x: 51, y: 10)) - self.sut.continueTracking(location: CGPoint(x: 101, y:10)) + self.sut.continueTracking(location: CGPoint(x: 101, y: 10)) // WHEN - self.sut.continueTracking(location: CGPoint(x: 1, y:10)) + self.sut.continueTracking(location: CGPoint(x: 1, y: 10)) // THEN XCTAssertEqual(self.sut.trackingPageIndex, 1) @@ -127,7 +126,7 @@ final class ProgressTrackerIndependentUITouchHandlerTests: XCTestCase { expect.fulfill() } // WHEN - self.sut.endTracking(location: CGPoint(x: 251, y:10)) + self.sut.endTracking(location: CGPoint(x: 251, y: 10)) // THEN wait(for: [expect]) @@ -146,7 +145,7 @@ final class ProgressTrackerIndependentUITouchHandlerTests: XCTestCase { expect.fulfill() } // WHEN - self.sut.endTracking(location: CGPoint(x: 251, y:10)) + self.sut.endTracking(location: CGPoint(x: 251, y: 10)) // THEN wait(for: [expect], timeout: 0.01) diff --git a/core/Sources/Components/ProgressTracker/View/UIKit/ProgressTrackerIndicatorUIControl.swift b/core/Sources/Components/ProgressTracker/View/UIKit/ProgressTrackerIndicatorUIControl.swift index 662dd4742..804a4a9f7 100644 --- a/core/Sources/Components/ProgressTracker/View/UIKit/ProgressTrackerIndicatorUIControl.swift +++ b/core/Sources/Components/ProgressTracker/View/UIKit/ProgressTrackerIndicatorUIControl.swift @@ -86,10 +86,8 @@ final class ProgressTrackerIndicatorUIControl: UIControl { imageView.isUserInteractionEnabled = false imageView.adjustsImageSizeForAccessibilityContentSizeCategory = true - imageView.setContentCompressionResistancePriority(.required, - for: .horizontal) - imageView.setContentCompressionResistancePriority(.required, - for: .vertical) + imageView.setContentCompressionResistancePriority(.required, for: .horizontal) + imageView.setContentCompressionResistancePriority(.required, for: .vertical) return imageView }() @@ -183,7 +181,7 @@ final class ProgressTrackerIndicatorUIControl: UIControl { required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } - + // MARK: Private functions private func setupView() { self.addSubviewSizedEqually(self.indicatorView) diff --git a/core/Sources/Components/ProgressTracker/View/UIKit/ProgressTrackerUIControl.swift b/core/Sources/Components/ProgressTracker/View/UIKit/ProgressTrackerUIControl.swift index cff22fa45..a6cbb5408 100644 --- a/core/Sources/Components/ProgressTracker/View/UIKit/ProgressTrackerUIControl.swift +++ b/core/Sources/Components/ProgressTracker/View/UIKit/ProgressTrackerUIControl.swift @@ -252,7 +252,7 @@ public final class ProgressTrackerUIControl: UIControl { } } - //MARK: - Handle touch events + // MARK: - Handle touch events public override func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool { let touchHandler = self.interactionState.touchHandler( currentPageIndex: self.currentPageIndex, @@ -291,7 +291,7 @@ public final class ProgressTrackerUIControl: UIControl { self.touchHandler = nil } - //MARK: Touch handling actions + // MARK: Touch handling actions private func updateCurrentPageTrackingIndex(_ index: Int) { self.cancelHighlighted() @@ -301,7 +301,7 @@ public final class ProgressTrackerUIControl: UIControl { self.sendActions(for: .valueChanged) } - //MARK: - Private functions + // MARK: - Private functions private func cancelHighlighted() { guard let index = self.touchHandler?.trackingPageIndex else { return } self.indicatorViews[safe: index]?.isHighlighted = false @@ -341,7 +341,7 @@ public final class ProgressTrackerUIControl: UIControl { } } - //MARK: - View creation + // MARK: - View creation private func createLabels(content: Content) -> [UILabel] { guard content.hasLabel else { return [] } @@ -436,14 +436,14 @@ public final class ProgressTrackerUIControl: UIControl { theme: self.theme, intent: self.intent, orientation: orientation) - view.isEnabled = !self.viewModel.disabledIndices.contains(index+1) + view.isEnabled = !self.viewModel.disabledIndices.contains(index + 1) view.isUserInteractionEnabled = false view.translatesAutoresizingMaskIntoConstraints = false return view } } - //MARK: - View setup + // MARK: - View setup private func setupIndicatorsAndLabels(content: Content, orientation: ProgressTrackerOrientation) { NSLayoutConstraint.deactivate(self.labelSpacingConstraints) NSLayoutConstraint.deactivate(self.trackSpacingConstraints) @@ -577,7 +577,7 @@ public final class ProgressTrackerUIControl: UIControl { } for i in 1.. Int? { if let index = self.indicatorViews.index(closestTo: location), index != self.currentPageIndex { - let trackingPageIndex = index < self.currentPageIndex ? max(0, self.currentPageIndex - 1) : min(self.numberOfPages - 1, self.currentPageIndex + 1) - return trackingPageIndex + return index < self.currentPageIndex ? max(0, self.currentPageIndex - 1) : min(self.numberOfPages - 1, self.currentPageIndex + 1) } return nil } @@ -131,16 +130,16 @@ class ProgressTrackerUITouchHandler: ProgressTrackerUITouchHandling { /// The `none` touch handler ignores all touch events final class ProgressTrackerNoneUITouchHandler: ProgressTrackerUITouchHandling { var trackingPageIndex: Int? - + private var voidSubject = PassthroughSubject() var currentPagePublisher: any Publisher { return self.voidSubject } func beginTracking(location: CGPoint) {} - + func continueTracking(location: CGPoint) {} - + func endTracking(location: CGPoint) {} } @@ -215,9 +214,7 @@ final class ProgressTrackerContinuousUITouchHandler: ProgressTrackerUITouchHandl index != trackingPageIndex else { return nil } - let nextTrackingPageIndex = index < trackingPageIndex ? max(0, trackingPageIndex - 1) : min(self.numberOfPages - 1, trackingPageIndex + 1) - - return nextTrackingPageIndex + return index < trackingPageIndex ? max(0, trackingPageIndex - 1) : min(self.numberOfPages - 1, trackingPageIndex + 1) } } diff --git a/core/Sources/Components/ProgressTracker/View/UIKit/ProgressTrackerUITouchHandlerCreationTests.swift b/core/Sources/Components/ProgressTracker/View/UIKit/ProgressTrackerUITouchHandlerCreationTests.swift index 57490b5f8..226e9a5b8 100644 --- a/core/Sources/Components/ProgressTracker/View/UIKit/ProgressTrackerUITouchHandlerCreationTests.swift +++ b/core/Sources/Components/ProgressTracker/View/UIKit/ProgressTrackerUITouchHandlerCreationTests.swift @@ -13,7 +13,7 @@ import XCTest final class ProgressTrackerUITouchHandlerCreationTests: XCTestCase { var controls: [UIControl]! - //MARK: - Setup + // MARK: - Setup override func setUp() { super.setUp() self.controls = (0...4) @@ -23,7 +23,7 @@ final class ProgressTrackerUITouchHandlerCreationTests: XCTestCase { .map(UIControl.init(frame:)) } - //MARK: - Tests + // MARK: - Tests func test_setup_none() { let sut = ProgressTrackerInteractionState.none.touchHandler(currentPageIndex: 0, indicatorViews: self.controls) diff --git a/core/Sources/Components/RadioButton/Properties/Internal/RadioButtonConstants.swift b/core/Sources/Components/RadioButton/Properties/Internal/RadioButtonConstants.swift index c11d331ae..ba664a3b1 100644 --- a/core/Sources/Components/RadioButton/Properties/Internal/RadioButtonConstants.swift +++ b/core/Sources/Components/RadioButton/Properties/Internal/RadioButtonConstants.swift @@ -11,5 +11,5 @@ import Foundation /// Constant definition for the extra padding used in a radio button, to ensure the touch area is large enough. enum RadioButtonConstants { - public static let radioButtonPadding: CGFloat = 8 + static let radioButtonPadding: CGFloat = 8 } diff --git a/core/Sources/Components/RadioButton/Properties/Public/RadioButtonItem.swift b/core/Sources/Components/RadioButton/Properties/Public/RadioButtonItem.swift index 4484695e6..981220b04 100644 --- a/core/Sources/Components/RadioButton/Properties/Public/RadioButtonItem.swift +++ b/core/Sources/Components/RadioButton/Properties/Public/RadioButtonItem.swift @@ -11,12 +11,12 @@ import Foundation /// A simple struct for defining radio buttons using the ``RadioButtonGroupView``. public struct RadioButtonItem { - //MARK: - Properties + // MARK: - Properties public let id: ID public let label: String - //MARK: - Initialization + // MARK: - Initialization /// Parameters: /// - id: A unique ID bound to a generic type which has the constraints that it need be ``Equatable`` & ``Hashable``. /// - label: The label of the radio button diff --git a/core/Sources/Components/RadioButton/Properties/Public/RadioButtonUIItem.swift b/core/Sources/Components/RadioButton/Properties/Public/RadioButtonUIItem.swift index de0d84068..db65ab81a 100644 --- a/core/Sources/Components/RadioButton/Properties/Public/RadioButtonUIItem.swift +++ b/core/Sources/Components/RadioButton/Properties/Public/RadioButtonUIItem.swift @@ -11,12 +11,12 @@ import Foundation /// A simple struct for defining radio buttons using the ``RadioButtonGroupView``. public struct RadioButtonUIItem: Equatable & Hashable { - //MARK: - Properties + // MARK: - Properties public let id: ID public let label: NSAttributedString - //MARK: - Initialization + // MARK: - Initialization /// Parameters: /// - id: A unique ID bound to a generic type which has the constraints that it need be ``Equatable`` & ``Hashable``. /// - label: The label of the radio button diff --git a/core/Sources/Components/RadioButton/UseCases/RadioButtonGetColorsUseCase.swift b/core/Sources/Components/RadioButton/UseCases/RadioButtonGetColorsUseCase.swift index 7eb1a3c30..651f345ab 100644 --- a/core/Sources/Components/RadioButton/UseCases/RadioButtonGetColorsUseCase.swift +++ b/core/Sources/Components/RadioButton/UseCases/RadioButtonGetColorsUseCase.swift @@ -81,7 +81,7 @@ private extension SparkCore.Colors { func surfaceColor(intent: RadioButtonIntent) -> any ColorToken { switch intent { - case .basic: + case .basic: return self.basic.onBasic case .support: return self.support.onSupport diff --git a/core/Sources/Components/RadioButton/UseCases/RadioButtonGetGroupColorUseCase.swift b/core/Sources/Components/RadioButton/UseCases/RadioButtonGetGroupColorUseCase.swift index 9f5b17719..adc62ec3f 100644 --- a/core/Sources/Components/RadioButton/UseCases/RadioButtonGetGroupColorUseCase.swift +++ b/core/Sources/Components/RadioButton/UseCases/RadioButtonGetGroupColorUseCase.swift @@ -23,7 +23,7 @@ struct RadioButtonGetGroupColorUseCase: RadioButtonGetGroupColorUseCaseable { /// Return the color token corresponding to the state func execute(colors: Colors, intent: RadioButtonIntent) -> any ColorToken { switch intent { - case .basic: + case .basic: return colors.basic.basic case .support: return colors.support.support diff --git a/core/Sources/Components/RadioButton/View/RadioButtonGroupViewModel.swift b/core/Sources/Components/RadioButton/View/RadioButtonGroupViewModel.swift index 4a613d4d1..2737fd925 100644 --- a/core/Sources/Components/RadioButton/View/RadioButtonGroupViewModel.swift +++ b/core/Sources/Components/RadioButton/View/RadioButtonGroupViewModel.swift @@ -25,7 +25,7 @@ final class RadioButtonGroupViewModel: ObservableObject { // MARK: - Internal Properties var theme: any Theme { didSet { - self.sublabelFont = self.theme.typography.caption + self.sublabelFont = self.theme.typography.caption self.titleFont = self.theme.typography.subhead self.titleColor = self.theme.colors.base.onSurface self.sublabelColor = useCase.execute(colors: self.theme.colors, intent: self.intent) diff --git a/core/Sources/Components/RadioButton/View/RadioButtonGroupViewModelTests.swift b/core/Sources/Components/RadioButton/View/RadioButtonGroupViewModelTests.swift index a33ab40c1..516a0f012 100644 --- a/core/Sources/Components/RadioButton/View/RadioButtonGroupViewModelTests.swift +++ b/core/Sources/Components/RadioButton/View/RadioButtonGroupViewModelTests.swift @@ -15,7 +15,7 @@ final class RadioButtonGroupViewModelTests: XCTestCase { var subscriptions = Set() // MARK: - Tests - public func test_expect_all_values_published_on_setup() { + func test_expect_all_values_published_on_setup() { // Given let sut = sut(intent: .basic) let expectation = expectation(description: "Wait for subscriptions to be published") @@ -26,14 +26,15 @@ final class RadioButtonGroupViewModelTests: XCTestCase { Publishers.Zip(sut.$spacing, sut.$labelSpacing) ) - publisher.sink { _ in + publisher.sink(receiveValue: { _ in expectation.fulfill() - }.store(in: &self.subscriptions) + }) + .store(in: &self.subscriptions) wait(for: [expectation], timeout: 0.1) } - public func test_theme_change() { + func test_theme_change() { // Given let sut = sut(intent: .basic) let expectation = expectation(description: "Wait for subscriptions to be published") @@ -44,25 +45,26 @@ final class RadioButtonGroupViewModelTests: XCTestCase { Publishers.Zip(sut.$spacing, sut.$labelSpacing) ) - publisher.sink { _ in + publisher.sink(receiveValue: { _ in expectation.fulfill() - }.store(in: &self.subscriptions) + }) + .store(in: &self.subscriptions) sut.theme = ThemeGeneratedMock.mocked() wait(for: [expectation], timeout: 0.1) } - public func test_intent_change() { + func test_intent_change() { // Given let sut = sut(intent: .basic) let expectation = expectation(description: "Wait for sublabel color to be published") expectation.expectedFulfillmentCount = 2 - - sut.$sublabelColor.sink { _ in + sut.$sublabelColor.sink(receiveValue: { _ in expectation.fulfill() - }.store(in: &self.subscriptions) + }) + .store(in: &self.subscriptions) sut.intent = .alert @@ -75,13 +77,11 @@ final class RadioButtonGroupViewModelTests: XCTestCase { useCase.executeWithColorsAndIntentReturnValue = ColorTokenGeneratedMock.random() let theme = ThemeGeneratedMock.mocked() - let sut = RadioButtonGroupViewModel( + return RadioButtonGroupViewModel( theme: theme, intent: intent, content: (), useCase: useCase ) - - return sut } } diff --git a/core/Sources/Components/RadioButton/View/RadioButtonViewModel.swift b/core/Sources/Components/RadioButton/View/RadioButtonViewModel.swift index 42c0e110b..7db0235d8 100644 --- a/core/Sources/Components/RadioButton/View/RadioButtonViewModel.swift +++ b/core/Sources/Components/RadioButton/View/RadioButtonViewModel.swift @@ -47,7 +47,7 @@ final class RadioButtonViewModel: Obser label: label, selectedID: selectedID, alignment: alignment, - useCase:RadioButtonGetAttributesUseCase()) + useCase: RadioButtonGetAttributesUseCase()) } init(theme: Theme, diff --git a/core/Sources/Components/RadioButton/View/RadioButtonViewModelTests.swift b/core/Sources/Components/RadioButton/View/RadioButtonViewModelTests.swift index ff8d28259..e07c46fcc 100644 --- a/core/Sources/Components/RadioButton/View/RadioButtonViewModelTests.swift +++ b/core/Sources/Components/RadioButton/View/RadioButtonViewModelTests.swift @@ -76,7 +76,8 @@ final class RadioButtonViewModelTests: XCTestCase { sut.$colors.sink(receiveValue: { _ in expectation.fulfill() - }).store(in: &self.subscriptions) + }) + .store(in: &self.subscriptions) // When sut.set(selected: true) @@ -94,9 +95,11 @@ final class RadioButtonViewModelTests: XCTestCase { let publishers = Publishers.Zip4(sut.$opacity, sut.$spacing, sut.$font, sut.$colors) - Publishers.Zip(publishers, sut.$colors).sink { _ in - expectation.fulfill() - }.store(in: &self.subscriptions) + Publishers.Zip(publishers, sut.$colors) + .sink(receiveValue: { _ in + expectation.fulfill() + }) + .store(in: &self.subscriptions) // When sut.set(theme: ThemeGeneratedMock.mocked()) @@ -111,9 +114,11 @@ final class RadioButtonViewModelTests: XCTestCase { let expectation = XCTestExpectation(description: "Changes to state publishes value changes.") expectation.expectedFulfillmentCount = 2 - Publishers.Zip(sut.$isDisabled, sut.$colors).sink { _ in - expectation.fulfill() - }.store(in: &self.subscriptions) + Publishers.Zip(sut.$isDisabled, sut.$colors) + .sink(receiveValue: { _ in + expectation.fulfill() + }) + .store(in: &self.subscriptions) // When sut.set(enabled: false) @@ -130,10 +135,11 @@ final class RadioButtonViewModelTests: XCTestCase { var spacings = [CGFloat]() - sut.$spacing.sink { spacing in + sut.$spacing.sink(receiveValue: { spacing in spacings.append(spacing) expectation.fulfill() - }.store(in: &self.subscriptions) + }) + .store(in: &self.subscriptions) // When sut.set(alignment: .leading) diff --git a/core/Sources/Components/RadioButton/View/SwiftUI/RadioButtonGroupView.swift b/core/Sources/Components/RadioButton/View/SwiftUI/RadioButtonGroupView.swift index 5b218a1f8..8164a7b29 100644 --- a/core/Sources/Components/RadioButton/View/SwiftUI/RadioButtonGroupView.swift +++ b/core/Sources/Components/RadioButton/View/SwiftUI/RadioButtonGroupView.swift @@ -28,7 +28,7 @@ import SwiftUI /// ] /// } /// ``` -public struct RadioButtonGroupView : View { +public struct RadioButtonGroupView: View { // MARK: - Injected properties @@ -148,7 +148,7 @@ public struct RadioButtonGroupView, atIndex index: Int = Int.max) { + public func addRadioButton(_ item: RadioButtonUIItem, atIndex index: Int = Int.max) { var items = self.items if index < items.count { @@ -365,9 +365,9 @@ public final class RadioButtonUIGroupView]) -> [RadioButtonUIView] + items: [RadioButtonUIItem]) -> [RadioButtonUIView] { - let radioButtonViews = items.map { + return items.map { let radioButtonView = RadioButtonUIView( theme: self.theme, intent: self.viewModel.intent, @@ -387,7 +387,6 @@ public final class RadioButtonUIGroupView(_ radioButtonGroup: some RadioButtonUIGroupView, didChangeSelection item: ID) + func radioButtonGroup(_ radioButtonGroup: some RadioButtonUIGroupView, didChangeSelection item: ID) } diff --git a/core/Sources/Components/RadioButton/View/UIKit/RadioButtonUIView.swift b/core/Sources/Components/RadioButton/View/UIKit/RadioButtonUIView.swift index 3835cf5fd..56951c503 100644 --- a/core/Sources/Components/RadioButton/View/UIKit/RadioButtonUIView.swift +++ b/core/Sources/Components/RadioButton/View/UIKit/RadioButtonUIView.swift @@ -211,7 +211,7 @@ public final class RadioButtonUIView: U labelPosition: RadioButtonLabelPosition = .right ) { let viewModel = RadioButtonViewModel( - theme: theme, + theme: theme, intent: groupState.intent, id: id, label: .left(label), @@ -325,7 +325,6 @@ public final class RadioButtonUIView: U toggleViewTrailingConstraint?.constant = self.haloWidth } - // MARK: - Private Functions private func setupSubscriptions() { @@ -480,7 +479,7 @@ public final class RadioButtonUIView: U } } -//MARK: - Private Helpers +// MARK: - Private Helpers private extension UILabel { static var standard: UILabel { diff --git a/core/Sources/Components/Rating/Cache/CGLayerCache.swift b/core/Sources/Components/Rating/Cache/CGLayerCache.swift index 5a3e96f67..1b9af148a 100644 --- a/core/Sources/Components/Rating/Cache/CGLayerCache.swift +++ b/core/Sources/Components/Rating/Cache/CGLayerCache.swift @@ -22,7 +22,7 @@ final class CGLayerCache: CGLayerCaching { func object(forKey key: NSString) -> CGLayer? { return Self.cache.object(forKey: key) } - + func setObject(_ layer: CGLayer, forKey key: NSString) { Self.cache.setObject(layer, forKey: key) } diff --git a/core/Sources/Components/Rating/Enum/StarFillMode.swift b/core/Sources/Components/Rating/Enum/StarFillMode.swift index 178e3d362..c42ff80ac 100644 --- a/core/Sources/Components/Rating/Enum/StarFillMode.swift +++ b/core/Sources/Components/Rating/Enum/StarFillMode.swift @@ -17,7 +17,7 @@ import Foundation public enum StarFillMode { case full case half - case fraction(_ :CGFloat) + case fraction(_: CGFloat) case exact // MARK: - Public functions diff --git a/core/Sources/Components/Rating/Graphics/ShapeLayer.swift b/core/Sources/Components/Rating/Graphics/ShapeLayer.swift index aa6cdbd3f..5fe3aabac 100644 --- a/core/Sources/Components/Rating/Graphics/ShapeLayer.swift +++ b/core/Sources/Components/Rating/Graphics/ShapeLayer.swift @@ -58,7 +58,7 @@ final class ShapeLayer { graphicsContext.setStrokeColor(self.strokeColor) graphicsContext.drawPath(using: .stroke) - let insets = self.shape.insets.withHorizontalPadding(self.strokeWidth/2.0) + let insets = self.shape.insets.withHorizontalPadding(self.strokeWidth / 2.0) let maskWidth = CGFloat((insets.right - insets.left) * fillPercentage) let maskHeight = rect.height diff --git a/core/Sources/Components/Rating/Graphics/Star.swift b/core/Sources/Components/Rating/Graphics/Star.swift index 3baf8a3b4..01300af43 100644 --- a/core/Sources/Components/Rating/Graphics/Star.swift +++ b/core/Sources/Components/Rating/Graphics/Star.swift @@ -41,15 +41,15 @@ final class Star: CGPathShape { self.insets = UIEdgeInsets(top: rect.minY, left: rect.minX, bottom: rect.maxY, right: rect.maxX) // the size of each angle step - let angleStep = ((.pi * 2) / CGFloat(self.numberOfVertices)) + let angleStep = ((.pi * 2) / CGFloat(self.numberOfVertices)) - let initialOffset: CGFloat = -.pi/2 + let initialOffset: CGFloat = -.pi / 2 // the start angle, the first star vertex is to start at the top, therefore the -90° rotation. var angle: CGFloat = angleStep + initialOffset var centerPoint = CGPoint(x: rect.midX, y: rect.midY) - let fullRadius = (min(rect.width, rect.height)/2) + let fullRadius = (min(rect.width, rect.height) / 2) let cornerRadius = self.cornerRadiusSize * fullRadius let radius = fullRadius - cornerRadius @@ -81,13 +81,13 @@ final class Star: CGPathShape { // draw the star for i in 1...self.numberOfVertices { let outerPoint1 = CGPoint( - x: centerPoint.x + (radius + cornerRadius) * cos(angle - arcAngle/2), - y: centerPoint.y + (radius + cornerRadius) * sin(angle - arcAngle/2) + x: centerPoint.x + (radius + cornerRadius) * cos(angle - arcAngle / 2), + y: centerPoint.y + (radius + cornerRadius) * sin(angle - arcAngle / 2) ) let outerPoint2 = CGPoint( - x: centerPoint.x + (radius + cornerRadius) * cos(angle + arcAngle/2), - y: centerPoint.y + (radius + cornerRadius) * sin(angle + arcAngle/2) + x: centerPoint.x + (radius + cornerRadius) * cos(angle + arcAngle / 2), + y: centerPoint.y + (radius + cornerRadius) * sin(angle + arcAngle / 2) ) let tangentPoint = CGPoint( @@ -101,8 +101,8 @@ final class Star: CGPathShape { ) let innerPoint = CGPoint( - x: centerPoint.x + (radius * self.vertexSize) * cos(angle + angleStep/2), - y: centerPoint.y + (radius * self.vertexSize) * sin(angle + angleStep/2) + x: centerPoint.x + (radius * self.vertexSize) * cos(angle + angleStep / 2), + y: centerPoint.y + (radius * self.vertexSize) * sin(angle + angleStep / 2) ) if i == 1 { diff --git a/core/Sources/Components/Rating/Model/StarConfiguration.swift b/core/Sources/Components/Rating/Model/StarConfiguration.swift index 28c6463ee..21b7aad33 100644 --- a/core/Sources/Components/Rating/Model/StarConfiguration.swift +++ b/core/Sources/Components/Rating/Model/StarConfiguration.swift @@ -23,12 +23,12 @@ public struct StarConfiguration: Equatable, Sendable { public static let vertexSize = CGFloat(0.65) public static let cornerRadiusSize = CGFloat(0.15) } - + public static let `default` = StarConfiguration( numberOfVertices: Defaults.numberOfVertices, vertexSize: Defaults.vertexSize, cornerRadiusSize: Defaults.cornerRadiusSize) - + public init(numberOfVertices: Int, vertexSize: CGFloat, cornerRadiusSize: CGFloat) { diff --git a/core/Sources/Components/Rating/TestHelpers/RatingDisplayConfigurationSnapshotTests.swift b/core/Sources/Components/Rating/TestHelpers/RatingDisplayConfigurationSnapshotTests.swift index 5123a3a33..a6431cf27 100644 --- a/core/Sources/Components/Rating/TestHelpers/RatingDisplayConfigurationSnapshotTests.swift +++ b/core/Sources/Components/Rating/TestHelpers/RatingDisplayConfigurationSnapshotTests.swift @@ -24,7 +24,7 @@ struct RatingDisplayConfigurationSnapshotTests { let modes: [ComponentSnapshotTestMode] let sizes: [UIContentSizeCategory] - + // MARK: - Getter func testName() -> String { diff --git a/core/Sources/Components/Rating/TestHelpers/RatingInputScenarioSnapshotTests.swift b/core/Sources/Components/Rating/TestHelpers/RatingInputScenarioSnapshotTests.swift index ff36a8a56..55a10b0f2 100644 --- a/core/Sources/Components/Rating/TestHelpers/RatingInputScenarioSnapshotTests.swift +++ b/core/Sources/Components/Rating/TestHelpers/RatingInputScenarioSnapshotTests.swift @@ -13,7 +13,7 @@ import SwiftUI @testable import SparkCore enum RatingInputScenarioSnapshotTests: String, CaseIterable { - + case test1 case test2 case test3 @@ -22,7 +22,6 @@ enum RatingInputScenarioSnapshotTests: String, CaseIterable { typealias Constants = ComponentSnapshotTestConstants - // MARK: - Configurations func configuration(isSwiftUIComponent: Bool) -> [RatingInputConfigurationSnapshotTests] { switch self { diff --git a/core/Sources/Components/Rating/UseCases/RatingGetColorsUseCase.swift b/core/Sources/Components/Rating/UseCases/RatingGetColorsUseCase.swift index cac431f39..1e5d86a33 100644 --- a/core/Sources/Components/Rating/UseCases/RatingGetColorsUseCase.swift +++ b/core/Sources/Components/Rating/UseCases/RatingGetColorsUseCase.swift @@ -37,13 +37,15 @@ struct RatingGetColorsUseCase: RatingGetColorsUseCaseable { intent: RatingIntent, state: RatingState ) -> RatingColors { - + var colors: RatingColors + let fillColor = state.isPressed ? theme.colors.states.mainVariantPressed : theme.colors.main.mainVariant switch intent { case .main: colors = RatingColors( - fillColor: state.isPressed ? theme.colors.states.mainVariantPressed : theme.colors.main.mainVariant, - strokeColor: theme.colors.base.onSurface.opacity(theme.dims.dim3), opacity: theme.dims.none + fillColor: fillColor, + strokeColor: theme.colors.base.onSurface.opacity(theme.dims.dim3), + opacity: theme.dims.none ) } diff --git a/core/Sources/Components/Rating/View/RatingDisplayViewModel.swift b/core/Sources/Components/Rating/View/RatingDisplayViewModel.swift index c9e9ab8a0..63884127c 100644 --- a/core/Sources/Components/Rating/View/RatingDisplayViewModel.swift +++ b/core/Sources/Components/Rating/View/RatingDisplayViewModel.swift @@ -66,7 +66,6 @@ final class RatingDisplayViewModel: ObservableObject { private let colorsUseCase: RatingGetColorsUseCaseable private let sizeUseCase: RatingSizeAttributesUseCaseable - // MARK: Initializer init(theme: Theme, intent: RatingIntent, diff --git a/core/Sources/Components/Rating/View/RatingDisplayViewModelTests.swift b/core/Sources/Components/Rating/View/RatingDisplayViewModelTests.swift index 737c6b546..f5a55bb76 100644 --- a/core/Sources/Components/Rating/View/RatingDisplayViewModelTests.swift +++ b/core/Sources/Components/Rating/View/RatingDisplayViewModelTests.swift @@ -34,7 +34,6 @@ final class RatingDisplayViewModelTests: XCTestCase { self.sizeUseCase.executeWithSpacingAndSizeReturnValue = RatingSizeAttributes(borderWidth: 2.0, height: 20, spacing: 8) - self.sut = RatingDisplayViewModel( theme: self.theme, intent: .main, diff --git a/core/Sources/Components/Rating/View/SwiftUI/RatingDisplayViewSnapshotTests.swift b/core/Sources/Components/Rating/View/SwiftUI/RatingDisplayViewSnapshotTests.swift index 6a0e9c599..e5ff4f33b 100644 --- a/core/Sources/Components/Rating/View/SwiftUI/RatingDisplayViewSnapshotTests.swift +++ b/core/Sources/Components/Rating/View/SwiftUI/RatingDisplayViewSnapshotTests.swift @@ -8,7 +8,6 @@ import XCTest - import UIKit @testable import SparkCore diff --git a/core/Sources/Components/Rating/View/UIKit/RatingDisplayUIView.swift b/core/Sources/Components/Rating/View/UIKit/RatingDisplayUIView.swift index c9dae3507..d3ad8cdb3 100644 --- a/core/Sources/Components/Rating/View/UIKit/RatingDisplayUIView.swift +++ b/core/Sources/Components/Rating/View/UIKit/RatingDisplayUIView.swift @@ -22,7 +22,7 @@ public class RatingDisplayUIView: UIView { stackView.distribution = .fillEqually return stackView }() - + private let viewModel: RatingDisplayViewModel private let fillMode: StarFillMode private var sizeConstraints = [NSLayoutConstraint]() @@ -62,7 +62,7 @@ public class RatingDisplayUIView: UIView { self.viewModel.theme = newValue } } - + /// The intent for defining the color. public var intent: RatingIntent { get { @@ -72,7 +72,7 @@ public class RatingDisplayUIView: UIView { self.viewModel.intent = newValue } } - + /// The size of the rating stars. /// Possible sizes `small`, `medium` and `input`. public var size: RatingDisplaySize { @@ -103,7 +103,7 @@ public class RatingDisplayUIView: UIView { } } - internal var ratingStarViews : [StarUIView] { self.stackView.arrangedSubviews.compactMap { view in + internal var ratingStarViews: [StarUIView] { self.stackView.arrangedSubviews.compactMap { view in return view as? StarUIView } } @@ -115,7 +115,6 @@ public class RatingDisplayUIView: UIView { // MARK: - Initialization - /// Create a rating display view with the following parameters /// - Parameters: /// - theme: The current theme @@ -185,7 +184,7 @@ public class RatingDisplayUIView: UIView { ) currentRating -= 1 - star.accessibilityIdentifier = "\(RatingDisplayAccessibilityIdentifier.identifier)-\(i+1)" + star.accessibilityIdentifier = "\(RatingDisplayAccessibilityIdentifier.identifier)-\(i + 1)" self.sizeConstraints.append(star.widthAnchor.constraint(equalToConstant: self.ratingSize)) self.sizeConstraints.append(star.heightAnchor.constraint(equalToConstant: self.ratingSize)) diff --git a/core/Sources/Components/Rating/View/UIKit/RatingInputUIView.swift b/core/Sources/Components/Rating/View/UIKit/RatingInputUIView.swift index 381555177..4588741f5 100644 --- a/core/Sources/Components/Rating/View/UIKit/RatingInputUIView.swift +++ b/core/Sources/Components/Rating/View/UIKit/RatingInputUIView.swift @@ -106,12 +106,12 @@ public final class RatingInputUIView: UIControl { self.addPanGestureToPreventCancelTracking() self.setupAccessibility() } - + required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } - - //MARK: - Handle touch events + + // MARK: - Handle touch events public override func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool { return self.handleTouch(touch, with: event) } diff --git a/core/Sources/Components/Rating/View/UIKit/StarUIView.swift b/core/Sources/Components/Rating/View/UIKit/StarUIView.swift index 633afa5df..194630b3e 100644 --- a/core/Sources/Components/Rating/View/UIKit/StarUIView.swift +++ b/core/Sources/Components/Rating/View/UIKit/StarUIView.swift @@ -30,7 +30,7 @@ public final class StarUIView: UIView { self.configuration.numberOfVertices = newValue } } - + /// The vertex size determins how deep the inner angle of the star is. /// This value is a percentage of the radius and should be in the range [0...1]. public var vertexSize: CGFloat { @@ -53,7 +53,6 @@ public final class StarUIView: UIView { } } - /// The fill mode. /// The fill mode determines how to round the rating value to fill the star. public var fillMode: StarFillMode { @@ -91,7 +90,7 @@ public final class StarUIView: UIView { self.setNeedsDisplay() } } - + public var configuration: StarConfiguration { didSet { guard self.configuration != oldValue else { return } @@ -118,7 +117,7 @@ public final class StarUIView: UIView { // MARK: - Initializer /// Create a StarUIView with the following parameters - /// + /// /// - Parameters: /// - rating: the value of the rating. This should be a number in the range [0...1] /// - fillMode: the fill mode of the start. The star will be filled according to the rating and the fillMode. @@ -213,7 +212,7 @@ public final class StarUIView: UIView { // MARK: Internal functions internal func cacheKey(rect: CGRect) -> NSString { - let key = [Self.self, + let key = [Self.self, self.numberOfVertices, self.normalizedRating, self.lineWidth, diff --git a/core/Sources/Components/Slider/UseCase/CreateValuesFromSteps/SliderCreateStepsUseCase.swift b/core/Sources/Components/Slider/UseCase/CreateValuesFromSteps/SliderCreateStepsUseCase.swift index 6332694ce..151a47c77 100644 --- a/core/Sources/Components/Slider/UseCase/CreateValuesFromSteps/SliderCreateStepsUseCase.swift +++ b/core/Sources/Components/Slider/UseCase/CreateValuesFromSteps/SliderCreateStepsUseCase.swift @@ -25,7 +25,7 @@ final class SliderCreateValuesFromStepsUseCase: SliderCreateValuesFromStepsUseCa guard from < to else { throw SliderCreateValuesFromStepsUseCasableError.invalidRange } guard steps > .zero, steps <= (to - from) else { throw SliderCreateValuesFromStepsUseCasableError.invalidStep } - + var values = Array(stride(from: from, through: to, by: steps)) // Last value should be added when `to` % `step` is > 0 if values.contains(to) == false { diff --git a/core/Sources/Components/Slider/UseCase/GetClosestValue/SliderGetClosestValueInBoundsUseCase.swift b/core/Sources/Components/Slider/UseCase/GetClosestValue/SliderGetClosestValueInBoundsUseCase.swift index 20a8b3f99..7b1d58f7a 100644 --- a/core/Sources/Components/Slider/UseCase/GetClosestValue/SliderGetClosestValueInBoundsUseCase.swift +++ b/core/Sources/Components/Slider/UseCase/GetClosestValue/SliderGetClosestValueInBoundsUseCase.swift @@ -13,7 +13,7 @@ protocol SliderGetClosestValueUseCasable { } final class SliderGetClosestValueUseCase: SliderGetClosestValueUseCasable { - func execute(value: V, in values: [V]) -> V where V : BinaryFloatingPoint { + func execute(value: V, in values: [V]) -> V where V: BinaryFloatingPoint { guard let closestValue = values.min(by: { return abs($0 - value) <= abs($1 - value) }) else { return value } diff --git a/core/Sources/Components/Slider/UseCase/GetClosestValue/SliderGetClosestValueUseCasableMock+Tests.swift b/core/Sources/Components/Slider/UseCase/GetClosestValue/SliderGetClosestValueUseCasableMock+Tests.swift index b6ec14351..b91e6e52f 100644 --- a/core/Sources/Components/Slider/UseCase/GetClosestValue/SliderGetClosestValueUseCasableMock+Tests.swift +++ b/core/Sources/Components/Slider/UseCase/GetClosestValue/SliderGetClosestValueUseCasableMock+Tests.swift @@ -9,16 +9,15 @@ import Foundation @testable import SparkCore +// swiftlint:disable force_cast final class SliderGetClosestValueUseCasableMock: SparkCore.SliderGetClosestValueUseCasable where U: BinaryFloatingPoint { - // MARK: - Initialization init() {} // MARK: - execute - var executeWithValueAndValuesCallsCount = 0 var executeWithValueAndValuesCalled: Bool { return executeWithValueAndValuesCallsCount > 0 diff --git a/core/Sources/Components/Slider/UseCase/GetColors/SliderGetColorsUseCase.swift b/core/Sources/Components/Slider/UseCase/GetColors/SliderGetColorsUseCase.swift index cc3be0970..296d4e58b 100644 --- a/core/Sources/Components/Slider/UseCase/GetColors/SliderGetColorsUseCase.swift +++ b/core/Sources/Components/Slider/UseCase/GetColors/SliderGetColorsUseCase.swift @@ -15,7 +15,7 @@ protocol SliderGetColorsUseCasable { } final class SliderGetColorsUseCase: SliderGetColorsUseCasable { - func execute(theme: Theme, + func execute(theme: Theme, intent: SliderIntent) -> SliderColors { let colors = theme.colors let dims = theme.dims diff --git a/core/Sources/Components/Slider/UseCase/GetStepValues/SliderGetStepValuesInBoundsUseCasableMock+Tests.swift b/core/Sources/Components/Slider/UseCase/GetStepValues/SliderGetStepValuesInBoundsUseCasableMock+Tests.swift index f99c36139..3f5c3cd7d 100644 --- a/core/Sources/Components/Slider/UseCase/GetStepValues/SliderGetStepValuesInBoundsUseCasableMock+Tests.swift +++ b/core/Sources/Components/Slider/UseCase/GetStepValues/SliderGetStepValuesInBoundsUseCasableMock+Tests.swift @@ -9,6 +9,7 @@ import Foundation @testable import SparkCore +// swiftlint:disable force_cast final class SliderGetStepValuesInBoundsUseCasableMock: SparkCore.SliderGetStepValuesInBoundsUseCasable where U: BinaryFloatingPoint, U.Stride: BinaryFloatingPoint { // MARK: - Initialization @@ -17,7 +18,6 @@ final class SliderGetStepValuesInBoundsUseCasableMock: SparkCore.SliderGetSte // MARK: - execute - var executeWithBoundsAndStepCallsCount = 0 var executeWithBoundsAndStepCalled: Bool { return executeWithBoundsAndStepCallsCount > 0 @@ -29,7 +29,7 @@ final class SliderGetStepValuesInBoundsUseCasableMock: SparkCore.SliderGetSte func execute(bounds: ClosedRange, step: V.Stride) -> [V] where V: BinaryFloatingPoint, V.Stride: BinaryFloatingPoint { guard let castedBounds = bounds as? ClosedRange, - let castedStep = step as? U.Stride else { + let castedStep = step as? U.Stride else { fatalError("\(U.self) is not equal to \(V.self)") } executeWithBoundsAndStepCallsCount += 1 diff --git a/core/Sources/Components/Slider/View/UIKit/SliderUIControl.swift b/core/Sources/Components/Slider/View/UIKit/SliderUIControl.swift index 11ac72ad0..e7f9d8dc2 100644 --- a/core/Sources/Components/Slider/View/UIKit/SliderUIControl.swift +++ b/core/Sources/Components/Slider/View/UIKit/SliderUIControl.swift @@ -141,7 +141,7 @@ public final class SliderUIControl: UIControl where V: BinaryFloatingPoint, V public override func layoutSubviews() { super.layoutSubviews() - + self.viewModel.resetBoundsIfNeeded() self.indicatorView.center.y = self.frame.height / 2 diff --git a/core/Sources/Components/Slider/ViewModel/Base/SliderViewModel.swift b/core/Sources/Components/Slider/ViewModel/Base/SliderViewModel.swift index 3d895fa05..c34426a00 100644 --- a/core/Sources/Components/Slider/ViewModel/Base/SliderViewModel.swift +++ b/core/Sources/Components/Slider/ViewModel/Base/SliderViewModel.swift @@ -45,15 +45,15 @@ class SliderViewModel: ObservableObject where V: BinaryFloatingPoint, V.Strid } var isContinuous = true - //TODO: var numberOfSteps + // TODO: var numberOfSteps - var step: V.Stride? = nil { + var step: V.Stride? { didSet { guard self.step != oldValue else { return } self.setStepValues() } } - private(set) var stepValues: [V]? = nil + private(set) var stepValues: [V]? // MARK: - Published Colors @Published var trackColor: any ColorToken diff --git a/core/Sources/Components/Slider/ViewModel/Single/SingleSliderViewModel.swift b/core/Sources/Components/Slider/ViewModel/Single/SingleSliderViewModel.swift index 90bc2d4cb..6deaf3e9b 100644 --- a/core/Sources/Components/Slider/ViewModel/Single/SingleSliderViewModel.swift +++ b/core/Sources/Components/Slider/ViewModel/Single/SingleSliderViewModel.swift @@ -19,8 +19,7 @@ final class SingleSliderViewModel: SliderViewModel where V: BinaryFloating } private func getDefaultIncrementValue() -> V { - let tenPercent = 10 * (bounds.upperBound - bounds.lowerBound) / 100.0 - return tenPercent + return 10 * (bounds.upperBound - bounds.lowerBound) / 100.0 } func incrementValue() { diff --git a/core/Sources/Components/Spinner/SpinnerViewModelTests.swift b/core/Sources/Components/Spinner/SpinnerViewModelTests.swift index 1a17f2415..a1f8b0f99 100644 --- a/core/Sources/Components/Spinner/SpinnerViewModelTests.swift +++ b/core/Sources/Components/Spinner/SpinnerViewModelTests.swift @@ -31,7 +31,7 @@ final class SpinnerViewModelTests: XCTestCase { let sut = sut(intent: .main, spinnerSize: .small) let expect = expectation(description: "All publishers should have published") - Publishers.Zip(sut.$intentColor, sut.$size).subscribe(in: &self.subscriptions) { (colorToken, size) in + Publishers.Zip(sut.$intentColor, sut.$size).subscribe(in: &self.subscriptions) { colorToken, size in XCTAssertEqual(colorToken.color, Color.red) XCTAssertEqual(size, SpinnerViewModel.Constants.Size.small) diff --git a/core/Sources/Components/Spinner/UIKit/SpinnerUIView.swift b/core/Sources/Components/Spinner/UIKit/SpinnerUIView.swift index e97e2ec13..9d7125912 100644 --- a/core/Sources/Components/Spinner/UIKit/SpinnerUIView.swift +++ b/core/Sources/Components/Spinner/UIKit/SpinnerUIView.swift @@ -110,7 +110,7 @@ public final class SpinnerUIView: UIView { let center = rect.width / 2 let centerPoint = CGPoint(x: center, y: center) - let spinnerArc = UIBezierPath.arc(arcCenter: centerPoint, radius: (rect.width - self.strokeWidth)/2 ) + let spinnerArc = UIBezierPath.arc(arcCenter: centerPoint, radius: (rect.width - self.strokeWidth) / 2 ) spinnerArc.lineWidth = self.strokeWidth ctx.setStrokeColor(self.viewModel.intentColor.uiColor.cgColor) spinnerArc.stroke() @@ -137,8 +137,8 @@ public final class SpinnerUIView: UIView { private func animate() { self.layer.removeAllAnimations() - - let fullRotation = CABasicAnimation(keyPath: "transform.rotation.z") + + let fullRotation = CABasicAnimation(keyPath: "transform.rotation.z") fullRotation.fromValue = 0 fullRotation.toValue = 2 * CGFloat.pi fullRotation.duration = self.viewModel.duration @@ -156,4 +156,3 @@ private extension UIBezierPath { } } - diff --git a/core/Sources/Components/Switch/UseCase/GetColor/SwitchGetColorUseCaseTests.swift b/core/Sources/Components/Switch/UseCase/GetColor/SwitchGetColorUseCaseTests.swift index 15937da14..dd64bf39b 100644 --- a/core/Sources/Components/Switch/UseCase/GetColor/SwitchGetColorUseCaseTests.swift +++ b/core/Sources/Components/Switch/UseCase/GetColor/SwitchGetColorUseCaseTests.swift @@ -92,13 +92,13 @@ private extension SwitchGetColorUseCaseTests { ) throws { // GIVEN let useCase = SwitchGetColorUseCase() - + // WHEN let colorToken = useCase.execute( intent: givenIntent, colors: self.colorsMock ) - + // THEN XCTAssertIdentical(colorToken as? ColorTokenGeneratedMock, expectedColorToken as? ColorTokenGeneratedMock, diff --git a/core/Sources/Components/Switch/UseCase/GetPosition/SwitchGetPositionUseCase.swift b/core/Sources/Components/Switch/UseCase/GetPosition/SwitchGetPositionUseCase.swift index e524e093d..90fb32cf2 100644 --- a/core/Sources/Components/Switch/UseCase/GetPosition/SwitchGetPositionUseCase.swift +++ b/core/Sources/Components/Switch/UseCase/GetPosition/SwitchGetPositionUseCase.swift @@ -30,7 +30,7 @@ struct SwitchGetPositionUseCase: SwitchGetPositionUseCaseable { case .left: horizontalSpacing = spacing.medium isToggleOnLeft = true - + case .right: horizontalSpacing = spacing.xxxLarge isToggleOnLeft = false diff --git a/core/Sources/Components/Switch/View/SwiftUI/SwitchView.swift b/core/Sources/Components/Switch/View/SwiftUI/SwitchView.swift index 9119e9975..4a10d2336 100644 --- a/core/Sources/Components/Switch/View/SwiftUI/SwitchView.swift +++ b/core/Sources/Components/Switch/View/SwiftUI/SwitchView.swift @@ -34,7 +34,7 @@ public struct SwitchView: View { /// - theme: The spark theme of the switch. /// - intent: The intent of the switch. /// - alignment: The alignment of the switch. - /// - isOn: The Binding value of the switch. + /// - isOn: The Binding value of the switch. public init( theme: any Theme, intent: SwitchIntent, diff --git a/core/Sources/Components/Switch/ViewModel/SwitchViewModelTests.swift b/core/Sources/Components/Switch/ViewModel/SwitchViewModelTests.swift index e8db2cef3..3bea2544f 100644 --- a/core/Sources/Components/Switch/ViewModel/SwitchViewModelTests.swift +++ b/core/Sources/Components/Switch/ViewModel/SwitchViewModelTests.swift @@ -1110,7 +1110,7 @@ private extension SwitchViewModelTests { numberOfCalls: Int, givenIsOn: Bool? = nil ) { - let givenStatusAndStateColors = [ + let givenStatusAndStateColors = [ stub.colorsMock.toggleBackgroundColors, stub.colorsMock.toggleDotForegroundColors ] @@ -1574,7 +1574,7 @@ private final class Stub { alignment: alignment, intent: intent, isEnabled: isEnabled, - images: imagesEither, + images: imagesEither, text: text, attributedText: attributedTextEither, dependencies: dependenciesMock diff --git a/core/Sources/Components/Tab/Properties/TabItemColors.swift b/core/Sources/Components/Tab/Properties/TabItemColors.swift index bccb127fa..1c0748e72 100644 --- a/core/Sources/Components/Tab/Properties/TabItemColors.swift +++ b/core/Sources/Components/Tab/Properties/TabItemColors.swift @@ -30,11 +30,11 @@ struct TabItemColors: Equatable, Updateable { self.background = background self.opacity = opacity } - + static func == (lhs: TabItemColors, rhs: TabItemColors) -> Bool { return colorsEqual(lhs.label, rhs.label) && colorsEqual(lhs.line, rhs.line) && colorsEqual(lhs.background, rhs.background) && lhs.opacity == rhs.opacity } - + private static func colorsEqual(_ lhs: any ColorToken, _ rhs: any ColorToken) -> Bool { return lhs.color == rhs.color && lhs.uiColor == rhs.uiColor } diff --git a/core/Sources/Components/Tab/Properties/TabItemContent.swift b/core/Sources/Components/Tab/Properties/TabItemContent.swift index 68ef3a44a..bbd773df9 100644 --- a/core/Sources/Components/Tab/Properties/TabItemContent.swift +++ b/core/Sources/Components/Tab/Properties/TabItemContent.swift @@ -15,7 +15,7 @@ public protocol TitleContaining { /// The content of a tab item. public struct TabItemContent: TitleContaining, Equatable, Updateable { public static func == (lhs: TabItemContent, rhs: TabItemContent) -> Bool { - return lhs.id == rhs.id + return lhs.id == rhs.id } /// A unique id of each tab item diff --git a/core/Sources/Components/Tab/Properties/TabItemSpacings.swift b/core/Sources/Components/Tab/Properties/TabItemSpacings.swift index 2d3047cda..cdea65206 100644 --- a/core/Sources/Components/Tab/Properties/TabItemSpacings.swift +++ b/core/Sources/Components/Tab/Properties/TabItemSpacings.swift @@ -13,11 +13,11 @@ import Foundation /// - horizontalEdge: The horizontal edge determines leading and trailing spacing of the tab item. /// - content: The content determines the space between the icon, text and badge. struct TabItemSpacings: Equatable { - + let verticalEdge: CGFloat let horizontalEdge: CGFloat let content: CGFloat - + static func == (lhs: TabItemSpacings, rhs: TabItemSpacings) -> Bool { return lhs.verticalEdge == rhs.verticalEdge && lhs.horizontalEdge == lhs.horizontalEdge && diff --git a/core/Sources/Components/Tab/Properties/TabState.swift b/core/Sources/Components/Tab/Properties/TabState.swift index ec7d64429..9703a2927 100644 --- a/core/Sources/Components/Tab/Properties/TabState.swift +++ b/core/Sources/Components/Tab/Properties/TabState.swift @@ -13,7 +13,7 @@ struct TabState: Equatable, Updateable { var isEnabled: Bool var isPressed: Bool var isSelected: Bool - + init( isEnabled: Bool = true, isPressed: Bool = false, diff --git a/core/Sources/Components/Tab/Properties/TabStateAttributes.swift b/core/Sources/Components/Tab/Properties/TabStateAttributes.swift index c3d944d79..6a281c724 100644 --- a/core/Sources/Components/Tab/Properties/TabStateAttributes.swift +++ b/core/Sources/Components/Tab/Properties/TabStateAttributes.swift @@ -14,7 +14,7 @@ import Foundation /// - opacity: The opacity of the tab item. /// - separatorLineHeight: The lineHeight of the tab item. struct TabStateAttributes: Equatable { - + let spacings: TabItemSpacings let colors: TabItemColors let heights: TabItemHeights diff --git a/core/Sources/Components/Tab/UseCases/TabGetIntentColorUseCaseTests.swift b/core/Sources/Components/Tab/UseCases/TabGetIntentColorUseCaseTests.swift index b11f787ee..6a49c8b08 100644 --- a/core/Sources/Components/Tab/UseCases/TabGetIntentColorUseCaseTests.swift +++ b/core/Sources/Components/Tab/UseCases/TabGetIntentColorUseCaseTests.swift @@ -10,23 +10,23 @@ import XCTest final class TabGetIntentColorUseCaseTests: XCTestCase { - + // MARK: - Private properties private var sut: TabGetIntentColorUseCase! private var colors: ColorsGeneratedMock! - + // MARK: - Setup override func setUp() { super.setUp() self.sut = TabGetIntentColorUseCase() self.colors = ColorsGeneratedMock.mocked() } - + // MARK: - Tests func test_execute_main() { XCTAssertEqual(self.sut.execute(colors: self.colors, intent: .main).color, self.colors.main.main.color) } - + func test_execute_support() { XCTAssertEqual(self.sut.execute(colors: self.colors, intent: .support).color, self.colors.support.support.color) } diff --git a/core/Sources/Components/Tab/UseCases/TabGetStateAttributesUseCase.swift b/core/Sources/Components/Tab/UseCases/TabGetStateAttributesUseCase.swift index 7a1fe00eb..8caee42d3 100644 --- a/core/Sources/Components/Tab/UseCases/TabGetStateAttributesUseCase.swift +++ b/core/Sources/Components/Tab/UseCases/TabGetStateAttributesUseCase.swift @@ -53,7 +53,7 @@ struct TabGetStateAttributesUseCase: TabGetStateAttributesUseCasable { ) -> TabStateAttributes { let size = hasTitle ? tabSize : TabSize.md - + let font = self.getFontUseCase.execute(typography: theme.typography, size: size) let spacings = TabItemSpacings( diff --git a/core/Sources/Components/Tab/UseCases/TabGetStateAttributesUseCaseTests.swift b/core/Sources/Components/Tab/UseCases/TabGetStateAttributesUseCaseTests.swift index 482901444..024865116 100644 --- a/core/Sources/Components/Tab/UseCases/TabGetStateAttributesUseCaseTests.swift +++ b/core/Sources/Components/Tab/UseCases/TabGetStateAttributesUseCaseTests.swift @@ -10,7 +10,7 @@ import XCTest final class TabGetStateAttributesUseCaseTests: XCTestCase { - + // MARK: - Private properties private var sut: TabGetStateAttributesUseCase! private var theme: ThemeGeneratedMock! @@ -18,7 +18,7 @@ final class TabGetStateAttributesUseCaseTests: XCTestCase { private var getFontUseCase: TabGetFontUseCaseableGeneratedMock! private var spacings: TabItemSpacings! private var colors: TabItemColors! - + // MARK: - Setup override func setUp() { super.setUp() @@ -43,7 +43,7 @@ final class TabGetStateAttributesUseCaseTests: XCTestCase { self.getFontUseCase.executeWithTypographyAndSizeReturnValue = self.theme.typography.body2 } - + // MARK: - Tests func test_selected() { let mockedColor = ColorTokenGeneratedMock(uiColor: .black) @@ -74,7 +74,7 @@ final class TabGetStateAttributesUseCaseTests: XCTestCase { ) XCTAssertEqual(stateAttribute, expectedAttribute) } - + func test_enabled() { let stateAttribute = sut.execute( theme: self.theme, @@ -98,7 +98,7 @@ final class TabGetStateAttributesUseCaseTests: XCTestCase { ) XCTAssertEqual(stateAttribute, expectedAttribute) } - + func test_pressed() { let stateAttribute = sut.execute( theme: self.theme, @@ -128,7 +128,7 @@ final class TabGetStateAttributesUseCaseTests: XCTestCase { ) XCTAssertEqual(stateAttribute, expectedAttribute) } - + func test_disabled() { let stateAttribute = sut.execute( theme: self.theme, @@ -138,7 +138,6 @@ final class TabGetStateAttributesUseCaseTests: XCTestCase { hasTitle: true ) - let expectedHeights = TabItemHeights( separatorLineHeight: self.theme.border.width.small, itemHeight: 34, @@ -163,7 +162,6 @@ final class TabGetStateAttributesUseCaseTests: XCTestCase { hasTitle: false ) - let expectedHeights = TabItemHeights( separatorLineHeight: self.theme.border.width.small, itemHeight: 40, @@ -184,15 +182,15 @@ private extension TabState { static var enabled: TabState { return .init() } - + static var selected: TabState { return .init(isSelected: true) } - + static var pressed: TabState { return .init(isPressed: true) } - + static var disabled: TabState { return .init(isEnabled: false) } diff --git a/core/Sources/Components/Tab/UseCases/TabsGetAttributesUseCaseTests.swift b/core/Sources/Components/Tab/UseCases/TabsGetAttributesUseCaseTests.swift index 95346e051..0c9e63cc6 100644 --- a/core/Sources/Components/Tab/UseCases/TabsGetAttributesUseCaseTests.swift +++ b/core/Sources/Components/Tab/UseCases/TabsGetAttributesUseCaseTests.swift @@ -41,7 +41,6 @@ final class TabsGetAttributesUseCaseTests: XCTestCase { let attributes = self.sut.execute(theme: self.theme, size: .md, isEnabled: true) - XCTAssertEqual(attributes, expectedAttributes) } diff --git a/core/Sources/Components/Tab/View/SwiftUI/TabApportionsSizeView.swift b/core/Sources/Components/Tab/View/SwiftUI/TabApportionsSizeView.swift index f6417b969..a7e712d4b 100644 --- a/core/Sources/Components/Tab/View/SwiftUI/TabApportionsSizeView.swift +++ b/core/Sources/Components/Tab/View/SwiftUI/TabApportionsSizeView.swift @@ -9,7 +9,6 @@ import Foundation import SwiftUI - /// TabApportionsSizeView is the similar to a SegmentControl with apportionsSegmentWidthsByContent == true. struct TabApportionsSizeView: View { private let intent: TabIntent @@ -34,7 +33,7 @@ struct TabApportionsSizeView: View { /// - viewModel: the current view model /// - intent: the tab intent. /// - selectedIndex: Binding of the index of the current selected tab. - public init(viewModel: TabViewModel, + init(viewModel: TabViewModel, intent: TabIntent, selectedIndex: Binding ) { @@ -80,7 +79,7 @@ struct TabApportionsSizeView: View { private func tabItems() -> some View { ScrollViewReader { proxy in HStack(spacing: 0) { - ForEach(Array(self.viewModel.content.enumerated()), id: \.element.id) { (index, content) in + ForEach(Array(self.viewModel.content.enumerated()), id: \.element.id) { index, content in self.tabItem(index: index, content: content, proxy: proxy) } Spacer() @@ -99,7 +98,7 @@ struct TabApportionsSizeView: View { content: content, proxy: proxy, selectedIndex: self.$selectedIndex, - index: index) + index: index) .background { GeometryReader { geometry in Color.clear diff --git a/core/Sources/Components/Tab/View/SwiftUI/TabEqualSizeView.swift b/core/Sources/Components/Tab/View/SwiftUI/TabEqualSizeView.swift index 8e52d069b..74ab61c60 100644 --- a/core/Sources/Components/Tab/View/SwiftUI/TabEqualSizeView.swift +++ b/core/Sources/Components/Tab/View/SwiftUI/TabEqualSizeView.swift @@ -39,7 +39,7 @@ struct TabEqualSizeView: View { /// - selectedIndex: A binding with the selected index. /// - tab size: the default value is `md`. /// - An array of tuples of image and string. - + init(viewModel: TabViewModel, intent: TabIntent, selectedIndex: Binding @@ -50,7 +50,7 @@ struct TabEqualSizeView: View { } // MARK: - View - public var body: some View { + var body: some View { ZStack(alignment: .bottom) { GeometryReader { geometry in VStack(alignment: .trailing) { @@ -89,7 +89,7 @@ struct TabEqualSizeView: View { private func tabItems() -> some View { ScrollViewReader { proxy in HStack(spacing: 0) { - ForEach(Array(self.viewModel.content.enumerated()), id: \.element.id) { (index, content) in + ForEach(Array(self.viewModel.content.enumerated()), id: \.element.id) { index, content in self.tabItem(index: index, content: content, proxy: proxy) .frame(minWidth: self.minItemWidth) } diff --git a/core/Sources/Components/Tab/View/SwiftUI/TabItemView.swift b/core/Sources/Components/Tab/View/SwiftUI/TabItemView.swift index 98fe19595..83daf0906 100644 --- a/core/Sources/Components/Tab/View/SwiftUI/TabItemView.swift +++ b/core/Sources/Components/Tab/View/SwiftUI/TabItemView.swift @@ -117,21 +117,21 @@ struct TabItemView: View { } } - //MARK: - Public modifiers + // MARK: - Public modifiers /// Indicates whether the control attempts to adjust segment widths based on their content widths. - public func apportionsSegmentWidthsByContent(_ newValue: Bool) -> Self { + func apportionsSegmentWidthsByContent(_ newValue: Bool) -> Self { self.viewModel.apportionsSegmentWidthsByContent = newValue return self } /// Add a badge to the view - public func badge(_ badge: BadgeView) -> Self { + func badge(_ badge: BadgeView) -> Self { self.viewModel.content.badge = badge return self } /// Set the tab as selected - public func selected(_ selected: Bool) -> Self { + func selected(_ selected: Bool) -> Self { self.viewModel.updateState(isSelected: selected) return self } diff --git a/core/Sources/Components/Tab/View/SwiftUI/TabItemViewSnapshotTests.swift b/core/Sources/Components/Tab/View/SwiftUI/TabItemViewSnapshotTests.swift index 77799fff0..62215c48f 100644 --- a/core/Sources/Components/Tab/View/SwiftUI/TabItemViewSnapshotTests.swift +++ b/core/Sources/Components/Tab/View/SwiftUI/TabItemViewSnapshotTests.swift @@ -18,7 +18,7 @@ final class TabItemViewSnapshotTests: SwiftUIComponentSnapshotTestCase { var badge: BadgeView! // MARK: - Setup - + override func setUp() { super.setUp() @@ -28,7 +28,7 @@ final class TabItemViewSnapshotTests: SwiftUIComponentSnapshotTestCase { // MARK: - Tests func test_tab_icon_and_title_and_badge() throws { - //GIVEN + // GIVEN let viewModel: TabItemViewModel = .init( theme: theme, @@ -44,12 +44,12 @@ final class TabItemViewSnapshotTests: SwiftUIComponentSnapshotTestCase { .badge(self.badge) .background(.systemBackground) - //THEN + // THEN assertSnapshot(matching: sut, modes: [.light, .dark], sizes: [.medium]) } func test_selected_tab_with_intent_main() throws { - //GIVEN + // GIVEN let viewModel: TabItemViewModel = .init( theme: theme, @@ -62,12 +62,12 @@ final class TabItemViewSnapshotTests: SwiftUIComponentSnapshotTestCase { .selected(true) .background(.systemBackground) - //THEN + // THEN assertSnapshot(matching: sut, modes: [.light, .dark], sizes: [.medium]) } func test_with_badge_only() throws { - //GIVEN + // GIVEN let viewModel: TabItemViewModel = .init( theme: theme, @@ -81,12 +81,12 @@ final class TabItemViewSnapshotTests: SwiftUIComponentSnapshotTestCase { .selected(true) .background(.systemBackground) - //THEN + // THEN assertSnapshot(matching: sut, modes: [.light, .dark], sizes: [.medium]) } func test_with_label_only() throws { - //GIVEN + // GIVEN let viewModel: TabItemViewModel = .init( theme: theme, @@ -98,12 +98,12 @@ final class TabItemViewSnapshotTests: SwiftUIComponentSnapshotTestCase { .apportionsSegmentWidthsByContent(true) .background(.systemBackground) - //THEN + // THEN assertSnapshot(matching: sut, modes: [.light, .dark], sizes: [.small, .medium, .large, .extraLarge]) } func test_with_icon_only() throws { - //GIVEN + // GIVEN let viewModel: TabItemViewModel = .init( theme: theme, @@ -116,12 +116,12 @@ final class TabItemViewSnapshotTests: SwiftUIComponentSnapshotTestCase { .apportionsSegmentWidthsByContent(true) .background(.systemBackground) - //THEN + // THEN assertSnapshot(matching: sut, modes: [.light, .dark], sizes: [.medium]) } func test_with_label_and_badge() throws { - //GIVEN + // GIVEN let viewModel: TabItemViewModel = .init( theme: theme, @@ -135,12 +135,12 @@ final class TabItemViewSnapshotTests: SwiftUIComponentSnapshotTestCase { .selected(true) .background(.systemBackground) - //THEN + // THEN assertSnapshot(matching: sut, modes: [.dark, .light], sizes: [.small, .medium, .large, .extraLarge]) } func test_with_icon_and_label() throws { - //GIVEN + // GIVEN let viewModel: TabItemViewModel = .init( theme: theme, @@ -154,12 +154,12 @@ final class TabItemViewSnapshotTests: SwiftUIComponentSnapshotTestCase { .apportionsSegmentWidthsByContent(false) .background(.systemBackground) - //THEN + // THEN assertSnapshot(matching: sut, modes: [.dark, .light], sizes: [.large]) } func test_with_icon_and_badge() throws { - //GIVEN + // GIVEN let viewModel: TabItemViewModel = .init( theme: theme, @@ -173,7 +173,7 @@ final class TabItemViewSnapshotTests: SwiftUIComponentSnapshotTestCase { .badge(self.badge) .background(.systemBackground) - //THEN + // THEN assertSnapshot(matching: sut, modes: [.dark, .light], sizes: [.extraSmall]) } } diff --git a/core/Sources/Components/Tab/View/SwiftUI/TabView.swift b/core/Sources/Components/Tab/View/SwiftUI/TabView.swift index dd76af559..50d7e2ce6 100644 --- a/core/Sources/Components/Tab/View/SwiftUI/TabView.swift +++ b/core/Sources/Components/Tab/View/SwiftUI/TabView.swift @@ -72,7 +72,7 @@ public struct TabView: View { self._selectedIndex = selectedIndex let viewModel = TabViewModel( theme: theme, - content: content, + content: content, tabSize: tabSize ) self.viewModel = viewModel @@ -81,7 +81,7 @@ public struct TabView: View { // MARK: - View public var body: some View { let viewModel = self.viewModel.setIsEnabled(self.isEnabled) - + if self.containerViewModel.apportionsSegmentWidthsByContent { TabApportionsSizeView(viewModel: viewModel, intent: self.intent, selectedIndex: self.$selectedIndex) } else { diff --git a/core/Sources/Components/Tab/View/UIKit/TabItemUIView.swift b/core/Sources/Components/Tab/View/UIKit/TabItemUIView.swift index 3f52c757f..1f9baad19 100644 --- a/core/Sources/Components/Tab/View/UIKit/TabItemUIView.swift +++ b/core/Sources/Components/Tab/View/UIKit/TabItemUIView.swift @@ -114,10 +114,8 @@ public final class TabItemUIView: UIControl { imageView.isUserInteractionEnabled = false imageView.adjustsImageSizeForAccessibilityContentSizeCategory = true - imageView.setContentCompressionResistancePriority(.required, - for: .horizontal) - imageView.setContentCompressionResistancePriority(.required, - for: .vertical) + imageView.setContentCompressionResistancePriority(.required, for: .horizontal) + imageView.setContentCompressionResistancePriority(.required, for: .vertical) return imageView }() @@ -271,7 +269,7 @@ public final class TabItemUIView: UIControl { } if let badge = self.badge, self.isNotHidden { - itemsWidth += badge.intrinsicContentSize.width == UIView.noIntrinsicMetric ? self.height: badge.intrinsicContentSize.width + itemsWidth += badge.intrinsicContentSize.width == UIView.noIntrinsicMetric ? self.height : badge.intrinsicContentSize.width } let numberOfSpacings = max(self.stackView.arrangedSubviews.filter(\.isNotHidden).count - (Constants.numberOfSpacerViews + 1), 0) @@ -279,9 +277,7 @@ public final class TabItemUIView: UIControl { let totalWidth = self.paddingHorizontal + (itemsWidth + spacingsWidth) + self.paddingHorizontal - let size = CGSize(width: totalWidth, height: self.height) - - return size + return CGSize(width: totalWidth, height: self.height) } /// An optional action which can be set. The action will be invoked when the tab is tapped. diff --git a/core/Sources/Components/Tab/View/UIKit/TabItemUIViewSnapshotTests.swift b/core/Sources/Components/Tab/View/UIKit/TabItemUIViewSnapshotTests.swift index f22ac8fae..711c4c78f 100644 --- a/core/Sources/Components/Tab/View/UIKit/TabItemUIViewSnapshotTests.swift +++ b/core/Sources/Components/Tab/View/UIKit/TabItemUIViewSnapshotTests.swift @@ -22,6 +22,7 @@ final class TabItemUIViewSnapshotTests: UIKitComponentSnapshotTestCase { super.setUp() self.badge = BadgeUIView(theme: theme, intent: .danger, isBorderVisible: false) + // swiftlint:disable force_unwrapping self.image = UIImage(systemName: "trash")! } diff --git a/core/Sources/Components/Tab/View/UIKit/TabItemUIViewTests.swift b/core/Sources/Components/Tab/View/UIKit/TabItemUIViewTests.swift index 590bb3046..87d7f05c8 100644 --- a/core/Sources/Components/Tab/View/UIKit/TabItemUIViewTests.swift +++ b/core/Sources/Components/Tab/View/UIKit/TabItemUIViewTests.swift @@ -187,7 +187,7 @@ final class TabItemUIViewTests: TestCase { touchDownExpectation.fulfill() } let actionExpectation = expectation(description: "Class action sent") - + self.sut.action = UIAction{ _ in actionExpectation.fulfill() } diff --git a/core/Sources/Components/Tab/View/UIKit/TabUIView.swift b/core/Sources/Components/Tab/View/UIKit/TabUIView.swift index c93be026a..414b78d7f 100644 --- a/core/Sources/Components/Tab/View/UIKit/TabUIView.swift +++ b/core/Sources/Components/Tab/View/UIKit/TabUIView.swift @@ -127,8 +127,7 @@ public final class TabUIView: UIControl { .map(\.intrinsicContentSize.height) .reduce(0, max) - let size = CGSize(width: self.maxWidth, height: height) - return size + return CGSize(width: self.maxWidth, height: height) } // MARK: - Managing interaction with the tab. @@ -277,7 +276,7 @@ public final class TabUIView: UIControl { return self.segments[safe: index]?.badge } - //MARK: - Managing segment actions + // MARK: - Managing segment actions /// Fetches the action of the segment at the index you specify, if one exists. public func actionForSegment(at index: Int) -> UIAction? { @@ -289,7 +288,7 @@ public final class TabUIView: UIControl { self.segments[safe: index]?.action = action } - //MARK: - Managing segments + // MARK: - Managing segments /// Returns the number of segments the segmented control has. public var numberOfSegments: Int { @@ -304,7 +303,7 @@ public final class TabUIView: UIControl { /// The index of the segment with an action that has a matching identifier, or NSNotFound /// if no matching action is found. public func segmentIndex(identifiedBy identifier: UIAction.Identifier) -> Int { - return self.segments.firstIndex(where: { $0.action?.identifier == identifier }) ?? NSNotFound + return self.segments.firstIndex(where: { $0.action?.identifier == identifier }) ?? NSNotFound } /// Inserts a segment at the last position you specify and gives it an image as content. @@ -322,7 +321,7 @@ public final class TabUIView: UIControl { self.insertTab(tab, at: index, animated: animated) } - ///Inserts a segment at the last position you specify and gives it a title as content. + /// Inserts a segment at the last position you specify and gives it a title as content. public func addSegment(with title: String, animated: Bool = false) { let index = self.numberOfSegments @@ -337,7 +336,7 @@ public final class TabUIView: UIControl { self.insertTab(tab, at: index, animated: animated) } - ///Inserts a segment at the last position you specify and gives it a title as content. + /// Inserts a segment at the last position you specify and gives it a title as content. public func addSegment(withImage icon: UIImage, andTitle title: String, animated: Bool = false) { @@ -367,7 +366,7 @@ public final class TabUIView: UIControl { self.insertTab(tab, at: index, animated: animated) } - ///Inserts a segment at the position you specify and gives it a title as content. + /// Inserts a segment at the position you specify and gives it a title as content. public func insertSegment(with title: String, at index: Int, animated: Bool = false) { @@ -381,10 +380,11 @@ public final class TabUIView: UIControl { self.insertTab(tab, at: index, animated: animated) } - ///Inserts a segment at the position you specify and gives it a title as content. + /// Inserts a segment at the position you specify and gives it a title as content. public func insertSegment(withImage icon: UIImage, andTitle title: String, - at index: Int, animated: Bool = false) { + at index: Int, + animated: Bool = false) { self.viewModel.content.insert(.init(icon: icon, title: title), at: index) let tab = TabItemUIView( theme: self.theme, @@ -395,24 +395,24 @@ public final class TabUIView: UIControl { self.insertTab(tab, at: index, animated: animated) } - ///Replace all current segments with segments with just icons + /// Replace all current segments with segments with just icons public func setSegments(withImages icons: [UIImage]) { let content: [TabUIItemContent] = icons.map{ .init(icon: $0, title: nil) } self.setTabItems(content: content) } - ///Replace all current segments with segments with just titles + /// Replace all current segments with segments with just titles public func setSegments(withTitles titles: [String]) { let content: [TabUIItemContent] = titles.map{ .init(icon: nil, title: $0) } self.setTabItems(content: content) } - ///Replace all current segments with segments with icons & titles + /// Replace all current segments with segments with icons & titles public func setSegments(withContent content: [TabUIItemContent]) { self.setTabItems(content: content) } - ///Enables the segment you specify. + /// Enables the segment you specify. public func setEnabled(_ isEnabled: Bool, at index: Int, animated: Bool = false) { @@ -421,12 +421,12 @@ public final class TabUIView: UIControl { } } - ///Returns whether the indicated segment is enabled. + /// Returns whether the indicated segment is enabled. public func isEnabledForSegment(at index: Int) -> Bool { self.segments[safe: index]?.isEnabled ?? false } - ///Removes all segments of the segmented control. + /// Removes all segments of the segmented control. public func removeAllSegments() { self.stackView.removeArrangedSubviews() } diff --git a/core/Sources/Components/Tab/View/UIKit/TabUIViewDelegate.swift b/core/Sources/Components/Tab/View/UIKit/TabUIViewDelegate.swift index 47a7a67ff..5696859c4 100644 --- a/core/Sources/Components/Tab/View/UIKit/TabUIViewDelegate.swift +++ b/core/Sources/Components/Tab/View/UIKit/TabUIViewDelegate.swift @@ -16,5 +16,5 @@ public protocol TabUIViewDelegate: AnyObject { /// - index: the index of the segement that is selected. /// - sender: the sender of the action. /// - note: This is equivalent to setting the action on the TabUIView `addAction(pressedAction, for: .valueChanged)` - func segmentSelected(index: Int, sender: TabUIView) + func segmentSelected(index: Int, sender: TabUIView) } diff --git a/core/Sources/Components/Tab/View/UIKit/TabUIViewTests.swift b/core/Sources/Components/Tab/View/UIKit/TabUIViewTests.swift index a4b975c79..6026efb3f 100644 --- a/core/Sources/Components/Tab/View/UIKit/TabUIViewTests.swift +++ b/core/Sources/Components/Tab/View/UIKit/TabUIViewTests.swift @@ -11,6 +11,7 @@ import XCTest @testable import SparkCore +// swiftlint:disable force_unwrapping final class TabUIViewTests: XCTestCase { var sut: TabUIView! var subscriptions = Set() @@ -96,10 +97,11 @@ final class TabUIViewTests: XCTestCase { // Given let expect = expectation(description: "Expect publisher to publish new selected tab") var tabTapped = 0 - self.sut.publisher.sink { selectedTab in + self.sut.publisher.sink(receiveValue: { selectedTab in tabTapped = selectedTab expect.fulfill() - }.store(in: &self.subscriptions) + }) + .store(in: &self.subscriptions) // When self.sut.segments[2].sendActions(for: .touchUpInside) @@ -114,9 +116,10 @@ final class TabUIViewTests: XCTestCase { let expect = expectation(description: "Expect publisher not to be called") expect.isInverted = true - self.sut.publisher.sink { (selectedTab: Int) in + self.sut.publisher.sink(receiveValue: { (selectedTab: Int) in expect.fulfill() - }.store(in: &self.subscriptions) + }) + .store(in: &self.subscriptions) // When self.sut.selectedSegmentIndex = 2 diff --git a/core/Sources/Components/Tab/ViewModel/TabItemViewModel.swift b/core/Sources/Components/Tab/ViewModel/TabItemViewModel.swift index 5a77ca7ff..60f2f0a32 100644 --- a/core/Sources/Components/Tab/ViewModel/TabItemViewModel.swift +++ b/core/Sources/Components/Tab/ViewModel/TabItemViewModel.swift @@ -9,7 +9,6 @@ import Combine import UIKit - /// `TabItemViewModel` is the view model for both the SwiftUI `TabItemView` as well as the UIKit `TabItemUIView`. /// The view model is responsible for returning the varying attributes to the views, i.e. colors and attributes. These are determined by the theme, intent, tabState, content and tabGetStateAttributesUseCase. /// When the theme, intent, states or contents change the new values are calculated and published. @@ -22,9 +21,9 @@ final class TabItemViewModel: ObservableObject where Content: TitleCont self.updateStateAttributes() } } - + private let tabGetStateAttributesUseCase: TabGetStateAttributesUseCasable - + // MARK: Properties var theme: Theme { didSet { @@ -46,7 +45,6 @@ final class TabItemViewModel: ObservableObject where Content: TitleCont } } - private (set) var isEnabled: Bool { get { self.tabState.isEnabled @@ -82,7 +80,7 @@ final class TabItemViewModel: ObservableObject where Content: TitleCont self.updateStateAttributes() } } - + // MARK: Init /// Init /// Parameters: diff --git a/core/Sources/Components/Tab/ViewModel/TabItemViewModelTests.swift b/core/Sources/Components/Tab/ViewModel/TabItemViewModelTests.swift index fee72eb43..5ef3290f1 100644 --- a/core/Sources/Components/Tab/ViewModel/TabItemViewModelTests.swift +++ b/core/Sources/Components/Tab/ViewModel/TabItemViewModelTests.swift @@ -11,20 +11,20 @@ import Combine import XCTest final class TabItemViewModelTests: XCTestCase { - + // MARK: - Private properties private var theme: ThemeGeneratedMock! private var tabGetStateAttributesUseCase: TabGetStateAttributesUseCasableGeneratedMock! private var cancellables = Set() private var spacings: TabItemSpacings! private var colors: TabItemColors! - + // MARK: - Setup override func setUp() { super.setUp() self.theme = ThemeGeneratedMock.mocked() tabGetStateAttributesUseCase = TabGetStateAttributesUseCasableGeneratedMock() - + self.spacings = TabItemSpacings( verticalEdge: self.theme.layout.spacing.medium, horizontalEdge: self.theme.layout.spacing.large, @@ -48,7 +48,7 @@ final class TabItemViewModelTests: XCTestCase { font: theme.typography.body1 ) } - + // MARK: - Tests func test_initialization() { // Given @@ -63,7 +63,7 @@ final class TabItemViewModelTests: XCTestCase { XCTAssertFalse(sut.isPressed, "sut's isPressed parameter should be false") XCTAssertTrue(sut.isEnabled, "sut's isDisabled parameter should be false") } - + func test_usecase_is_executed_on_initialization() { // Given _ = self.sut(intent: .support) @@ -74,7 +74,7 @@ final class TabItemViewModelTests: XCTestCase { XCTAssertEqual(arguments?.intent, .support, "sut intent should be support") XCTAssertEqual(arguments?.state, TabState(), "sut state should be TabState that has default parameters") } - + func test_published_attributes_on_initialization() { // Given let sut = self.sut() @@ -90,30 +90,30 @@ final class TabItemViewModelTests: XCTestCase { heights: expectedHeights, font: self.theme.typography.body1 ) - + let expectation = expectation(description: "wait for attributes") var givenAttributes: TabStateAttributes? // When - sut.$tabStateAttributes.sink { attributes in + sut.$tabStateAttributes.sink(receiveValue: { attributes in givenAttributes = attributes expectation.fulfill() - } + }) .store(in: &self.cancellables) // Then wait(for: [expectation], timeout: 0.1) XCTAssertEqual(givenAttributes, expectedAttributes) } - + func test_published_attributes_on_change() { // Given let sut = self.sut() let expectation = expectation(description: "wait for attributes") expectation.expectedFulfillmentCount = 2 - sut.$tabStateAttributes.sink { _ in + sut.$tabStateAttributes.sink(receiveValue: { _ in expectation.fulfill() - } + }) .store(in: &self.cancellables) // When @@ -122,14 +122,14 @@ final class TabItemViewModelTests: XCTestCase { // Then wait(for: [expectation], timeout: 0.1) } - + func test_attributes_not_published() { // Given let sut = self.sut() let expectation = expectation(description: "wait for attributes") - sut.$tabStateAttributes.sink { _ in + sut.$tabStateAttributes.sink(receiveValue: { _ in expectation.fulfill() - } + }) .store(in: &self.cancellables) // When @@ -138,15 +138,15 @@ final class TabItemViewModelTests: XCTestCase { // Then wait(for: [expectation], timeout: 0.1) } - + func test_published_is_pressed_on_change() { // Given let sut = self.sut() let expectation = expectation(description: "wait for attributes") expectation.expectedFulfillmentCount = 2 - sut.$tabStateAttributes.sink { _ in + sut.$tabStateAttributes.sink(receiveValue: { _ in expectation.fulfill() - } + }) .store(in: &self.cancellables) // When @@ -155,20 +155,20 @@ final class TabItemViewModelTests: XCTestCase { // Then wait(for: [expectation], timeout: 0.1) } - + func test_published_is_disable_on_change() { // Given let sut = self.sut() let expectation = expectation(description: "wait for attributes") expectation.expectedFulfillmentCount = 2 var counter = 0 - sut.$tabStateAttributes.sink { _ in + sut.$tabStateAttributes.sink(receiveValue: { _ in counter += 1 let arguments = self.tabGetStateAttributesUseCase.executeWithThemeAndIntentAndStateAndTabSizeAndHasTitleReceivedArguments XCTAssertEqual(arguments?.state.isEnabled, counter == 1) expectation.fulfill() - } + }) .store(in: &self.cancellables) // When @@ -185,9 +185,9 @@ final class TabItemViewModelTests: XCTestCase { let expectation = expectation(description: "wait for attributes") expectation.expectedFulfillmentCount = 2 - sut.$tabStateAttributes.sink { attributes in + sut.$tabStateAttributes.sink(receiveValue: { attributes in expectation.fulfill() - } + }) .store(in: &self.cancellables) // When @@ -205,9 +205,9 @@ final class TabItemViewModelTests: XCTestCase { let expectation = expectation(description: "wait for attributes") expectation.expectedFulfillmentCount = 1 - sut.$tabStateAttributes.sink { attributes in + sut.$tabStateAttributes.sink(receiveValue: { attributes in expectation.fulfill() - } + }) .store(in: &self.cancellables) // When @@ -225,9 +225,9 @@ final class TabItemViewModelTests: XCTestCase { let expectation = expectation(description: "wait for attributes") expectation.expectedFulfillmentCount = 2 - sut.$tabStateAttributes.sink { attributes in + sut.$tabStateAttributes.sink(receiveValue: { attributes in expectation.fulfill() - } + }) .store(in: &self.cancellables) // When @@ -237,7 +237,6 @@ final class TabItemViewModelTests: XCTestCase { wait(for: [expectation], timeout: 0.1) } - func test_when_intent_changes_then_attributes_published() { // Given let sut = self.sut(intent: .main, title: "Label") @@ -245,9 +244,9 @@ final class TabItemViewModelTests: XCTestCase { let expectation = expectation(description: "wait for attributes") expectation.expectedFulfillmentCount = 2 - sut.$tabStateAttributes.sink { attributes in + sut.$tabStateAttributes.sink(receiveValue: { attributes in expectation.fulfill() - } + }) .store(in: &self.cancellables) // When @@ -264,9 +263,9 @@ final class TabItemViewModelTests: XCTestCase { let expectation = expectation(description: "wait for attributes") expectation.expectedFulfillmentCount = 1 - sut.$tabStateAttributes.sink { attributes in + sut.$tabStateAttributes.sink(receiveValue: { attributes in expectation.fulfill() - } + }) .store(in: &self.cancellables) // When @@ -283,9 +282,9 @@ final class TabItemViewModelTests: XCTestCase { let expectation = expectation(description: "wait for attributes") expectation.expectedFulfillmentCount = 2 - sut.$tabStateAttributes.sink { attributes in + sut.$tabStateAttributes.sink(receiveValue: { attributes in expectation.fulfill() - } + }) .store(in: &self.cancellables) // When @@ -299,7 +298,7 @@ final class TabItemViewModelTests: XCTestCase { // MARK: - Helper private extension TabItemViewModelTests { - + func sut( intent: TabIntent = .main, size: TabSize = .md, diff --git a/core/Sources/Components/Tab/ViewModel/TabViewModelTests.swift b/core/Sources/Components/Tab/ViewModel/TabViewModelTests.swift index a82e9d466..cb4048b8d 100644 --- a/core/Sources/Components/Tab/ViewModel/TabViewModelTests.swift +++ b/core/Sources/Components/Tab/ViewModel/TabViewModelTests.swift @@ -36,13 +36,13 @@ final class TabViewModelTests: XCTestCase { backgroundColor: ColorTokenGeneratedMock(uiColor: .blue) ) - let content: [TabItemContent] = [.init(icon: nil, title: "Title")] + let content: [TabItemContent] = [.init(icon: nil, title: "Title")] self.useCase.executeWithThemeAndSizeAndIsEnabledReturnValue = expectedAttributes let sut = TabViewModel( theme: self.theme, apportionsSegmentWidthsByContent: false, - content: content, + content: content, tabSize: .md, useCase: self.useCase ) @@ -70,14 +70,14 @@ final class TabViewModelTests: XCTestCase { lineColor: ColorTokenGeneratedMock(uiColor: .red), backgroundColor: ColorTokenGeneratedMock(uiColor: .blue) ) - let content: [TabItemContent] = [.init(icon: nil, title: "Title")] + let content: [TabItemContent] = [.init(icon: nil, title: "Title")] self.useCase.executeWithThemeAndSizeAndIsEnabledReturnValue = expectedAttributes let sut = TabViewModel( theme: self.theme, apportionsSegmentWidthsByContent: false, - content: content, + content: content, tabSize: .md, useCase: self.useCase ) @@ -102,18 +102,18 @@ final class TabViewModelTests: XCTestCase { expect.expectedFulfillmentCount = 2 let expectedAttributes = TabsAttributes( - lineHeight: 1, + lineHeight: 1, itemHeight: 40.0, lineColor: ColorTokenGeneratedMock(uiColor: .red), backgroundColor: ColorTokenGeneratedMock(uiColor: .blue) ) - let content: [TabItemContent] = [.init(icon: nil, title: "Title")] + let content: [TabItemContent] = [.init(icon: nil, title: "Title")] self.useCase.executeWithThemeAndSizeAndIsEnabledReturnValue = expectedAttributes let sut = TabViewModel( theme: self.theme, apportionsSegmentWidthsByContent: false, - content: content, + content: content, tabSize: .md, useCase: self.useCase ) @@ -133,10 +133,10 @@ final class TabViewModelTests: XCTestCase { } func test_enable() { - let content: [TabItemContent] = [.init(icon: nil, title: "Title")] + let content: [TabItemContent] = [.init(icon: nil, title: "Title")] let expectedAttributes = TabsAttributes( - lineHeight: 1, + lineHeight: 1, itemHeight: 40.0, lineColor: ColorTokenGeneratedMock(uiColor: .red), backgroundColor: ColorTokenGeneratedMock(uiColor: .blue) @@ -147,7 +147,7 @@ final class TabViewModelTests: XCTestCase { let sut = TabViewModel( theme: self.theme, apportionsSegmentWidthsByContent: false, - content: content, + content: content, tabSize: .md, useCase: self.useCase ) @@ -158,10 +158,10 @@ final class TabViewModelTests: XCTestCase { } func test_disable() { - let content: [TabItemContent] = [.init(icon: nil, title: "Title")] + let content: [TabItemContent] = [.init(icon: nil, title: "Title")] let expectedAttributes = TabsAttributes( - lineHeight: 1, + lineHeight: 1, itemHeight: 40.0, lineColor: ColorTokenGeneratedMock(uiColor: .red), backgroundColor: ColorTokenGeneratedMock(uiColor: .blue) @@ -172,7 +172,7 @@ final class TabViewModelTests: XCTestCase { let sut = TabViewModel( theme: self.theme, apportionsSegmentWidthsByContent: false, - content: content, + content: content, tabSize: .md, useCase: self.useCase ) @@ -183,7 +183,7 @@ final class TabViewModelTests: XCTestCase { } func test_disable_single_tab() { - let content: [TabItemContent] = [.init(icon: nil, title: "Title")] + let content: [TabItemContent] = [.init(icon: nil, title: "Title")] let expectedAttributes = TabsAttributes( lineHeight: 1, diff --git a/core/Sources/Components/Tag/ViewModel/TagViewModelTests.swift b/core/Sources/Components/Tag/ViewModel/TagViewModelTests.swift index 999bb0b47..6194e1bb2 100644 --- a/core/Sources/Components/Tag/ViewModel/TagViewModelTests.swift +++ b/core/Sources/Components/Tag/ViewModel/TagViewModelTests.swift @@ -252,8 +252,7 @@ final class TagViewModelTests: XCTestCase { XCTAssertEqual(viewModel.text, newText, "Wrong text value") - XCTAssertNil(viewModel.attributedText, - "Wrong attributedText value") + XCTAssertNil(viewModel.attributedText, "Wrong attributedText value") } func test_setAttributedText() { @@ -273,7 +272,6 @@ final class TagViewModelTests: XCTestCase { XCTAssertEqual(viewModel.attributedText, newAttributedText, "Wrong attributedText value") - XCTAssertNil(viewModel.text, - "Wrong text value") + XCTAssertNil(viewModel.text, "Wrong text value") } } diff --git a/core/Sources/Components/TextField/Addons/View/SwiftUI/TextFieldAddon.swift b/core/Sources/Components/TextField/Addons/View/SwiftUI/TextFieldAddon.swift index 32d69d300..5d9ad6b7e 100644 --- a/core/Sources/Components/TextField/Addons/View/SwiftUI/TextFieldAddon.swift +++ b/core/Sources/Components/TextField/Addons/View/SwiftUI/TextFieldAddon.swift @@ -14,7 +14,7 @@ public struct TextFieldAddon: View { let withPadding: Bool let layoutPriority: Double private let content: () -> Content - + /// TextFieldAddon initializer /// - Parameters: /// - withPadding: Add addon padding if `true`, default is `false` diff --git a/core/Sources/Components/TextField/Addons/View/SwiftUI/TextFieldAddons.swift b/core/Sources/Components/TextField/Addons/View/SwiftUI/TextFieldAddons.swift index 5a1997069..edbeeb170 100644 --- a/core/Sources/Components/TextField/Addons/View/SwiftUI/TextFieldAddons.swift +++ b/core/Sources/Components/TextField/Addons/View/SwiftUI/TextFieldAddons.swift @@ -88,7 +88,7 @@ public struct TextFieldAddons: View { rightView: rightView ) } - + /// TextFieldView initializer /// - Parameters: /// - titleKey: The textfield's current placeholder diff --git a/core/Sources/Components/TextField/View/UIKit/TextFieldUIView.swift b/core/Sources/Components/TextField/View/UIKit/TextFieldUIView.swift index 8ab48b95a..12806808e 100644 --- a/core/Sources/Components/TextField/View/UIKit/TextFieldUIView.swift +++ b/core/Sources/Components/TextField/View/UIKit/TextFieldUIView.swift @@ -113,7 +113,8 @@ public final class TextFieldUIView: UITextField { private func subscribeToViewModel() { self.viewModel.$textColor.removeDuplicates(by: { lhs, rhs in lhs.equals(rhs) - }).subscribe(in: &self.cancellables) { [weak self] textColor in + }) + .subscribe(in: &self.cancellables) { [weak self] textColor in guard let self else { return } self.textColor = textColor.uiColor self.tintColor = textColor.uiColor @@ -121,21 +122,24 @@ public final class TextFieldUIView: UITextField { self.viewModel.$backgroundColor.removeDuplicates(by: { lhs, rhs in lhs.equals(rhs) - }).subscribe(in: &self.cancellables) { [weak self] backgroundColor in + }) + .subscribe(in: &self.cancellables) { [weak self] backgroundColor in guard let self else { return } self.backgroundColor = backgroundColor.uiColor } self.viewModel.$borderColor.removeDuplicates(by: { lhs, rhs in lhs.equals(rhs) - }).subscribe(in: &self.cancellables) { [weak self] borderColor in + }) + .subscribe(in: &self.cancellables) { [weak self] borderColor in guard let self else { return } self.setBorderColor(from: borderColor) } self.viewModel.$placeholderColor.removeDuplicates(by: { lhs, rhs in lhs.equals(rhs) - }).subscribe(in: &self.cancellables) { [weak self] placeholderColor in + }) + .subscribe(in: &self.cancellables) { [weak self] placeholderColor in guard let self else { return } self.setPlaceholder(self.placeholder, foregroundColor: placeholderColor, font: self.viewModel.font) } diff --git a/core/Sources/Components/TextField/ViewModel/TextFieldViewModel.swift b/core/Sources/Components/TextField/ViewModel/TextFieldViewModel.swift index 7d48a6207..d2a6dff95 100644 --- a/core/Sources/Components/TextField/ViewModel/TextFieldViewModel.swift +++ b/core/Sources/Components/TextField/ViewModel/TextFieldViewModel.swift @@ -146,7 +146,7 @@ class TextFieldViewModel: ObservableObject { func setBorderLayout() { let borderLayout = self.getBorderLayoutUseCase.execute( theme: self.theme, - borderStyle: self.borderStyle, //.none + borderStyle: self.borderStyle, // .none isFocused: self.isFocused ) self.borderWidth = borderLayout.width diff --git a/core/Sources/Components/TextField/ViewModel/TextFieldViewModelTests.swift b/core/Sources/Components/TextField/ViewModel/TextFieldViewModelTests.swift index bee749261..9efd062e3 100644 --- a/core/Sources/Components/TextField/ViewModel/TextFieldViewModelTests.swift +++ b/core/Sources/Components/TextField/ViewModel/TextFieldViewModelTests.swift @@ -243,7 +243,7 @@ final class TextFieldViewModelTests: XCTestCase { // THEN - Colors XCTAssertEqual(self.getColorsUseCase.executeWithThemeAndIntentAndIsFocusedAndIsEnabledAndIsUserInteractionEnabledCallsCount, 1, "getColorsUseCase.executeWithThemeAndIntentAndIsFocusedAndIsEnabledAndIsUserInteractionEnabled should have been called once") let getColorsReceivedArguments = try XCTUnwrap(self.getColorsUseCase.executeWithThemeAndIntentAndIsFocusedAndIsEnabledAndIsUserInteractionEnabledReceivedArguments, "Couldn't unwrap getColorsReceivedArguments") - XCTAssertEqual(getColorsReceivedArguments.intent , .neutral, "Wrong getColorsReceivedArguments.intent") + XCTAssertEqual(getColorsReceivedArguments.intent, .neutral, "Wrong getColorsReceivedArguments.intent") XCTAssertTrue(self.viewModel.textColor.equals(newExpectedColors.text), "Wrong textColor") XCTAssertTrue(self.viewModel.placeholderColor.equals(newExpectedColors.placeholder), "Wrong placeholderColor") XCTAssertTrue(self.viewModel.borderColor.equals(newExpectedColors.border), "Wrong borderColor") diff --git a/core/Sources/Components/TextLink/Enum/Public/TextLinkTypography.swift b/core/Sources/Components/TextLink/Enum/Public/TextLinkTypography.swift index c2c5a38b2..fe5268342 100644 --- a/core/Sources/Components/TextLink/Enum/Public/TextLinkTypography.swift +++ b/core/Sources/Components/TextLink/Enum/Public/TextLinkTypography.swift @@ -19,7 +19,7 @@ public enum TextLinkTypography: CaseIterable { case headline1 /// Use the **headline2** typography case headline2 - + /// Use the **subhead** typography case subhead diff --git a/core/Sources/Components/TextLink/UseCase/GetColor/TextLinkGetColorUseCase.swift b/core/Sources/Components/TextLink/UseCase/GetColor/TextLinkGetColorUseCase.swift index 7d4b236f7..2dc37556f 100644 --- a/core/Sources/Components/TextLink/UseCase/GetColor/TextLinkGetColorUseCase.swift +++ b/core/Sources/Components/TextLink/UseCase/GetColor/TextLinkGetColorUseCase.swift @@ -28,23 +28,23 @@ struct TextLinkGetColorUseCase: TextLinkGetColorUseCaseable { case .accent: return isHighlighted ? colors.states.accentPressed : colors.accent.accent case .alert: - return isHighlighted ? colors.states.alertPressed: colors.feedback.alert + return isHighlighted ? colors.states.alertPressed : colors.feedback.alert case .basic: - return isHighlighted ? colors.states.basicPressed: colors.basic.basic + return isHighlighted ? colors.states.basicPressed : colors.basic.basic case .danger: - return isHighlighted ? colors.states.errorPressed: colors.feedback.error + return isHighlighted ? colors.states.errorPressed : colors.feedback.error case .info: - return isHighlighted ? colors.states.infoPressed: colors.feedback.info + return isHighlighted ? colors.states.infoPressed : colors.feedback.info case .main: - return isHighlighted ? colors.states.mainPressed: colors.main.main + return isHighlighted ? colors.states.mainPressed : colors.main.main case .neutral: - return isHighlighted ? colors.states.neutralPressed: colors.feedback.neutral + return isHighlighted ? colors.states.neutralPressed : colors.feedback.neutral case .onSurface: return colors.base.onSurface case .success: - return isHighlighted ? colors.states.successPressed: colors.feedback.success + return isHighlighted ? colors.states.successPressed : colors.feedback.success case .support: - return isHighlighted ? colors.states.supportPressed: colors.support.support + return isHighlighted ? colors.states.supportPressed : colors.support.support } } } diff --git a/core/Sources/Components/TextLink/UseCase/GetColor/TextLinkGetColorUseCaseTests.swift b/core/Sources/Components/TextLink/UseCase/GetColor/TextLinkGetColorUseCaseTests.swift index 5fd7c9276..47d85ccbb 100644 --- a/core/Sources/Components/TextLink/UseCase/GetColor/TextLinkGetColorUseCaseTests.swift +++ b/core/Sources/Components/TextLink/UseCase/GetColor/TextLinkGetColorUseCaseTests.swift @@ -18,7 +18,7 @@ final class TextLinkGetColorUseCaseTests: XCTestCase { // GIVEN let useCase = TextLinkGetColorUseCase() let colorsMock = ColorsGeneratedMock.mocked() - + let givenIntents = TextLinkIntent.allCases // WHEN diff --git a/core/Sources/Components/TextLink/View/SwiftUI/TextLinkView.swift b/core/Sources/Components/TextLink/View/SwiftUI/TextLinkView.swift index ce5e45643..aa833288e 100644 --- a/core/Sources/Components/TextLink/View/SwiftUI/TextLinkView.swift +++ b/core/Sources/Components/TextLink/View/SwiftUI/TextLinkView.swift @@ -34,7 +34,7 @@ public struct TextLinkView: View { /// - textHighlightRange: The optional range to specify the highlighted part of the text link. /// - intent: The intent of the text link. /// - typography: The typography of the text link. - /// - variant: The variant of the text link. + /// - variant: The variant of the text link. /// - image: The optional image of the text link. /// - alignment: The alignment image of the text link. /// - action: The action of the text link when the user tap on the component. diff --git a/core/Sources/Components/TextLink/View/UIKit/TextLinkUIViewSnapshotTests.swift b/core/Sources/Components/TextLink/View/UIKit/TextLinkUIViewSnapshotTests.swift index 237564655..f910838ff 100644 --- a/core/Sources/Components/TextLink/View/UIKit/TextLinkUIViewSnapshotTests.swift +++ b/core/Sources/Components/TextLink/View/UIKit/TextLinkUIViewSnapshotTests.swift @@ -43,7 +43,7 @@ final class TextLinkUIViewSnapshotTests: UIKitComponentSnapshotTestCase { self.assertSnapshot( matching: view, modes: configuration.modes, - sizes: configuration.sizes, + sizes: configuration.sizes, testName: configuration.testName() ) } diff --git a/core/Sources/Components/TextLink/ViewModel/TextLinkViewModel.swift b/core/Sources/Components/TextLink/ViewModel/TextLinkViewModel.swift index d29130034..4e0787ca1 100644 --- a/core/Sources/Components/TextLink/ViewModel/TextLinkViewModel.swift +++ b/core/Sources/Components/TextLink/ViewModel/TextLinkViewModel.swift @@ -160,7 +160,7 @@ class TextLinkViewModel: ObservableObject { private func contentDidUpdate(forceToReload: Bool = false) { let color = self.getColorUseCase.execute( - intent: self.intent, + intent: self.intent, isHighlighted: self.isHighlighted, colors: self.theme.colors ) diff --git a/core/Sources/Components/TextLink/ViewModel/TextLinkViewModelTests.swift b/core/Sources/Components/TextLink/ViewModel/TextLinkViewModelTests.swift index 6a5a71b6a..aafabd731 100644 --- a/core/Sources/Components/TextLink/ViewModel/TextLinkViewModelTests.swift +++ b/core/Sources/Components/TextLink/ViewModel/TextLinkViewModelTests.swift @@ -319,7 +319,7 @@ final class TextLinkViewModelTests: XCTestCase { givenIsContentDidUpdate: givenIsDifferentNewValue ) } - + func test_set_textHighlightRange_with_different_new_value() { self.testSetTextHighlightRange( givenIsDifferentNewValue: true @@ -386,7 +386,7 @@ final class TextLinkViewModelTests: XCTestCase { let newValue = givenIsDifferentNewValue ? .accent : defaultValue let stub = Stub( - frameworkType: .swiftUI, + frameworkType: .swiftUI, intent: defaultValue ) let viewModel = stub.viewModel @@ -791,7 +791,7 @@ private final class Stub: TextLinkViewModelStub { ) super.init( - viewModel: viewModel, + viewModel: viewModel, getColorUseCaseMock: getColorUseCaseMock, getTypographiesUseCaseMock: getTypographiesUseCaseMock, getAttributedStringUseCaseMock: getAttributedStringUseCaseMock, diff --git a/core/Sources/Extension/PropertyWrapper/ScaledUIMetric.swift b/core/Sources/Extension/PropertyWrapper/ScaledUIMetric.swift index 0ece4ef12..6c01d6c5c 100644 --- a/core/Sources/Extension/PropertyWrapper/ScaledUIMetric.swift +++ b/core/Sources/Extension/PropertyWrapper/ScaledUIMetric.swift @@ -9,7 +9,7 @@ import UIKit /// ScaledUIMetric is a property wrapper for UIKit. It scales values according to the current trait collection content size and behaves similar to the @`ScaledMetric`-property wrapper for SwiftUI. -@propertyWrapper struct ScaledUIMetric where Value : BinaryFloatingPoint { +@propertyWrapper struct ScaledUIMetric where Value: BinaryFloatingPoint { // MARK: - Properties /// Returns the scaled value for the `baseValue` according to the trait collection. When setting this property a new baseValue is set. diff --git a/core/Sources/Extension/PropertyWrapper/ScaledUIMetricTests.swift b/core/Sources/Extension/PropertyWrapper/ScaledUIMetricTests.swift index f4b5a0c84..5393c9c6e 100644 --- a/core/Sources/Extension/PropertyWrapper/ScaledUIMetricTests.swift +++ b/core/Sources/Extension/PropertyWrapper/ScaledUIMetricTests.swift @@ -11,6 +11,7 @@ import Combine import SwiftUI import XCTest +// swiftlint:disable force_unwrapping final class ScaledUIMetricTests: XCTestCase { // MARK: - Properties diff --git a/core/Sources/Theming/Content/Colors/ColorsGeneratedMock+ExtensionTests.swift b/core/Sources/Theming/Content/Colors/ColorsGeneratedMock+ExtensionTests.swift index 21f0c88e4..08efeccd7 100644 --- a/core/Sources/Theming/Content/Colors/ColorsGeneratedMock+ExtensionTests.swift +++ b/core/Sources/Theming/Content/Colors/ColorsGeneratedMock+ExtensionTests.swift @@ -21,7 +21,7 @@ extension ColorsGeneratedMock { mock.basic = ColorsBasicGeneratedMock.mocked() mock.base = ColorsBaseGeneratedMock.mocked() mock.feedback = ColorsFeedbackGeneratedMock.mocked() - mock.states = ColorsStatesGeneratedMock.mocked() + mock.states = ColorsStatesGeneratedMock.mocked() return mock } diff --git a/core/Sources/Theming/Content/Colors/Content/Base/ColorsBaseGeneratedMock+ExtensionTests.swift b/core/Sources/Theming/Content/Colors/Content/Base/ColorsBaseGeneratedMock+ExtensionTests.swift index 9a3454027..9a6648eb0 100644 --- a/core/Sources/Theming/Content/Colors/Content/Base/ColorsBaseGeneratedMock+ExtensionTests.swift +++ b/core/Sources/Theming/Content/Colors/Content/Base/ColorsBaseGeneratedMock+ExtensionTests.swift @@ -14,7 +14,7 @@ extension ColorsBaseGeneratedMock { static func mocked() -> ColorsBaseGeneratedMock { let mock = ColorsBaseGeneratedMock() - + mock.underlyingBackground = ColorTokenGeneratedMock.random() mock.underlyingOnBackground = ColorTokenGeneratedMock.random() mock.underlyingBackgroundVariant = ColorTokenGeneratedMock.random() diff --git a/core/Sources/Theming/Content/Colors/Content/Support/ColorsSupportGeneratedMock+ExtensionTests.swift b/core/Sources/Theming/Content/Colors/Content/Support/ColorsSupportGeneratedMock+ExtensionTests.swift index 64203b0f1..7898835af 100644 --- a/core/Sources/Theming/Content/Colors/Content/Support/ColorsSupportGeneratedMock+ExtensionTests.swift +++ b/core/Sources/Theming/Content/Colors/Content/Support/ColorsSupportGeneratedMock+ExtensionTests.swift @@ -20,7 +20,7 @@ extension ColorsSupportGeneratedMock { mock.underlyingSupportVariant = ColorTokenGeneratedMock.random() mock.underlyingOnSupportVariant = ColorTokenGeneratedMock.random() - + mock.underlyingSupportContainer = ColorTokenGeneratedMock.random() mock.underlyingOnSupportContainer = ColorTokenGeneratedMock.random() diff --git a/core/Sources/Theming/Content/Elevation/Shadow/Drop/ElevationDropShadowsDefault.swift b/core/Sources/Theming/Content/Elevation/Shadow/Drop/ElevationDropShadowsDefault.swift index bb1d0424e..fc84fdf24 100644 --- a/core/Sources/Theming/Content/Elevation/Shadow/Drop/ElevationDropShadowsDefault.swift +++ b/core/Sources/Theming/Content/Elevation/Shadow/Drop/ElevationDropShadowsDefault.swift @@ -9,7 +9,7 @@ public struct ElevationDropShadowsDefault: ElevationDropShadows { // MARK: - Properties - + public let small: ElevationShadow public let medium: ElevationShadow public let large: ElevationShadow diff --git a/core/Sources/Theming/Content/Elevation/Shadow/ElevationShadowDefault.swift b/core/Sources/Theming/Content/Elevation/Shadow/ElevationShadowDefault.swift index ef08558d5..076de7c08 100644 --- a/core/Sources/Theming/Content/Elevation/Shadow/ElevationShadowDefault.swift +++ b/core/Sources/Theming/Content/Elevation/Shadow/ElevationShadowDefault.swift @@ -30,4 +30,3 @@ public struct ElevationShadowDefault: ElevationShadow { } } - diff --git a/core/Sources/Theming/Content/Typography/TypographyDefault.swift b/core/Sources/Theming/Content/Typography/TypographyDefault.swift index 08fc0caab..bd6d2b405 100644 --- a/core/Sources/Theming/Content/Typography/TypographyDefault.swift +++ b/core/Sources/Theming/Content/Typography/TypographyDefault.swift @@ -88,7 +88,7 @@ public struct TypographyFontTokenDefault: TypographyFontToken { let textStyle = UIFont.TextStyle(from: self.fontTextStyle) return UIFontMetrics(forTextStyle: textStyle).scaledFont(for: font) } - + public var font: Font { let textStyle = Font.TextStyle(from: self.fontTextStyle) return Font.custom(self.fontName, diff --git a/core/Sources/Theming/Content/Typography/TypographyGeneratedMock+ExtensionTests.swift b/core/Sources/Theming/Content/Typography/TypographyGeneratedMock+ExtensionTests.swift index ca008115b..e8efeeb6f 100644 --- a/core/Sources/Theming/Content/Typography/TypographyGeneratedMock+ExtensionTests.swift +++ b/core/Sources/Theming/Content/Typography/TypographyGeneratedMock+ExtensionTests.swift @@ -39,7 +39,7 @@ extension TypographyGeneratedMock { typography.subhead = TypographyFontTokenGeneratedMock.mocked(.subheadline) typography.callout = TypographyFontTokenGeneratedMock.mocked(.callout) - + return typography } } diff --git a/core/Sources/Theming/Theme/ThemeGeneratedMock+ExtensionTests.swift b/core/Sources/Theming/Theme/ThemeGeneratedMock+ExtensionTests.swift index bb6f3d3ab..3cf52bedd 100644 --- a/core/Sources/Theming/Theme/ThemeGeneratedMock+ExtensionTests.swift +++ b/core/Sources/Theming/Theme/ThemeGeneratedMock+ExtensionTests.swift @@ -12,7 +12,7 @@ extension ThemeGeneratedMock { static func mocked() -> ThemeGeneratedMock { let theme = ThemeGeneratedMock() - theme.colors = ColorsGeneratedMock.mocked() + theme.colors = ColorsGeneratedMock.mocked() theme.layout = LayoutGeneratedMock.mocked() theme.typography = TypographyGeneratedMock.mocked() diff --git a/core/Unit-tests/Classes/Publisher/PublisherMock.swift b/core/Unit-tests/Classes/Publisher/PublisherMock.swift index c4d00eea6..91faa2d5a 100644 --- a/core/Unit-tests/Classes/Publisher/PublisherMock.swift +++ b/core/Unit-tests/Classes/Publisher/PublisherMock.swift @@ -46,7 +46,7 @@ final class PublisherMock { extension PublisherMock where T.Failure == Never { func loadTesting(on subscriptions: inout Set) { - self.publisher.sink { [weak self] value in + self.publisher.sink(receiveValue: { [weak self] value in guard let self = self else { return } self.sinkCount += 1 @@ -55,6 +55,7 @@ extension PublisherMock where T.Failure == Never { self.sinkValue = value self.sinkValues.append(value) } - }.store(in: &subscriptions) + }) + .store(in: &subscriptions) } } diff --git a/core/Unit-tests/TestCase/Component/TestCase/SwiftUIComponentSnapshotTestCase.swift b/core/Unit-tests/TestCase/Component/TestCase/SwiftUIComponentSnapshotTestCase.swift index 24f8421a6..3473b622a 100644 --- a/core/Unit-tests/TestCase/Component/TestCase/SwiftUIComponentSnapshotTestCase.swift +++ b/core/Unit-tests/TestCase/Component/TestCase/SwiftUIComponentSnapshotTestCase.swift @@ -19,7 +19,7 @@ open class SwiftUIComponentSnapshotTestCase: SnapshotTestCase { private typealias Helpers = ComponentSnapshotTestHelpers // MARK: - Snapshot Testing - + func assertSnapshot( matching view: @autoclosure () -> some View, named name: String? = nil, @@ -33,11 +33,11 @@ open class SwiftUIComponentSnapshotTestCase: SnapshotTestCase { ) { for mode in modes { for size in sizes { + let sizeCategory = ContentSizeCategory(size) ?? .extraSmall + let view = view().environment(\.sizeCategory, sizeCategory) + .background(Color.gray) sparkAssertSnapshot( - matching: view().environment( - \.sizeCategory, - ContentSizeCategory(size) ?? .extraSmall - ).background(Color.gray), + matching: view, as: .image( precision: Constants.imagePrecision, perceptualPrecision: Constants.imagePerceptualPrecision, diff --git a/core/Unit-tests/TestCase/Deprecated/ComponentSnapshotTestCase.swift b/core/Unit-tests/TestCase/Deprecated/ComponentSnapshotTestCase.swift index 674911260..fb6ba0399 100644 --- a/core/Unit-tests/TestCase/Deprecated/ComponentSnapshotTestCase.swift +++ b/core/Unit-tests/TestCase/Deprecated/ComponentSnapshotTestCase.swift @@ -132,7 +132,7 @@ extension UIKitComponentSnapshotTestCase { let traits = UITraitCollection(preferredContentSizeCategory: size) let filename = [testName, Constants.namedSuffixForLight, size.identifier] .joined(separator: Constants.separator) - + sparkAssertSnapshot( matching: view(), as: .wait( diff --git a/core/Unit-tests/TestCase/SnapshotTestCaseTracker.swift b/core/Unit-tests/TestCase/SnapshotTestCaseTracker.swift index 5da917d06..6e65c77d9 100644 --- a/core/Unit-tests/TestCase/SnapshotTestCaseTracker.swift +++ b/core/Unit-tests/TestCase/SnapshotTestCaseTracker.swift @@ -9,6 +9,7 @@ import XCTest /// `TestCaseTracker` is used to keep the track of the current test suite. It creates a sub-directory for the current test case classname for snapshot-images. +// swiftlint:disable force_unwrapping final class SnapshotTestCaseTracker: NSObject, XCTestObservation { // MARK: - Shared instance diff --git a/spark/Demo/Classes/Enum/UIComponent.swift b/spark/Demo/Classes/Enum/UIComponent.swift index 3cfa64d03..da951380f 100644 --- a/spark/Demo/Classes/Enum/UIComponent.swift +++ b/spark/Demo/Classes/Enum/UIComponent.swift @@ -8,7 +8,6 @@ import Foundation - struct UIComponent: RawRepresentable, CaseIterable, Equatable { static var allCases: [UIComponent] = [ .badge, diff --git a/spark/Demo/Classes/Tabbar/SparkTabbarController.swift b/spark/Demo/Classes/Tabbar/SparkTabbarController.swift index 344e83a83..5448be93a 100644 --- a/spark/Demo/Classes/Tabbar/SparkTabbarController.swift +++ b/spark/Demo/Classes/Tabbar/SparkTabbarController.swift @@ -77,9 +77,9 @@ final class SparkTabbarController: UITabBarController { self.themePublisher .$theme .eraseToAnyPublisher() - .sink { theme in - self.tabBar.tintColor = theme.colors.main.main.uiColor - } - .store(in: &cancellables) + .sink(receiveValue: { theme in + self.tabBar.tintColor = theme.colors.main.main.uiColor + }) + .store(in: &cancellables) } } diff --git a/spark/Demo/Classes/View/ComponentVersionViewController.swift b/spark/Demo/Classes/View/ComponentVersionViewController.swift index 4bb3e36fb..c82c5741c 100644 --- a/spark/Demo/Classes/View/ComponentVersionViewController.swift +++ b/spark/Demo/Classes/View/ComponentVersionViewController.swift @@ -28,11 +28,10 @@ final class ComponentVersionViewController: UICollectionViewController { cell.accessories = [.disclosureIndicator(options: .init(tintColor: .systemGray3))] } /// CollectionView diffable data source - let dataSource = DataSource(collectionView: collectionView) { collectionView, indexPath, itemIdentifier in + return DataSource(collectionView: collectionView) { collectionView, indexPath, itemIdentifier in return collectionView.dequeueConfiguredReusableCell( using: cellRegistration, for: indexPath, item: itemIdentifier) } - return dataSource }() // MARK: - ViewDidLoad diff --git a/spark/Demo/Classes/View/Components/Badge/UIKit/BadgeComponentUIViewModel.swift b/spark/Demo/Classes/View/Components/Badge/UIKit/BadgeComponentUIViewModel.swift index 62b55edd9..f1ba41815 100644 --- a/spark/Demo/Classes/View/Components/Badge/UIKit/BadgeComponentUIViewModel.swift +++ b/spark/Demo/Classes/View/Components/Badge/UIKit/BadgeComponentUIViewModel.swift @@ -49,7 +49,6 @@ final class BadgeComponentUIViewModel: ObservableObject { private var showSizeSheetSubject: PassthroughSubject<[BadgeSize], Never> = .init() private var showFormatSheetSubject: PassthroughSubject<[String], Never> = .init() - // MARK: - Initializer init(theme: Theme) { self.theme = theme diff --git a/spark/Demo/Classes/View/Components/Badge/UIKit/BadgeComponentViewController.swift b/spark/Demo/Classes/View/Components/Badge/UIKit/BadgeComponentViewController.swift index d3fa55e1f..794b38700 100644 --- a/spark/Demo/Classes/View/Components/Badge/UIKit/BadgeComponentViewController.swift +++ b/spark/Demo/Classes/View/Components/Badge/UIKit/BadgeComponentViewController.swift @@ -51,11 +51,11 @@ final class BadgeComponentViewController: UIViewController { themePublisher .$theme - .sink { [weak self] theme in + .sink(receiveValue: { [weak self] theme in guard let self = self else { return } self.viewModel.theme = theme self.navigationController?.navigationBar.tintColor = theme.colors.main.main.uiColor - } + }) .store(in: &self.cancellables) self.viewModel.showThemeSheet.subscribe(in: &self.cancellables) { intents in @@ -81,8 +81,7 @@ extension BadgeComponentViewController { static func build() -> BadgeComponentViewController { let viewModel = BadgeComponentUIViewModel(theme: SparkThemePublisher.shared.theme) - let viewController = BadgeComponentViewController(viewModel: viewModel) - return viewController + return BadgeComponentViewController(viewModel: viewModel) } } diff --git a/spark/Demo/Classes/View/Components/BottomSheet/UIKit/BottomSheetDemoView.swift b/spark/Demo/Classes/View/Components/BottomSheet/UIKit/BottomSheetDemoView.swift index bd24180a7..d591aa9f4 100644 --- a/spark/Demo/Classes/View/Components/BottomSheet/UIKit/BottomSheetDemoView.swift +++ b/spark/Demo/Classes/View/Components/BottomSheet/UIKit/BottomSheetDemoView.swift @@ -72,7 +72,6 @@ final class BottomSheetDemoView: UIView, DidTapButtonable { } } - // MARK: - Init override init(frame: CGRect) { super.init(frame: frame) diff --git a/spark/Demo/Classes/View/Components/BottomSheet/UIKit/BottomSheetPresentingUIViewController.swift b/spark/Demo/Classes/View/Components/BottomSheet/UIKit/BottomSheetPresentingUIViewController.swift index 53df9035d..6e51d524a 100644 --- a/spark/Demo/Classes/View/Components/BottomSheet/UIKit/BottomSheetPresentingUIViewController.swift +++ b/spark/Demo/Classes/View/Components/BottomSheet/UIKit/BottomSheetPresentingUIViewController.swift @@ -11,7 +11,6 @@ import SparkCore final class BottomSheetPresentingUIViewController: UIViewController { - // MARK: - Computed Properties lazy var rootView = BottomSheetPresentingUIView() diff --git a/spark/Demo/Classes/View/Components/Button/UIKit/ButtonComponentViewController.swift b/spark/Demo/Classes/View/Components/Button/UIKit/ButtonComponentViewController.swift index 767ff7adc..cf62026b9 100644 --- a/spark/Demo/Classes/View/Components/Button/UIKit/ButtonComponentViewController.swift +++ b/spark/Demo/Classes/View/Components/Button/UIKit/ButtonComponentViewController.swift @@ -53,11 +53,11 @@ final class ButtonComponentViewController: UIViewController { themePublisher .$theme - .sink { [weak self] theme in + .sink(receiveValue: { [weak self] theme in guard let self = self else { return } self.viewModel.theme = theme self.navigationController?.navigationBar.tintColor = theme.colors.main.main.uiColor - } + }) .store(in: &self.cancellables) self.viewModel.showThemeSheet.subscribe(in: &self.cancellables) { intents in @@ -111,8 +111,7 @@ extension ButtonComponentViewController { static func build() -> ButtonComponentViewController { let viewModel = ButtonComponentUIViewModel(theme: SparkThemePublisher.shared.theme) - let viewController = ButtonComponentViewController(viewModel: viewModel) - return viewController + return ButtonComponentViewController(viewModel: viewModel) } } diff --git a/spark/Demo/Classes/View/Components/Checkbox/UIKit/Checkbox/CheckboxComponentUIViewController.swift b/spark/Demo/Classes/View/Components/Checkbox/UIKit/Checkbox/CheckboxComponentUIViewController.swift index 29caf2673..a8a209a6e 100644 --- a/spark/Demo/Classes/View/Components/Checkbox/UIKit/Checkbox/CheckboxComponentUIViewController.swift +++ b/spark/Demo/Classes/View/Components/Checkbox/UIKit/Checkbox/CheckboxComponentUIViewController.swift @@ -51,11 +51,11 @@ final class CheckboxComponentUIViewController: UIViewController { self.themePublisher .$theme - .sink { [weak self] theme in + .sink(receiveValue: { [weak self] theme in guard let self = self else { return } self.viewModel.theme = theme self.navigationController?.navigationBar.tintColor = theme.colors.main.main.uiColor - } + }) .store(in: &self.cancellables) self.viewModel.showThemeSheet.subscribe(in: &self.cancellables) { intents in @@ -85,8 +85,7 @@ extension CheckboxComponentUIViewController { static func build() -> CheckboxComponentUIViewController { let viewModel = CheckboxComponentUIViewModel(theme: SparkThemePublisher.shared.theme) - let viewController = CheckboxComponentUIViewController(viewModel: viewModel) - return viewController + return CheckboxComponentUIViewController(viewModel: viewModel) } } diff --git a/spark/Demo/Classes/View/Components/Checkbox/UIKit/CheckboxGroup/CheckboxGroupComponentUIViewController.swift b/spark/Demo/Classes/View/Components/Checkbox/UIKit/CheckboxGroup/CheckboxGroupComponentUIViewController.swift index 081a3fd25..60fa3bc2f 100644 --- a/spark/Demo/Classes/View/Components/Checkbox/UIKit/CheckboxGroup/CheckboxGroupComponentUIViewController.swift +++ b/spark/Demo/Classes/View/Components/Checkbox/UIKit/CheckboxGroup/CheckboxGroupComponentUIViewController.swift @@ -51,11 +51,11 @@ final class CheckboxGroupComponentUIViewController: UIViewController { self.themePublisher .$theme - .sink { [weak self] theme in + .sink(receiveValue: { [weak self] theme in guard let self = self else { return } self.viewModel.theme = theme self.navigationController?.navigationBar.tintColor = theme.colors.main.main.uiColor - } + }) .store(in: &self.cancellables) self.viewModel.showThemeSheet.subscribe(in: &self.cancellables) { intents in @@ -81,8 +81,7 @@ extension CheckboxGroupComponentUIViewController { static func build() -> CheckboxGroupComponentUIViewController { let viewModel = CheckboxGroupComponentUIViewModel(theme: SparkThemePublisher.shared.theme) - let viewController = CheckboxGroupComponentUIViewController(viewModel: viewModel) - return viewController + return CheckboxGroupComponentUIViewController(viewModel: viewModel) } } diff --git a/spark/Demo/Classes/View/Components/Chip/SwiftUI/ChipComponentViewRepresentable.swift b/spark/Demo/Classes/View/Components/Chip/SwiftUI/ChipComponentViewRepresentable.swift index cc2e6e0f6..e9df6c3c1 100644 --- a/spark/Demo/Classes/View/Components/Chip/SwiftUI/ChipComponentViewRepresentable.swift +++ b/spark/Demo/Classes/View/Components/Chip/SwiftUI/ChipComponentViewRepresentable.swift @@ -115,7 +115,6 @@ struct ChipComponentUIViewRepresentation: UIViewRepresentable { } } - struct ChipComponentView_Previews: PreviewProvider { static var previews: some View { ChipComponentViewRepresentable() diff --git a/spark/Demo/Classes/View/Components/Chip/UIKit/ChipComponentUIView.swift b/spark/Demo/Classes/View/Components/Chip/UIKit/ChipComponentUIView.swift index 5e4aac3e8..6cc738a96 100644 --- a/spark/Demo/Classes/View/Components/Chip/UIKit/ChipComponentUIView.swift +++ b/spark/Demo/Classes/View/Components/Chip/UIKit/ChipComponentUIView.swift @@ -34,11 +34,10 @@ final class ChipComponentUIView: ComponentUIView { } private static func makeChipView(viewModel: ChipComponentUIViewModel) -> ChipUIView { - let chipView = ChipUIView(theme: viewModel.theme, - intent: viewModel.intent, - variant: viewModel.variant, - label: viewModel.title ?? "No Title") - return chipView + return ChipUIView(theme: viewModel.theme, + intent: viewModel.intent, + variant: viewModel.variant, + label: viewModel.title ?? "No Title") } @@ -54,7 +53,6 @@ final class ChipComponentUIView: ComponentUIView { self.componentView.theme = theme } - self.viewModel.$variant.subscribe(in: &self.cancellables) { [weak self] variant in guard let self = self else { return } self.viewModel.variantConfigurationItemViewModel.buttonTitle = variant.name diff --git a/spark/Demo/Classes/View/Components/Chip/UIKit/ChipComponentUIViewController.swift b/spark/Demo/Classes/View/Components/Chip/UIKit/ChipComponentUIViewController.swift index 40513d001..988a5c203 100644 --- a/spark/Demo/Classes/View/Components/Chip/UIKit/ChipComponentUIViewController.swift +++ b/spark/Demo/Classes/View/Components/Chip/UIKit/ChipComponentUIViewController.swift @@ -53,11 +53,11 @@ final class ChipComponentViewController: UIViewController { self.themePublisher .$theme - .sink { [weak self] theme in + .sink(receiveValue: { [weak self] theme in guard let self = self else { return } self.viewModel.theme = theme self.navigationController?.navigationBar.tintColor = theme.colors.main.main.uiColor - } + }) .store(in: &self.cancellables) self.viewModel.showThemeSheet.subscribe(in: &self.cancellables) { intents in @@ -87,8 +87,7 @@ extension ChipComponentViewController { static func build() -> ChipComponentViewController { let viewModel = ChipComponentUIViewModel(theme: SparkThemePublisher.shared.theme, intent: .support, variant: .outlined) - let viewController = ChipComponentViewController(viewModel: viewModel) - return viewController + return ChipComponentViewController(viewModel: viewModel) } } diff --git a/spark/Demo/Classes/View/Components/ComponentsViewController.swift b/spark/Demo/Classes/View/Components/ComponentsViewController.swift index 4c1be1586..0acc6f9ae 100644 --- a/spark/Demo/Classes/View/Components/ComponentsViewController.swift +++ b/spark/Demo/Classes/View/Components/ComponentsViewController.swift @@ -28,11 +28,10 @@ final class ComponentsViewController: UICollectionViewController { cell.accessories = [.disclosureIndicator(options: .init(tintColor: .systemGray3))] } /// CollectionView diffable data source - let dataSource = DataSource(collectionView: collectionView) { collectionView, indexPath, itemIdentifier in + return DataSource(collectionView: collectionView) { collectionView, indexPath, itemIdentifier in return collectionView.dequeueConfiguredReusableCell( using: cellRegistration, for: indexPath, item: itemIdentifier) } - return dataSource }() // MARK: - ViewDidLoad diff --git a/spark/Demo/Classes/View/Components/FormField/UIKit/FormFieldComponentUIView.swift b/spark/Demo/Classes/View/Components/FormField/UIKit/FormFieldComponentUIView.swift index 7469236e1..e52387472 100644 --- a/spark/Demo/Classes/View/Components/FormField/UIKit/FormFieldComponentUIView.swift +++ b/spark/Demo/Classes/View/Components/FormField/UIKit/FormFieldComponentUIView.swift @@ -207,14 +207,13 @@ final class FormFieldComponentUIView: ComponentUIView { } static func makeSingleCheckbox() -> UIControl { - let view = CheckboxUIView( + return CheckboxUIView( theme: SparkTheme.shared, text: "Hello World", checkedImage: DemoIconography.shared.checkmark.uiImage, selectionState: .unselected, alignment: .left ) - return view } static func makeVerticalCheckbox() -> UIControl { @@ -262,18 +261,17 @@ final class FormFieldComponentUIView: ComponentUIView { } static func makeSingleRadioButton() -> UIControl { - let view = RadioButtonUIView( + return RadioButtonUIView( theme: SparkTheme.shared, intent: .info, id: "radiobutton", label: NSAttributedString(string: "Hello World"), isSelected: true ) - return view } static func makeVerticalRadioButton() -> UIControl { - let view = RadioButtonUIGroupView( + return RadioButtonUIGroupView( theme: SparkTheme.shared, intent: .danger, selectedID: "radiobutton", @@ -283,11 +281,10 @@ final class FormFieldComponentUIView: ComponentUIView { ], groupLayout: .vertical ) - return view } static func makeHorizontalRadioButton() -> UIControl { - let view = RadioButtonUIGroupView( + return RadioButtonUIGroupView( theme: SparkTheme.shared, intent: .support, selectedID: "radiobutton", @@ -297,7 +294,6 @@ final class FormFieldComponentUIView: ComponentUIView { ], groupLayout: .horizontal ) - return view } static func makeTextField() -> UIControl { @@ -319,11 +315,10 @@ final class FormFieldComponentUIView: ComponentUIView { } static func makeRatingInput() -> UIControl { - let view = RatingInputUIView( + return RatingInputUIView( theme: SparkTheme.shared, intent: .main, rating: 2.0 ) - return view } } diff --git a/spark/Demo/Classes/View/Components/FormField/UIKit/FormFieldComponentUIViewController.swift b/spark/Demo/Classes/View/Components/FormField/UIKit/FormFieldComponentUIViewController.swift index 53be5a745..b1ca401a9 100644 --- a/spark/Demo/Classes/View/Components/FormField/UIKit/FormFieldComponentUIViewController.swift +++ b/spark/Demo/Classes/View/Components/FormField/UIKit/FormFieldComponentUIViewController.swift @@ -51,11 +51,11 @@ final class FormFieldComponentUIViewController: UIViewController { self.themePublisher .$theme - .sink { [weak self] theme in + .sink(receiveValue: { [weak self] theme in guard let self = self else { return } self.viewModel.theme = theme self.navigationController?.navigationBar.tintColor = theme.colors.main.main.uiColor - } + }) .store(in: &self.cancellables) self.viewModel.showThemeSheet.subscribe(in: &self.cancellables) { intents in @@ -85,8 +85,7 @@ extension FormFieldComponentUIViewController { static func build() -> FormFieldComponentUIViewController { let viewModel = FormFieldComponentUIViewModel(theme: SparkThemePublisher.shared.theme) - let viewController = FormFieldComponentUIViewController(viewModel: viewModel) - return viewController + return FormFieldComponentUIViewController(viewModel: viewModel) } } diff --git a/spark/Demo/Classes/View/Components/Icon/UIKit/IconComponentUIView.swift b/spark/Demo/Classes/View/Components/Icon/UIKit/IconComponentUIView.swift index ba19ed948..43e7e4952 100644 --- a/spark/Demo/Classes/View/Components/Icon/UIKit/IconComponentUIView.swift +++ b/spark/Demo/Classes/View/Components/Icon/UIKit/IconComponentUIView.swift @@ -8,7 +8,6 @@ // This file was generated by http://www.popcornomnom.com // - import Combine import SparkCore import Spark diff --git a/spark/Demo/Classes/View/Components/Icon/UIKit/IconComponentUIViewController.swift b/spark/Demo/Classes/View/Components/Icon/UIKit/IconComponentUIViewController.swift index dcd351a86..2b7035560 100644 --- a/spark/Demo/Classes/View/Components/Icon/UIKit/IconComponentUIViewController.swift +++ b/spark/Demo/Classes/View/Components/Icon/UIKit/IconComponentUIViewController.swift @@ -53,11 +53,11 @@ final class IconComponentUIViewController: UIViewController { self.themePublisher .$theme - .sink { [weak self] theme in + .sink(receiveValue: { [weak self] theme in guard let self = self else { return } self.viewModel.theme = theme self.navigationController?.navigationBar.tintColor = theme.colors.main.main.uiColor - } + }) .store(in: &self.cancellables) self.viewModel.showThemeSheet.subscribe(in: &self.cancellables) { intents in @@ -79,8 +79,7 @@ extension IconComponentUIViewController { static func build() -> IconComponentUIViewController { let viewModel = IconComponentUIViewModel(theme: SparkThemePublisher.shared.theme) - let viewController = IconComponentUIViewController(viewModel: viewModel) - return viewController + return IconComponentUIViewController(viewModel: viewModel) } } diff --git a/spark/Demo/Classes/View/Components/IconButton/UIKit/IconButtonComponentViewController.swift b/spark/Demo/Classes/View/Components/IconButton/UIKit/IconButtonComponentViewController.swift index 58954309c..6db770083 100644 --- a/spark/Demo/Classes/View/Components/IconButton/UIKit/IconButtonComponentViewController.swift +++ b/spark/Demo/Classes/View/Components/IconButton/UIKit/IconButtonComponentViewController.swift @@ -57,11 +57,11 @@ final class IconButtonComponentViewController: UIViewController { private func addPublisher() { self.themePublisher .$theme - .sink { [weak self] theme in + .sink(receiveValue: { [weak self] theme in guard let self = self else { return } self.viewModel.theme = theme self.navigationController?.navigationBar.tintColor = theme.colors.main.main.uiColor - } + }) .store(in: &self.cancellables) self.viewModel.showThemeSheet.subscribe(in: &self.cancellables) { intents in @@ -108,8 +108,7 @@ extension IconButtonComponentViewController { static func build() -> IconButtonComponentViewController { let viewModel = IconButtonComponentUIViewModel(theme: SparkThemePublisher.shared.theme) - let viewController = IconButtonComponentViewController(viewModel: viewModel) - return viewController + return IconButtonComponentViewController(viewModel: viewModel) } } diff --git a/spark/Demo/Classes/View/Components/Main/Configuration/UIKit/Item/ComponentsConfigurationItemView.swift b/spark/Demo/Classes/View/Components/Main/Configuration/UIKit/Item/ComponentsConfigurationItemView.swift index 11bb2f815..e3a52e0de 100644 --- a/spark/Demo/Classes/View/Components/Main/Configuration/UIKit/Item/ComponentsConfigurationItemView.swift +++ b/spark/Demo/Classes/View/Components/Main/Configuration/UIKit/Item/ComponentsConfigurationItemView.swift @@ -212,35 +212,35 @@ final class ComponentsConfigurationItemUIViewModelView: UIView { // Colors self.viewModel.$color .receive(on: RunLoop.main) - .sink { [weak self] color in + .sink(receiveValue: { [weak self] color in self?.button?.setTitleColor(color, for: .normal) self?.toggle?.onTintColor = color - } + }) .store(in: &self.subscriptions) // Button Title self.viewModel.$buttonTitle .receive(on: RunLoop.main) - .sink { [weak self] buttonTitle in + .sink(receiveValue: { [weak self] buttonTitle in self?.button?.setTitle(buttonTitle, for: .normal) - } + }) .store(in: &self.subscriptions) // Toggle isOn self.viewModel.$isOn .receive(on: RunLoop.main) - .sink { [weak self] isOn in + .sink(receiveValue: { [weak self] isOn in guard let isOn = isOn else { return } self?.toggle?.isOn = isOn - } + }) .store(in: &self.subscriptions) // Label Text self.viewModel.$labelText .receive(on: RunLoop.main) - .sink { [weak self] text in + .sink(receiveValue: { [weak self] text in self?.valueLabel.text = text - } + }) .store(in: &self.subscriptions) } } diff --git a/spark/Demo/Classes/View/Components/ProgressBar/Indeterminate/UIKit/ProgressBarIndeterminateComponentUIViewController.swift b/spark/Demo/Classes/View/Components/ProgressBar/Indeterminate/UIKit/ProgressBarIndeterminateComponentUIViewController.swift index 912006feb..f1a70d66a 100644 --- a/spark/Demo/Classes/View/Components/ProgressBar/Indeterminate/UIKit/ProgressBarIndeterminateComponentUIViewController.swift +++ b/spark/Demo/Classes/View/Components/ProgressBar/Indeterminate/UIKit/ProgressBarIndeterminateComponentUIViewController.swift @@ -60,11 +60,11 @@ final class ProgressBarIndeterminateComponentUIViewController: UIViewController self.themePublisher .$theme - .sink { [weak self] theme in + .sink(receiveValue: { [weak self] theme in guard let self = self else { return } self.viewModel.theme = theme self.navigationController?.navigationBar.tintColor = theme.colors.main.main.uiColor - } + }) .store(in: &self.subscriptions) self.viewModel.showThemeSheet.subscribe(in: &self.subscriptions) { intents in @@ -86,8 +86,7 @@ extension ProgressBarIndeterminateComponentUIViewController { static func build() -> ProgressBarIndeterminateComponentUIViewController { let viewModel = ProgressBarIndeterminateComponentUIViewModel(theme: SparkThemePublisher.shared.theme) - let viewController = ProgressBarIndeterminateComponentUIViewController(viewModel: viewModel) - return viewController + return ProgressBarIndeterminateComponentUIViewController(viewModel: viewModel) } } diff --git a/spark/Demo/Classes/View/Components/ProgressBar/Single/UIKit/ProgressBarComponentUIViewController.swift b/spark/Demo/Classes/View/Components/ProgressBar/Single/UIKit/ProgressBarComponentUIViewController.swift index 3b1a8a285..98dfd6e4f 100644 --- a/spark/Demo/Classes/View/Components/ProgressBar/Single/UIKit/ProgressBarComponentUIViewController.swift +++ b/spark/Demo/Classes/View/Components/ProgressBar/Single/UIKit/ProgressBarComponentUIViewController.swift @@ -60,11 +60,11 @@ final class ProgressBarComponentUIViewController: UIViewController { self.themePublisher .$theme - .sink { [weak self] theme in + .sink(receiveValue: { [weak self] theme in guard let self = self else { return } self.viewModel.theme = theme self.navigationController?.navigationBar.tintColor = theme.colors.main.main.uiColor - } + }) .store(in: &self.subscriptions) self.viewModel.showThemeSheet.subscribe(in: &self.subscriptions) { intents in @@ -86,8 +86,7 @@ extension ProgressBarComponentUIViewController { static func build() -> ProgressBarComponentUIViewController { let viewModel = ProgressBarComponentUIViewModel(theme: SparkThemePublisher.shared.theme) - let viewController = ProgressBarComponentUIViewController(viewModel: viewModel) - return viewController + return ProgressBarComponentUIViewController(viewModel: viewModel) } } diff --git a/spark/Demo/Classes/View/Components/ProgressTracker/UIKit/ProgressTrackerComponentUIView.swift b/spark/Demo/Classes/View/Components/ProgressTracker/UIKit/ProgressTrackerComponentUIView.swift index 8ecf21783..05da70d65 100644 --- a/spark/Demo/Classes/View/Components/ProgressTracker/UIKit/ProgressTrackerComponentUIView.swift +++ b/spark/Demo/Classes/View/Components/ProgressTracker/UIKit/ProgressTrackerComponentUIView.swift @@ -21,7 +21,6 @@ final class ProgressTrackerComponentUIView: ComponentUIView { private let widthConstraint: NSLayoutConstraint private let heightConstraint: NSLayoutConstraint - // MARK: - Initializer init(viewModel: ProgressTrackerComponentUIViewModel) { self.viewModel = viewModel diff --git a/spark/Demo/Classes/View/Components/ProgressTracker/UIKit/ProgressTrackerComponentUIViewController.swift b/spark/Demo/Classes/View/Components/ProgressTracker/UIKit/ProgressTrackerComponentUIViewController.swift index 63b7cbe87..594980d5a 100644 --- a/spark/Demo/Classes/View/Components/ProgressTracker/UIKit/ProgressTrackerComponentUIViewController.swift +++ b/spark/Demo/Classes/View/Components/ProgressTracker/UIKit/ProgressTrackerComponentUIViewController.swift @@ -6,7 +6,6 @@ // Copyright © 2024 Adevinta. All rights reserved. // - import Combine import Spark import SwiftUI @@ -54,11 +53,11 @@ final class ProgressTrackerComponentUIViewController: UIViewController { self.themePublisher .$theme - .sink { [weak self] theme in + .sink(receiveValue: { [weak self] theme in guard let self = self else { return } self.viewModel.theme = theme self.navigationController?.navigationBar.tintColor = theme.colors.main.main.uiColor - } + }) .store(in: &self.cancellables) self.viewModel.showThemeSheet.subscribe(in: &self.cancellables) { intents in @@ -96,8 +95,7 @@ extension ProgressTrackerComponentUIViewController { static func build() -> ProgressTrackerComponentUIViewController { let viewModel = ProgressTrackerComponentUIViewModel(theme: SparkThemePublisher.shared.theme) - let viewController = ProgressTrackerComponentUIViewController(viewModel: viewModel) - return viewController + return ProgressTrackerComponentUIViewController(viewModel: viewModel) } } diff --git a/spark/Demo/Classes/View/Components/ProgressTracker/UIKit/ProgressTrackerComponentUIViewModel.swift b/spark/Demo/Classes/View/Components/ProgressTracker/UIKit/ProgressTrackerComponentUIViewModel.swift index 30bf1e94b..9a969d3f0 100644 --- a/spark/Demo/Classes/View/Components/ProgressTracker/UIKit/ProgressTrackerComponentUIViewModel.swift +++ b/spark/Demo/Classes/View/Components/ProgressTracker/UIKit/ProgressTrackerComponentUIViewModel.swift @@ -24,7 +24,6 @@ final class ProgressTrackerComponentUIViewModel: ComponentUIViewModel { case none } - // MARK: - Items Properties lazy var themeConfigurationItemViewModel: ComponentsConfigurationItemUIViewModel = { return .init( diff --git a/spark/Demo/Classes/View/Components/RadioButton/UIKit/RadioButtonComponentUIView.swift b/spark/Demo/Classes/View/Components/RadioButton/UIKit/RadioButtonComponentUIView.swift index f5efdc6f3..825930eb7 100644 --- a/spark/Demo/Classes/View/Components/RadioButton/UIKit/RadioButtonComponentUIView.swift +++ b/spark/Demo/Classes/View/Components/RadioButton/UIKit/RadioButtonComponentUIView.swift @@ -49,7 +49,6 @@ final class RadioButtonComponentUIView: ComponentUIView { fatalError("init(coder:) has not been implemented") } - // MARK: - Subscribe private func setupSubscriptions() { self.viewModel.$theme.subscribe(in: &self.cancellables) { [weak self] theme in @@ -213,4 +212,4 @@ final class RadioButtonComponentUIView: ComponentUIView { label: NSAttributedString(string: "Sample of toggle on radio button"), isSelected: false) } -} \ No newline at end of file +} diff --git a/spark/Demo/Classes/View/Components/RadioButton/UIKit/RadioButtonComponentUIViewController.swift b/spark/Demo/Classes/View/Components/RadioButton/UIKit/RadioButtonComponentUIViewController.swift index e96944244..48793de8b 100644 --- a/spark/Demo/Classes/View/Components/RadioButton/UIKit/RadioButtonComponentUIViewController.swift +++ b/spark/Demo/Classes/View/Components/RadioButton/UIKit/RadioButtonComponentUIViewController.swift @@ -53,11 +53,11 @@ final class RadioButtonComponentUIViewController: UIViewController { self.themePublisher .$theme - .sink { [weak self] theme in + .sink(receiveValue: { [weak self] theme in guard let self = self else { return } self.viewModel.theme = theme self.navigationController?.navigationBar.tintColor = theme.colors.main.main.uiColor - } + }) .store(in: &self.cancellables) self.viewModel.showThemeSheet.subscribe(in: &self.cancellables) { themes in @@ -75,8 +75,7 @@ extension RadioButtonComponentUIViewController { static func build() -> RadioButtonComponentUIViewController { let viewModel = RadioButtonComponentUIViewModel(theme: SparkThemePublisher.shared.theme) - let viewController = RadioButtonComponentUIViewController(viewModel: viewModel) - return viewController + return RadioButtonComponentUIViewController(viewModel: viewModel) } } diff --git a/spark/Demo/Classes/View/Components/RadioButton/UIKit/RadioButtonComponentUIViewModel.swift b/spark/Demo/Classes/View/Components/RadioButton/UIKit/RadioButtonComponentUIViewModel.swift index 4cfa14490..7b407b1ec 100644 --- a/spark/Demo/Classes/View/Components/RadioButton/UIKit/RadioButtonComponentUIViewModel.swift +++ b/spark/Demo/Classes/View/Components/RadioButton/UIKit/RadioButtonComponentUIViewModel.swift @@ -152,7 +152,6 @@ final class RadioButtonComponentUIViewModel: ComponentUIViewModel { super.init(identifier: "RadioButton") } - func attributedLabel(at index: Int) -> NSAttributedString { if self.showLongLabel { return self.longTitleAttributed(at: index) diff --git a/spark/Demo/Classes/View/Components/Rating/UIKit/RatingDisplayComponentUIView.swift b/spark/Demo/Classes/View/Components/Rating/UIKit/RatingDisplayComponentUIView.swift index 9a8c0ce85..9b710315c 100644 --- a/spark/Demo/Classes/View/Components/Rating/UIKit/RatingDisplayComponentUIView.swift +++ b/spark/Demo/Classes/View/Components/Rating/UIKit/RatingDisplayComponentUIView.swift @@ -37,13 +37,12 @@ final class RatingDisplayComponentUIView: ComponentUIView { } private static func makeRatingDisplayView(viewModel: RatingDisplayComponentUIViewModel) -> RatingDisplayUIView { - let view = RatingDisplayUIView( + return RatingDisplayUIView( theme: viewModel.theme, intent: viewModel.intent, count: viewModel.count, size: viewModel.size ) - return view } private func setupSubscriptions() { diff --git a/spark/Demo/Classes/View/Components/Rating/UIKit/RatingDisplayComponentViewController.swift b/spark/Demo/Classes/View/Components/Rating/UIKit/RatingDisplayComponentViewController.swift index 4a83957c6..9b673c0d6 100644 --- a/spark/Demo/Classes/View/Components/Rating/UIKit/RatingDisplayComponentViewController.swift +++ b/spark/Demo/Classes/View/Components/Rating/UIKit/RatingDisplayComponentViewController.swift @@ -53,11 +53,11 @@ final class RatingDisplayComponentViewController: UIViewController { self.themePublisher .$theme - .sink { [weak self] theme in + .sink(receiveValue: { [weak self] theme in guard let self = self else { return } self.viewModel.theme = theme self.navigationController?.navigationBar.tintColor = theme.colors.main.main.uiColor - } + }) .store(in: &self.cancellables) self.viewModel.showThemeSheet.subscribe(in: &self.cancellables) { intents in @@ -83,8 +83,7 @@ extension RatingDisplayComponentViewController { static func build() -> RatingDisplayComponentViewController { let viewModel = RatingDisplayComponentUIViewModel(theme: SparkThemePublisher.shared.theme) - let viewController = RatingDisplayComponentViewController(viewModel: viewModel) - return viewController + return RatingDisplayComponentViewController(viewModel: viewModel) } } diff --git a/spark/Demo/Classes/View/Components/Rating/UIKit/RatingInputComponentUIView.swift b/spark/Demo/Classes/View/Components/Rating/UIKit/RatingInputComponentUIView.swift index e7e37d59f..417ad2ec6 100644 --- a/spark/Demo/Classes/View/Components/Rating/UIKit/RatingInputComponentUIView.swift +++ b/spark/Demo/Classes/View/Components/Rating/UIKit/RatingInputComponentUIView.swift @@ -37,12 +37,11 @@ final class RatingInputComponentUIView: ComponentUIView { } private static func makeRatingInputView(viewModel: RatingInputComponentUIViewModel) -> RatingInputUIView { - let view = RatingInputUIView( + return RatingInputUIView( theme: viewModel.theme, intent: viewModel.intent, rating: viewModel.rating ) - return view } private func setupSubscriptions() { diff --git a/spark/Demo/Classes/View/Components/Rating/UIKit/RatingInputComponentUIViewModel.swift b/spark/Demo/Classes/View/Components/Rating/UIKit/RatingInputComponentUIViewModel.swift index 16f21dde5..e4549956a 100644 --- a/spark/Demo/Classes/View/Components/Rating/UIKit/RatingInputComponentUIViewModel.swift +++ b/spark/Demo/Classes/View/Components/Rating/UIKit/RatingInputComponentUIViewModel.swift @@ -54,7 +54,6 @@ final class RatingInputComponentUIViewModel: ComponentUIViewModel { target: (source: self, action: #selector(self.disableChanged(_:)))) }() - var showThemeSheet: AnyPublisher<[ThemeCellModel], Never> { showThemeSheetSubject .eraseToAnyPublisher() diff --git a/spark/Demo/Classes/View/Components/Rating/UIKit/RatingInputComponentViewController.swift b/spark/Demo/Classes/View/Components/Rating/UIKit/RatingInputComponentViewController.swift index cfc58898b..320d41000 100644 --- a/spark/Demo/Classes/View/Components/Rating/UIKit/RatingInputComponentViewController.swift +++ b/spark/Demo/Classes/View/Components/Rating/UIKit/RatingInputComponentViewController.swift @@ -53,11 +53,11 @@ final class RatingInputComponentViewController: UIViewController { self.themePublisher .$theme - .sink { [weak self] theme in + .sink(receiveValue: { [weak self] theme in guard let self = self else { return } self.viewModel.theme = theme self.navigationController?.navigationBar.tintColor = theme.colors.main.main.uiColor - } + }) .store(in: &self.cancellables) self.viewModel.showThemeSheet.subscribe(in: &self.cancellables) { intents in @@ -75,8 +75,7 @@ extension RatingInputComponentViewController { static func build() -> RatingInputComponentViewController { let viewModel = RatingInputComponentUIViewModel(theme: SparkThemePublisher.shared.theme) - let viewController = RatingInputComponentViewController(viewModel: viewModel) - return viewController + return RatingInputComponentViewController(viewModel: viewModel) } } diff --git a/spark/Demo/Classes/View/Components/Rating/UIKit/StarComponentUIView.swift b/spark/Demo/Classes/View/Components/Rating/UIKit/StarComponentUIView.swift index 67daa8d91..9c438dd32 100644 --- a/spark/Demo/Classes/View/Components/Rating/UIKit/StarComponentUIView.swift +++ b/spark/Demo/Classes/View/Components/Rating/UIKit/StarComponentUIView.swift @@ -46,7 +46,7 @@ final class StarComponentUIView: ComponentUIView { vertexSize: viewModel.vertexSize, cornerRadiusSize: viewModel.cornerRadiusSize) - let view = StarUIView( + return StarUIView( rating: viewModel.rating, fillMode: viewModel.fillMode, lineWidth: CGFloat(viewModel.lineWidth), @@ -54,8 +54,6 @@ final class StarComponentUIView: ComponentUIView { fillColor: viewModel.fillColor.uiColor, configuration: configuration ) - - return view } private func setupSubscriptions() { diff --git a/spark/Demo/Classes/View/Components/Rating/UIKit/StarComponentViewController.swift b/spark/Demo/Classes/View/Components/Rating/UIKit/StarComponentViewController.swift index 7c3d367a0..71cfe6d33 100644 --- a/spark/Demo/Classes/View/Components/Rating/UIKit/StarComponentViewController.swift +++ b/spark/Demo/Classes/View/Components/Rating/UIKit/StarComponentViewController.swift @@ -67,8 +67,7 @@ extension StarComponentViewController { static func build() -> StarComponentViewController { let viewModel = StarComponentUIViewModel() - let viewController = StarComponentViewController(viewModel: viewModel) - return viewController + return StarComponentViewController(viewModel: viewModel) } } diff --git a/spark/Demo/Classes/View/Components/Slider/UIKit/SliderComponentUIViewController.swift b/spark/Demo/Classes/View/Components/Slider/UIKit/SliderComponentUIViewController.swift index 6fdf70613..4cb9d7eab 100644 --- a/spark/Demo/Classes/View/Components/Slider/UIKit/SliderComponentUIViewController.swift +++ b/spark/Demo/Classes/View/Components/Slider/UIKit/SliderComponentUIViewController.swift @@ -56,11 +56,11 @@ final class SliderComponentUIViewController: UIViewController { private func addPublisher() { self.themePublisher .$theme - .sink { [weak self] theme in + .sink(receiveValue: { [weak self] theme in guard let self = self else { return } self.viewModel.theme = theme self.navigationController?.navigationBar.tintColor = theme.colors.main.main.uiColor - } + }) .store(in: &self.cancellables) self.viewModel.showThemeSheet.subscribe(in: &self.cancellables) { intents in @@ -82,8 +82,7 @@ extension SliderComponentUIViewController { static func build() -> SliderComponentUIViewController { let viewModel = SliderComponentUIViewModel(theme: SparkThemePublisher.shared.theme) - let viewController = SliderComponentUIViewController(viewModel: viewModel) - return viewController + return SliderComponentUIViewController(viewModel: viewModel) } } diff --git a/spark/Demo/Classes/View/Components/Slider/UIKit/SliderComponentUIViewModel.swift b/spark/Demo/Classes/View/Components/Slider/UIKit/SliderComponentUIViewModel.swift index 8356c3dde..cde9fb546 100644 --- a/spark/Demo/Classes/View/Components/Slider/UIKit/SliderComponentUIViewModel.swift +++ b/spark/Demo/Classes/View/Components/Slider/UIKit/SliderComponentUIViewModel.swift @@ -126,7 +126,6 @@ final class SliderComponentUIViewModel: ComponentUIViewModel, ObservableObject { ] } - // MARK: - Initialization @Published var theme: Theme @Published var intent: SliderIntent diff --git a/spark/Demo/Classes/View/Components/Spinner/UIKit/SpinnerComponentUIView.swift b/spark/Demo/Classes/View/Components/Spinner/UIKit/SpinnerComponentUIView.swift index 7d1aca1fc..8484d66e1 100644 --- a/spark/Demo/Classes/View/Components/Spinner/UIKit/SpinnerComponentUIView.swift +++ b/spark/Demo/Classes/View/Components/Spinner/UIKit/SpinnerComponentUIView.swift @@ -8,7 +8,6 @@ // This file was generated by http://www.popcornomnom.com // - import Combine import SparkCore import Spark diff --git a/spark/Demo/Classes/View/Components/Spinner/UIKit/SpinnerComponentUIViewController.swift b/spark/Demo/Classes/View/Components/Spinner/UIKit/SpinnerComponentUIViewController.swift index 797eff3d0..0eef598c5 100644 --- a/spark/Demo/Classes/View/Components/Spinner/UIKit/SpinnerComponentUIViewController.swift +++ b/spark/Demo/Classes/View/Components/Spinner/UIKit/SpinnerComponentUIViewController.swift @@ -53,11 +53,11 @@ final class SpinnerComponentUIViewController: UIViewController { self.themePublisher .$theme - .sink { [weak self] theme in + .sink(receiveValue: { [weak self] theme in guard let self = self else { return } self.viewModel.theme = theme self.navigationController?.navigationBar.tintColor = theme.colors.main.main.uiColor - } + }) .store(in: &self.cancellables) self.viewModel.showThemeSheet.subscribe(in: &self.cancellables) { intents in @@ -79,8 +79,7 @@ extension SpinnerComponentUIViewController { static func build() -> SpinnerComponentUIViewController { let viewModel = SpinnerComponentUIViewModel(theme: SparkThemePublisher.shared.theme) - let viewController = SpinnerComponentUIViewController(viewModel: viewModel) - return viewController + return SpinnerComponentUIViewController(viewModel: viewModel) } } diff --git a/spark/Demo/Classes/View/Components/Switch/UIKit/SwitchComponentUIViewController.swift b/spark/Demo/Classes/View/Components/Switch/UIKit/SwitchComponentUIViewController.swift index ce05f61d8..e076dfea3 100644 --- a/spark/Demo/Classes/View/Components/Switch/UIKit/SwitchComponentUIViewController.swift +++ b/spark/Demo/Classes/View/Components/Switch/UIKit/SwitchComponentUIViewController.swift @@ -53,11 +53,11 @@ final class SwitchComponentUIViewController: UIViewController { self.themePublisher .$theme - .sink { [weak self] theme in + .sink(receiveValue: { [weak self] theme in guard let self = self else { return } self.viewModel.theme = theme self.navigationController?.navigationBar.tintColor = theme.colors.main.main.uiColor - } + }) .store(in: &self.cancellables) self.viewModel.showThemeSheet.subscribe(in: &self.cancellables) { theme in @@ -83,8 +83,7 @@ extension SwitchComponentUIViewController { static func build() -> SwitchComponentUIViewController { let viewModel = SwitchComponentUIViewModel(theme: SparkThemePublisher.shared.theme) - let viewController = SwitchComponentUIViewController(viewModel: viewModel) - return viewController + return SwitchComponentUIViewController(viewModel: viewModel) } } diff --git a/spark/Demo/Classes/View/Components/Tab/UIKit/TabComponentUIView.swift b/spark/Demo/Classes/View/Components/Tab/UIKit/TabComponentUIView.swift index fadbf16c4..8cb4227e4 100644 --- a/spark/Demo/Classes/View/Components/Tab/UIKit/TabComponentUIView.swift +++ b/spark/Demo/Classes/View/Components/Tab/UIKit/TabComponentUIView.swift @@ -39,7 +39,6 @@ final class TabComponentUIView: ComponentUIView { fatalError("init(coder:) has not been implemented") } - // MARK: - Subscribe private func setupSubscriptions() { self.viewModel.$theme.subscribe(in: &self.cancellables) { [weak self] theme in @@ -150,13 +149,11 @@ final class TabComponentUIView: ComponentUIView { // MARK: - Private construction helper static private func makeTabView(_ viewModel: TabComponentUIViewModel) -> TabUIView { - let tabView = TabUIView( + return TabUIView( theme: viewModel.theme, intent: viewModel.intent, tabSize: viewModel.size, content: viewModel.content) - - return tabView } } diff --git a/spark/Demo/Classes/View/Components/Tab/UIKit/TabComponentUIViewController.swift b/spark/Demo/Classes/View/Components/Tab/UIKit/TabComponentUIViewController.swift index 77d233e12..6b120d02b 100644 --- a/spark/Demo/Classes/View/Components/Tab/UIKit/TabComponentUIViewController.swift +++ b/spark/Demo/Classes/View/Components/Tab/UIKit/TabComponentUIViewController.swift @@ -53,11 +53,11 @@ final class TabComponentUIViewController: UIViewController { self.themePublisher .$theme - .sink { [weak self] theme in + .sink(receiveValue: { [weak self] theme in guard let self = self else { return } self.viewModel.theme = theme self.navigationController?.navigationBar.tintColor = theme.colors.main.main.uiColor - } + }) .store(in: &self.cancellables) self.viewModel.showThemeSheet.subscribe(in: &self.cancellables) { themes in @@ -80,8 +80,7 @@ extension TabComponentUIViewController { static func build() -> TabComponentUIViewController { let viewModel = TabComponentUIViewModel(theme: SparkThemePublisher.shared.theme) - let viewController = TabComponentUIViewController(viewModel: viewModel) - return viewController + return TabComponentUIViewController(viewModel: viewModel) } } diff --git a/spark/Demo/Classes/View/Components/Tag/UIKit/TagComponentUIViewController.swift b/spark/Demo/Classes/View/Components/Tag/UIKit/TagComponentUIViewController.swift index d4fc5f570..cc71666dd 100644 --- a/spark/Demo/Classes/View/Components/Tag/UIKit/TagComponentUIViewController.swift +++ b/spark/Demo/Classes/View/Components/Tag/UIKit/TagComponentUIViewController.swift @@ -53,11 +53,11 @@ final class TagComponentUIViewController: UIViewController { self.themePublisher .$theme - .sink { [weak self] theme in + .sink(receiveValue: { [weak self] theme in guard let self = self else { return } self.viewModel.theme = theme self.navigationController?.navigationBar.tintColor = theme.colors.main.main.uiColor - } + }) .store(in: &self.cancellables) self.viewModel.showThemeSheet.subscribe(in: &self.cancellables) { intents in @@ -83,8 +83,7 @@ extension TagComponentUIViewController { static func build() -> TagComponentUIViewController { let viewModel = TagComponentUIViewModel(theme: SparkThemePublisher.shared.theme) - let viewController = TagComponentUIViewController(viewModel: viewModel) - return viewController + return TagComponentUIViewController(viewModel: viewModel) } } diff --git a/spark/Demo/Classes/View/Components/TextField/Addons/SwiftUI/TextFieldAddonsComponentView.swift b/spark/Demo/Classes/View/Components/TextField/Addons/SwiftUI/TextFieldAddonsComponentView.swift index a698b3c7f..0606fda1f 100644 --- a/spark/Demo/Classes/View/Components/TextField/Addons/SwiftUI/TextFieldAddonsComponentView.swift +++ b/spark/Demo/Classes/View/Components/TextField/Addons/SwiftUI/TextFieldAddonsComponentView.swift @@ -167,7 +167,6 @@ struct TextFieldAddonsComponentView: View { } } - @ViewBuilder private func createImage(side: ContentSide) -> some View { let imageName = side == .right ? "delete.left" : "command" diff --git a/spark/Demo/Classes/View/Components/TextField/Addons/UIKit/TextFieldAddonsComponentUIView.swift b/spark/Demo/Classes/View/Components/TextField/Addons/UIKit/TextFieldAddonsComponentUIView.swift index 9a4b1cfb1..a9fec0f34 100644 --- a/spark/Demo/Classes/View/Components/TextField/Addons/UIKit/TextFieldAddonsComponentUIView.swift +++ b/spark/Demo/Classes/View/Components/TextField/Addons/UIKit/TextFieldAddonsComponentUIView.swift @@ -155,13 +155,12 @@ final class TextFieldAddonsComponentUIView: ComponentUIView { } private func createIcon(side: TextFieldContentSide) -> IconUIView { - let icon = IconUIView( + return IconUIView( iconImage: .init(systemName: side == .left ? "power" : "eject.circle.fill"), theme: self.viewModel.theme, intent: .support, size: .extraLarge ) - return icon } private func createText(side: TextFieldContentSide) -> UILabel { diff --git a/spark/Demo/Classes/View/Components/TextField/Addons/UIKit/TextFieldAddonsComponentUIViewController.swift b/spark/Demo/Classes/View/Components/TextField/Addons/UIKit/TextFieldAddonsComponentUIViewController.swift index a7fa26885..21a91e641 100644 --- a/spark/Demo/Classes/View/Components/TextField/Addons/UIKit/TextFieldAddonsComponentUIViewController.swift +++ b/spark/Demo/Classes/View/Components/TextField/Addons/UIKit/TextFieldAddonsComponentUIViewController.swift @@ -49,11 +49,11 @@ final class TextFieldAddonsComponentUIViewController: UIViewController { private func setupSubscriptions() { self.themePublisher .$theme - .sink { [weak self] theme in + .sink(receiveValue: { [weak self] theme in guard let self = self else { return } self.viewModel.theme = theme self.navigationController?.navigationBar.tintColor = theme.colors.main.main.uiColor - } + }) .store(in: &self.cancellables) self.viewModel.showThemeSheet.subscribe(in: &self.cancellables) { theme in @@ -127,7 +127,6 @@ final class TextFieldAddonsComponentUIViewController: UIViewController { extension TextFieldAddonsComponentUIViewController { static func build() -> TextFieldAddonsComponentUIViewController { let viewModel = TextFieldAddonsComponentUIViewModel(theme: SparkThemePublisher.shared.theme) - let viewController = TextFieldAddonsComponentUIViewController(viewModel: viewModel) - return viewController + return TextFieldAddonsComponentUIViewController(viewModel: viewModel) } } diff --git a/spark/Demo/Classes/View/Components/TextField/UIKit/TextFieldComponentUIViewController.swift b/spark/Demo/Classes/View/Components/TextField/UIKit/TextFieldComponentUIViewController.swift index e7b16b629..68defdf4b 100644 --- a/spark/Demo/Classes/View/Components/TextField/UIKit/TextFieldComponentUIViewController.swift +++ b/spark/Demo/Classes/View/Components/TextField/UIKit/TextFieldComponentUIViewController.swift @@ -49,11 +49,11 @@ final class TextFieldComponentUIViewController: UIViewController { private func setupSubscriptions() { self.themePublisher .$theme - .sink { [weak self] theme in + .sink(receiveValue: { [weak self] theme in guard let self = self else { return } self.viewModel.theme = theme self.navigationController?.navigationBar.tintColor = theme.colors.main.main.uiColor - } + }) .store(in: &self.cancellables) self.viewModel.showThemeSheet.subscribe(in: &self.cancellables) { theme in @@ -133,8 +133,7 @@ final class TextFieldComponentUIViewController: UIViewController { extension TextFieldComponentUIViewController { static func build() -> TextFieldComponentUIViewController { let viewModel = TextFieldComponentUIViewModel(theme: SparkThemePublisher.shared.theme) - let viewController = TextFieldComponentUIViewController(viewModel: viewModel) - return viewController + return TextFieldComponentUIViewController(viewModel: viewModel) } } diff --git a/spark/Demo/Classes/View/Components/TextLink/UIKit/TextLinkComponentUIViewController.swift b/spark/Demo/Classes/View/Components/TextLink/UIKit/TextLinkComponentUIViewController.swift index 296a52fd9..8f3f5f0f3 100644 --- a/spark/Demo/Classes/View/Components/TextLink/UIKit/TextLinkComponentUIViewController.swift +++ b/spark/Demo/Classes/View/Components/TextLink/UIKit/TextLinkComponentUIViewController.swift @@ -60,11 +60,11 @@ final class TextLinkComponentUIViewController: UIViewController { self.themePublisher .$theme - .sink { [weak self] theme in + .sink(receiveValue: { [weak self] theme in guard let self = self else { return } self.viewModel.theme = theme self.navigationController?.navigationBar.tintColor = theme.colors.main.main.uiColor - } + }) .store(in: &self.subscriptions) self.viewModel.showThemeSheet.subscribe(in: &self.subscriptions) { intents in @@ -110,8 +110,7 @@ extension TextLinkComponentUIViewController { static func build() -> TextLinkComponentUIViewController { let viewModel = TextLinkComponentUIViewModel(theme: SparkThemePublisher.shared.theme) - let viewController = TextLinkComponentUIViewController(viewModel: viewModel) - return viewController + return TextLinkComponentUIViewController(viewModel: viewModel) } } diff --git a/spark/Demo/Classes/View/ListView/Cells/BadgeCell/BadgeCell.swift b/spark/Demo/Classes/View/ListView/Cells/BadgeCell/BadgeCell.swift index 6c291dea6..bfe3b9296 100644 --- a/spark/Demo/Classes/View/ListView/Cells/BadgeCell/BadgeCell.swift +++ b/spark/Demo/Classes/View/ListView/Cells/BadgeCell/BadgeCell.swift @@ -15,7 +15,7 @@ final class BadgeCell: UITableViewCell, Configurable { typealias Component = BadgeUIView lazy var component: BadgeUIView = { - let view = BadgeUIView( + return BadgeUIView( theme: SparkThemePublisher.shared.theme, intent: .main, size: .medium, @@ -23,7 +23,6 @@ final class BadgeCell: UITableViewCell, Configurable { format: .default, isBorderVisible: false ) - return view }() override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { diff --git a/spark/Demo/Classes/View/ListView/Cells/ButtonCell/ButtonCell.swift b/spark/Demo/Classes/View/ListView/Cells/ButtonCell/ButtonCell.swift index 7e9884f6d..5600dcb0f 100644 --- a/spark/Demo/Classes/View/ListView/Cells/ButtonCell/ButtonCell.swift +++ b/spark/Demo/Classes/View/ListView/Cells/ButtonCell/ButtonCell.swift @@ -15,7 +15,7 @@ final class ButtonCell: UITableViewCell, Configurable { typealias Component = ButtonUIView lazy var component: ButtonUIView = { - let view = ButtonUIView( + return ButtonUIView( theme: SparkTheme.shared, intent: .main, variant: .filled, @@ -23,7 +23,6 @@ final class ButtonCell: UITableViewCell, Configurable { shape: .rounded, alignment: .leadingImage ) - return view }() var attributeString: NSAttributedString { diff --git a/spark/Demo/Classes/View/ListView/Cells/CheckboxCell/CheckboxCell.swift b/spark/Demo/Classes/View/ListView/Cells/CheckboxCell/CheckboxCell.swift index 3ca8f80a4..8d1ad8a2b 100644 --- a/spark/Demo/Classes/View/ListView/Cells/CheckboxCell/CheckboxCell.swift +++ b/spark/Demo/Classes/View/ListView/Cells/CheckboxCell/CheckboxCell.swift @@ -15,7 +15,7 @@ final class CheckboxCell: UITableViewCell, Configurable { typealias Component = CheckboxUIView lazy var component: CheckboxUIView = { - let view = CheckboxUIView( + return CheckboxUIView( theme: SparkTheme.shared, text: "Checkbox", checkedImage: DemoIconography.shared.checkmark.uiImage, @@ -23,7 +23,6 @@ final class CheckboxCell: UITableViewCell, Configurable { selectionState: .selected, alignment: .left ) - return view }() var stackViewAlignment: UIStackView.Alignment { diff --git a/spark/Demo/Classes/View/ListView/Cells/CheckboxGroupCell/CheckboxGroupCell.swift b/spark/Demo/Classes/View/ListView/Cells/CheckboxGroupCell/CheckboxGroupCell.swift index e1d00cea2..a4b85a37f 100644 --- a/spark/Demo/Classes/View/ListView/Cells/CheckboxGroupCell/CheckboxGroupCell.swift +++ b/spark/Demo/Classes/View/ListView/Cells/CheckboxGroupCell/CheckboxGroupCell.swift @@ -23,7 +23,7 @@ final class CheckboxGroupCell: UITableViewCell, Configurable { CheckboxGroupItemDefault(title: "Text", id: "1", selectionState: .selected, isEnabled: true) ] - let view = CheckboxGroupUIView( + return CheckboxGroupUIView( checkedImage: DemoIconography.shared.checkmark.uiImage, items: items, alignment: .left, @@ -31,7 +31,6 @@ final class CheckboxGroupCell: UITableViewCell, Configurable { intent: .main, accessibilityIdentifierPrefix: "CheckboxGroup" ) - return view }() override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { diff --git a/spark/Demo/Classes/View/ListView/Cells/ChipCell/ChipCell.swift b/spark/Demo/Classes/View/ListView/Cells/ChipCell/ChipCell.swift index 029f1fbb1..b176faca6 100644 --- a/spark/Demo/Classes/View/ListView/Cells/ChipCell/ChipCell.swift +++ b/spark/Demo/Classes/View/ListView/Cells/ChipCell/ChipCell.swift @@ -15,13 +15,12 @@ final class ChipCell: UITableViewCell, Configurable { typealias Component = ChipUIView lazy var component: ChipUIView = { - let view = ChipUIView( + return ChipUIView( theme: SparkTheme.shared, intent: .basic, variant: .outlined, label: "No Title" ) - return view }() override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { diff --git a/spark/Demo/Classes/View/ListView/Cells/IconCell/IconCell.swift b/spark/Demo/Classes/View/ListView/Cells/IconCell/IconCell.swift index a67136d4d..53219596a 100644 --- a/spark/Demo/Classes/View/ListView/Cells/IconCell/IconCell.swift +++ b/spark/Demo/Classes/View/ListView/Cells/IconCell/IconCell.swift @@ -15,13 +15,12 @@ final class IconCell: UITableViewCell, Configurable { typealias Component = IconUIView lazy var component: IconUIView = { - let view = IconUIView( + return IconUIView( iconImage: UIImage(systemName: "lock.circle") ?? UIImage(), theme: SparkTheme.shared, intent: .main, size: .medium ) - return view }() override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { diff --git a/spark/Demo/Classes/View/ListView/Cells/ProgressBarIndeterminateCell/ProgressBarIndeterminateCell.swift b/spark/Demo/Classes/View/ListView/Cells/ProgressBarIndeterminateCell/ProgressBarIndeterminateCell.swift index a927d1d18..f10e43bf3 100644 --- a/spark/Demo/Classes/View/ListView/Cells/ProgressBarIndeterminateCell/ProgressBarIndeterminateCell.swift +++ b/spark/Demo/Classes/View/ListView/Cells/ProgressBarIndeterminateCell/ProgressBarIndeterminateCell.swift @@ -15,12 +15,11 @@ final class ProgressBarIndeterminateCell: UITableViewCell, Configurable { typealias Component = ProgressBarIndeterminateUIView lazy var component: ProgressBarIndeterminateUIView = { - let view = ProgressBarIndeterminateUIView( + return ProgressBarIndeterminateUIView( theme: SparkTheme.shared, intent: .main, shape: .square ) - return view }() var stackViewAlignment: UIStackView.Alignment { diff --git a/spark/Demo/Classes/View/ListView/Cells/ProgressBarSingleCell/ProgressBarSingleCell.swift b/spark/Demo/Classes/View/ListView/Cells/ProgressBarSingleCell/ProgressBarSingleCell.swift index ee3dca062..740fa1195 100644 --- a/spark/Demo/Classes/View/ListView/Cells/ProgressBarSingleCell/ProgressBarSingleCell.swift +++ b/spark/Demo/Classes/View/ListView/Cells/ProgressBarSingleCell/ProgressBarSingleCell.swift @@ -15,12 +15,11 @@ final class ProgressBarSingleCell: UITableViewCell, Configurable { typealias Component = ProgressBarUIView lazy var component: ProgressBarUIView = { - let view = ProgressBarUIView( + return ProgressBarUIView( theme: SparkTheme.shared, intent: .main, shape: .square ) - return view }() var stackViewAlignment: UIStackView.Alignment { diff --git a/spark/Demo/Classes/View/ListView/Cells/RadioButtonCell/RadioButtonCell.swift b/spark/Demo/Classes/View/ListView/Cells/RadioButtonCell/RadioButtonCell.swift index 9c33a8d9c..16a37cd2f 100644 --- a/spark/Demo/Classes/View/ListView/Cells/RadioButtonCell/RadioButtonCell.swift +++ b/spark/Demo/Classes/View/ListView/Cells/RadioButtonCell/RadioButtonCell.swift @@ -15,14 +15,13 @@ final class RadioButtonCell: UITableViewCell, Configurable { typealias Component = RadioButtonUIView lazy var component: RadioButtonUIView = { - let view = RadioButtonUIView( + return RadioButtonUIView( theme: SparkTheme.shared, intent: .main, id: 99, label: NSAttributedString(string: "Sample of toggle on radio button"), isSelected: true ) - return view }() var stackViewAlignment: UIStackView.Alignment { diff --git a/spark/Demo/Classes/View/ListView/Cells/RadioButtonGroupCell/RadioButtonGroupCell.swift b/spark/Demo/Classes/View/ListView/Cells/RadioButtonGroupCell/RadioButtonGroupCell.swift index 5993f369d..371dd375e 100644 --- a/spark/Demo/Classes/View/ListView/Cells/RadioButtonGroupCell/RadioButtonGroupCell.swift +++ b/spark/Demo/Classes/View/ListView/Cells/RadioButtonGroupCell/RadioButtonGroupCell.swift @@ -37,7 +37,7 @@ final class RadioButtonGroupCell: UITableViewCell, Configurable { RadioButtonUIItem.init(id: 1, label: "This is an example of a multi-line text which is very long and in which the user should read all the information."), RadioButtonUIItem.init(id: 2, label: self.attributeString) ] - let view = RadioButtonUIGroupView( + return RadioButtonUIGroupView( theme: SparkTheme.shared, intent: .main, selectedID: 0, @@ -45,7 +45,6 @@ final class RadioButtonGroupCell: UITableViewCell, Configurable { labelAlignment: .trailing, groupLayout: .vertical ) - return view }() var stackViewAlignment: UIStackView.Alignment { diff --git a/spark/Demo/Classes/View/ListView/Cells/RatingDisplayCell/RatingDisplayCell.swift b/spark/Demo/Classes/View/ListView/Cells/RatingDisplayCell/RatingDisplayCell.swift index 6e288c4b5..65a68ee2f 100644 --- a/spark/Demo/Classes/View/ListView/Cells/RatingDisplayCell/RatingDisplayCell.swift +++ b/spark/Demo/Classes/View/ListView/Cells/RatingDisplayCell/RatingDisplayCell.swift @@ -15,11 +15,10 @@ final class RatingDisplayCell: UITableViewCell, Configurable { typealias Component = RatingDisplayUIView lazy var component: RatingDisplayUIView = { - let view = RatingDisplayUIView( + return RatingDisplayUIView( theme: SparkTheme.shared, intent: .main ) - return view }() override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { diff --git a/spark/Demo/Classes/View/ListView/Cells/RatingInputCell/RatingInputCell.swift b/spark/Demo/Classes/View/ListView/Cells/RatingInputCell/RatingInputCell.swift index 85faba32d..ec3c53d25 100644 --- a/spark/Demo/Classes/View/ListView/Cells/RatingInputCell/RatingInputCell.swift +++ b/spark/Demo/Classes/View/ListView/Cells/RatingInputCell/RatingInputCell.swift @@ -15,11 +15,10 @@ final class RatingInputCell: UITableViewCell, Configurable { typealias Component = RatingInputUIView lazy var component: RatingInputUIView = { - let view = RatingInputUIView( + return RatingInputUIView( theme: SparkTheme.shared, intent: .main ) - return view }() override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { diff --git a/spark/Demo/Classes/View/ListView/Cells/SpinnerCell/SpinnerCell.swift b/spark/Demo/Classes/View/ListView/Cells/SpinnerCell/SpinnerCell.swift index c0ae213a7..f3dba444c 100644 --- a/spark/Demo/Classes/View/ListView/Cells/SpinnerCell/SpinnerCell.swift +++ b/spark/Demo/Classes/View/ListView/Cells/SpinnerCell/SpinnerCell.swift @@ -15,10 +15,9 @@ final class SpinnerCell: UITableViewCell, Configurable { typealias Component = SpinnerUIView lazy var component: SpinnerUIView = { - let view = SpinnerUIView( + return SpinnerUIView( theme: SparkTheme.shared ) - return view }() override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { diff --git a/spark/Demo/Classes/View/ListView/Cells/StarCell/StarCell.swift b/spark/Demo/Classes/View/ListView/Cells/StarCell/StarCell.swift index fd9208284..ac40a9137 100644 --- a/spark/Demo/Classes/View/ListView/Cells/StarCell/StarCell.swift +++ b/spark/Demo/Classes/View/ListView/Cells/StarCell/StarCell.swift @@ -20,7 +20,7 @@ final class StarCell: UITableViewCell, Configurable { vertexSize: CGFloat(0.65), cornerRadiusSize: CGFloat(0.15) ) - let view = StarUIView( + return StarUIView( rating: CGFloat(0.5), fillMode: StarFillMode.half, lineWidth: 2, @@ -28,7 +28,6 @@ final class StarCell: UITableViewCell, Configurable { fillColor: UIColor.lightGray, configuration: configuration ) - return view }() override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { diff --git a/spark/Demo/Classes/View/ListView/Cells/SwitchButtonCell/SwitchButtonCell.swift b/spark/Demo/Classes/View/ListView/Cells/SwitchButtonCell/SwitchButtonCell.swift index 49c7603a5..45a4ab9a6 100644 --- a/spark/Demo/Classes/View/ListView/Cells/SwitchButtonCell/SwitchButtonCell.swift +++ b/spark/Demo/Classes/View/ListView/Cells/SwitchButtonCell/SwitchButtonCell.swift @@ -15,7 +15,7 @@ final class SwitchButtonCell: UITableViewCell, Configurable { typealias Component = SwitchUIView lazy var component: SwitchUIView = { - let view = SwitchUIView( + return SwitchUIView( theme: SparkTheme.shared, isOn: true, alignment: .left, @@ -27,7 +27,6 @@ final class SwitchButtonCell: UITableViewCell, Configurable { ), text: "Text" ) - return view }() var attributeString: NSAttributedString { diff --git a/spark/Demo/Classes/View/ListView/Cells/TabCell/TabCell.swift b/spark/Demo/Classes/View/ListView/Cells/TabCell/TabCell.swift index 3fc9c3bcf..9a73259ab 100644 --- a/spark/Demo/Classes/View/ListView/Cells/TabCell/TabCell.swift +++ b/spark/Demo/Classes/View/ListView/Cells/TabCell/TabCell.swift @@ -15,13 +15,12 @@ final class TabCell: UITableViewCell, Configurable { typealias Component = TabUIView lazy var component: TabUIView = { - let view = TabUIView( + return TabUIView( theme: SparkTheme.shared, intent: .main, tabSize: .md, content: [] ) - return view }() var badge: BadgeUIView { diff --git a/spark/Demo/Classes/View/ListView/Cells/TagCell/TagCell.swift b/spark/Demo/Classes/View/ListView/Cells/TagCell/TagCell.swift index f09249d10..2b8b92bb7 100644 --- a/spark/Demo/Classes/View/ListView/Cells/TagCell/TagCell.swift +++ b/spark/Demo/Classes/View/ListView/Cells/TagCell/TagCell.swift @@ -15,13 +15,12 @@ final class TagCell: UITableViewCell, Configurable { typealias Component = TagUIView lazy var component: TagUIView = { - let view = TagUIView( + return TagUIView( theme: SparkTheme.shared, intent: .main, variant: .filled, text: "Tag" ) - return view }() override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { diff --git a/spark/Demo/Classes/View/ListView/Controllers/RadioCheckboxView.swift b/spark/Demo/Classes/View/ListView/Controllers/RadioCheckboxView.swift index 05362368f..fff301f71 100644 --- a/spark/Demo/Classes/View/ListView/Controllers/RadioCheckboxView.swift +++ b/spark/Demo/Classes/View/ListView/Controllers/RadioCheckboxView.swift @@ -26,7 +26,6 @@ struct RadioCheckboxView: View { RadioButtonItem(id: 1, label: "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.") ] - // MARK: - View var body: some View { Component( diff --git a/spark/Demo/Classes/View/ListView/ListComponentsViewController.swift b/spark/Demo/Classes/View/ListView/ListComponentsViewController.swift index 0ed21fc56..cb389f2a8 100644 --- a/spark/Demo/Classes/View/ListView/ListComponentsViewController.swift +++ b/spark/Demo/Classes/View/ListView/ListComponentsViewController.swift @@ -35,11 +35,10 @@ final class ListComponentsViewController: UICollectionViewController { cell.accessories = [.disclosureIndicator(options: .init(tintColor: .systemGray3))] } /// CollectionView diffable data source - let dataSource = DataSource(collectionView: collectionView) { collectionView, indexPath, itemIdentifier in + return DataSource(collectionView: collectionView) { collectionView, indexPath, itemIdentifier in return collectionView.dequeueConfiguredReusableCell( using: cellRegistration, for: indexPath, item: itemIdentifier) } - return dataSource }() // MARK: - ViewDidLoad diff --git a/spark/Demo/Classes/View/ListView/ListViewDatasource.swift b/spark/Demo/Classes/View/ListView/ListViewDatasource.swift index 9ec9a81f3..f12f4b428 100644 --- a/spark/Demo/Classes/View/ListView/ListViewDatasource.swift +++ b/spark/Demo/Classes/View/ListView/ListViewDatasource.swift @@ -68,7 +68,6 @@ final class ListViewDataSource: NSObject, } return UITableViewCell() - /// Icon case let iconConfiguration as IconConfiguration: if let cell = tableView.dequeueReusableCell(withIdentifier: IconCell.reuseIdentifier, for: indexPath) as? IconCell { diff --git a/spark/Demo/Classes/View/SettingsViewController.swift b/spark/Demo/Classes/View/SettingsViewController.swift index 2f3a103c7..dbdf947d6 100644 --- a/spark/Demo/Classes/View/SettingsViewController.swift +++ b/spark/Demo/Classes/View/SettingsViewController.swift @@ -28,11 +28,10 @@ final class SettingsViewController: UICollectionViewController { cell.accessories = [.disclosureIndicator(options: .init(tintColor: .systemGray3))] } /// CollectionView diffable data source - let dataSource = DataSource(collectionView: collectionView) { collectionView, indexPath, itemIdentifier in + return DataSource(collectionView: collectionView) { collectionView, indexPath, itemIdentifier in return collectionView.dequeueConfiguredReusableCell( using: cellRegistration, for: indexPath, item: itemIdentifier) } - return dataSource }() // MARK: - ViewDidLoad diff --git a/spark/Sources/Theming/Content/SparkTypographyTests.swift b/spark/Sources/Theming/Content/SparkTypographyTests.swift index 28bc9ca4a..c007e9b63 100644 --- a/spark/Sources/Theming/Content/SparkTypographyTests.swift +++ b/spark/Sources/Theming/Content/SparkTypographyTests.swift @@ -36,7 +36,6 @@ final class SparkTypographyTests: XCTestCase { } } - private func getTypographyFontTokens(from object: Any) -> [SparkCore.TypographyFontToken] { let mirror = Mirror(reflecting: object) return mirror.children.compactMap { (label: String?, value: Any) in