Skip to content

Commit

Permalink
Merge pull request #55 from JobsIsMyHomeboy/feature/ActiveLabel
Browse files Browse the repository at this point in the history
Feature/active label
  • Loading branch information
br-tyler-milner committed Jul 8, 2019
2 parents d536e3f + fe9cc31 commit 4011dc7
Show file tree
Hide file tree
Showing 31 changed files with 972 additions and 10 deletions.
10 changes: 9 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,24 @@ env:
- WORKSPACE=UtiliKit.xcworkspace
- IOS_FRAMEWORK_SCHEME=UtiliKit-iOS
matrix:
- DESTINATION="platform=iOS Simulator,OS=11.2,name=iPhone X" SCHEME="$IOS_FRAMEWORK_SCHEME" RUN_TESTS="YES" POD_LINT="YES" RUN_DANGER="YES"
- DESTINATION="platform=iOS Simulator,OS=12.2,name=iPhone X" SCHEME="$IOS_FRAMEWORK_SCHEME" RUN_TESTS="YES" POD_LINT="YES" RUN_DANGER="YES"
#- DESTINATION="platform=tvOS Simulator,OS=11.2,name=Apple TV 4K" SCHEME="$TVOS_FRAMEWORK_SCHEME" RUN_TESTS="YES" POD_LINT="NO" RUN_DANGER="NO"
#- DESTINATION="platform=watchOS Simulator,OS=4.2,name=Apple Watch Series 3 - 42mm" SCHEME="$WATCHOS_FRAMEWORK_SCHEME" RUN_TESTS="NO" POD_LINT="NO" RUN_DANGER="NO"
cache:
directories:
- Carthage
- ~/.danger-swift
addons:
homebrew:
update: true
taps:
- danger/tap
packages:
- carthage
- danger-swift
before_install:
- carthage bootstrap --verbose --no-use-binaries --platform iOS,tvOS,watchOS --cache-builds

script:
#- swiftlint
- set -o pipefail
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

##### Enhancements

* Add `ActiveLabel` class to help show activity on a label.
[Brian Miller](https://github.com/JobsIsMyHomeboy)
[#55](https://github.com/BottleRocketStudios/iOS-UtiliKit/pull/55)

* Add support for `Configurable` types when dequeuing reusable views.
[Will McGinty](https://github.com/willmcginty)
[#53](https://github.com/BottleRocketStudios/iOS-UtiliKit/pull/58)
Expand Down
1 change: 1 addition & 0 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github "pointfreeco/swift-snapshot-testing" ~> 1.5
1 change: 1 addition & 0 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github "pointfreeco/swift-snapshot-testing" "1.5.0"
215 changes: 206 additions & 9 deletions Examples/UtiliKit-iOSExample/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// ActiveLabelViewController.swift
// UtiliKit-iOS
//
// Copyright © 2019 CocoaPods. All rights reserved.
//

import UIKit

class ActiveLabelViewController: UIViewController {
@IBOutlet private var activeLabels: [ActiveLabel]!

override func viewDidLoad() {
super.viewDidLoad()

activeLabels.forEach { $0.text = nil }
}
}
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,50 @@ func containerViewController(_ container: ContainerViewController, animationCont

return nil
}
```

#### ActiveLabel
`ActiveLabel` is a `UILabel` subclass that adds horizontal activity indicators to your label while its `text` property is set to `nil`. You can customize this view quite a bit in code or in Interface Builder to fit your specific needs. The purpose of this subclass is to have a visual indication at the label level while you are loading data into labels.

Default Configuration
``` swift
let label: ActiveLabel = ActiveLabel()
```
![](docs/images/ActiveLabelDefault.gif)

Custom Configuration
``` swift
let label: ActiveLabel = ActiveLabel()
label.estimatedNumberOfLines = 3
label.finalLineTrailingInset = 100
```
![](docs/images/ActiveLabelEdited01.gif)

Custom Configuration using convenience initializer.
``` swift
var configuration = ActiveLabelConfiguration.default
configuration.estimatedNumberOfLines = 3
configuration.finalLineLength = 100
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)

Add some color, change line height and spacing.
``` swift
let label: ActiveLabel = ActiveLabel()
label.estimatedNumberOfLines = 3
label.finalLineTrailingInset = 100
label.loadingView.color = UIColor(red: 233.0/255.0, green: 231.0/255.0, blue: 237.0/255.0, alpha: 1.0))
label.loadingView.lineHeight = 16
label.loadingView.lineVerticalSpacing = 8
```
![](docs/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.

When using `ActiveLabel` for snapshot tests you can center the gradient by calling `configureForSnapshotTest()` on your label.

### Example

Expand Down
Loading

0 comments on commit 4011dc7

Please sign in to comment.