Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,5 @@ extension AvatarVM {
///
/// - Parameter image: See ``UniversalImage``.
case local(_ image: UniversalImage)

/// An image loaded from a local asset.
@available(*, deprecated, message: "Use `local(_:)` instead.")
public static func local(_ name: String, _ bundle: Bundle? = nil) -> Self {
return .local(.init(name, bundle: bundle))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,5 @@ extension AvatarVM {
///
/// - Parameter image: See ``UniversalImage``.
case image(_ image: UniversalImage)

/// A placeholder that displays an SF Symbol.
@available(*, deprecated, message: "Use `image(_:)` instead.")
public static func sfSymbol(_ name: String) -> Self {
return .image(.init(systemName: name))
}

/// A placeholder that displays a custom icon from an asset catalog.
@available(*, deprecated, message: "Use `image(_:)` instead.")
public static func icon(_ name: String, _ bundle: Bundle? = nil) -> Self {
return .image(.init(name, bundle: bundle))
}
}
}
29 changes: 2 additions & 27 deletions Sources/ComponentsKit/Components/Button/Models/ButtonVM.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ public struct ButtonVM: ComponentVM {
/// Defaults to `.leading`.
public var imageLocation: ImageLocation = .leading

/// Defines how image is rendered.
@available(*, deprecated, message: "Use `image.withRenderingMode(_:)` instead.")
public var imageRenderingMode: ImageRenderingMode?

/// The source of the image to be displayed.
@available(*, deprecated, message: "Use `image` instead.")
public var imageSrc: ImageSource?

/// A Boolean value indicating whether the button is enabled or disabled.
///
/// Defaults to `true`.
Expand Down Expand Up @@ -200,30 +192,13 @@ extension ButtonVM {
}
}
}
var imageWithLegacyFallback: UniversalImage? {
if let image { return image }

guard let imageSrc else { return nil }

let image = switch imageSrc {
case .sfSymbol(let name):
UniversalImage(systemName: name)
case .local(let name, let bundle):
UniversalImage(name, bundle: bundle)
}
if let imageRenderingMode {
return image.withRenderingMode(imageRenderingMode)
} else {
return image
}
}
}

// MARK: UIKit Helpers

extension ButtonVM {
var isImageHidden: Bool {
return self.isLoading || self.imageWithLegacyFallback.isNil
return self.isLoading || self.image.isNil
}
func preferredSize(
for contentSize: CGSize,
Expand Down Expand Up @@ -256,7 +231,7 @@ extension ButtonVM {
|| self.font != oldModel.font
|| self.isFullWidth != oldModel.isFullWidth
|| self.isLoading != oldModel.isLoading
|| self.imageWithLegacyFallback != oldModel.imageWithLegacyFallback
|| self.image != oldModel.image
|| self.contentSpacing != oldModel.contentSpacing
|| self.title != oldModel.title
|| self.style != oldModel.style
Expand Down
2 changes: 1 addition & 1 deletion Sources/ComponentsKit/Components/Button/SUButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public struct SUButton: View {

@ViewBuilder
private var content: some View {
switch (self.model.isLoading, self.model.imageWithLegacyFallback, self.model.imageLocation) {
switch (self.model.isLoading, self.model.image, self.model.imageLocation) {
case (true, _, _) where self.model.title.isEmpty:
SULoading(model: self.model.preferredLoadingVM)
case (true, _, _):
Expand Down
2 changes: 1 addition & 1 deletion Sources/ComponentsKit/Components/Button/UKButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ extension UKButton {
view.isVisible = model.isLoading
}
static func imageView(_ imageView: UIImageView, model: Model) {
imageView.image = model.imageWithLegacyFallback?.uiImage
imageView.image = model.image?.uiImage
imageView.contentMode = .scaleAspectFit
imageView.isHidden = model.isImageHidden
imageView.tintColor = model.foregroundColor.uiColor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,6 @@ public struct SUCircularProgress: View {

// MARK: - Initializer

/// Initializer.
/// - Parameters:
/// - currentValue: Current progress.
/// - model: A model that defines the appearance properties.
@available(*, deprecated, message: "Set `currentValue` in the model instead.")
public init(
currentValue: CGFloat = 0,
model: CircularProgressVM = .init()
) {
self.currentValue = currentValue
self.model = model
}

/// Initializer.
/// - Parameters:
/// - model: A model that defines the appearance properties.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,6 @@ open class UKCircularProgress: UIView, UKComponent {

// MARK: - Initialization

/// Initializer.
/// - Parameters:
/// - initialValue: The initial progress value. Defaults to `0`.
/// - model: The model that defines the appearance properties.
@available(*, deprecated, message: "Set `currentValue` in the model instead.")
public init(
initialValue: CGFloat = 0,
model: CircularProgressVM = .init()
) {
self.model = model
self.currentValue = initialValue
super.init(frame: .zero)

self.setup()
self.style()
self.layout()
}

/// Initializer.
/// - Parameters:
/// - model: The model that defines the appearance properties.
Expand Down
13 changes: 0 additions & 13 deletions Sources/ComponentsKit/Components/ProgressBar/SUProgressBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,6 @@ public struct SUProgressBar: View {

// MARK: - Initializer

/// Initializer.
/// - Parameters:
/// - currentValue: The current progress value.
/// - model: A model that defines the appearance properties.
@available(*, deprecated, message: "Set `currentValue` in the model instead.")
public init(
currentValue: CGFloat,
model: ProgressBarVM = .init()
) {
self.currentValue = currentValue
self.model = model
}

/// Initializer.
/// - Parameters:
/// - model: A model that defines the appearance properties.
Expand Down
18 changes: 0 additions & 18 deletions Sources/ComponentsKit/Components/ProgressBar/UKProgressBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,6 @@ open class UKProgressBar: FullWidthComponent, UKComponent {

// MARK: - Initialization

/// Initializer.
/// - Parameters:
/// - initialValue: The initial progress value. Defaults to `0`.
/// - model: A model that defines the appearance properties.
@available(*, deprecated, message: "Set `currentValue` in the model instead.")
public init(
initialValue: CGFloat = 0,
model: ProgressBarVM = .init()
) {
self.currentValue = initialValue
self.model = model
super.init(frame: .zero)

self.setup()
self.style()
self.layout()
}

/// Initializer.
/// - Parameters:
/// - model: A model that defines the appearance properties.
Expand Down