Skip to content

Commit

Permalink
Rewrite Base64 with protocols, and update coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
leoho0722 committed Feb 9, 2024
1 parent dddab05 commit 59a1429
Show file tree
Hide file tree
Showing 11 changed files with 580 additions and 216 deletions.
35 changes: 20 additions & 15 deletions Sources/SwiftHelpers/Extensions/SwiftUI/Image+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,32 @@

import SwiftUI

public extension Image {

/// Use ``SFSymbols`` to initialize `Image`
init(symbols: SFSymbols) {
self.init(systemName: symbols.rawValue)
}

/// Use ``SFSymbols`` to initialize `Image`
///
/// This initializer is available in iOS 16.0 and macOS 13.0 or above
@available(iOS 16.0, macOS 13.0, *)
init(symbols: SFSymbols, variableValue: Double?) {
self.init(systemName: symbols.rawValue, variableValue: variableValue)
}
}

// MARK: - Deprecated

public extension Image {

/// Use ``SFSymbols`` to initialize `Image`
@available(
*,
deprecated,
renamed: "init(symbols:)",
message: "Deprecated since version 0.0.9, renamed to init(symbols:)"
message: "Deprecated since version 0.0.9, renamed to init(symbols:) and will be removed in a future version"
)
init(systemIcon: SFSymbols) {
self.init(systemName: systemIcon.rawValue)
Expand All @@ -28,22 +46,9 @@ public extension Image {
*,
deprecated,
renamed: "init(symbols:variableValue:)",
message: "Deprecated since version 0.0.9, renamed to init(symbols:variableValue:)"
message: "Deprecated since version 0.0.9, renamed to init(symbols:variableValue:) and will be removed in a future version"
)
init(systemIcon: SFSymbols, variableValue: Double?) {
self.init(systemName: systemIcon.rawValue, variableValue: variableValue)
}

/// Use ``SFSymbols`` to initialize `Image`
init(symbols: SFSymbols) {
self.init(systemName: symbols.rawValue)
}

/// Use ``SFSymbols`` to initialize `Image`
///
/// This initializer is available in iOS 16.0 and macOS 13.0 or above
@available(iOS 16.0, macOS 13.0, *)
init(symbols: SFSymbols, variableValue: Double?) {
self.init(systemName: symbols.rawValue, variableValue: variableValue)
}
}
29 changes: 17 additions & 12 deletions Sources/SwiftHelpers/Extensions/SwiftUI/Label+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,29 @@

import SwiftUI

public extension Label where Title == Text, Icon == Image {

/// Use ``SFSymbols`` and `LocalizedStringKey` to initialize `Label`
init(_ titleKey: LocalizedStringKey, symbols name: SFSymbols) {
self.init(titleKey, systemImage: name.rawValue)
}

/// Use ``SFSymbols`` and `String` to initialize `Label`
init<S>(_ title: S, symbols name: SFSymbols) where S : StringProtocol {
self.init(title, systemImage: name.rawValue)
}
}

// MARK: - Deprecated

public extension Label where Title == Text, Icon == Image {

/// Use ``SFSymbols`` and `LocalizedStringKey` to initialize `Label`
@available(
*,
deprecated,
renamed: "init(_:symbols:)",
message: "Deprecated since version 0.0.9, renamed to init(symbols:)"
message: "Deprecated since version 0.0.9, renamed to init(symbols:) and will be removed in a future version"
)
init(_ titleKey: LocalizedStringKey, systemIcon name: SFSymbols) {
self.init(titleKey, systemImage: name.rawValue)
Expand All @@ -25,19 +40,9 @@ public extension Label where Title == Text, Icon == Image {
*,
deprecated,
renamed: "init(_:symbols:)",
message: "Deprecated since version 0.0.9, renamed to init(symbols:)"
message: "Deprecated since version 0.0.9, renamed to init(symbols:) and will be removed in a future version"
)
init<S>(_ title: S, systemIcon name: SFSymbols) where S : StringProtocol {
self.init(title, systemImage: name.rawValue)
}

/// Use ``SFSymbols`` and `LocalizedStringKey` to initialize `Label`
init(_ titleKey: LocalizedStringKey, symbols name: SFSymbols) {
self.init(titleKey, systemImage: name.rawValue)
}

/// Use ``SFSymbols`` and `String` to initialize `Label`
init<S>(_ title: S, symbols name: SFSymbols) where S : StringProtocol {
self.init(title, systemImage: name.rawValue)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,6 @@ public extension UIAlertController {
}
}

/// Customize the attributedMessage of the UIAlertController message
/// - Parameters:
/// - value: attributedMessage
@available(
*,
deprecated,
renamed: "allAttribtes(with:)",
message: "Deprecated since version 0.0.17, renamed to allAttribtes(with:)"
)
func setAttributedMessage(value: Any?) {
setValue(value, forKey: "attributedMessage")
}

/// Add multiple UIAlertActions to UIAlertController at once.
/// - Parameters:
/// - actions: Array of the UIAlertAction
Expand All @@ -55,8 +42,8 @@ public extension UIAlertController {
}
}

/// Add multiple UIAlertActions to UIAlertController at once.
///
/// Add multiple UIAlertActions to UIAlertController at once.
///
/// Same as ```func addActions(_ actions: UIAlertAction...)```
///
/// - Parameters:
Expand All @@ -67,4 +54,22 @@ public extension UIAlertController {
}
}
}

// MARK: - Deprecated

public extension UIAlertController {

/// Customize the attributedMessage of the UIAlertController message
/// - Parameters:
/// - value: attributedMessage
@available(
*,
deprecated,
renamed: "allAttribtes(with:)",
message: "Deprecated since version 0.0.17, renamed to allAttribtes(with:) and will be removed in a future version"
)
func setAttributedMessage(value: Any?) {
setValue(value, forKey: "attributedMessage")
}
}
#endif
17 changes: 11 additions & 6 deletions Sources/SwiftHelpers/Extensions/UIKit/UIImage+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,27 @@
#if canImport(UIKit)
import UIKit

public extension UIImage {

/// Use ``SFSymbols`` to initialize `UIImage`
convenience init?(symbols: SFSymbols) {
self.init(systemName: symbols.rawValue)
}
}

// MARK: - Deprecated

public extension UIImage {

/// Use ``SFSymbols`` to initialize `UIImage`
@available(
*,
deprecated,
renamed: "init(symbols:)",
message: "Deprecated since version 0.0.9, renamed to init(symbols:)"
message: "Deprecated since version 0.0.9, renamed to init(symbols:) and will be removed in a future version"
)
convenience init?(systemIcon: SFSymbols) {
self.init(systemName: systemIcon.rawValue)
}

/// Use ``SFSymbols`` to initialize `UIImage`
convenience init?(symbols: SFSymbols) {
self.init(systemName: symbols.rawValue)
}
}
#endif
144 changes: 0 additions & 144 deletions Sources/SwiftHelpers/Types/Base64.swift

This file was deleted.

Loading

0 comments on commit 59a1429

Please sign in to comment.