From fcc5805dac6f00d4a10fa0dfa846cfe7c81d0859 Mon Sep 17 00:00:00 2001 From: Vlad Date: Fri, 7 Aug 2020 14:10:21 +0300 Subject: [PATCH] Replace retry button with retry view --- CHANGELOG.md | 6 ++++ LeadKit.podspec | 2 +- LeadKit.xcodeproj/project.pbxproj | 20 +++++++++++++ .../PaginationWrapper.swift | 19 +++++------- .../CustomizableButtonView.swift | 10 +++---- ...pperUIDelegate+DefaultImplementation.swift | 4 +-- .../UIButton/UIButton+ButtonHolder.swift | 29 ++++++++++++++++++ .../UIKit/ButtonHolder/ButtonHolder.swift | 30 +++++++++++++++++++ .../UIKit/ButtonHolder/ButtonHolderView.swift | 26 ++++++++++++++++ .../PaginationWrapperUIDelegate.swift | 10 +++---- 10 files changed, 132 insertions(+), 24 deletions(-) create mode 100644 Sources/Extensions/UIKit/UIButton/UIButton+ButtonHolder.swift create mode 100644 Sources/Protocols/UIKit/ButtonHolder/ButtonHolder.swift create mode 100644 Sources/Protocols/UIKit/ButtonHolder/ButtonHolderView.swift diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fb2421f..c1fe613e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +### 0.9.34 +- **Add**: `ButtonHolder` - protocol that contains button property. +- **Add**: `ButtonHolderView` - view which contains button. +- **Add**: Conformance `UIButton` to `ButtonHolderView`. +- **[Breaking change]**: Replace functions `footerRetryButton() -> UIButton?` to `footerRetryView() -> ButtonHolderView?` and `footerRetryButtonHeight() -> CGFloat` to `footerRetryViewHeight() -> CGFloat` for `PaginationWrapperUIDelegate`. + ### 0.9.33 - **Fix**: `CustomizableButtonView` container class that provides great customization. - **Fix**: `CustomizableButtonViewModel` viewModel class for `CustomizableButtonView` configuration. diff --git a/LeadKit.podspec b/LeadKit.podspec index 73c4280c..33a7d43f 100644 --- a/LeadKit.podspec +++ b/LeadKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "LeadKit" - s.version = "0.9.33" + s.version = "0.9.34" 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/LeadKit.xcodeproj/project.pbxproj b/LeadKit.xcodeproj/project.pbxproj index 010fe015..b5340cff 100644 --- a/LeadKit.xcodeproj/project.pbxproj +++ b/LeadKit.xcodeproj/project.pbxproj @@ -16,6 +16,9 @@ 40F118471F8FEF97004AADAF /* AppearanceConfigurable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40F118461F8FEF97004AADAF /* AppearanceConfigurable.swift */; }; 40F118491F8FF223004AADAF /* TableRow+AppearanceExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40F118481F8FF223004AADAF /* TableRow+AppearanceExtension.swift */; }; 411073AF23466B41002DD9B9 /* UIViewController+PresentFullScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 411073AE23466B41002DD9B9 /* UIViewController+PresentFullScreen.swift */; }; + 4CF65D1424DD684A0006B001 /* ButtonHolder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CF65D1324DD684A0006B001 /* ButtonHolder.swift */; }; + 4CF65D1624DD69250006B001 /* UIButton+ButtonHolder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CF65D1524DD69250006B001 /* UIButton+ButtonHolder.swift */; }; + 4CF65D1824DD6C080006B001 /* ButtonHolderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CF65D1724DD6C080006B001 /* ButtonHolderView.swift */; }; 67051ADB1EBC7C36008EADC0 /* SpinnerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67051ADA1EBC7C36008EADC0 /* SpinnerView.swift */; }; 67051ADD1EBC7C36008EADC0 /* SpinnerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67051ADA1EBC7C36008EADC0 /* SpinnerView.swift */; }; 6713C23720AF0C4D00875921 /* NetworkOperationState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6713C23620AF0C4D00875921 /* NetworkOperationState.swift */; }; @@ -550,6 +553,9 @@ 40F118461F8FEF97004AADAF /* AppearanceConfigurable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppearanceConfigurable.swift; sourceTree = ""; }; 40F118481F8FF223004AADAF /* TableRow+AppearanceExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TableRow+AppearanceExtension.swift"; sourceTree = ""; }; 411073AE23466B41002DD9B9 /* UIViewController+PresentFullScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+PresentFullScreen.swift"; sourceTree = ""; }; + 4CF65D1324DD684A0006B001 /* ButtonHolder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonHolder.swift; sourceTree = ""; }; + 4CF65D1524DD69250006B001 /* UIButton+ButtonHolder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIButton+ButtonHolder.swift"; sourceTree = ""; }; + 4CF65D1724DD6C080006B001 /* ButtonHolderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonHolderView.swift; sourceTree = ""; }; 67051ADA1EBC7C36008EADC0 /* SpinnerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpinnerView.swift; sourceTree = ""; }; 6713C23620AF0C4D00875921 /* NetworkOperationState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkOperationState.swift; sourceTree = ""; }; 6713C23B20AF0D5900875921 /* NetworkOperationModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkOperationModel.swift; sourceTree = ""; }; @@ -859,6 +865,15 @@ path = UITableView; sourceTree = ""; }; + 4CF65D1924DD6C3D0006B001 /* ButtonHolder */ = { + isa = PBXGroup; + children = ( + 4CF65D1324DD684A0006B001 /* ButtonHolder.swift */, + 4CF65D1724DD6C080006B001 /* ButtonHolderView.swift */, + ); + path = ButtonHolder; + sourceTree = ""; + }; 671461C41EB3396E00EAB194 /* Classes */ = { isa = PBXGroup; children = ( @@ -1433,6 +1448,7 @@ 6741CE9F20E2413300FEC4D9 /* UIKit */ = { isa = PBXGroup; children = ( + 4CF65D1924DD6C3D0006B001 /* ButtonHolder */, 6741CEA020E2416C00FEC4D9 /* ScrollViewHolder.swift */, 6741CEA420E2418200FEC4D9 /* TableViewHolder.swift */, 6741CEA820E2418B00FEC4D9 /* CollectionViewHolder.swift */, @@ -1845,6 +1861,7 @@ isa = PBXGroup; children = ( 67E352512119AC060035BDDB /* UIButton+ViewTextConfigurable.swift */, + 4CF65D1524DD69250006B001 /* UIButton+ButtonHolder.swift */, ); path = UIButton; sourceTree = ""; @@ -2397,6 +2414,7 @@ 67EB7FF8206175F700BDD9FB /* PaginationWrappable.swift in Sources */, 67990AD6213EA6A50040D195 /* ContentLoadingViewModel+Extensions.swift in Sources */, 671463541EB3396E00EAB194 /* StaticViewHeightProtocol.swift in Sources */, + 4CF65D1824DD6C080006B001 /* ButtonHolderView.swift in Sources */, 72AECC6B224A979D00D12E7C /* BaseSearchViewController.swift in Sources */, 673CF4112063ABD100C329F6 /* GeneralDataLoadingState+Extensions.swift in Sources */, 72005A1E2266226800ECE090 /* CustomizableButton.swift in Sources */, @@ -2424,6 +2442,7 @@ 671462FC1EB3396E00EAB194 /* UIView+XibNameProtocol.swift in Sources */, 67EB7FC0206140E600BDD9FB /* TotalCountCursor.swift in Sources */, 36DAAF512007CC920090BE0D /* UITableView+Extensions.swift in Sources */, + 4CF65D1624DD69250006B001 /* UIButton+ButtonHolder.swift in Sources */, 671463841EB3396E00EAB194 /* ResizeDrawingOperation.swift in Sources */, 6774528D20625C9E0024EEEF /* GeneralDataLoadingState.swift in Sources */, 72005A1F2266226800ECE090 /* CustomizableButtonViewModel.swift in Sources */, @@ -2500,6 +2519,7 @@ A6E0DDF11F8A6C80002CA74E /* SeparatorConfiguration.swift in Sources */, 6727477F206CD3BD00725163 /* ViewText+Extensions.swift in Sources */, 67EB7FEB2061667900BDD9FB /* DefaultTotalCountCursorListingResult.swift in Sources */, + 4CF65D1424DD684A0006B001 /* ButtonHolder.swift in Sources */, 671AD26C206A3E8500EAF887 /* Array+TotalCountCursorListingResult.swift in Sources */, 673CF4382063E7CE00C329F6 /* GeneralDataLoadingController+DefaultImplementation.swift in Sources */, B85B768720B1CF6700F837C4 /* Encodable+Extensions.swift in Sources */, diff --git a/Sources/Classes/DataLoading/PaginationDataLoading/PaginationWrapper.swift b/Sources/Classes/DataLoading/PaginationDataLoading/PaginationWrapper.swift index a0dfb8ba..53e2e40b 100644 --- a/Sources/Classes/DataLoading/PaginationDataLoading/PaginationWrapper.swift +++ b/Sources/Classes/DataLoading/PaginationDataLoading/PaginationWrapper.swift @@ -144,7 +144,7 @@ final public class PaginationWrapper UIButton? { + func footerRetryView() -> ButtonHolderView? { let retryButton = UIButton(type: .custom) retryButton.backgroundColor = .lightGray retryButton.setTitle("Retry load more", for: .normal) @@ -57,7 +57,7 @@ public extension PaginationWrapperUIDelegate { return retryButton } - func footerRetryButtonHeight() -> CGFloat { + func footerRetryViewHeight() -> CGFloat { return 44 } diff --git a/Sources/Extensions/UIKit/UIButton/UIButton+ButtonHolder.swift b/Sources/Extensions/UIKit/UIButton/UIButton+ButtonHolder.swift new file mode 100644 index 00000000..4c3c5e1d --- /dev/null +++ b/Sources/Extensions/UIKit/UIButton/UIButton+ButtonHolder.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.UIButton + +public extension UIButton: ButtonHolderView { + var button: UIButton { + self + } +} diff --git a/Sources/Protocols/UIKit/ButtonHolder/ButtonHolder.swift b/Sources/Protocols/UIKit/ButtonHolder/ButtonHolder.swift new file mode 100644 index 00000000..0f3b4120 --- /dev/null +++ b/Sources/Protocols/UIKit/ButtonHolder/ButtonHolder.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. +// + +import UIKit.UIButton + +/// Protocol that contains button property. +public protocol ButtonHolder { + + /// Contained UIButton instance. + var button: UIButton { get } +} diff --git a/Sources/Protocols/UIKit/ButtonHolder/ButtonHolderView.swift b/Sources/Protocols/UIKit/ButtonHolder/ButtonHolderView.swift new file mode 100644 index 00000000..22b08e84 --- /dev/null +++ b/Sources/Protocols/UIKit/ButtonHolder/ButtonHolderView.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.UIView + +/// View which contains button +public typealias ButtonHolderView = UIView & ButtonHolder diff --git a/Sources/Structures/DataLoading/PaginationDataLoading/PaginationWrapperUIDelegate.swift b/Sources/Structures/DataLoading/PaginationDataLoading/PaginationWrapperUIDelegate.swift index 039eb2a4..2d004320 100644 --- a/Sources/Structures/DataLoading/PaginationDataLoading/PaginationWrapperUIDelegate.swift +++ b/Sources/Structures/DataLoading/PaginationDataLoading/PaginationWrapperUIDelegate.swift @@ -55,21 +55,21 @@ public protocol PaginationWrapperUIDelegate: class { /// - Returns: Configured instace of AnyLoadingIndicator. func loadingMoreIndicator() -> AnyLoadingIndicator? - /// Returns instance of UIButton for "retry load more" action. + /// Returns instance of ButtonHolderView with retry button for "retry load more" action. /// /// - Returns: Configured instace of AnyLoadingIndicator. - func footerRetryButton() -> UIButton? + func footerRetryView() -> ButtonHolderView? /// Returns height for "retry load more" button. /// /// - Returns: Height of "retry load more" button. - func footerRetryButtonHeight() -> CGFloat + func footerRetryViewHeight() -> CGFloat /// Method is called before "retry load more" will be shown. /// Typically, it's used when you need to show custom footer view. - func footerRetryButtonWillAppear() + func footerRetryViewWillAppear() /// Method is called before "retry load more" will be hidden. /// Typically, it's used when you need to hide custom footer view. - func footerRetryButtonWillDisappear() + func footerRetryViewWillDisappear() }