From d4ad3c18e82af7dbad5f341a30a2cd2d73b309d2 Mon Sep 17 00:00:00 2001 From: Gary Tokman Date: Sat, 24 Apr 2021 13:24:47 -0400 Subject: [PATCH] feat: add docs --- .../Reference/ExtensionKit/README.md | 39 +++ .../enums/UIImage.ArrowDirection.md | 14 + .../UIView.GradientLayerChangingDirection.md | 14 + .../ExtensionKit/extensions/Array.md | 33 ++ .../ExtensionKit/extensions/CFRunLoopTimer.md | 15 + .../ExtensionKit/extensions/CGPoint.md | 26 ++ .../ExtensionKit/extensions/CGRect.md | 81 +++++ .../Reference/ExtensionKit/extensions/Data.md | 15 + .../Reference/ExtensionKit/extensions/Date.md | 15 + .../ExtensionKit/extensions/FileManager.md | 58 ++++ .../Reference/ExtensionKit/extensions/Int.md | 112 +++++++ .../ExtensionKit/extensions/NSObject.md | 43 +++ .../ExtensionKit/extensions/String.md | 147 +++++++++ .../ExtensionKit/extensions/Timer.md | 40 +++ .../ExtensionKit/extensions/UIApplication.md | 84 +++++ .../ExtensionKit/extensions/UIButton.md | 103 ++++++ .../ExtensionKit/extensions/UIColor.md | 62 ++++ .../ExtensionKit/extensions/UIImage.md | 297 ++++++++++++++++++ .../ExtensionKit/extensions/UITableView.md | 49 +++ .../ExtensionKit/extensions/UIView.md | 126 ++++++++ .../extensions/UIViewController.md | 234 ++++++++++++++ .../Reference/ExtensionKit/extensions/View.md | 23 ++ .../Reference/ExtensionKit/methods/+(____).md | 5 + .../Reference/ExtensionKit/methods/-(____).md | 5 + .../Reference/ExtensionKit/methods/_(____).md | 5 + .../ExtensionKit/methods/dprint(__).md | 17 + .../ExtensionKit/methods/sleep(duration_).md | 14 + Package.swift | 8 +- README.md | 33 ++ Sources/ExtensionKit/Foundation/String.swift | 4 + .../ExtensionKit/UIKit/UIApplication.swift | 4 + Sources/ExtensionKit/UIKit/UIButton.swift | 4 + Sources/ExtensionKit/UIKit/UIColor.swift | 4 + Sources/ExtensionKit/UIKit/UIImage.swift | 4 + Sources/ExtensionKit/UIKit/UITableView.swift | 4 + Sources/ExtensionKit/UIKit/UIView.swift | 4 + .../ExtensionKit/UIKit/UIViewController.swift | 4 + 37 files changed, 1742 insertions(+), 7 deletions(-) create mode 100644 Documentation/Reference/ExtensionKit/README.md create mode 100644 Documentation/Reference/ExtensionKit/enums/UIImage.ArrowDirection.md create mode 100644 Documentation/Reference/ExtensionKit/enums/UIView.GradientLayerChangingDirection.md create mode 100644 Documentation/Reference/ExtensionKit/extensions/Array.md create mode 100644 Documentation/Reference/ExtensionKit/extensions/CFRunLoopTimer.md create mode 100644 Documentation/Reference/ExtensionKit/extensions/CGPoint.md create mode 100644 Documentation/Reference/ExtensionKit/extensions/CGRect.md create mode 100644 Documentation/Reference/ExtensionKit/extensions/Data.md create mode 100644 Documentation/Reference/ExtensionKit/extensions/Date.md create mode 100644 Documentation/Reference/ExtensionKit/extensions/FileManager.md create mode 100644 Documentation/Reference/ExtensionKit/extensions/Int.md create mode 100644 Documentation/Reference/ExtensionKit/extensions/NSObject.md create mode 100644 Documentation/Reference/ExtensionKit/extensions/String.md create mode 100644 Documentation/Reference/ExtensionKit/extensions/Timer.md create mode 100644 Documentation/Reference/ExtensionKit/extensions/UIApplication.md create mode 100644 Documentation/Reference/ExtensionKit/extensions/UIButton.md create mode 100644 Documentation/Reference/ExtensionKit/extensions/UIColor.md create mode 100644 Documentation/Reference/ExtensionKit/extensions/UIImage.md create mode 100644 Documentation/Reference/ExtensionKit/extensions/UITableView.md create mode 100644 Documentation/Reference/ExtensionKit/extensions/UIView.md create mode 100644 Documentation/Reference/ExtensionKit/extensions/UIViewController.md create mode 100644 Documentation/Reference/ExtensionKit/extensions/View.md create mode 100644 Documentation/Reference/ExtensionKit/methods/+(____).md create mode 100644 Documentation/Reference/ExtensionKit/methods/-(____).md create mode 100644 Documentation/Reference/ExtensionKit/methods/_(____).md create mode 100644 Documentation/Reference/ExtensionKit/methods/dprint(__).md create mode 100644 Documentation/Reference/ExtensionKit/methods/sleep(duration_).md diff --git a/Documentation/Reference/ExtensionKit/README.md b/Documentation/Reference/ExtensionKit/README.md new file mode 100644 index 0000000..697ab49 --- /dev/null +++ b/Documentation/Reference/ExtensionKit/README.md @@ -0,0 +1,39 @@ +# Reference Documentation + +## Enums + +- [UIImage.ArrowDirection](enums/UIImage.ArrowDirection.md) +- [UIView.GradientLayerChangingDirection](enums/UIView.GradientLayerChangingDirection.md) + +## Extensions + +- [Array](extensions/Array.md) +- [CFRunLoopTimer](extensions/CFRunLoopTimer.md) +- [CGPoint](extensions/CGPoint.md) +- [CGRect](extensions/CGRect.md) +- [Data](extensions/Data.md) +- [Date](extensions/Date.md) +- [FileManager](extensions/FileManager.md) +- [Int](extensions/Int.md) +- [NSObject](extensions/NSObject.md) +- [String](extensions/String.md) +- [Timer](extensions/Timer.md) +- [UIApplication](extensions/UIApplication.md) +- [UIButton](extensions/UIButton.md) +- [UIColor](extensions/UIColor.md) +- [UIImage](extensions/UIImage.md) +- [UITableView](extensions/UITableView.md) +- [UIView](extensions/UIView.md) +- [UIViewController](extensions/UIViewController.md) +- [View](extensions/View.md) + +## Methods + +- [+(____)](methods/+(____).md) +- [-(____)](methods/-(____).md) +- [_(____)](methods/_(____).md) +- [_(____)](methods/_(____).md) +- [dprint(__)](methods/dprint(__).md) +- [sleep(duration_)](methods/sleep(duration_).md) + +This file was generated by [SourceDocs](https://github.com/eneko/SourceDocs) on 2021-04-24 17:16:56 +0000 \ No newline at end of file diff --git a/Documentation/Reference/ExtensionKit/enums/UIImage.ArrowDirection.md b/Documentation/Reference/ExtensionKit/enums/UIImage.ArrowDirection.md new file mode 100644 index 0000000..4ee1f88 --- /dev/null +++ b/Documentation/Reference/ExtensionKit/enums/UIImage.ArrowDirection.md @@ -0,0 +1,14 @@ +**ENUM** + +# `UIImage.ArrowDirection` + +```swift +enum ArrowDirection +``` + +## Cases +### `up` + +```swift +case up +``` diff --git a/Documentation/Reference/ExtensionKit/enums/UIView.GradientLayerChangingDirection.md b/Documentation/Reference/ExtensionKit/enums/UIView.GradientLayerChangingDirection.md new file mode 100644 index 0000000..bc3b28f --- /dev/null +++ b/Documentation/Reference/ExtensionKit/enums/UIView.GradientLayerChangingDirection.md @@ -0,0 +1,14 @@ +**ENUM** + +# `UIView.GradientLayerChangingDirection` + +```swift +enum GradientLayerChangingDirection +``` + +## Cases +### `top` + +```swift +case top +``` diff --git a/Documentation/Reference/ExtensionKit/extensions/Array.md b/Documentation/Reference/ExtensionKit/extensions/Array.md new file mode 100644 index 0000000..d813d9c --- /dev/null +++ b/Documentation/Reference/ExtensionKit/extensions/Array.md @@ -0,0 +1,33 @@ +**EXTENSION** + +# `Array` +```swift +public extension Array where Element: Equatable +``` + +## Properties +### `removingRepeatElements` + +```swift +var removingRepeatElements: Array +``` + +Returns an array where repeating elements of the receiver got removed. + +## Methods +### `remove(_:)` + +```swift +mutating func remove(_ element: Element) -> Element? +``` + +Removes the given element in the array. + +- Parameter element: The element to be removed. +- Returns: The element got removed, or `nil` if the element doesn't exist. + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| element | The element to be removed. | \ No newline at end of file diff --git a/Documentation/Reference/ExtensionKit/extensions/CFRunLoopTimer.md b/Documentation/Reference/ExtensionKit/extensions/CFRunLoopTimer.md new file mode 100644 index 0000000..e47ac3e --- /dev/null +++ b/Documentation/Reference/ExtensionKit/extensions/CFRunLoopTimer.md @@ -0,0 +1,15 @@ +**EXTENSION** + +# `CFRunLoopTimer` +```swift +public extension CFRunLoopTimer +``` + +## Methods +### `invalidate()` + +```swift +func invalidate() +``` + +Invalidate CFRunLoopTimer diff --git a/Documentation/Reference/ExtensionKit/extensions/CGPoint.md b/Documentation/Reference/ExtensionKit/extensions/CGPoint.md new file mode 100644 index 0000000..30b1bda --- /dev/null +++ b/Documentation/Reference/ExtensionKit/extensions/CGPoint.md @@ -0,0 +1,26 @@ +**EXTENSION** + +# `CGPoint` +```swift +public extension CGPoint +``` + +## Methods +### `offseted(x:y:)` + +```swift +func offseted(x: CGFloat = 0.0, y: CGFloat = 0.0) -> CGPoint +``` + +Offset point by new x and y +- Parameters: + - x: x + - y: y +- Returns: new point + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| x | x | +| y | y | \ No newline at end of file diff --git a/Documentation/Reference/ExtensionKit/extensions/CGRect.md b/Documentation/Reference/ExtensionKit/extensions/CGRect.md new file mode 100644 index 0000000..629c423 --- /dev/null +++ b/Documentation/Reference/ExtensionKit/extensions/CGRect.md @@ -0,0 +1,81 @@ +**EXTENSION** + +# `CGRect` +```swift +public extension CGRect +``` + +## Properties +### `topLeft` + +```swift +var topLeft: CGPoint +``` + +### `topRight` + +```swift +var topRight: CGPoint +``` + +### `topMiddle` + +```swift +var topMiddle: CGPoint +``` + +### `bottomLeft` + +```swift +var bottomLeft: CGPoint +``` + +### `bottomRight` + +```swift +var bottomRight: CGPoint +``` + +### `bottomMiddle` + +```swift +var bottomMiddle: CGPoint +``` + +### `leftMiddle` + +```swift +var leftMiddle: CGPoint +``` + +### `rightMiddle` + +```swift +var rightMiddle: CGPoint +``` + +### `midX` + +```swift +var midX: CGFloat +``` + +### `midY` + +```swift +var midY: CGFloat +``` + +### `center` + +```swift +var center: CGPoint +``` + +Center taking size into account + +### `sameCenterSquare` + +```swift +var sameCenterSquare: CGRect +``` diff --git a/Documentation/Reference/ExtensionKit/extensions/Data.md b/Documentation/Reference/ExtensionKit/extensions/Data.md new file mode 100644 index 0000000..ba5303f --- /dev/null +++ b/Documentation/Reference/ExtensionKit/extensions/Data.md @@ -0,0 +1,15 @@ +**EXTENSION** + +# `Data` +```swift +public extension Data +``` + +## Properties +### `hexString` + +```swift +var hexString: String +``` + +Returns a string of hex value. diff --git a/Documentation/Reference/ExtensionKit/extensions/Date.md b/Documentation/Reference/ExtensionKit/extensions/Date.md new file mode 100644 index 0000000..7520872 --- /dev/null +++ b/Documentation/Reference/ExtensionKit/extensions/Date.md @@ -0,0 +1,15 @@ +**EXTENSION** + +# `Date` +```swift +public extension Date +``` + +## Properties +### `day` + +```swift +var day: String +``` + +Current day of the week in Gregorian calendar diff --git a/Documentation/Reference/ExtensionKit/extensions/FileManager.md b/Documentation/Reference/ExtensionKit/extensions/FileManager.md new file mode 100644 index 0000000..d5bd891 --- /dev/null +++ b/Documentation/Reference/ExtensionKit/extensions/FileManager.md @@ -0,0 +1,58 @@ +**EXTENSION** + +# `FileManager` +```swift +public extension FileManager +``` + +## Methods +### `fileSize(atPath:)` + +```swift +func fileSize(atPath path: String) -> Int +``` + +Size of file at path + +- Parameter path: file path +- Returns: Size in bytes + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| path | file path | + +### `folderSize(atPath:)` + +```swift +func folderSize(atPath path: String) -> Int +``` + +Size of folder + +- Parameter path: folder path +- Returns: size in bytes + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| path | folder path | + +### `directorySize(at:)` + +```swift +func directorySize(at URL: URL) -> Int +``` + +Size of directory at URL + +- Parameter URL: URL +- Returns: Size in bytes + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| URL | URL | \ No newline at end of file diff --git a/Documentation/Reference/ExtensionKit/extensions/Int.md b/Documentation/Reference/ExtensionKit/extensions/Int.md new file mode 100644 index 0000000..ccd9e20 --- /dev/null +++ b/Documentation/Reference/ExtensionKit/extensions/Int.md @@ -0,0 +1,112 @@ +**EXTENSION** + +# `Int` +```swift +public extension Int +``` + +## Properties +### `isOdd` + +```swift +var isOdd: Bool +``` + +Whether self is an odd number + +### `isEven` + +```swift +var isEven: Bool +``` + +Whether self is an even number + +### `nilIfZero` + +```swift +var nilIfZero: Int? +``` + +Treats 0 as nil + +### `string` + +```swift +var string: String +``` + +Make the number to string + +### `range` + +```swift +var range: CountableRange +``` + +Make a range from zero to self + +### `minutes` + +```swift +var minutes: Int +``` + +### `hours` + +```swift +var hours: Int +``` + +### `days` + +```swift +var days: Int +``` + +### `months` + +```swift +var months: Int +``` + +### `years` + +```swift +var years: Int +``` + +## Methods +### `instances(of:)` + +```swift +func instances(of creation: @autoclosure () throws -> T) rethrows -> [T] +``` + +Return a number of instances + +- Parameter creation: The initialization of the object +- Returns: An array containing the objects + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| creation | The initialization of the object | + +### `inRange(_:)` + +```swift +func inRange(_ range: Range) -> Bool +``` + +Return if `self` is in the given range. + +- Parameter range: Target range. +- Returns: `true` if self is in the range, otherwise `false`. + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| range | Target range. | \ No newline at end of file diff --git a/Documentation/Reference/ExtensionKit/extensions/NSObject.md b/Documentation/Reference/ExtensionKit/extensions/NSObject.md new file mode 100644 index 0000000..ac189b1 --- /dev/null +++ b/Documentation/Reference/ExtensionKit/extensions/NSObject.md @@ -0,0 +1,43 @@ +**EXTENSION** + +# `NSObject` +```swift +public extension NSObject +``` + +## Properties +### `className` + +```swift +var className: String +``` + +Return class name. + +## Methods +### `exchangeImplementations(originalSelector:swizzledSelector:)` + +```swift +class func exchangeImplementations(originalSelector: Selector, swizzledSelector: Selector) +``` + +Exchange two implementations of the given selectors, aka method swizzling. + +- Parameters: + - originalSelector: The original selector. + - swizzledSelector: Another selector. + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| originalSelector | The original selector. | +| swizzledSelector | Another selector. | + +### `printDeinitMessage()` + +```swift +final func printDeinitMessage() +``` + +Print the deinitialization message of self. diff --git a/Documentation/Reference/ExtensionKit/extensions/String.md b/Documentation/Reference/ExtensionKit/extensions/String.md new file mode 100644 index 0000000..f185583 --- /dev/null +++ b/Documentation/Reference/ExtensionKit/extensions/String.md @@ -0,0 +1,147 @@ +**EXTENSION** + +# `String` +```swift +public extension String +``` + +## Properties +### `isEmail` + +```swift +var isEmail: Bool +``` + +Is valid email + +### `areNumbers` + +```swift +var areNumbers: Bool +``` + +Are numbers 0-9 + +### `toInt` + +```swift +var toInt: Int? +``` + +Cast to Int + +### `toDouble` + +```swift +var toDouble: Double? +``` + +Cast to Double + +### `trimmingZeroDecimal` + +```swift +var trimmingZeroDecimal: String +``` + +Trimming ".0" + +### `addingPlusSymbol` + +```swift +var addingPlusSymbol: String +``` + +Adding "+" at the very beginning. + +### `addingMinusSymbol` + +```swift +var addingMinusSymbol: String +``` + +Adding "-" at the very beginning. + +### `uppercasingFirstLetter` + +```swift +var uppercasingFirstLetter: String +``` + +### `lowercasingFirstLetter` + +```swift +var lowercasingFirstLetter: String +``` + +### `isBlank` + +```swift +var isBlank: Bool +``` + +Return `true` if self is empty or only contains white spaces and/or new lines. + +### `isVisible` + +```swift +var isVisible: Bool +``` + +Return `false` if self is empty or only contains white spaces and/or new lines. + +### `nilIfBlank` + +```swift +var nilIfBlank: String? +``` + +Return `nil` if `self.isBlank` is `true`. + +## Methods +### `layoutSize(with:)` + +```swift +func layoutSize(with font: UIFont) -> CGSize +``` + +Returns the CGSize that the string being layout on screen. + +- Parameter font: The given font. +- Returns: The result CGSize. + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| font | The given font. | + +### `advanceNumberValue(step:)` + +```swift +mutating func advanceNumberValue(step: Int = 1) +``` + +Cast as Int and add the given value. No changes if casting fails. + +### `isOldAppVersion(comparedWith:)` + +```swift +func isOldAppVersion(comparedWith aVersion: String) -> Bool +``` + +Comparing app versions. Returns `true` if self is `1.1.0` and the given value is `1.2.0`. +- Parameter aVersion: Another version. +- Returns: `true` if the give version is newer than self. + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| aVersion | Another version. | + +### `treatsVisuallyEmptyAsNil()` + +```swift +func treatsVisuallyEmptyAsNil() -> String? +``` diff --git a/Documentation/Reference/ExtensionKit/extensions/Timer.md b/Documentation/Reference/ExtensionKit/extensions/Timer.md new file mode 100644 index 0000000..950ca3a --- /dev/null +++ b/Documentation/Reference/ExtensionKit/extensions/Timer.md @@ -0,0 +1,40 @@ +**EXTENSION** + +# `Timer` +```swift +public extension Timer +``` + +## Methods +### `schedule(delay:handler:)` + +```swift +class func schedule(delay: TimeInterval, handler: @escaping () -> Void) -> CFRunLoopTimer? +``` + +Schedule closure to run on main run loop after delay + +- Parameters: + - delay: Delay interval + - handler: Closure to run +- Returns: `CFRunLoopTimer` + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| delay | Delay interval | +| handler | Closure to run | + +### `schedule(repeatInterval:handler:)` + +```swift +class func schedule(repeatInterval interval: TimeInterval, handler: @escaping () -> Void) -> CFRunLoopTimer? +``` + + Schedule closure to run on main run loop and repeat at the interval + +- Parameters: + - interval: 触发时长,从现在开始经过interval时长后触发第一次 + - handler: Closure to run +- Returns: CFRunLoopTimer diff --git a/Documentation/Reference/ExtensionKit/extensions/UIApplication.md b/Documentation/Reference/ExtensionKit/extensions/UIApplication.md new file mode 100644 index 0000000..2476251 --- /dev/null +++ b/Documentation/Reference/ExtensionKit/extensions/UIApplication.md @@ -0,0 +1,84 @@ +**EXTENSION** + +# `UIApplication` + +## Methods +### `openSettings()` + +```swift +func openSettings() +``` + +Open application settings + +### `openPhone(calling:)` + +```swift +func openPhone(calling number: String) +``` + +Opens application sheet for phonen number + +### `openFacebook(name:id:)` + +```swift +func openFacebook(name: String?, id: String?) +``` + +Find My Facebook ID: https://findmyfbid.com/ +- Parameters: + - name: Facebook name + - id: Facebook ID + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| name | Facebook name | +| id | Facebook ID | + +### `openInstagram(name:)` + +```swift +func openInstagram(name: String?) +``` + +Launches the Instagram app and loads the Instagram user +- Parameter name: Instagram username + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| name | Instagram username | + +### `openInstagram(media:)` + +```swift +func openInstagram(media: String?) +``` + +Launches the Instagram app and loads the Instagram user +- Parameter name: Instagram username + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| name | Instagram username | + +### `openExternalMapApp(query:)` + +```swift +func openExternalMapApp(query: String) +``` + +Open a map app with the given query. Orders: Google Map -> Apple Map + +- Parameter query: The query to search on the map. + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| query | The query to search on the map. | \ No newline at end of file diff --git a/Documentation/Reference/ExtensionKit/extensions/UIButton.md b/Documentation/Reference/ExtensionKit/extensions/UIButton.md new file mode 100644 index 0000000..d1cd10d --- /dev/null +++ b/Documentation/Reference/ExtensionKit/extensions/UIButton.md @@ -0,0 +1,103 @@ +**EXTENSION** + +# `UIButton` + +## Properties +### `normalStateBackgroundColor` + +```swift +@IBInspectable var normalStateBackgroundColor: UIColor? +``` + +### `disabledStateBackgroundColor` + +```swift +@IBInspectable var disabledStateBackgroundColor: UIColor? +``` + +### `highlightedStateBackgroundColor` + +```swift +@IBInspectable var highlightedStateBackgroundColor: UIColor? +``` + +### `selectedStateBackgroundColor` + +```swift +@IBInspectable var selectedStateBackgroundColor: UIColor? +``` + +### `titleImageSpacing` + +```swift +@IBInspectable var titleImageSpacing: CGFloat +``` + +### `isTitleImagePositionReversed` + +```swift +var isTitleImagePositionReversed: Bool +``` + +### `backgroundImageView` + +```swift +var backgroundImageView: UIImageView? +``` + +## Methods +### `setBackgroundColor(_:for:)` + +```swift +func setBackgroundColor(_ color: UIColor, for state: UIControl.State) +``` + +Set background color for state +- Parameters: + - color: color + - state: state + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| color | color | +| state | state | + +### `centerTextAndImage(spacing:forceRightToLeft:)` + +```swift +func centerTextAndImage(spacing: CGFloat, forceRightToLeft: Bool) +``` + +Adjust `contentEdgeInsets`, `imageEdgeInsets` and `titleEdgeInsets` with appropriate value so as to make a specified spacing between the button's title and image. +- Reference: https://stackoverflow.com/questions/4564621/aligning-text-and-image-on-uibutton-with-imageedgeinsets-and-titleedgeinsets + +- Parameters: + - spacing: The desired spacing to make. + - forceRightToLeft: Whether the content of the button is in `forceRightToLeft` semantic. + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| spacing | The desired spacing to make. | +| forceRightToLeft | Whether the content of the button is in `forceRightToLeft` semantic. | + +### `addAction(for:closure:)` + +```swift +func addAction(for controlEvent: UIControl.Event, closure: @escaping () -> Void) +``` + +Button action for event +- Parameters: + - controlEvent: Event + - closure: Closure to run + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| controlEvent | Event | +| closure | Closure to run | \ No newline at end of file diff --git a/Documentation/Reference/ExtensionKit/extensions/UIColor.md b/Documentation/Reference/ExtensionKit/extensions/UIColor.md new file mode 100644 index 0000000..1b2a52d --- /dev/null +++ b/Documentation/Reference/ExtensionKit/extensions/UIColor.md @@ -0,0 +1,62 @@ +**EXTENSION** + +# `UIColor` + +## Properties +### `isLight` + +```swift +var isLight: Bool +``` + +Check whether self is a light/bright color. +https://stackoverflow.com/questions/2509443/check-if-uicolor-is-dark-or-bright + +### `isExtremelyLight` + +```swift +var isExtremelyLight: Bool +``` + +Check whether self is a light/bright color. +https://stackoverflow.com/questions/2509443/check-if-uicolor-is-dark-or-bright + +## Methods +### `init(rgbValue:alpha:)` + +```swift +convenience init(rgbValue: UInt, alpha: CGFloat) +``` + +New color from RGB value +- Parameters: + - rgbValue: value + - alpha: alpha + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| rgbValue | value | +| alpha | alpha | + +### `init(rgbValue:)` + +```swift +convenience init(rgbValue: UInt) +``` + +### `init(hexCode:)` + +```swift +convenience init(hexCode: String) +``` + +Color from HEX +- Parameter hexCode: Hex w/o `#` + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| hexCode | Hex w/o `#` | \ No newline at end of file diff --git a/Documentation/Reference/ExtensionKit/extensions/UIImage.md b/Documentation/Reference/ExtensionKit/extensions/UIImage.md new file mode 100644 index 0000000..1b084ff --- /dev/null +++ b/Documentation/Reference/ExtensionKit/extensions/UIImage.md @@ -0,0 +1,297 @@ +**EXTENSION** + +# `UIImage` + +## Properties +### `isSquare` + +```swift +var isSquare: Bool +``` + +Is square aspect ratio + +### `sizeOnDisk` + +```swift +var sizeOnDisk: String +``` + +Size in KB or MB + +### `heightForScreenWidth` + +```swift +var heightForScreenWidth: CGFloat +``` + +Height for screen width + +### `orientationFixed` + +```swift +var orientationFixed: UIImage +``` + +Correct the direction of the picture so that it positioned correctly + +- Returns: Image + +## Methods +### `init(qrCodeFrom:)` + +```swift +convenience init?(qrCodeFrom string: String) +``` + +Create QR code from string +- Parameter string: String for QR code + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| string | String for QR code | + +### `withStarShape(size:strokeColor:lineWidth:fillColor:)` + +```swift +static func withStarShape(size: CGSize, strokeColor: UIColor = .clear, lineWidth: CGFloat = 2.0, fillColor: UIColor?) -> UIImage? +``` + +Draw a star +- Parameters: + - size: Size + - strokeColor: Stroke color + - lineWidth: Line width + - fillColor: Fill color +- Returns: Drawn star as UIImage + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| size | Size | +| strokeColor | Stroke color | +| lineWidth | Line width | +| fillColor | Fill color | + +### `withTintColor(_:)` + +```swift +func withTintColor(_ color: UIColor) -> UIImage? +``` + +Returns an identical image with specified tint color. Note that the returned image is with rendering mode `.alwaysOriginal` + +- Reference + + https://stackoverflow.com/questions/31803157/how-can-i-color-a-uiimage-in-swift + +- Parameter color: The tint color +- Returns: An identical image with specified tint color + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| color | The tint color | + +### `aspectHeight(for:)` + +```swift +func aspectHeight(for width: CGFloat) -> CGFloat +``` + +Scale the height of the given width proportionally + +- parameter width: width + +- returns: New height + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| width | width | + +### `aspectWidth(for:)` + +```swift +func aspectWidth(for height: CGFloat) -> CGFloat +``` + +Scale the width of the given height proportionally + +- parameter height: Height + +- returns: New width + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| height | Height | + +### `aspectFitSize(forBindingSize:)` + +```swift +func aspectFitSize(forBindingSize binding: CGSize) -> CGSize +``` + +Keep the aspect ratio and return the fitting size of the given size + +- Parameter binding: Size +- Returns: New size + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| binding | Size | + +### `image(withPureColor:for:rounded:)` + +```swift +class func image(withPureColor color: UIColor, for rect: CGRect, rounded: Bool) -> UIImage? +``` + +Get an single-colored image + +- Parameters: + - color: The color + - rect: The rect to draw in a CGContext. +- Returns: An single-colored image object, nil if any problems occur, such as CGRect.zero got passed. + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| color | The color | +| rect | The rect to draw in a CGContext. | + +### `subImage(in:)` + +```swift +func subImage(in rect: CGRect) -> UIImage? +``` + +Get certain part of image + +- Parameter rect: Part of the image +- Returns: Image + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| rect | Part of the image | + +### `resized(to:)` + +```swift +func resized(to size: CGSize) -> UIImage? +``` + +Redraw the image to the specified size + +- Parameter size: Size +- Returns: Image + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| size | Size | + +### `resizedImageWithAspectFitSize(forBindingSize:)` + +```swift +func resizedImageWithAspectFitSize(forBindingSize binding: CGSize) -> UIImage? +``` + +### `square()` + +```swift +func square() -> UIImage? +``` + +Resize the image so that its width and height are equal. + +- Returns: A newly created image. + +### `with(backgroundColor:cornerRadius:insets:)` + +```swift +func with(backgroundColor: UIColor, cornerRadius: CGFloat, insets: UIEdgeInsets) -> UIImage? +``` + +Redraw a new image with the given requirements. + +- Parameters: + - backgroundColor: The background color of the image. + - cornerRadius: The corner radius of the image, pass 0.0 if you perfer a squared one. + - insets: The inset to apply to the image. +- Returns: A newly created image. + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| backgroundColor | The background color of the image. | +| cornerRadius | The corner radius of the image, pass 0.0 if you perfer a squared one. | +| insets | The inset to apply to the image. | + +### `arrowHead(direction:color:size:lineWidth:)` + +```swift +static func arrowHead(direction: ArrowDirection, color: UIColor, size: CGSize, lineWidth: CGFloat = 2.0) -> UIImage? +``` + +### `borderImage(size:backgroundColor:borderColor:borderWidth:cornerRadius:)` + +```swift +class func borderImage(size: CGSize, backgroundColor: UIColor, borderColor: UIColor, borderWidth: CGFloat, cornerRadius: CGFloat) -> UIImage? +``` + +Draw a image with a border +- Parameters: + - size: size + - backgroundColor: color + - borderColor: border color + - borderWidth: border width + - cornerRadius: radius +- Returns: New image + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| size | size | +| backgroundColor | color | +| borderColor | border color | +| borderWidth | border width | +| cornerRadius | radius | + +### `buttonBackgroundBorderImage(backgroundColor:borderColor:borderWidth:cornerRadius:)` + +```swift +class func buttonBackgroundBorderImage(backgroundColor: UIColor, borderColor: UIColor, borderWidth: CGFloat, cornerRadius: CGFloat) -> UIImage? +``` + +Draw background image +- Parameters: + - backgroundColor: color + - borderColor: border color + - borderWidth: width + - cornerRadius: radius +- Returns: New image + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| backgroundColor | color | +| borderColor | border color | +| borderWidth | width | +| cornerRadius | radius | \ No newline at end of file diff --git a/Documentation/Reference/ExtensionKit/extensions/UITableView.md b/Documentation/Reference/ExtensionKit/extensions/UITableView.md new file mode 100644 index 0000000..261ee1e --- /dev/null +++ b/Documentation/Reference/ExtensionKit/extensions/UITableView.md @@ -0,0 +1,49 @@ +**EXTENSION** + +# `UITableView` + +## Properties +### `isEmpty` + +```swift +var isEmpty: Bool +``` + +Zero rows in all sections + +## Methods +### `reloadCell(_:with:)` + +```swift +func reloadCell(_ cell: UITableViewCell, with animation: UITableView.RowAnimation) +``` + +Reload cell at index path +- Parameters: + - cell: cell + - animation: animation + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| cell | cell | +| animation | animation | + +### `scrollToBottom(position:animated:)` + +```swift +func scrollToBottom(position: UITableView.ScrollPosition = .bottom, animated: Bool = true) +``` + +Scroll to last index in last section +- Parameters: + - position: position + - animated: animated + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| position | position | +| animated | animated | \ No newline at end of file diff --git a/Documentation/Reference/ExtensionKit/extensions/UIView.md b/Documentation/Reference/ExtensionKit/extensions/UIView.md new file mode 100644 index 0000000..d765c76 --- /dev/null +++ b/Documentation/Reference/ExtensionKit/extensions/UIView.md @@ -0,0 +1,126 @@ +**EXTENSION** + +# `UIView` + +## Properties +### `anchorPoint` + +```swift +var anchorPoint: CGPoint +``` + +Set anchor point on layer + +### `layerCornerRadius` + +```swift +@IBInspectable var layerCornerRadius: CGFloat +``` + +Set corner radius on layer + +### `layerBorderWidth` + +```swift +@IBInspectable var layerBorderWidth: CGFloat +``` + +Set border width on layer + +### `layerBorderColor` + +```swift +@IBInspectable var layerBorderColor: UIColor? +``` + +Set a border color on layer + +## Methods +### `addCleanBorder(cornerRadius:color:width:targetBounds:)` + +```swift +func addCleanBorder(cornerRadius: CGFloat, color: UIColor, width: CGFloat, targetBounds: CGRect?) +``` + +Add border using path +- Parameters: + - cornerRadius: radius + - color: color + - width: width + - targetBounds: bounds or view bounds + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| cornerRadius | radius | +| color | color | +| width | width | +| targetBounds | bounds or view bounds | + +### `addCleanBorder(roundingCorners:cornerRadii:color:width:targetBounds:)` + +```swift +func addCleanBorder(roundingCorners: UIRectCorner, cornerRadii: CGSize, color: UIColor, width: CGFloat, targetBounds: CGRect?) +``` + +Add border using path +- Parameters: + - roundingCorners: Corners to round + - cornerRadii: radius + - color: color + - width: width + - targetBounds: view bounds + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| roundingCorners | Corners to round | +| cornerRadii | radius | +| color | color | +| width | width | +| targetBounds | view bounds | + +### `addTransparentGradientLayer(frame:toColor:minAlpha:maxAlpha:from:to:)` + +```swift +func addTransparentGradientLayer(frame: CGRect? = nil, toColor: UIColor, minAlpha: CGFloat, maxAlpha: CGFloat, from start: GradientLayerChangingDirection, to end: GradientLayerChangingDirection) -> CAGradientLayer +``` + +Add a transparent gradient layer + +- Parameters: + - frame: View frame (default to bounds) + - toColor: Color to add + - minAlpha: Alpha + - maxAlpha: End alpha + - start: Start direction + - end: End direction + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| frame | View frame (default to bounds) | +| toColor | Color to add | +| minAlpha | Alpha | +| maxAlpha | End alpha | +| start | Start direction | +| end | End direction | + +### `sizeToFitConstraintedBasedLayout()` + +```swift +func sizeToFitConstraintedBasedLayout() +``` + +Resizes `self.frame` so as to fit the constraint-based layout. + +### `shakeToIndicateError()` + +```swift +func shakeToIndicateError() +``` + +Commit a shake animation and vibrate to indicate the occured error. diff --git a/Documentation/Reference/ExtensionKit/extensions/UIViewController.md b/Documentation/Reference/ExtensionKit/extensions/UIViewController.md new file mode 100644 index 0000000..c48b3f3 --- /dev/null +++ b/Documentation/Reference/ExtensionKit/extensions/UIViewController.md @@ -0,0 +1,234 @@ +**EXTENSION** + +# `UIViewController` + +## Properties +### `titleColor` + +```swift +var titleColor: UIColor? +``` + +NavigationBar tint color + +### `titleFont` + +```swift +var titleFont: UIFont? +``` + +NavigationBar font + +### `viewIsVisible` + +```swift +var viewIsVisible: Bool +``` + +Is view loaded and in window + +### `automaticallyHideKeyboardWhenViewTapped` + +```swift +var automaticallyHideKeyboardWhenViewTapped: Bool +``` + +Should hide keyboard on view tap + +### `bottomToolBar` + +```swift +var bottomToolBar: UIView? +``` + +Add a bottom tool bar to view controller + +### `hidesNavigationBarBackgroundWhenVisible` + +```swift +var hidesNavigationBarBackgroundWhenVisible: Bool +``` + +Hide navigation bar background when visible + +### `navigationBarHeight` + +```swift +var navigationBarHeight: CGFloat +``` + +Navigation bar height + +### `tabBarHeight` + +```swift +var tabBarHeight: CGFloat +``` + +Tab bar height + +## Methods +### `combine(models:into:newViewGeneration:using:remainingViews:)` + +```swift +class func combine(models: [Model], into views: inout [View], newViewGeneration: () -> View, using operation: (Model, View) -> Void, remainingViews: (ArraySlice) -> Void) +``` + +Combine an array of models and an array of views. + +- Parameters: + - models: The models as data source. + - views: The views in need of loading data. Note that this is an inout parameters. + - newViewGeneration: The function to generate new views, which would immediately be appended into `views`. + - operation: The main operation that combine each model and view together. + - remainingViews: The handler responsible for dealing with the rest of unused views. + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| models | The models as data source. | +| views | The views in need of loading data. Note that this is an inout parameters. | +| newViewGeneration | The function to generate new views, which would immediately be appended into `views`. | +| operation | The main operation that combine each model and view together. | +| remainingViews | The handler responsible for dealing with the rest of unused views. | + +### `showSystemAlert(title:message:confirmTitle:confirmHandler:cancelTitle:cancelHandler:)` + +```swift +func showSystemAlert( + title: String?, + message: String? = nil, + confirmTitle: String? = nil, + confirmHandler: (() -> Void)? = nil, + cancelTitle: String = "Cancel", + cancelHandler: (() -> Void)? = nil) +``` + +Present system alert + +- Parameters: + - title: Title + - message: Message + - confirmTitle: Confirm button title + - confirmHandler: Confirm handler to run on press + - cancelTitle: Cancel button title + - cancelHandler: Cancel handler to run on press + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| title | Title | +| message | Message | +| confirmTitle | Confirm button title | +| confirmHandler | Confirm handler to run on press | +| cancelTitle | Cancel button title | +| cancelHandler | Cancel handler to run on press | + +### `showSystemDistructiveAlert(title:message:destructiveTitle:destructiveHandler:cancelTitle:cancelHandler:)` + +```swift +func showSystemDistructiveAlert( + title: String?, + message: String? = nil, + destructiveTitle: String?, + destructiveHandler: (() -> Void)?, + cancelTitle: String?, + cancelHandler: (() -> Void)? = nil) +``` + +Present system alert with distructive primary action + +- Parameters: + - title: Title + - message: Message + - confirmTitle: Confirm button title + - confirmHandler: Confirm handler to run on press + - cancelTitle: Cancel button title + - cancelHandler: Cancel handler to run on press + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| title | Title | +| message | Message | +| confirmTitle | Confirm button title | +| confirmHandler | Confirm handler to run on press | +| cancelTitle | Cancel button title | +| cancelHandler | Cancel handler to run on press | + +### `showSystemActionSheet(title:message:validActions:)` + +```swift +func showSystemActionSheet(title: String?, message: String?, validActions: (String?, (() -> Void)?)...) +``` + +Present action sheet + +- Parameters: + - title: Title + - message: Message + - actions: Actions in the sheet + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| title | Title | +| message | Message | +| actions | Actions in the sheet | + +### `resignTextFieldToHideKeyboard(_:)` + +```swift +@IBAction func resignTextFieldToHideKeyboard(_ sender: AnyObject) +``` + +Resign keyboard + +### `getCurrentViewController(base:)` + +```swift +class func getCurrentViewController(base: UIViewController? = UIApplication.shared.keyWindow?.rootViewController) -> UIViewController? +``` + +Get the current visible view controller by crawling the view controller heirarchy + +- Parameter base: `UIViewController` to search +- Returns: Current `UIViewController` + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| base | `UIViewController` to search | + +### `popFromNavigationStack()` + +```swift +func popFromNavigationStack() +``` + +Pop view controller from nav stack + +### `addDismissNavigationItem(localizedTitle:image:)` + +```swift +func addDismissNavigationItem(localizedTitle: String = "Dismiss", image: UIImage? = nil) +``` + +Add dismiss `UIBarButtonItem` naviation item + +### `dismissSelf(_:)` + +```swift +@objc func dismissSelf(_ sender: Any) +``` + +### `pushSafariViewController(urlString:entersReaderIfAvailable:)` + +```swift +func pushSafariViewController(urlString: String, entersReaderIfAvailable: Bool = false) +``` diff --git a/Documentation/Reference/ExtensionKit/extensions/View.md b/Documentation/Reference/ExtensionKit/extensions/View.md new file mode 100644 index 0000000..4528038 --- /dev/null +++ b/Documentation/Reference/ExtensionKit/extensions/View.md @@ -0,0 +1,23 @@ +**EXTENSION** + +# `View` +```swift +public extension View +``` + +## Methods +### `fillParent(alignment:)` + +```swift +func fillParent(alignment: Alignment = .center) -> some View +``` + +Fill parent view +- Parameter alignment: alignment +- Returns: View with filled frame + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| alignment | alignment | \ No newline at end of file diff --git a/Documentation/Reference/ExtensionKit/methods/+(____).md b/Documentation/Reference/ExtensionKit/methods/+(____).md new file mode 100644 index 0000000..d41fc5f --- /dev/null +++ b/Documentation/Reference/ExtensionKit/methods/+(____).md @@ -0,0 +1,5 @@ +### `+(_:_:)` + +```swift +public func +(lhs: CGSize, rhs: CGSize) -> CGSize +``` diff --git a/Documentation/Reference/ExtensionKit/methods/-(____).md b/Documentation/Reference/ExtensionKit/methods/-(____).md new file mode 100644 index 0000000..40ac310 --- /dev/null +++ b/Documentation/Reference/ExtensionKit/methods/-(____).md @@ -0,0 +1,5 @@ +### `-(_:_:)` + +```swift +public func -(lhs: CGSize, rhs: CGSize) -> CGSize +``` diff --git a/Documentation/Reference/ExtensionKit/methods/_(____).md b/Documentation/Reference/ExtensionKit/methods/_(____).md new file mode 100644 index 0000000..9652d75 --- /dev/null +++ b/Documentation/Reference/ExtensionKit/methods/_(____).md @@ -0,0 +1,5 @@ +### `/(_:_:)` + +```swift +public func /(lhs: CGSize, rhs: CGFloat) -> CGSize +``` diff --git a/Documentation/Reference/ExtensionKit/methods/dprint(__).md b/Documentation/Reference/ExtensionKit/methods/dprint(__).md new file mode 100644 index 0000000..c7e6e9a --- /dev/null +++ b/Documentation/Reference/ExtensionKit/methods/dprint(__).md @@ -0,0 +1,17 @@ +### `dprint(_:)` + +```swift +public func dprint(_ item: @autoclosure () -> Any) +``` + +Swift still calls `print()` and/or `debugPrint()` in shipped apps. +We use a method described in onevcat's post (https://onevcat.com/2016/02/swift-performance/) +to optimaze the performance. + +- Parameter item: items to print + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| item | items to print | \ No newline at end of file diff --git a/Documentation/Reference/ExtensionKit/methods/sleep(duration_).md b/Documentation/Reference/ExtensionKit/methods/sleep(duration_).md new file mode 100644 index 0000000..1ab1efc --- /dev/null +++ b/Documentation/Reference/ExtensionKit/methods/sleep(duration_).md @@ -0,0 +1,14 @@ +### `sleep(duration:)` + +```swift +public func sleep(duration: TimeInterval) +``` + +Sleeps the thread +- Parameter duration: in seconds + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| duration | in seconds | \ No newline at end of file diff --git a/Package.swift b/Package.swift index ae65e4e..7675484 100644 --- a/Package.swift +++ b/Package.swift @@ -5,19 +5,13 @@ import PackageDescription let package = Package( name: "ExtensionKit", + platforms: [.iOS(.v13)], products: [ - // Products define the executables and libraries a package produces, and make them visible to other packages. .library( name: "ExtensionKit", targets: ["ExtensionKit"]), ], - dependencies: [ - // Dependencies declare other packages that this package depends on. - // .package(url: /* package url */, from: "1.0.0"), - ], targets: [ - // Targets are the basic building blocks of a package. A target can define a module or a test suite. - // Targets can depend on other targets in this package, and on products in packages this package depends on. .target( name: "ExtensionKit", dependencies: []), diff --git a/README.md b/README.md index f390ec0..60dccf9 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,36 @@ Petrify 2021-04-24 at 10 48 09 AM #### A collection of UIKit and SwiftUI extensions to speed up app development + +# Reference Documentation + +## Extensions + +- [Array](Documentation/Reference/ExtensionKit/extensions/Array.md) +- [CFRunLoopTimer](Documentation/Reference/ExtensionKit/extensions/CFRunLoopTimer.md) +- [CGPoint](Documentation/Reference/ExtensionKit/extensions/CGPoint.md) +- [CGRect](Documentation/Reference/ExtensionKit/extensions/CGRect.md) +- [Data](Documentation/Reference/ExtensionKit/extensions/Data.md) +- [Date](Documentation/Reference/ExtensionKit/extensions/Date.md) +- [FileManager](Documentation/Reference/ExtensionKit/extensions/FileManager.md) +- [Int](Documentation/Reference/ExtensionKit/extensions/Int.md) +- [NSObject](Documentation/Reference/ExtensionKit/extensions/NSObject.md) +- [String](Documentation/Reference/ExtensionKit/extensions/String.md) +- [Timer](Documentation/Reference/ExtensionKit/extensions/Timer.md) +- [UIApplication](Documentation/Reference/ExtensionKit/extensions/UIApplication.md) +- [UIButton](Documentation/Reference/ExtensionKit/extensions/UIButton.md) +- [UIColor](Documentation/Reference/ExtensionKit/extensions/UIColor.md) +- [UIImage](Documentation/Reference/ExtensionKit/extensions/UIImage.md) +- [UITableView](Documentation/Reference/ExtensionKit/extensions/UITableView.md) +- [UIView](Documentation/Reference/ExtensionKit/extensions/UIView.md) +- [UIViewController](Documentation/Reference/ExtensionKit/extensions/UIViewController.md) +- [View](Documentation/Reference/ExtensionKit/extensions/View.md) + +## Methods + +- [+](Documentation/Reference/ExtensionKit/methods/+(____).md) +- [-](Documentation/Reference/ExtensionKit/methods/-(____).md) +- [/](Documentation/Reference/ExtensionKit/methods/_(____).md) +- [/](Documentation/Reference/ExtensionKit/methods/_(____).md) +- [dprint(__)](Documentation/Reference/ExtensionKit/methods/dprint(__).md) +- [sleep(duration_)](Documentation/Reference/ExtensionKit/methods/sleep(duration_).md) diff --git a/Sources/ExtensionKit/Foundation/String.swift b/Sources/ExtensionKit/Foundation/String.swift index 13095af..fa2e8a1 100644 --- a/Sources/ExtensionKit/Foundation/String.swift +++ b/Sources/ExtensionKit/Foundation/String.swift @@ -1,5 +1,9 @@ +#if canImport(UIKit) + import UIKit +#endif + public extension String { /// Is valid email diff --git a/Sources/ExtensionKit/UIKit/UIApplication.swift b/Sources/ExtensionKit/UIKit/UIApplication.swift index c7feabb..c086494 100644 --- a/Sources/ExtensionKit/UIKit/UIApplication.swift +++ b/Sources/ExtensionKit/UIKit/UIApplication.swift @@ -1,5 +1,9 @@ +#if canImport(UIKit) + import UIKit +#endif + public extension UIApplication { /// Open application settings diff --git a/Sources/ExtensionKit/UIKit/UIButton.swift b/Sources/ExtensionKit/UIKit/UIButton.swift index 679459f..f689638 100644 --- a/Sources/ExtensionKit/UIKit/UIButton.swift +++ b/Sources/ExtensionKit/UIKit/UIButton.swift @@ -1,5 +1,9 @@ +#if canImport(UIKit) + import UIKit +#endif + public extension UIButton { @IBInspectable var normalStateBackgroundColor: UIColor? { diff --git a/Sources/ExtensionKit/UIKit/UIColor.swift b/Sources/ExtensionKit/UIKit/UIColor.swift index 8366244..ead8f61 100644 --- a/Sources/ExtensionKit/UIKit/UIColor.swift +++ b/Sources/ExtensionKit/UIKit/UIColor.swift @@ -1,5 +1,9 @@ +#if canImport(UIKit) + import UIKit +#endif + public extension UIColor { /// New color from RGB value diff --git a/Sources/ExtensionKit/UIKit/UIImage.swift b/Sources/ExtensionKit/UIKit/UIImage.swift index f3f1838..76d2a64 100644 --- a/Sources/ExtensionKit/UIKit/UIImage.swift +++ b/Sources/ExtensionKit/UIKit/UIImage.swift @@ -1,5 +1,9 @@ +#if canImport(UIKit) + import UIKit +#endif + public extension UIImage { /// Create QR code from string diff --git a/Sources/ExtensionKit/UIKit/UITableView.swift b/Sources/ExtensionKit/UIKit/UITableView.swift index 7fe49d2..e2d4af8 100644 --- a/Sources/ExtensionKit/UIKit/UITableView.swift +++ b/Sources/ExtensionKit/UIKit/UITableView.swift @@ -1,5 +1,9 @@ +#if canImport(UIKit) + import UIKit +#endif + public extension UITableView { /// Zero rows in all sections diff --git a/Sources/ExtensionKit/UIKit/UIView.swift b/Sources/ExtensionKit/UIKit/UIView.swift index 1a3640e..3ee7deb 100644 --- a/Sources/ExtensionKit/UIKit/UIView.swift +++ b/Sources/ExtensionKit/UIKit/UIView.swift @@ -1,4 +1,8 @@ +#if canImport(UIKit) + import UIKit + +#endif import AudioToolbox // These methods are for fixing a bug that `layer.content` exceeds its border programmically set by those `layer.borderxxx`. diff --git a/Sources/ExtensionKit/UIKit/UIViewController.swift b/Sources/ExtensionKit/UIKit/UIViewController.swift index 3364c77..a67d72c 100644 --- a/Sources/ExtensionKit/UIKit/UIViewController.swift +++ b/Sources/ExtensionKit/UIKit/UIViewController.swift @@ -1,6 +1,10 @@ +#if canImport(UIKit) + import UIKit import SafariServices +#endif + public extension UIViewController { /// Combine an array of models and an array of views.