Skip to content

Commit

Permalink
Merge branch 'main' into feature/projectStructure
Browse files Browse the repository at this point in the history
  • Loading branch information
wmcginty committed Jan 25, 2022
2 parents bf6452d + e375ddc commit cd6cdb2
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
scheme: "UtiliKit-iOS"
destination: "platform=iOS Simulator,OS=15.2,name=iPhone 12 Pro"
test: true

steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

##### Enhancements

* Extend CLLocationCoordinate2D with isValid computed property
[Andrew Winn](https://github.com/andrew-winn-br)
[#102](https://github.com/BottleRocketStudios/iOS-UtiliKit/pull/102)

* Improve support for registering supplementary and decoration views with UICollectionView.
[Will McGinty](https://github.com/willmcginty)
[#110](https://github.com/BottleRocketStudios/iOS-UtiliKit/pull/110)
Expand Down
63 changes: 19 additions & 44 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.0
// swift-tools-version:5.5
import PackageDescription

let package = Package(
Expand All @@ -9,51 +9,26 @@ let package = Package(
products: [
.library(
name: "UtiliKit",
targets: ["GeneralUtilities", "Instantiation", "TimelessDate", "Versioning", "ContainerViewController", "ActiveLabel", "Obfuscation"]),
.library(
name: "GeneralUtilities",
targets: ["GeneralUtilities"]),
.library(
name: "Instantiation",
targets: ["Instantiation"]),
.library(
name: "TimelessDate",
targets: ["TimelessDate"]),
.library(
name: "Versioning",
targets: ["Versioning"]),
.library(
name: "ContainerViewController",
targets: ["ContainerViewController"]),
.library(
name: "ActiveLabel",
targets: ["ActiveLabel"]),
.library(
name: "Obfuscation",
targets: ["Obfuscation"]),
targets: ["GeneralUtilities", "Instantiation", "TimelessDate", "Versioning",
"ContainerViewController", "ActiveLabel", "Obfuscation", "ScrollingPageControl"]),
.library(name: "GeneralUtilities", targets: ["GeneralUtilities"]),
.library(name: "Instantiation", targets: ["Instantiation"]),
.library(name: "TimelessDate", targets: ["TimelessDate"]),
.library(name: "Versioning", targets: ["Versioning"]),
.library(name: "ContainerViewController", targets: ["ContainerViewController"]),
.library(name: "ActiveLabel", targets: ["ActiveLabel"]),
.library(name: "Obfuscation", targets: ["Obfuscation"]),
.library(name: "ScrollingPageControl", targets: ["ScrollingPageControl"])
],
targets: [
.target(
name: "GeneralUtilities",
path: "Sources/UtiliKit/General"),
.target(
name: "Instantiation",
path: "Sources/UtiliKit/Instantiation"),
.target(
name: "TimelessDate",
path: "Sources/UtiliKit/TimelessDate"),
.target(
name: "Versioning",
path: "Sources/UtiliKit/Version"),
.target(
name: "ContainerViewController",
path: "Sources/UtiliKit/Container"),
.target(
name: "ActiveLabel",
path: "Sources/UtiliKit/ActiveLabel"),
.target(
name: "Obfuscation",
path: "Sources/UtiliKit/Obfuscation")
.target(name: "GeneralUtilities", path: "Sources/General"),
.target(name: "Instantiation", path: "Sources/Instantiation"),
.target(name: "TimelessDate", path: "Sources/TimelessDate"),
.target(name: "Versioning", path: "Sources/Version"),
.target(name: "ContainerViewController", path: "Sources/Container"),
.target(name: "ActiveLabel", path: "Sources/ActiveLabel"),
.target(name: "Obfuscation", path: "Sources/Obfuscation"),
.target(name: "ScrollingPageControl", dependencies: [.target(name: "GeneralUtilities")], path: "Sources/ScrollingPageControl")
]
)

12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ let label: ActiveLabel = ActiveLabel()
label.estimatedNumberOfLines = 3
label.finalLineTrailingInset = 100
```
![](docs/images/ActiveLabelEdited01.gif)
![](Documentation/Images/ActiveLabelEdited01.gif)

Custom Configuration using convenience initializer.
``` swift
Expand All @@ -252,7 +252,7 @@ configuration.loadingView.animationDuration = 2.0
configuration.loadingView.animationDelay = 0
let label: ActiveLabel = ActiveLabel(frame: CGRect(x: 0, y: 0, width: 335, height: 21), configuration: configuration)
```
![](docs/images/ActiveLabelEdited02.gif)
![](Documentation/Images/ActiveLabelEdited02.gif)

Add some color, change line height and spacing.
``` swift
Expand All @@ -263,7 +263,7 @@ label.loadingView.color = UIColor(red: 233.0/255.0, green: 231.0/255.0, blue: 23
label.loadingView.lineHeight = 16
label.loadingView.lineVerticalSpacing = 8
```
![](docs/images/ActiveLabelEdited03.gif)
![](Documentation/Images/ActiveLabelEdited03.gif)

When initializing `ActiveLabel` in Storyboards or Xibs you must set the labels text to `nil` in code because IB initializes labels with an empty string value.

Expand All @@ -283,7 +283,7 @@ pageControl.hidesForSinglePage = false // default
pageControl.pageIndicatorTintColor = .systemGray // default
pageControl.currentPageIndicatorTintColor = .systemBlue // default
```
![](docs/images/ScrollingPageControl/ScrollingPageControl-Default.png)
![](Documentation/Images/ScrollingPageControl/ScrollingPageControl-Default.png)

Customize dot layout
``` swift
Expand All @@ -293,15 +293,15 @@ pageControl.dotSize = CGSize(width: 5.0, height: 10.0) // default is 7.0 x 7.0
pageControl.dotSpacing = 14.0 // default is 9.0
pageControl.minimumDotScale = 0.25 // default is 0.4
```
![](docs/images/ScrollingPageControl/ScrollingPageControl-CustomizedLayout.png)
![](Documentation/Images/ScrollingPageControl/ScrollingPageControl-CustomizedLayout.png)

Responding to ScrollingPageControl interaction
``` swift
pageControl.didSetCurrentPage = { [weak self] (index) in
self?.scrollToPageAtIndex(index)
}
```
![](docs/images/ScrollingPageControl/ScrollingPageControl-ControlInteraction.gif)
![](Documentation/Images/ScrollingPageControl/ScrollingPageControl-ControlInteraction.gif)

Adding custom page dots
``` swift
Expand Down
32 changes: 32 additions & 0 deletions Sources/General/CLLocationCoordinate2D+Extensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// CLLocationCoordinate2D+Extensions.swift
// UtiliKit-iOS
//
// Created by Andrew Winn on 8/24/21.
// Copyright © 2021 Bottle Rocket Studios. All rights reserved.
//

import CoreLocation

public extension CLLocationCoordinate2D {

/// Checks if a coordinate is valid. Attempting to use an invalid coordinate (e.g. by setting a map region to center on it) will crash the app.
///
/// A coordinate is considered **invalid** if it meets at least one of the following criteria:
/// - Its latitude is greater than 90 degrees or less than -90 degrees.
/// - Its longitude is greater than 180 degrees or less than -180 degrees.
///
/// An invalid coordinate can be generated from:
/// - Invalid data from an API
/// - `mkMapView.userLocation.coordinate` is not an optional property and will provide an invalid coordinate when the user is not sharing their location.
/// - `locationManager.location.coordinate` is an optional property but may still provide an invalid coordinate (e.g. when the user has revoked location permissions while the app is running after previously granting)
var isValid: Bool {
if CLLocationCoordinate2DIsValid(self) {
return true
}
debugPrint("================================================")
debugPrint("Invalid CLLocationCoordinate2D Detected: \(self)")
debugPrint("================================================")
return false
}
}
4 changes: 2 additions & 2 deletions Sources/ScrollingPageControl/ScrollingPageControl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import UIKit

// MARK: -
@available(iOS, deprecated: 14.0, message: "Functionality is available with UIKit UIPageControls starting with iOS 14")
@available(iOS, deprecated: 14.0, message: "Functionality is available with UIKit `UIPageControl` starting with iOS 14")
@IBDesignable
public class ScrollingPageControl: UIView {

Expand Down Expand Up @@ -365,7 +365,7 @@ public class ScrollingPageControl: UIView {
}
}

@available(iOS, deprecated: 14.0, message: "Functionality is available with UIKit UIPageControls starting with iOS 14")
@available(iOS, deprecated: 14.0, message: "Functionality is available with UIKit `UIPageControl` starting with iOS 14")
private extension ScrollingPageControl {

/// The default class used by `ScrollingPageControl` to represent pages.
Expand Down
3 changes: 2 additions & 1 deletion Tests/ScrollingPageControlTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import UIKit
import SnapshotTesting
@testable import UtiliKit

@available(iOS, deprecated: 14.0, message: "Functionality is available with UIKit `UIPageControl` starting with iOS 14")
class ScrollingPageControlTests: XCTestCase {

func testDefaultsWithNoPages() {
Expand Down Expand Up @@ -156,7 +157,7 @@ class ScrollingPageControlTests: XCTestCase {
pageControl.currentPage = 5
assertSnapshot(matching: snapshotVC, as: .image(on: .iPhoneX))
}

private func setupForSnapshot(pageControl: ScrollingPageControl) -> UIViewController {
return setupForSnapshot(pageControls: [pageControl])
}
Expand Down
42 changes: 42 additions & 0 deletions Tests/UtiliKitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import XCTest
import CoreLocation
@testable import UtiliKit

class OpenSourceUtilitiesTests: XCTestCase {
Expand Down Expand Up @@ -77,4 +78,45 @@ class OpenSourceUtilitiesTests: XCTestCase {

XCTAssertEqual(superview.bounds.inset(by: insets), view.frame)
}

//MARK: - CLLocationCoordinate2D Tests
func test_CLLocationCoordinate2D_Valid() {
let coordinates = [CLLocationCoordinate2D(latitude: CLLocationDegrees(0),
longitude: CLLocationDegrees(0)),
CLLocationCoordinate2D(latitude: CLLocationDegrees(-0),
longitude: CLLocationDegrees(-0)),
CLLocationCoordinate2D(latitude: CLLocationDegrees(90),
longitude: CLLocationDegrees(180)),
CLLocationCoordinate2D(latitude: CLLocationDegrees(-90),
longitude: CLLocationDegrees(180)),
CLLocationCoordinate2D(latitude: CLLocationDegrees(90),
longitude: CLLocationDegrees(-180)),
CLLocationCoordinate2D(latitude: CLLocationDegrees(-90),
longitude: CLLocationDegrees(-180))
]

XCTAssertTrue(coordinates.allSatisfy { $0.isValid }, "All test coordinates should be valid")
}

func test_CLLocationCoordinate2d_Invalid() {
let coordinates = [CLLocationCoordinate2D(latitude: CLLocationDegrees(95),
longitude: CLLocationDegrees(0)),
CLLocationCoordinate2D(latitude: CLLocationDegrees(-95),
longitude: CLLocationDegrees(0)),
CLLocationCoordinate2D(latitude: CLLocationDegrees(0),
longitude: CLLocationDegrees(185)),
CLLocationCoordinate2D(latitude: CLLocationDegrees(0),
longitude: CLLocationDegrees(-185)),
CLLocationCoordinate2D(latitude: CLLocationDegrees(95),
longitude: CLLocationDegrees(185)),
CLLocationCoordinate2D(latitude: CLLocationDegrees(-95),
longitude: CLLocationDegrees(185)),
CLLocationCoordinate2D(latitude: CLLocationDegrees(95),
longitude: CLLocationDegrees(-185)),
CLLocationCoordinate2D(latitude: CLLocationDegrees(-95),
longitude: CLLocationDegrees(-185))
]

XCTAssertTrue(coordinates.allSatisfy { !$0.isValid }, "All test coordinates should be invalid")
}
}
23 changes: 14 additions & 9 deletions UtiliKit.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ s.homepage = 'https://github.com/BottleRocketStudios/iOS-UtiliKit'
s.license = { :type => 'Apache 2.0', :file => 'LICENSE' }
s.author = { 'Bottle Rocket Studios' => '[email protected]' }
s.source = { :git => 'https://github.com/bottlerocketstudios/iOS-UtiliKit.git', :tag => s.version.to_s }
s.source_files = 'Sources/UtiliKit/**/*'
s.source_files = 'Sources/**/*'
s.ios.deployment_target = '10.0'
s.swift_version = '5.0'
s.swift_version = '5.5'

s.default_subspec = 'Core'

Expand All @@ -31,31 +31,36 @@ core.dependency 'UtiliKit/General'
end

s.subspec 'Instantiation' do |instantiation|
instantiation.source_files = 'Sources/UtiliKit/Instantiation/*.swift'
instantiation.source_files = 'Sources/Instantiation/*.swift'
end

s.subspec 'TimelessDate' do |timeless|
timeless.source_files = 'Sources/UtiliKit/TimelessDate/*.swift'
timeless.source_files = 'Sources/TimelessDate/*.swift'
end

s.subspec 'General' do |general|
general.source_files = 'Sources/UtiliKit/General/*.swift'
general.source_files = 'Sources/General/*.swift'
end

s.subspec 'Version' do |version|
version.source_files = 'Sources/UtiliKit/Version/*.swift'
version.source_files = 'Sources/Version/*.swift'
end

s.subspec 'Container' do |container|
container.source_files = 'Sources/UtiliKit/Container/**/*.swift'
container.source_files = 'Sources/Container/**/*.swift'
end

s.subspec 'ActiveLabel' do |activeLabel|
activeLabel.source_files = 'Sources/UtiliKit/ActiveLabel/*.swift'
activeLabel.source_files = 'Sources/ActiveLabel/*.swift'
end

s.subspec 'Obfuscation' do |obfuscation|
obfuscation.source_files = 'Sources/UtiliKit/Obfuscation/*.swift'
obfuscation.source_files = 'Sources/Obfuscation/*.swift'
end

s.subspec 'ScrollingPageControl' do |pagecontrol|
pagecontrol.dependency 'UtiliKit/General'
pagecontrol.source_files = 'Sources/ScrollingPageControl/*.swift'
end

end
6 changes: 5 additions & 1 deletion UtiliKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
0E666BDE27A074E7001082D0 /* CLLocationCoordinate2D+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E666BDD27A074E7001082D0 /* CLLocationCoordinate2D+Extensions.swift */; };
0EC7EFEC2792317600F712F3 /* UtiliKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0EC7EFE32792317600F712F3 /* UtiliKit.framework */; };
0EC7F054279231A400F712F3 /* UtiliKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 0EC7EFFC279231A300F712F3 /* UtiliKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
0EC7F055279231A400F712F3 /* ReuseIdentifiable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EC7EFFE279231A300F712F3 /* ReuseIdentifiable.swift */; };
Expand Down Expand Up @@ -65,6 +66,7 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
0E666BDD27A074E7001082D0 /* CLLocationCoordinate2D+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "CLLocationCoordinate2D+Extensions.swift"; sourceTree = "<group>"; };
0EC7EFE32792317600F712F3 /* UtiliKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = UtiliKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
0EC7EFEB2792317600F712F3 /* UtiliKit iOS Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "UtiliKit iOS Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
0EC7EFFC279231A300F712F3 /* UtiliKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UtiliKit.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -199,6 +201,7 @@
children = (
0EC7F007279231A300F712F3 /* UIView+Extensions.swift */,
0EC7F008279231A300F712F3 /* FileManager+Extensions.swift */,
0E666BDD27A074E7001082D0 /* CLLocationCoordinate2D+Extensions.swift */,
0EC7F009279231A300F712F3 /* URL+Extensions.swift */,
);
path = General;
Expand Down Expand Up @@ -332,9 +335,9 @@
0EC7F09B279231AB00F712F3 /* Deployment */ = {
isa = PBXGroup;
children = (
0EC7F09D279231BB00F712F3 /* LICENSE */,
0EC7F09E279231BB00F712F3 /* Package.swift */,
0EC7F09C279231BB00F712F3 /* UtiliKit.podspec */,
0EC7F09D279231BB00F712F3 /* LICENSE */,
);
name = Deployment;
sourceTree = "<group>";
Expand Down Expand Up @@ -473,6 +476,7 @@
0EC7F06A279231A400F712F3 /* VersionConfig.swift in Sources */,
0EC7F068279231A400F712F3 /* ContainerViewController.swift in Sources */,
0EC7F066279231A400F712F3 /* DefaultContainerTransitionAnimator.swift in Sources */,
0E666BDE27A074E7001082D0 /* CLLocationCoordinate2D+Extensions.swift in Sources */,
0EC7F05F279231A400F712F3 /* URL+Extensions.swift in Sources */,
0EC7F05B279231A400F712F3 /* UICollectionView+Extensions.swift in Sources */,
0EC7F05C279231A400F712F3 /* NibLoadable.swift in Sources */,
Expand Down

0 comments on commit cd6cdb2

Please sign in to comment.