From 2808d015bf34bd8279b89e5fbc825bd50d0fa0dc Mon Sep 17 00:00:00 2001 From: Vlad Date: Wed, 19 Aug 2020 23:35:02 +0300 Subject: [PATCH] Fix PR --- Package.swift | 4 +- TIActivityIndicators/README.md | 44 -------------- .../Sources/Views/AnyActivityIndicator.swift | 60 ------------------- TIUIElements/README.md | 7 +++ ...ndicatorView+ActivityIndicatorHolder.swift | 5 +- .../UIActivityIndicatorView+Animatable.swift | 0 TIUIKitCore/README.md | 13 +++- .../ActivityIndicator.swift | 10 +--- .../ActivityIndicatorHolder.swift | 1 - .../{ => Animatable}/Animatable.swift | 0 .../InitializableView.swift | 0 11 files changed, 25 insertions(+), 119 deletions(-) delete mode 100644 TIActivityIndicators/README.md delete mode 100644 TIActivityIndicators/Sources/Views/AnyActivityIndicator.swift create mode 100644 TIUIElements/README.md rename TIActivityIndicators/Sources/Extensions/UIActivityIndicatorView/UIActivityIndicatorView+ActivityIndicator.swift => TIUIElements/Sources/Extensions/UIActivityIndicatorView/UIActivityIndicatorView+ActivityIndicatorHolder.swift (90%) rename {TIActivityIndicators => TIUIElements}/Sources/Extensions/UIActivityIndicatorView/UIActivityIndicatorView+Animatable.swift (100%) rename {TIActivityIndicators/Sources/Protocols => TIUIKitCore/Sources/Protocols/ActivityIndicator}/ActivityIndicator.swift (83%) rename {TIActivityIndicators/Sources/Protocols => TIUIKitCore/Sources/Protocols/ActivityIndicator}/ActivityIndicatorHolder.swift (98%) rename TIUIKitCore/Sources/Protocols/{ => Animatable}/Animatable.swift (100%) rename TIUIKitCore/Sources/Protocols/{ => InitializableView}/InitializableView.swift (100%) diff --git a/Package.swift b/Package.swift index 923173ab..8f21aae1 100644 --- a/Package.swift +++ b/Package.swift @@ -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") ] ) diff --git a/TIActivityIndicators/README.md b/TIActivityIndicators/README.md deleted file mode 100644 index 9d809a2e..00000000 --- a/TIActivityIndicators/README.md +++ /dev/null @@ -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. diff --git a/TIActivityIndicators/Sources/Views/AnyActivityIndicator.swift b/TIActivityIndicators/Sources/Views/AnyActivityIndicator.swift deleted file mode 100644 index d3f2c643..00000000 --- a/TIActivityIndicators/Sources/Views/AnyActivityIndicator.swift +++ /dev/null @@ -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(_ 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() - } -} diff --git a/TIUIElements/README.md b/TIUIElements/README.md new file mode 100644 index 00000000..50d4e5af --- /dev/null +++ b/TIUIElements/README.md @@ -0,0 +1,7 @@ +# TIUIElements + +Bunch of useful protocols and views. + +# Installation via SPM + +You can install this framework as a target of LeadKit. diff --git a/TIActivityIndicators/Sources/Extensions/UIActivityIndicatorView/UIActivityIndicatorView+ActivityIndicator.swift b/TIUIElements/Sources/Extensions/UIActivityIndicatorView/UIActivityIndicatorView+ActivityIndicatorHolder.swift similarity index 90% rename from TIActivityIndicators/Sources/Extensions/UIActivityIndicatorView/UIActivityIndicatorView+ActivityIndicator.swift rename to TIUIElements/Sources/Extensions/UIActivityIndicatorView/UIActivityIndicatorView+ActivityIndicatorHolder.swift index b6184c33..b24434a4 100644 --- a/TIActivityIndicators/Sources/Extensions/UIActivityIndicatorView/UIActivityIndicatorView+ActivityIndicator.swift +++ b/TIUIElements/Sources/Extensions/UIActivityIndicatorView/UIActivityIndicatorView+ActivityIndicatorHolder.swift @@ -21,9 +21,10 @@ // import UIKit +import TIUIKitCore -extension UIActivityIndicatorView: ActivityIndicator { - public var view: UIActivityIndicatorView { +extension UIActivityIndicatorView: ActivityIndicatorHolder { + public var activityIndicator: Animatable { self } } diff --git a/TIActivityIndicators/Sources/Extensions/UIActivityIndicatorView/UIActivityIndicatorView+Animatable.swift b/TIUIElements/Sources/Extensions/UIActivityIndicatorView/UIActivityIndicatorView+Animatable.swift similarity index 100% rename from TIActivityIndicators/Sources/Extensions/UIActivityIndicatorView/UIActivityIndicatorView+Animatable.swift rename to TIUIElements/Sources/Extensions/UIActivityIndicatorView/UIActivityIndicatorView+Animatable.swift diff --git a/TIUIKitCore/README.md b/TIUIKitCore/README.md index 9953d1a8..201d28db 100644 --- a/TIUIKitCore/README.md +++ b/TIUIKitCore/README.md @@ -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 diff --git a/TIActivityIndicators/Sources/Protocols/ActivityIndicator.swift b/TIUIKitCore/Sources/Protocols/ActivityIndicator/ActivityIndicator.swift similarity index 83% rename from TIActivityIndicators/Sources/Protocols/ActivityIndicator.swift rename to TIUIKitCore/Sources/Protocols/ActivityIndicator/ActivityIndicator.swift index f84598d7..6d289364 100644 --- a/TIActivityIndicators/Sources/Protocols/ActivityIndicator.swift +++ b/TIUIKitCore/Sources/Protocols/ActivityIndicator/ActivityIndicator.swift @@ -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 diff --git a/TIActivityIndicators/Sources/Protocols/ActivityIndicatorHolder.swift b/TIUIKitCore/Sources/Protocols/ActivityIndicator/ActivityIndicatorHolder.swift similarity index 98% rename from TIActivityIndicators/Sources/Protocols/ActivityIndicatorHolder.swift rename to TIUIKitCore/Sources/Protocols/ActivityIndicator/ActivityIndicatorHolder.swift index b48e6f6a..64d2e0ab 100644 --- a/TIActivityIndicators/Sources/Protocols/ActivityIndicatorHolder.swift +++ b/TIUIKitCore/Sources/Protocols/ActivityIndicator/ActivityIndicatorHolder.swift @@ -21,7 +21,6 @@ // import UIKit -import TIUIKitCore /// Protocol that describes placeholder view, containing activity indicator. public protocol ActivityIndicatorHolder: class { diff --git a/TIUIKitCore/Sources/Protocols/Animatable.swift b/TIUIKitCore/Sources/Protocols/Animatable/Animatable.swift similarity index 100% rename from TIUIKitCore/Sources/Protocols/Animatable.swift rename to TIUIKitCore/Sources/Protocols/Animatable/Animatable.swift diff --git a/TIUIKitCore/Sources/Protocols/InitializableView.swift b/TIUIKitCore/Sources/Protocols/InitializableView/InitializableView.swift similarity index 100% rename from TIUIKitCore/Sources/Protocols/InitializableView.swift rename to TIUIKitCore/Sources/Protocols/InitializableView/InitializableView.swift