From 91e690614500cdcd2bc4e978e972f933a7e8bc48 Mon Sep 17 00:00:00 2001 From: Vlad Date: Wed, 19 Aug 2020 15:47:31 +0300 Subject: [PATCH 1/9] Add Animatable to TIUIKitCore and add TIActivityIndicators --- Package.swift | 4 +- TIActivityIndicators/README.md | 44 ++++++++++++++ ...ivityIndicatorView+ActivityIndicator.swift | 29 +++++++++ .../UIActivityIndicatorView+Animatable.swift | 26 ++++++++ .../Sources/Protocols/ActivityIndicator.swift | 34 +++++++++++ .../Protocols/ActivityIndicatorHolder.swift | 36 +++++++++++ .../Sources/Views/AnyActivityIndicator.swift | 60 +++++++++++++++++++ .../Sources/Protocols/Animatable.swift | 30 ++++++++++ 8 files changed, 262 insertions(+), 1 deletion(-) create mode 100644 TIActivityIndicators/README.md create mode 100644 TIActivityIndicators/Sources/Extensions/UIActivityIndicatorView/UIActivityIndicatorView+ActivityIndicator.swift create mode 100644 TIActivityIndicators/Sources/Extensions/UIActivityIndicatorView/UIActivityIndicatorView+Animatable.swift create mode 100644 TIActivityIndicators/Sources/Protocols/ActivityIndicator.swift create mode 100644 TIActivityIndicators/Sources/Protocols/ActivityIndicatorHolder.swift create mode 100644 TIActivityIndicators/Sources/Views/AnyActivityIndicator.swift create mode 100644 TIUIKitCore/Sources/Protocols/Animatable.swift diff --git a/Package.swift b/Package.swift index 7c2250b7..923173ab 100644 --- a/Package.swift +++ b/Package.swift @@ -8,10 +8,12 @@ let package = Package( ], products: [ .library(name: "TITransitions", targets: ["TITransitions"]), - .library(name: "TIUIKitCore", targets: ["TIUIKitCore"]) + .library(name: "TIUIKitCore", targets: ["TIUIKitCore"]), + .library(name: "TIActivityIndicators", targets: ["TIActivityIndicators"]) ], targets: [ .target(name: "TITransitions", path: "TITransitions/Sources"), .target(name: "TIUIKitCore", path: "TIUIKitCore/Sources"), + .target(name: "TIActivityIndicators", dependencies: ["TIUIKitCore"], path: "TIActivityIndicators/Sources") ] ) diff --git a/TIActivityIndicators/README.md b/TIActivityIndicators/README.md new file mode 100644 index 00000000..67af07a2 --- /dev/null +++ b/TIActivityIndicators/README.md @@ -0,0 +1,44 @@ +# 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 PaginationWrapper of main framework LeadKit. + +# Installation via SPM + +You can install this framework as a target of LeadKit. diff --git a/TIActivityIndicators/Sources/Extensions/UIActivityIndicatorView/UIActivityIndicatorView+ActivityIndicator.swift b/TIActivityIndicators/Sources/Extensions/UIActivityIndicatorView/UIActivityIndicatorView+ActivityIndicator.swift new file mode 100644 index 00000000..b6184c33 --- /dev/null +++ b/TIActivityIndicators/Sources/Extensions/UIActivityIndicatorView/UIActivityIndicatorView+ActivityIndicator.swift @@ -0,0 +1,29 @@ +// +// 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 + +extension UIActivityIndicatorView: ActivityIndicator { + public var view: UIActivityIndicatorView { + self + } +} diff --git a/TIActivityIndicators/Sources/Extensions/UIActivityIndicatorView/UIActivityIndicatorView+Animatable.swift b/TIActivityIndicators/Sources/Extensions/UIActivityIndicatorView/UIActivityIndicatorView+Animatable.swift new file mode 100644 index 00000000..2d709284 --- /dev/null +++ b/TIActivityIndicators/Sources/Extensions/UIActivityIndicatorView/UIActivityIndicatorView+Animatable.swift @@ -0,0 +1,26 @@ +// +// 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 + +extension UIActivityIndicatorView: Animatable {} diff --git a/TIActivityIndicators/Sources/Protocols/ActivityIndicator.swift b/TIActivityIndicators/Sources/Protocols/ActivityIndicator.swift new file mode 100644 index 00000000..f84598d7 --- /dev/null +++ b/TIActivityIndicators/Sources/Protocols/ActivityIndicator.swift @@ -0,0 +1,34 @@ +// +// 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 + +/// 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 } +} diff --git a/TIActivityIndicators/Sources/Protocols/ActivityIndicatorHolder.swift b/TIActivityIndicators/Sources/Protocols/ActivityIndicatorHolder.swift new file mode 100644 index 00000000..b48e6f6a --- /dev/null +++ b/TIActivityIndicators/Sources/Protocols/ActivityIndicatorHolder.swift @@ -0,0 +1,36 @@ +// +// 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 + +/// Protocol that describes placeholder view, containing activity indicator. +public protocol ActivityIndicatorHolder: class { + var activityIndicator: Animatable { get } + var indicatorOwner: UIView { get } +} + +public extension ActivityIndicatorHolder where Self: UIView { + var indicatorOwner: UIView { + return self + } +} diff --git a/TIActivityIndicators/Sources/Views/AnyActivityIndicator.swift b/TIActivityIndicators/Sources/Views/AnyActivityIndicator.swift new file mode 100644 index 00000000..d3f2c643 --- /dev/null +++ b/TIActivityIndicators/Sources/Views/AnyActivityIndicator.swift @@ -0,0 +1,60 @@ +// +// 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/TIUIKitCore/Sources/Protocols/Animatable.swift b/TIUIKitCore/Sources/Protocols/Animatable.swift new file mode 100644 index 00000000..927884dd --- /dev/null +++ b/TIUIKitCore/Sources/Protocols/Animatable.swift @@ -0,0 +1,30 @@ +// +// 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. +// + +/// Protocol that ensures that specific type support basic animation actions. +public protocol Animatable { + + /// Method that starts animation. + func startAnimating() + /// Method that stops animation. + func stopAnimating() +} From 16e2d222a43d763da626eb17553799682ef2ac0e Mon Sep 17 00:00:00 2001 From: Vlad Date: Wed, 19 Aug 2020 15:54:51 +0300 Subject: [PATCH 2/9] Up version --- CHANGELOG.md | 4 ++++ LeadKit.podspec | 2 +- README.md | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2387df8a..db438234 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +### 0.9.39 +- **Add**: `Animatable` protocol to TIUIKitCore. +- **Add**: `TIActivityIndicators` for activity indicators. + ### 0.9.37 - **Fix**: ScrollView content offset of `PaginationWrapper` for iOS 13. - **Fix**: Load more request crash of `PaginationWrapper`. diff --git a/LeadKit.podspec b/LeadKit.podspec index 047c7558..a8dc1db2 100644 --- a/LeadKit.podspec +++ b/LeadKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "LeadKit" - s.version = "0.9.37" + s.version = "0.9.39" s.summary = "iOS framework with a bunch of tools for rapid development" s.homepage = "https://github.com/TouchInstinct/LeadKit" s.license = "Apache License, Version 2.0" diff --git a/README.md b/README.md index c4298f10..77a3e5a9 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ LeadKit is the iOS framework with a bunch of tools for rapid app development. ## Additional This repository contains the following additional frameworks: +- [TIUIKitCore](TIUIKitCore) - core ui elements and protocols from LeadKit. - [TITransitions](TITransitions) - set of custom transitions to present controller. -- [TIUIKitCore](TIUIKitCore) - core ui elements from LeadKit. +- [TIActivityIndicators](TIActivityIndicators) - bunch of protocols and views of Activity Indicators. From b6ef182d56bf92904d3b09a3246d69b054495d05 Mon Sep 17 00:00:00 2001 From: Loupehope <31570429+Loupehope@users.noreply.github.com> Date: Wed, 19 Aug 2020 16:04:10 +0300 Subject: [PATCH 3/9] Update README.md --- TIActivityIndicators/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TIActivityIndicators/README.md b/TIActivityIndicators/README.md index 67af07a2..9d809a2e 100644 --- a/TIActivityIndicators/README.md +++ b/TIActivityIndicators/README.md @@ -37,7 +37,7 @@ Type that performs some kind of type erasure for ActivityIndicator. # Usage examples -- Loading Indicator in PaginationWrapper of main framework LeadKit. +- 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 From 2808d015bf34bd8279b89e5fbc825bd50d0fa0dc Mon Sep 17 00:00:00 2001 From: Vlad Date: Wed, 19 Aug 2020 23:35:02 +0300 Subject: [PATCH 4/9] 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 From 00c60e6fb0edac4f9ce11147c4afbd703422dd44 Mon Sep 17 00:00:00 2001 From: Vlad Date: Wed, 19 Aug 2020 23:35:57 +0300 Subject: [PATCH 5/9] Update changelog --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db438234..c2150c23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,9 @@ ### 0.9.39 - **Add**: `Animatable` protocol to TIUIKitCore. -- **Add**: `TIActivityIndicators` for activity indicators. +- **Add**: `ActivityIndicator` protocol to TIUIKitCore. +- **Add**: `ActivityIndicatorHolder` protocol to TIUIKitCore. +- **Add**: `TIUIElements` for ui elements. ### 0.9.37 - **Fix**: ScrollView content offset of `PaginationWrapper` for iOS 13. From ec29cb0e278527c9f5f5777fa630ed11d1f4fe56 Mon Sep 17 00:00:00 2001 From: Vlad Date: Wed, 19 Aug 2020 23:37:25 +0300 Subject: [PATCH 6/9] Update Readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 77a3e5a9..b0849610 100644 --- a/README.md +++ b/README.md @@ -5,5 +5,5 @@ LeadKit is the iOS framework with a bunch of tools for rapid app development. This repository contains the following additional frameworks: - [TIUIKitCore](TIUIKitCore) - core ui elements and protocols from LeadKit. - [TITransitions](TITransitions) - set of custom transitions to present controller. -- [TIActivityIndicators](TIActivityIndicators) - bunch of protocols and views of Activity Indicators. +- [TIUIElements](TIUIElements) - bunch of of useful protocols and views. From eaf58da24aef50bf63cda3963243c5d879f30f30 Mon Sep 17 00:00:00 2001 From: Vlad Date: Wed, 19 Aug 2020 23:38:47 +0300 Subject: [PATCH 7/9] Update readme --- TIUIKitCore/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TIUIKitCore/README.md b/TIUIKitCore/README.md index 201d28db..9c46b9b3 100644 --- a/TIUIKitCore/README.md +++ b/TIUIKitCore/README.md @@ -5,7 +5,7 @@ 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. +- [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. From eabfa7ec01b3ce47a322e3a37c01f92d28702d47 Mon Sep 17 00:00:00 2001 From: Vlad Date: Wed, 19 Aug 2020 23:48:00 +0300 Subject: [PATCH 8/9] Code correction, fix iOS version --- Package.swift | 2 +- .../Protocols/ActivityIndicator/ActivityIndicatorHolder.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Package.swift b/Package.swift index 8f21aae1..6d1622df 100644 --- a/Package.swift +++ b/Package.swift @@ -4,7 +4,7 @@ import PackageDescription let package = Package( name: "LeadKit", platforms: [ - .iOS(.v12) + .iOS(.v11) ], products: [ .library(name: "TITransitions", targets: ["TITransitions"]), diff --git a/TIUIKitCore/Sources/Protocols/ActivityIndicator/ActivityIndicatorHolder.swift b/TIUIKitCore/Sources/Protocols/ActivityIndicator/ActivityIndicatorHolder.swift index 64d2e0ab..feaa592e 100644 --- a/TIUIKitCore/Sources/Protocols/ActivityIndicator/ActivityIndicatorHolder.swift +++ b/TIUIKitCore/Sources/Protocols/ActivityIndicator/ActivityIndicatorHolder.swift @@ -30,6 +30,6 @@ public protocol ActivityIndicatorHolder: class { public extension ActivityIndicatorHolder where Self: UIView { var indicatorOwner: UIView { - return self + self } } From 90b82edd6419e3a051e9b90094de698ce0599bef Mon Sep 17 00:00:00 2001 From: Vlad Date: Wed, 19 Aug 2020 23:50:50 +0300 Subject: [PATCH 9/9] Code correction --- .../UIView+ActivityIndicatorHolder.swift | 29 +++++++++++++++++++ .../ActivityIndicatorHolder.swift | 6 ---- 2 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 TIUIKitCore/Sources/Extensions/UIView/UIView+ActivityIndicatorHolder.swift diff --git a/TIUIKitCore/Sources/Extensions/UIView/UIView+ActivityIndicatorHolder.swift b/TIUIKitCore/Sources/Extensions/UIView/UIView+ActivityIndicatorHolder.swift new file mode 100644 index 00000000..16c6baf4 --- /dev/null +++ b/TIUIKitCore/Sources/Extensions/UIView/UIView+ActivityIndicatorHolder.swift @@ -0,0 +1,29 @@ +// +// 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 + +public extension ActivityIndicatorHolder where Self: UIView { + var indicatorOwner: UIView { + self + } +} diff --git a/TIUIKitCore/Sources/Protocols/ActivityIndicator/ActivityIndicatorHolder.swift b/TIUIKitCore/Sources/Protocols/ActivityIndicator/ActivityIndicatorHolder.swift index feaa592e..dffd4b32 100644 --- a/TIUIKitCore/Sources/Protocols/ActivityIndicator/ActivityIndicatorHolder.swift +++ b/TIUIKitCore/Sources/Protocols/ActivityIndicator/ActivityIndicatorHolder.swift @@ -27,9 +27,3 @@ public protocol ActivityIndicatorHolder: class { var activityIndicator: Animatable { get } var indicatorOwner: UIView { get } } - -public extension ActivityIndicatorHolder where Self: UIView { - var indicatorOwner: UIView { - self - } -}