This commit is contained in:
Vlad 2020-08-19 23:35:02 +03:00
parent b6ef182d56
commit 2808d015bf
11 changed files with 25 additions and 119 deletions

View File

@ -9,11 +9,11 @@ let package = Package(
products: [
.library(name: "TITransitions", targets: ["TITransitions"]),
.library(name: "TIUIKitCore", targets: ["TIUIKitCore"]),
.library(name: "TIActivityIndicators", targets: ["TIActivityIndicators"])
.library(name: "TIUIElements", targets: ["TIUIElements"])
],
targets: [
.target(name: "TITransitions", path: "TITransitions/Sources"),
.target(name: "TIUIKitCore", path: "TIUIKitCore/Sources"),
.target(name: "TIActivityIndicators", dependencies: ["TIUIKitCore"], path: "TIActivityIndicators/Sources")
.target(name: "TIUIElements", dependencies: ["TIUIKitCore"], path: "TIUIElements/Sources")
]
)

View File

@ -1,44 +0,0 @@
# TIActivityIndicators
Bunch of protocols and views of Activity Indicators.
# Protocols
## ActivityIndicator
Protocol that describes basic activity indicator which conforms to Animatable.
```swift
public protocol ActivityIndicator {
/// Type of view. Should be instance of UIView with basic animation actions.
associatedtype View: UIView, Animatable
/// The underlying view.
var view: View { get }
}
```
## ActivityIndicatorHolder
Protocol that describes placeholder view, containing activity indicator.
```swift
public protocol ActivityIndicatorHolder: class {
var activityIndicator: Animatable { get }
var indicatorOwner: UIView { get }
}
```
# Views
## AnyActivityIndicator
Type that performs some kind of type erasure for ActivityIndicator.
# Usage examples
- Loading Indicator in [PaginationWrapperUIDelegate](https://github.com/TouchInstinct/LeadKit/blob/master/Sources/Extensions/DataLoading/PaginationDataLoading/PaginationWrapperUIDelegate+DefaultImplementation.swift) of main framework LeadKit.
# Installation via SPM
You can install this framework as a target of LeadKit.

View File

@ -1,60 +0,0 @@
//
// Copyright (c) 2020 Touch Instinct
//
// 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
import TIUIKitCore
/// Type that performs some kind of type erasure for ActivityIndicator.
public struct AnyActivityIndicator: Animatable {
private let backgroundView: UIView
private let animatableView: Animatable
/// Initializer with indicator that should be wrapped.
///
/// - Parameter _: indicator for wrapping.
public init<Indicator>(_ base: Indicator) where Indicator: ActivityIndicator {
animatableView = base.view
backgroundView = base.view
}
/// Initializer with placeholder view, that wraps indicator.
///
/// - Parameter loadingIndicatorHolder: placeholder view, containing indicator.
public init(activityIndicatorHolder: ActivityIndicatorHolder) {
animatableView = activityIndicatorHolder.activityIndicator
backgroundView = activityIndicatorHolder.indicatorOwner
}
/// The background view.
var view: UIView {
return backgroundView
}
public func startAnimating() {
animatableView.startAnimating()
}
public func stopAnimating() {
animatableView.stopAnimating()
}
}

7
TIUIElements/README.md Normal file
View File

@ -0,0 +1,7 @@
# TIUIElements
Bunch of useful protocols and views.
# Installation via SPM
You can install this framework as a target of LeadKit.

View File

@ -21,9 +21,10 @@
//
import UIKit
import TIUIKitCore
extension UIActivityIndicatorView: ActivityIndicator {
public var view: UIActivityIndicatorView {
extension UIActivityIndicatorView: ActivityIndicatorHolder {
public var activityIndicator: Animatable {
self
}
}

View File

@ -1,6 +1,17 @@
# TIUIKitCore
Core UI elements from LeadKit.
Core UI elements: protocols, views and helpers.
# Protocols
- [InitializableView](InitializableView/InitializableView.swift) - protocol with methods that should be called in constructor methods of view.
- [Animatable](Animatable/Animatable.swift)- protocol that ensures that specific type support basic animation actions.
- [ActivityIndicator](ActivityIndicator/ActivityIndicator.swift) - basic activity indicator.
- [ActivityIndicatorHolder](ActivityIndicator/ActivityIndicatorHolder.swift) - placeholder view, containing activity indicator.
# Views
- [BaseInitializableView](BaseInitializableView/BaseInitializableView.swift) - UIView conformance to InitializableView.
# Installation via SPM

View File

@ -21,14 +21,6 @@
//
import UIKit
import TIUIKitCore
/// Protocol that describes basic activity indicator.
public protocol ActivityIndicator {
/// Type of view. Should be instance of UIView with basic animation actions.
associatedtype View: UIView, Animatable
/// The underlying view.
var view: View { get }
}
public typealias ActivityIndicator = UIView & Animatable

View File

@ -21,7 +21,6 @@
//
import UIKit
import TIUIKitCore
/// Protocol that describes placeholder view, containing activity indicator.
public protocol ActivityIndicatorHolder: class {