From e11776716045ac3250259266357eb622a8b593e5 Mon Sep 17 00:00:00 2001 From: Gary Tokman Date: Sat, 24 Apr 2021 15:32:12 -0400 Subject: [PATCH] chore: update docs --- .../Reference/ExtensionKit/README.md | 3 +- .../ExtensionKit/extensions/CGRect.md | 12 -- .../ExtensionKit/extensions/Color.md | 70 ++++++++++++ .../ExtensionKit/extensions/UIColor.md | 50 +++++++- .../ExtensionKit/extensions/UIView.md | 49 ++++++++ .../Reference/ExtensionKit/extensions/View.md | 108 +++++++++++++++++- README.md | 36 +++--- 7 files changed, 300 insertions(+), 28 deletions(-) create mode 100644 Documentation/Reference/ExtensionKit/extensions/Color.md diff --git a/Documentation/Reference/ExtensionKit/README.md b/Documentation/Reference/ExtensionKit/README.md index 697ab49..d330435 100644 --- a/Documentation/Reference/ExtensionKit/README.md +++ b/Documentation/Reference/ExtensionKit/README.md @@ -11,6 +11,7 @@ - [CFRunLoopTimer](extensions/CFRunLoopTimer.md) - [CGPoint](extensions/CGPoint.md) - [CGRect](extensions/CGRect.md) +- [Color](extensions/Color.md) - [Data](extensions/Data.md) - [Date](extensions/Date.md) - [FileManager](extensions/FileManager.md) @@ -36,4 +37,4 @@ - [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 +This file was generated by [SourceDocs](https://github.com/eneko/SourceDocs) on 2021-04-24 19:31:50 +0000 \ No newline at end of file diff --git a/Documentation/Reference/ExtensionKit/extensions/CGRect.md b/Documentation/Reference/ExtensionKit/extensions/CGRect.md index 629c423..caced0e 100644 --- a/Documentation/Reference/ExtensionKit/extensions/CGRect.md +++ b/Documentation/Reference/ExtensionKit/extensions/CGRect.md @@ -54,18 +54,6 @@ var leftMiddle: CGPoint var rightMiddle: CGPoint ``` -### `midX` - -```swift -var midX: CGFloat -``` - -### `midY` - -```swift -var midY: CGFloat -``` - ### `center` ```swift diff --git a/Documentation/Reference/ExtensionKit/extensions/Color.md b/Documentation/Reference/ExtensionKit/extensions/Color.md new file mode 100644 index 0000000..7697c32 --- /dev/null +++ b/Documentation/Reference/ExtensionKit/extensions/Color.md @@ -0,0 +1,70 @@ +**EXTENSION** + +# `Color` +```swift +public extension Color +``` + +## Methods +### `init(hex:)` + +```swift +init(hex: String) +``` + +Initialize with HEX +- Parameter hex: HEX + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| hex | HEX | + +### `random(opacity:)` + +```swift +static func random(opacity: CGFloat = 1.0) -> Color +``` + +Generate a random color +- Parameter opacity: opacity +- Returns: New color + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| opacity | opacity | + +### `lighten(by:)` + +```swift +func lighten(by percentage: CGFloat = 30.0) -> Color +``` + +Lighten color +- Parameter percentage: percentage (1 -100), default: 30 +- Returns: new color + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| percentage | percentage (1 -100), default: 30 | + +### `darken(by:)` + +```swift +func darken(by percentage: CGFloat = 30.0) -> Color +``` + +Darken color +- Parameter percentage: percentage (1 -100), default: 30 +- Returns: new color + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| percentage | percentage (1 -100), default: 30 | \ No newline at end of file diff --git a/Documentation/Reference/ExtensionKit/extensions/UIColor.md b/Documentation/Reference/ExtensionKit/extensions/UIColor.md index 1b2a52d..7516a4c 100644 --- a/Documentation/Reference/ExtensionKit/extensions/UIColor.md +++ b/Documentation/Reference/ExtensionKit/extensions/UIColor.md @@ -59,4 +59,52 @@ Color from HEX | Name | Description | | ---- | ----------- | -| hexCode | Hex w/o `#` | \ No newline at end of file +| hexCode | Hex w/o `#` | + +### `random(alpha:)` + +```swift +static func random(alpha: CGFloat = 1.0) -> UIColor +``` + +Random color +- Parameter alpha: alpha +- Returns: new color + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| alpha | alpha | + +### `lighten(by:)` + +```swift +func lighten(by percentage: CGFloat = 30.0) -> UIColor +``` + +Darken color +- Parameter percentage: percentage +- Returns: new color + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| percentage | percentage | + +### `darken(by:)` + +```swift +func darken(by percentage: CGFloat = 30.0) -> UIColor +``` + +Darken color +- Parameter percentage: percentage +- Returns: new color + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| percentage | percentage | \ No newline at end of file diff --git a/Documentation/Reference/ExtensionKit/extensions/UIView.md b/Documentation/Reference/ExtensionKit/extensions/UIView.md index d765c76..1ea1520 100644 --- a/Documentation/Reference/ExtensionKit/extensions/UIView.md +++ b/Documentation/Reference/ExtensionKit/extensions/UIView.md @@ -124,3 +124,52 @@ func shakeToIndicateError() ``` Commit a shake animation and vibrate to indicate the occured error. + +### `dropRealShadow(shadowColor:fillColor:opacity:offset:radius:)` + +```swift +func dropRealShadow(shadowColor: UIColor = UIColor.black, fillColor: UIColor = UIColor.white, opacity: Float = 0.2, offset: CGSize = CGSize(width: 0.0, height: 1.0), radius: CGFloat = 10) -> CAShapeLayer +``` + +New drop shadow by adding new layer +- Parameters: + - shadowColor: color + - fillColor: fill default: white + - opacity: opacity default 20% + - offset: offset default y: 1 + - radius: radius (blur) default 10 +- Returns: new layer + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| shadowColor | color | +| fillColor | fill default: white | +| opacity | opacity default 20% | +| offset | offset default y: 1 | +| radius | radius (blur) default 10 | + +### `dropShadow(color:opacity:offSet:radius:scale:)` + +```swift +func dropShadow(color: UIColor, opacity: Float = 0.5, offSet: CGSize, radius: CGFloat = 1, scale: Bool = true) +``` + +Draw a simple drop shadow for the views layer +- Parameters: + - color: color + - opacity: opacity default: 50% + - offSet: offset + - radius: radius (blur) default 1 + - scale: scale default: true + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| color | color | +| opacity | opacity default: 50% | +| offSet | offset | +| radius | radius (blur) default 1 | +| scale | scale default: true | \ No newline at end of file diff --git a/Documentation/Reference/ExtensionKit/extensions/View.md b/Documentation/Reference/ExtensionKit/extensions/View.md index 4528038..e374999 100644 --- a/Documentation/Reference/ExtensionKit/extensions/View.md +++ b/Documentation/Reference/ExtensionKit/extensions/View.md @@ -20,4 +20,110 @@ Fill parent view | Name | Description | | ---- | ----------- | -| alignment | alignment | \ No newline at end of file +| alignment | alignment | + +### `if(_:transform:)` + +```swift +func `if`(_ condition: Bool, transform: (Self) -> Transform) -> some View +``` + +If a condition is true, transform and return a new view +- Parameters: + - condition: condition + - transform: transformation if true +- Returns: new view + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| condition | condition | +| transform | transformation if true | + +### `if(_:if:else:)` + +```swift +func `if`( + _ condition: Bool, + if ifTransform: (Self) -> TrueContent, + else elseTransform: (Self) -> FalseContent +) -> some View +``` + +If a condition is true, transform and return a new view +- Parameters: + - condition: condition + - ifTransform: true case transform + - elseTransform: else case transform +- Returns: new view + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| condition | condition | +| ifTransform | true case transform | +| elseTransform | else case transform | + +### `embedInNavigationView()` + +```swift +func embedInNavigationView() -> some View +``` + +Embed Self in `NavigationView` +- Returns: New view with `NavigationView` parent + +### `cornerRadius(_:corners:)` + +```swift +func cornerRadius(_ radius: CGFloat, corners: UIRectCorner) -> some View +``` + +Round view with specific corners +- Parameters: + - radius: radius + - corners: corners to round +- Returns: new rounded view + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| radius | radius | +| corners | corners to round | + +### `debug()` + +```swift +func debug() -> Self +``` + +Debug print view representation +- Returns: Self after printing + +### `eraseToAnyView()` + +```swift +func eraseToAnyView() -> AnyView +``` + +Erase view to `AnyView` +- Returns: new view + +### `hidden(_:)` + +```swift +func hidden(_ hidden: Bool) -> some View +``` + +Hides the view conditionally +- Parameter hidden: is hidden +- Returns: hidden view but not drawn on screen + +#### Parameters + +| Name | Description | +| ---- | ----------- | +| hidden | is hidden | \ No newline at end of file diff --git a/README.md b/README.md index b16f61d..3ef34fe 100644 --- a/README.md +++ b/README.md @@ -5,16 +5,29 @@ Petrify 2021-04-24 at 10 48 09 AM -#### A collection of UIKit and SwiftUI extensions to speed up app development - -# Reference Documentation +# Documentation ## Extensions +### SwiftUI + +- [View](Documentation/Reference/ExtensionKit/extensions/View.md) +- [Color](Documentation/Reference/ExtensionKit/extensions/Color.md) + +### UIKit + +- [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/UITableView.md) +- [UIView](Documentation/Reference/ExtensionKit/UIView.md) +- [UIViewController](Documentation/Reference/ExtensionKit/UIViewController.md) + +### Foundation + - [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) @@ -22,14 +35,11 @@ - [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) + +### CoreGraphics + +- [CGPoint](Documentation/Reference/ExtensionKit/extensions/CGPoint.md) +- [CGRect](Documentation/Reference/ExtensionKit/extensions/CGRect.md) ## Methods