This repository has been archived by the owner on Mar 5, 2021. It is now read-only.
forked from signalapp/Signal-Pods
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start implementing device linking UI
- Loading branch information
1 parent
9784419
commit 1e949da
Showing
59 changed files
with
13,860 additions
and
9,049 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 Vinh Nguyen | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,240 @@ | ||
NVActivityIndicatorView | ||
======================= | ||
|
||
[![Build Status](https://travis-ci.org/ninjaprox/NVActivityIndicatorView.svg?branch=master)](https://travis-ci.org/ninjaprox/NVActivityIndicatorView) | ||
[![Cocoapods Compatible](https://img.shields.io/cocoapods/v/NVActivityIndicatorView.svg)](https://img.shields.io/cocoapods/v/NVActivityIndicatorView.svg) | ||
[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) | ||
[![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com) | ||
|
||
## Introduction | ||
`NVActivityIndicatorView` is a collection of awesome loading animations. | ||
|
||
This is original a fork from [DGActivityIndicatorView](https://github.com/gontovnik/DGActivityIndicatorView), inspired by [Loaders.css](https://github.com/ConnorAtherton/loaders.css), written in Swift with full implementation of animations, plus more. | ||
|
||
You can also find Objective-C version of this [here](https://github.com/ninjaprox/DGActivityIndicatorView). | ||
|
||
## Demo | ||
![alt tag](https://raw.githubusercontent.com/ninjaprox/NVActivityIndicatorView/master/Demo.gif) | ||
|
||
For first-hand experience, just open the project and run it. | ||
|
||
## Animation types | ||
|
||
| Type | Type | Type | Type | | ||
|---|---|---|---| | ||
|1. ballPulse | 2. ballGridPulse | 3. ballClipRotate | 4. squareSpin| | ||
|5. ballClipRotatePulse | 6. ballClipRotateMultiple | 7. ballPulseRise | 8. ballRotate| | ||
|9. cubeTransition | 10. ballZigZag | 11. ballZigZagDeflect | 12. ballTrianglePath| | ||
|13. ballScale | 14. lineScale | 15. lineScaleParty | 16. ballScaleMultiple| | ||
|17. ballPulseSync | 18. ballBeat | 19. lineScalePulseOut | 20. lineScalePulseOutRapid| | ||
|21. ballScaleRipple | 22. ballScaleRippleMultiple | 23. ballSpinFadeLoader | 24. lineSpinFadeLoader| | ||
|25. triangleSkewSpin | 26. pacman | 27. ballGridBeat | 28. semiCircleSpin| | ||
|29. ballRotateChase | 30. orbit | 31. audioEqualizer | 32. circleStrokeSpin| | ||
|
||
## Installation | ||
|
||
### Cocoapods | ||
|
||
Install [Cocoapods](https://cocoapods.org/#install) if need be. | ||
|
||
```bash | ||
$ gem install cocoapods | ||
``` | ||
|
||
Add `NVActivityIndicatorView` in your `Podfile`. | ||
|
||
```ruby | ||
use_frameworks! | ||
|
||
pod 'NVActivityIndicatorView' | ||
``` | ||
|
||
If you're using `NVActivityIndicatorView` in an app extension, use `NVActivityIndicatorView/AppExtension` instead. | ||
|
||
```ruby | ||
use_frameworks! | ||
|
||
pod 'NVActivityIndicatorView/AppExtension' | ||
``` | ||
|
||
Then, run the following command. | ||
|
||
```bash | ||
$ pod install | ||
``` | ||
|
||
_**Note:** Please refer to the migration note for version [`3.7.0`](#version-370) below._ | ||
|
||
### Carthage | ||
|
||
Install [Carthage](https://github.com/Carthage/Carthage#installing-carthage) if need be. | ||
|
||
```bash | ||
$ brew update | ||
$ brew install carthage | ||
``` | ||
|
||
Add `NVActivityIndicatorView` in your `Cartfile`. | ||
|
||
```ruby | ||
github "ninjaprox/NVActivityIndicatorView" | ||
``` | ||
|
||
Run `carthage` to build the framework and drag the built `NVActivityIndicatorView.framework` in the folder appropriateto the platform, e.g. iOS, tvOS, into your Xcode project. | ||
|
||
_**Note:** You might encounter compile issue, if so please use `carthage` branch instead. Check issue [#101](https://github.com/ninjaprox/NVActivityIndicatorView/issues/101) for more information._ | ||
|
||
### Manual | ||
|
||
Copy `NVActivityIndicatorView` folder to your project. That's it. | ||
|
||
_**Note:** Make sure that all files in `NVActivityIndicatorView` included in Compile Sources in Build Phases._ | ||
|
||
_**Note:** If you encounter issues while uploading the app to iTunes Connect, remove the `Info.plist` file in `NVActivityIndicatorView`. Check issue [#129](https://github.com/ninjaprox/NVActivityIndicatorView/issues/129) for more information._ | ||
|
||
## Migration | ||
|
||
### Version 4.4.0 | ||
|
||
This version requires Xcode 10.1 and Swift 4.2. | ||
|
||
### Version 4.0.0 | ||
|
||
This version requires Xcode 9.0 and Swift 4. | ||
|
||
### Version 3.7.0 | ||
|
||
This version splits `NVActivityIndicatorView` pod to 2 subpods `NVActivityIndicatorView/Presenter` and `NVActivityIndicatorView/AppExtension`. There is no need to change `pod NVActivityIndicatorView` to `pod NVActivityIndicatorView/Presenter` since it will be installed by default if you use the main pod name. | ||
|
||
However, if you want to use `NVActivityIndicatorView` in an app extension, use `pod NVActivityIndicatorView/AppExtension` instead. | ||
|
||
_**Note:** Related issue [#119](https://github.com/ninjaprox/NVActivityIndicatorView/issues/119)._ | ||
|
||
## Usage | ||
|
||
Firstly, import `NVActivityIndicatorView`. | ||
|
||
```swift | ||
import NVActivityIndicatorView | ||
``` | ||
|
||
### Initialization | ||
|
||
Then, there are two ways you can create `NVActivityIndicatorView`: | ||
|
||
- By storyboard, changing class of any `UIView` to `NVActivityIndicatorView`. | ||
|
||
_**Note:** Set Module to `NVActivityIndicatorView`._ | ||
|
||
- By code, using initializer. All parameters other than `frame` are optional and `NVActivityIndicatorView.DEFAULT_*` are used as default values. | ||
|
||
```swift | ||
NVActivityIndicatorView(frame: frame, type: type, color: color, padding: padding) | ||
``` | ||
|
||
### Control | ||
|
||
Start animating. | ||
|
||
```swift | ||
activityIndicatorView.startAnimating() | ||
``` | ||
|
||
Stop animating. | ||
|
||
```swift | ||
activityIndicatorView.stopAnimating() | ||
``` | ||
|
||
Determine if it is animating. | ||
|
||
```swift | ||
animating = activityIndicatorView.isAnimating | ||
``` | ||
|
||
### Change properties | ||
|
||
In storyboard, you can change all properties in Attributes inspector tab of Utilities panel. | ||
|
||
_**Note:** Use one of values (case-insensitive) in [Animation types](#animation-types) for `Type Name`._ | ||
|
||
All properties are public so you can change them after initializing. | ||
|
||
_**Note:** All changes must be made before calling `startAnimating()`._ | ||
|
||
### UI blocker | ||
|
||
By conforming `NVActivityIndicatorViewable` protocol, you can use `NVActivityIndicatorView` as UI blocker for `UIViewController`. | ||
|
||
```swift | ||
class ViewController: UIViewController, NVActivityIndicatorViewable { } | ||
``` | ||
|
||
Start animating. | ||
|
||
```swift | ||
startAnimating(size, message) // plus other parameters as in initializer. | ||
``` | ||
|
||
Stop animating. | ||
|
||
```swift | ||
stopAnimating() | ||
``` | ||
|
||
Check if it is animating. | ||
|
||
```swift | ||
animating = isAnimating | ||
``` | ||
|
||
Or you can use `NVActivityIndicatorPresenter` to display UI blocker anywhere. | ||
|
||
Start animating. | ||
|
||
```swift | ||
let activityData = ActivityData() | ||
|
||
NVActivityIndicatorPresenter.sharedInstance.startAnimating(activityData) | ||
``` | ||
|
||
_**Note:** Check [documentation](https://nvactivityindicatorview.vinhis.me) for detail of `ActivityData`._ | ||
|
||
Stop animating. | ||
|
||
```swift | ||
NVActivityIndicatorPresenter.sharedInstance.stopAnimating() | ||
``` | ||
|
||
Change message. | ||
|
||
```swift | ||
NVActivityIndicatorPresenter.sharedInstance.setMessage("Done") | ||
``` | ||
|
||
Check if it is animating. | ||
|
||
```swift | ||
animating = NVActivityIndicatorPresenter.sharedInstance.isAnimating | ||
``` | ||
|
||
#### Fade in/out animation | ||
|
||
You have control over showing and hiding UI blocker animation. | ||
|
||
```swift | ||
startAnimating(fadeInAnimation: fadeInAnimation) | ||
stopAnimating(fadeOutAnimation) | ||
``` | ||
|
||
Check `DEFAULT_FADE_IN_ANIMATION` and `DEFAULT_FADE_OUT_ANIMATION` for examples of how to implement animation. | ||
|
||
## Acknowledgment | ||
|
||
Thanks [Connor Atherton](https://github.com/ConnorAtherton) for great loaders and [Danil Gontovnik](https://github.com/gontovnik) for kick-start. | ||
|
||
## License | ||
|
||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 Vinh Nguyen [@ninjaprox](http://twitter.com/ninjaprox) |
70 changes: 70 additions & 0 deletions
70
...ource/NVActivityIndicatorView/Animations/NVActivityIndicatorAnimationAudioEqualizer.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// | ||
// NVActivityIndicatorAnimationAudioEqualizer.swift | ||
// NVActivityIndicatorView | ||
// | ||
// The MIT License (MIT) | ||
|
||
// Copyright (c) 2016 Vinh Nguyen | ||
|
||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
|
||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
|
||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
// | ||
|
||
import UIKit | ||
|
||
class NVActivityIndicatorAnimationAudioEqualizer: NVActivityIndicatorAnimationDelegate { | ||
|
||
func setUpAnimation(in layer: CALayer, size: CGSize, color: UIColor) { | ||
let lineSize = size.width / 9 | ||
let x = (layer.bounds.size.width - lineSize * 7) / 2 | ||
let y = (layer.bounds.size.height - size.height) / 2 | ||
let duration: [CFTimeInterval] = [4.3, 2.5, 1.7, 3.1] | ||
let values = [0, 0.7, 0.4, 0.05, 0.95, 0.3, 0.9, 0.4, 0.15, 0.18, 0.75, 0.01] | ||
|
||
// Draw lines | ||
for i in 0 ..< 4 { | ||
let animation = CAKeyframeAnimation() | ||
|
||
animation.keyPath = "path" | ||
animation.isAdditive = true | ||
animation.values = [] | ||
|
||
for j in 0 ..< values.count { | ||
let heightFactor = values[j] | ||
let height = size.height * CGFloat(heightFactor) | ||
let point = CGPoint(x: 0, y: size.height - height) | ||
let path = UIBezierPath(rect: CGRect(origin: point, size: CGSize(width: lineSize, height: height))) | ||
|
||
animation.values?.append(path.cgPath) | ||
} | ||
animation.duration = duration[i] | ||
animation.repeatCount = HUGE | ||
animation.isRemovedOnCompletion = false | ||
|
||
let line = NVActivityIndicatorShape.line.layerWith(size: CGSize(width: lineSize, height: size.height), color: color) | ||
let frame = CGRect(x: x + lineSize * 2 * CGFloat(i), | ||
y: y, | ||
width: lineSize, | ||
height: size.height) | ||
|
||
line.frame = frame | ||
line.add(animation, forKey: "animation") | ||
layer.addSublayer(line) | ||
} | ||
} | ||
} |
Oops, something went wrong.