From aff508ed440a111066fbc7906739c5039e562c9d Mon Sep 17 00:00:00 2001 From: Sasha Malina Date: Thu, 10 May 2018 12:21:32 +0300 Subject: [PATCH 01/18] Remove some source files from 'iosTests' target Update project structure for building ios tests --- LeadKit.xcodeproj/project.pbxproj | 8 -------- 1 file changed, 8 deletions(-) diff --git a/LeadKit.xcodeproj/project.pbxproj b/LeadKit.xcodeproj/project.pbxproj index 3d14bcd8..896bdc19 100644 --- a/LeadKit.xcodeproj/project.pbxproj +++ b/LeadKit.xcodeproj/project.pbxproj @@ -503,9 +503,7 @@ 67FDC2621FA310EA00C76A77 /* RequestError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67FDC25E1FA310EA00C76A77 /* RequestError.swift */; }; 82F8BB181F5DDED100C1061B /* Single+DeferredJust.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82F8BB171F5DDED100C1061B /* Single+DeferredJust.swift */; }; A658E54D1F8CD7790093527A /* TableRow+SeparatorsExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = A658E54C1F8CD7790093527A /* TableRow+SeparatorsExtensions.swift */; }; - A658E54E1F8CD7790093527A /* TableRow+SeparatorsExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = A658E54C1F8CD7790093527A /* TableRow+SeparatorsExtensions.swift */; }; A658E5501F8CD9350093527A /* Array+SeparatorRowBoxExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = A658E54F1F8CD9350093527A /* Array+SeparatorRowBoxExtensions.swift */; }; - A658E5511F8CD9350093527A /* Array+SeparatorRowBoxExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = A658E54F1F8CD9350093527A /* Array+SeparatorRowBoxExtensions.swift */; }; A676AE481F97D28A001F9214 /* String+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = A676AE471F97D28A001F9214 /* String+Extensions.swift */; }; A676AE491F97D28A001F9214 /* String+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = A676AE471F97D28A001F9214 /* String+Extensions.swift */; }; A676AE4A1F97D28A001F9214 /* String+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = A676AE471F97D28A001F9214 /* String+Extensions.swift */; }; @@ -527,8 +525,6 @@ A6E0DDDE1F8A696F002CA74E /* EmptyCellRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = A66428A71F8A654600C6308D /* EmptyCellRow.swift */; }; A6E0DDDF1F8A696F002CA74E /* SeparatorCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A66428A61F8A653600C6308D /* SeparatorCell.swift */; }; A6E0DDE11F8A696F002CA74E /* SeparatorRowBox.swift in Sources */ = {isa = PBXBuildFile; fileRef = A66428A81F8A655600C6308D /* SeparatorRowBox.swift */; }; - A6E0DDE31F8A696F002CA74E /* SeparatorCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A66428A61F8A653600C6308D /* SeparatorCell.swift */; }; - A6E0DDE51F8A696F002CA74E /* SeparatorRowBox.swift in Sources */ = {isa = PBXBuildFile; fileRef = A66428A81F8A655600C6308D /* SeparatorRowBox.swift */; }; A6E0DDF11F8A6C80002CA74E /* SeparatorConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = A6E0DDF01F8A6C80002CA74E /* SeparatorConfiguration.swift */; }; A6F32C081F6EBDAA00AC08EE /* String+LocalizedComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = A6F32C071F6EBDAA00AC08EE /* String+LocalizedComponent.swift */; }; A6F32C0A1F6EBE5B00AC08EE /* String+LocalizedComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = A6F32C071F6EBDAA00AC08EE /* String+LocalizedComponent.swift */; }; @@ -2723,15 +2719,11 @@ A6C9A5051F8BC78F009311CC /* SeparatorConfiguration.swift in Sources */, 671463CA1EB34B1E00EAB194 /* TestView.swift in Sources */, 671463B81EB34B1E00EAB194 /* StubCursor.swift in Sources */, - A658E54E1F8CD7790093527A /* TableRow+SeparatorsExtensions.swift in Sources */, - A658E5511F8CD9350093527A /* Array+SeparatorRowBoxExtensions.swift in Sources */, 671463BB1EB34B1E00EAB194 /* CursorTests.swift in Sources */, A6F32C101F6EBE9600AC08EE /* StringExtensionTests.swift in Sources */, 671463BE1EB34B1E00EAB194 /* LoadFromNibTests.swift in Sources */, - A6E0DDE31F8A696F002CA74E /* SeparatorCell.swift in Sources */, A6C9A50F1F8BC79D009311CC /* Comparable+Extensions.swift in Sources */, 671463C41EB34B1E00EAB194 /* Post.swift in Sources */, - A6E0DDE51F8A696F002CA74E /* SeparatorRowBox.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; From f0fb443f6b8e7a5bcb042d9eee374c0f6328fcad Mon Sep 17 00:00:00 2001 From: Sasha Malina Date: Thu, 10 May 2018 12:28:48 +0300 Subject: [PATCH 02/18] Fix double rounding issue & typo In current state "normal" rounding type produce error: `3.14.roundValue(withPrecision: 0) == 4`, `3.14.roundValue(withPrecision: 1) == 3.2`, looks strange. Fix typo in word `precision`, improve description --- .../Extensions/Double/Double+Rounding.swift | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/Sources/Extensions/Double/Double+Rounding.swift b/Sources/Extensions/Double/Double+Rounding.swift index 09a406ad..860b31ad 100644 --- a/Sources/Extensions/Double/Double+Rounding.swift +++ b/Sources/Extensions/Double/Double+Rounding.swift @@ -23,10 +23,10 @@ import Foundation public extension Double { - + /** Type of rounding double value - + - Normal: From 167.567 you will get 167.6 - Down: From 167.567 you will get 167.5 */ @@ -34,25 +34,26 @@ public extension Double { case normal case down } - + /** Rounding of double value - - - parameter persicion: important number of digits after comma + + - parameter precision: significant digits after decimal point - parameter roundType: rounding type - + - returns: rounded value */ - func roundValue(withPersicion persicion: UInt, + func roundValue(withPrecision precision: UInt, roundType: RoundingType = .normal) -> Double { - let divider = pow(10.0, Double(persicion)) - + let divider = pow(10.0, Double(precision)) + switch roundType { case .normal: - return (self * divider).rounded(.up) / divider + return (self * divider).rounded(.toNearestOrEven) / divider case .down: return (self * divider).rounded(.down) / divider } } - + } + From 538138ada5aca4145f14cb6327dc2f8e45dbdfd3 Mon Sep 17 00:00:00 2001 From: Sasha Malina Date: Thu, 10 May 2018 12:34:59 +0300 Subject: [PATCH 03/18] Add tests for Double extension Add `roundValue` test case --- LeadKit.xcodeproj/project.pbxproj | 8 +++ Tests/Extensions/Double+RoundingTests.swift | 54 +++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 Tests/Extensions/Double+RoundingTests.swift diff --git a/LeadKit.xcodeproj/project.pbxproj b/LeadKit.xcodeproj/project.pbxproj index 896bdc19..8702c079 100644 --- a/LeadKit.xcodeproj/project.pbxproj +++ b/LeadKit.xcodeproj/project.pbxproj @@ -535,6 +535,9 @@ A6F32C121F6EBE9800AC08EE /* StringExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A6F32C0E1F6EBE8E00AC08EE /* StringExtensionTests.swift */; }; BA6C6DB45950382041948FC5 /* Pods_LeadKit_LeadKit_iOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CFE9323150A9760008093F73 /* Pods_LeadKit_LeadKit_iOS.framework */; }; D6EE55093E404DEA62B03DDF /* Pods_LeadKit_LeadKit_watchOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8590CA7831555C295C5DC572 /* Pods_LeadKit_LeadKit_watchOS.framework */; }; + D93221EE20A44896003799D5 /* Double+RoundingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D93221ED20A44896003799D5 /* Double+RoundingTests.swift */; }; + D93221EF20A44896003799D5 /* Double+RoundingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D93221ED20A44896003799D5 /* Double+RoundingTests.swift */; }; + D93221F020A44896003799D5 /* Double+RoundingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D93221ED20A44896003799D5 /* Double+RoundingTests.swift */; }; DEE25FE98D40ED1C168F384A /* Pods_LeadKit_LeadKit_iOS_Extensions.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 887F99C5326BD220C2811BD6 /* Pods_LeadKit_LeadKit_iOS_Extensions.framework */; }; EF24213A2076D5BD00FA9BE6 /* NetworkServiceConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = EF2421392076D5BD00FA9BE6 /* NetworkServiceConfiguration.swift */; }; EF24213B2076D5C700FA9BE6 /* NetworkServiceConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = EF2421392076D5BD00FA9BE6 /* NetworkServiceConfiguration.swift */; }; @@ -786,6 +789,7 @@ CFE9323150A9760008093F73 /* Pods_LeadKit_LeadKit_iOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_LeadKit_LeadKit_iOS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D0F8D0002B21A4F31981F1ED /* Pods_LeadKit_LeadKit_tvOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_LeadKit_LeadKit_tvOS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D840E55867DC9BB63460B856 /* Pods-LeadKit tvOSTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-LeadKit tvOSTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-LeadKit tvOSTests/Pods-LeadKit tvOSTests.release.xcconfig"; sourceTree = ""; }; + D93221ED20A44896003799D5 /* Double+RoundingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Double+RoundingTests.swift"; sourceTree = ""; }; DF1148A279C7AC7A42B0A0F8 /* Pods_LeadKit_iOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_LeadKit_iOS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; EF2421392076D5BD00FA9BE6 /* NetworkServiceConfiguration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkServiceConfiguration.swift; sourceTree = ""; }; EFA4C66320864F9C008C4DD8 /* UniversalMappable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UniversalMappable.swift; sourceTree = ""; }; @@ -1730,6 +1734,7 @@ A6F32C0D1F6EBE7700AC08EE /* Extensions */ = { isa = PBXGroup; children = ( + D93221ED20A44896003799D5 /* Double+RoundingTests.swift */, A6F32C0E1F6EBE8E00AC08EE /* StringExtensionTests.swift */, ); path = Extensions; @@ -2717,6 +2722,7 @@ buildActionMask = 2147483647; files = ( A6C9A5051F8BC78F009311CC /* SeparatorConfiguration.swift in Sources */, + D93221EE20A44896003799D5 /* Double+RoundingTests.swift in Sources */, 671463CA1EB34B1E00EAB194 /* TestView.swift in Sources */, 671463B81EB34B1E00EAB194 /* StubCursor.swift in Sources */, 671463BB1EB34B1E00EAB194 /* CursorTests.swift in Sources */, @@ -2983,6 +2989,7 @@ 671463BA1EB34B1E00EAB194 /* StubCursor.swift in Sources */, 671463BD1EB34B1E00EAB194 /* CursorTests.swift in Sources */, A6F32C121F6EBE9800AC08EE /* StringExtensionTests.swift in Sources */, + D93221F020A44896003799D5 /* Double+RoundingTests.swift in Sources */, 671463C01EB34B1E00EAB194 /* LoadFromNibTests.swift in Sources */, 671463C61EB34B1E00EAB194 /* Post.swift in Sources */, ); @@ -3138,6 +3145,7 @@ 671463BF1EB34B1E00EAB194 /* LoadFromNibTests.swift in Sources */, 671463C51EB34B1E00EAB194 /* Post.swift in Sources */, 671463CB1EB34B1E00EAB194 /* TestView.swift in Sources */, + D93221EF20A44896003799D5 /* Double+RoundingTests.swift in Sources */, A6F32C111F6EBE9700AC08EE /* StringExtensionTests.swift in Sources */, 671463BC1EB34B1E00EAB194 /* CursorTests.swift in Sources */, 671463B91EB34B1E00EAB194 /* StubCursor.swift in Sources */, diff --git a/Tests/Extensions/Double+RoundingTests.swift b/Tests/Extensions/Double+RoundingTests.swift new file mode 100644 index 00000000..f77d732c --- /dev/null +++ b/Tests/Extensions/Double+RoundingTests.swift @@ -0,0 +1,54 @@ +// +// Copyright (c) 2017 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 XCTest + +class Double_RoundingTests: XCTestCase { + + func testPositiveNumbers() { + let pi = 3.1415926 + + XCTAssertTrue(pi.roundValue(withPrecision: 0) == 3.0) + XCTAssertTrue(pi.roundValue(withPrecision: 1) == 3.1) + XCTAssertTrue(pi.roundValue(withPrecision: 2) == 3.14) + XCTAssertTrue(pi.roundValue(withPrecision: 3) == 3.142) + + let some = 1.778297 + XCTAssertTrue(some.roundValue(withPrecision: 1) == 1.8) + XCTAssertTrue(some.roundValue(withPrecision: 1, roundType: .down) == 1.7) + XCTAssertTrue(some.roundValue(withPrecision: 2, roundType: .down) == 1.77) + } + + func testNegativeNumbers() { + let e = 2.7182 + + XCTAssertTrue(-e.roundValue(withPrecision: 0) == -3.0) + XCTAssertTrue(-e.roundValue(withPrecision: 1) == -2.7) + XCTAssertTrue(-e.roundValue(withPrecision: 2) == -2.72) + XCTAssertTrue(-e.roundValue(withPrecision: 3) == -2.718) + + let some = -1.778297 + XCTAssertTrue(some.roundValue(withPrecision: 1) == -1.8) + XCTAssertTrue(some.roundValue(withPrecision: 1, roundType: .down) == -1.8) + XCTAssertTrue(some.roundValue(withPrecision: 2, roundType: .down) == -1.78) + } + +} From ad0ed37095b5eb95b78510b7f4b779d826db3905 Mon Sep 17 00:00:00 2001 From: Sasha Malina Date: Thu, 10 May 2018 12:39:24 +0300 Subject: [PATCH 04/18] Increment version --- CHANGELOG.md | 4 ++++ LeadKit.podspec | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5d42ea9..eda17078 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +### 0.7.13 +- **Fix**: `Double.roundValue(withPrecision:)` rounding issue +- **Add**: `Double+Rounding` test case + ### 0.7.12 - **Add**: `UniversalMappable` protocol to have ability generate generic mapping models diff --git a/LeadKit.podspec b/LeadKit.podspec index 9f6594da..196953b8 100644 --- a/LeadKit.podspec +++ b/LeadKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "LeadKit" - s.version = "0.7.12" + s.version = "0.7.13" 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" From 7afa723ed56a3aa5da30b3838b0a0f98571ff7b3 Mon Sep 17 00:00:00 2001 From: Sasha Malina Date: Sat, 12 May 2018 00:31:26 +0300 Subject: [PATCH 05/18] Undo useless changes --- Sources/Extensions/Double/Double+Rounding.swift | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Sources/Extensions/Double/Double+Rounding.swift b/Sources/Extensions/Double/Double+Rounding.swift index 860b31ad..88f275ff 100644 --- a/Sources/Extensions/Double/Double+Rounding.swift +++ b/Sources/Extensions/Double/Double+Rounding.swift @@ -23,10 +23,8 @@ import Foundation public extension Double { - /** Type of rounding double value - - Normal: From 167.567 you will get 167.6 - Down: From 167.567 you will get 167.5 */ @@ -34,7 +32,7 @@ public extension Double { case normal case down } - + /** Rounding of double value From f890fb58e071d5d2e33072c5669b0ab629d3272f Mon Sep 17 00:00:00 2001 From: Pavel Lukandiy Date: Mon, 21 May 2018 20:32:52 +0300 Subject: [PATCH 06/18] Implemented wrapper ui delegate --- LeadKit.xcodeproj/project.pbxproj | 12 ++- .../PaginationWrapper.swift | 26 ++++--- ...perUIDelegate+DefaultImplementation.swift} | 12 +-- .../PaginationWrapperDelegate.swift | 50 ------------- .../PaginationWrapperUIDelegate.swift | 73 +++++++++++++++++++ 5 files changed, 97 insertions(+), 76 deletions(-) rename Sources/Extensions/DataLoading/PaginationDataLoading/{PaginationWrapperDelegate+DefaultImplementation.swift => PaginationWrapperUIDelegate+DefaultImplementation.swift} (88%) create mode 100644 Sources/Structures/DataLoading/PaginationDataLoading/PaginationWrapperUIDelegate.swift diff --git a/LeadKit.xcodeproj/project.pbxproj b/LeadKit.xcodeproj/project.pbxproj index e7db21a3..f0163709 100644 --- a/LeadKit.xcodeproj/project.pbxproj +++ b/LeadKit.xcodeproj/project.pbxproj @@ -363,7 +363,7 @@ 6774526C206249E30024EEEF /* UICollectionView+PaginationWrappable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6774526B206249E30024EEEF /* UICollectionView+PaginationWrappable.swift */; }; 6774526D206249E30024EEEF /* UICollectionView+PaginationWrappable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6774526B206249E30024EEEF /* UICollectionView+PaginationWrappable.swift */; }; 6774526E206249E30024EEEF /* UICollectionView+PaginationWrappable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6774526B206249E30024EEEF /* UICollectionView+PaginationWrappable.swift */; }; - 6774527020624A2A0024EEEF /* PaginationWrapperDelegate+DefaultImplementation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6774526F20624A2A0024EEEF /* PaginationWrapperDelegate+DefaultImplementation.swift */; }; + 6774527020624A2A0024EEEF /* PaginationWrapperUIDelegate+DefaultImplementation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6774526F20624A2A0024EEEF /* PaginationWrapperUIDelegate+DefaultImplementation.swift */; }; 6774527420624E820024EEEF /* DataLoadingModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6774527320624E820024EEEF /* DataLoadingModel.swift */; }; 6774527520624E820024EEEF /* DataLoadingModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6774527320624E820024EEEF /* DataLoadingModel.swift */; }; 6774527620624E820024EEEF /* DataLoadingModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6774527320624E820024EEEF /* DataLoadingModel.swift */; }; @@ -503,6 +503,7 @@ 67FDC2601FA310EA00C76A77 /* RequestError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67FDC25E1FA310EA00C76A77 /* RequestError.swift */; }; 67FDC2611FA310EA00C76A77 /* RequestError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67FDC25E1FA310EA00C76A77 /* RequestError.swift */; }; 67FDC2621FA310EA00C76A77 /* RequestError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67FDC25E1FA310EA00C76A77 /* RequestError.swift */; }; + 825F8F2820B3384C00594857 /* PaginationWrapperUIDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 825F8F2720B3384C00594857 /* PaginationWrapperUIDelegate.swift */; }; 82F8BB181F5DDED100C1061B /* Single+DeferredJust.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82F8BB171F5DDED100C1061B /* Single+DeferredJust.swift */; }; A658E54D1F8CD7790093527A /* TableRow+SeparatorsExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = A658E54C1F8CD7790093527A /* TableRow+SeparatorsExtensions.swift */; }; A658E54E1F8CD7790093527A /* TableRow+SeparatorsExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = A658E54C1F8CD7790093527A /* TableRow+SeparatorsExtensions.swift */; }; @@ -717,7 +718,7 @@ 6771DFE91EEA7CB8002DCDAE /* DateFormattingService+MappingTransform.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "DateFormattingService+MappingTransform.swift"; sourceTree = ""; }; 67745267206249360024EEEF /* UITableView+PaginationWrappable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITableView+PaginationWrappable.swift"; sourceTree = ""; }; 6774526B206249E30024EEEF /* UICollectionView+PaginationWrappable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UICollectionView+PaginationWrappable.swift"; sourceTree = ""; }; - 6774526F20624A2A0024EEEF /* PaginationWrapperDelegate+DefaultImplementation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PaginationWrapperDelegate+DefaultImplementation.swift"; sourceTree = ""; }; + 6774526F20624A2A0024EEEF /* PaginationWrapperUIDelegate+DefaultImplementation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PaginationWrapperUIDelegate+DefaultImplementation.swift"; sourceTree = ""; }; 6774527320624E820024EEEF /* DataLoadingModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataLoadingModel.swift; sourceTree = ""; }; 67745278206252020024EEEF /* DataLoadingState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataLoadingState.swift; sourceTree = ""; }; 6774527F206256A20024EEEF /* RxDataLoadingModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RxDataLoadingModel.swift; sourceTree = ""; }; @@ -768,6 +769,7 @@ 67FD4381206BD24B005B0C64 /* EqutableOptionalArray.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EqutableOptionalArray.swift; sourceTree = ""; }; 67FDC25E1FA310EA00C76A77 /* RequestError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestError.swift; sourceTree = ""; }; 78405D3B3D3C3E17456877FF /* Pods_LeadKit_iOSTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_LeadKit_iOSTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 825F8F2720B3384C00594857 /* PaginationWrapperUIDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaginationWrapperUIDelegate.swift; sourceTree = ""; }; 82F8BB171F5DDED100C1061B /* Single+DeferredJust.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Single+DeferredJust.swift"; sourceTree = ""; }; 8590CA7831555C295C5DC572 /* Pods_LeadKit_LeadKit_watchOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_LeadKit_LeadKit_watchOS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 887F99C5326BD220C2811BD6 /* Pods_LeadKit_LeadKit_iOS_Extensions.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_LeadKit_LeadKit_iOS_Extensions.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -1465,7 +1467,7 @@ 67745266206248F00024EEEF /* PaginationDataLoading */ = { isa = PBXGroup; children = ( - 6774526F20624A2A0024EEEF /* PaginationWrapperDelegate+DefaultImplementation.swift */, + 6774526F20624A2A0024EEEF /* PaginationWrapperUIDelegate+DefaultImplementation.swift */, 6774526B206249E30024EEEF /* UICollectionView+PaginationWrappable.swift */, 67745267206249360024EEEF /* UITableView+PaginationWrappable.swift */, ); @@ -1544,6 +1546,7 @@ children = ( 67EB7FFC206176C900BDD9FB /* AnyPaginationWrappable.swift */, 67EB8000206177D600BDD9FB /* PaginationWrapperDelegate.swift */, + 825F8F2720B3384C00594857 /* PaginationWrapperUIDelegate.swift */, ); path = PaginationDataLoading; sourceTree = ""; @@ -2591,6 +2594,7 @@ 67EB8001206177D600BDD9FB /* PaginationWrapperDelegate.swift in Sources */, 67FD4382206BD24B005B0C64 /* EqutableOptionalArray.swift in Sources */, 6774529A20625E5B0024EEEF /* PaginationDataLoadingState.swift in Sources */, + 825F8F2820B3384C00594857 /* PaginationWrapperUIDelegate.swift in Sources */, 678D26A020692BFF00B05B93 /* TextFieldViewEvents.swift in Sources */, 6727478F206CD88600725163 /* DateFormattingService.swift in Sources */, 678D26A420692BFF00B05B93 /* TextFieldViewModelEvents.swift in Sources */, @@ -2690,7 +2694,7 @@ 671463981EB3396E00EAB194 /* AnyLoadingIndicator.swift in Sources */, 671463A71EB340C000EAB194 /* UIViewController+ConfigurableController.swift in Sources */, 671463141EB3396E00EAB194 /* UIViewController+TopVisibleViewController.swift in Sources */, - 6774527020624A2A0024EEEF /* PaginationWrapperDelegate+DefaultImplementation.swift in Sources */, + 6774527020624A2A0024EEEF /* PaginationWrapperUIDelegate+DefaultImplementation.swift in Sources */, 6727478A206CD83600725163 /* DateFormat.swift in Sources */, 67745280206256A20024EEEF /* RxDataLoadingModel.swift in Sources */, A6F32C081F6EBDAA00AC08EE /* String+LocalizedComponent.swift in Sources */, diff --git a/Sources/Classes/DataLoading/PaginationDataLoading/PaginationWrapper.swift b/Sources/Classes/DataLoading/PaginationDataLoading/PaginationWrapper.swift index e222f183..9411263b 100644 --- a/Sources/Classes/DataLoading/PaginationDataLoading/PaginationWrapper.swift +++ b/Sources/Classes/DataLoading/PaginationDataLoading/PaginationWrapper.swift @@ -25,7 +25,9 @@ import RxCocoa import UIScrollView_InfiniteScroll /// Class that connects PaginationDataLoadingModel with UIScrollView. It handles all non-visual and visual states. -final public class PaginationWrapper +final public class PaginationWrapper // "Segmentation fault: 11" in Xcode 9.2 without redundant same-type constraint :( where Cursor == Delegate.DataSourceType, Cursor.ResultType == [Cursor.Element] { @@ -36,6 +38,7 @@ final public class PaginationWrapper UIView { return TextPlaceholderView(title: .empty) @@ -68,14 +68,4 @@ public extension PaginationWrapperDelegate { func footerRetryButtonWillDisappear() { // by default - nothing will happen } - -} - -public extension PaginationWrapperDelegate - where DataSourceType: ResettableRxDataSourceCursor, - DataSourceType.ResultType == [DataSourceType.Element] { - - /// Convenient typealias. - typealias PaginationWrapperType = PaginationWrapper - } diff --git a/Sources/Structures/DataLoading/PaginationDataLoading/PaginationWrapperDelegate.swift b/Sources/Structures/DataLoading/PaginationDataLoading/PaginationWrapperDelegate.swift index 97f181d6..a372e74d 100644 --- a/Sources/Structures/DataLoading/PaginationDataLoading/PaginationWrapperDelegate.swift +++ b/Sources/Structures/DataLoading/PaginationDataLoading/PaginationWrapperDelegate.swift @@ -42,56 +42,6 @@ public protocol PaginationWrapperDelegate: class { func paginationWrapper(didReload allItems: DataSourceType.ResultType, using dataSource: DataSourceType) - /// Returns placeholder view for empty state. - /// - /// - Returns: Configured instace of UIView. - func emptyPlaceholder() -> UIView - - /// Called when initial loading error is occured. - /// It should return true if error is handled and false if it doesn't. - /// - /// - Parameters: - /// - error: Error that occured due data loading. - /// - Returns: Bool value. If true - then error placeholder wouldn't be shown. - func customInitialLoadingErrorHandling(for error: Error) -> Bool - - /// Returns placeholder view for error state. - /// - /// - Parameters: - /// - error: Error that occured due data loading. - /// - Returns: Configured instace of UIView. - func errorPlaceholder(for error: Error) -> UIView - - /// Returns loading idicator for initial loading state. - /// This indicator will appear at center of the placeholders container. - /// - /// - Returns: Configured instace of AnyLoadingIndicator. - func initialLoadingIndicator() -> AnyLoadingIndicator - - /// Returns loading idicator for initial loading state. - /// - /// - Returns: Configured instace of AnyLoadingIndicator. - func loadingMoreIndicator() -> AnyLoadingIndicator - - /// Returns instance of UIButton for "retry load more" action. - /// - /// - Returns: Configured instace of AnyLoadingIndicator. - func footerRetryButton() -> UIButton - - /// Returns height for "retry load more" button. - /// - /// - Returns: Height of "retry load more" button. - func footerRetryButtonHeight() -> 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() - - /// Method is called before "retry load more" will be hidden. - /// Typically, it's used when you need to hide custom footer view. - func footerRetryButtonWillDisappear() - /// Clears view when placeholder is shown. func clearView() - } diff --git a/Sources/Structures/DataLoading/PaginationDataLoading/PaginationWrapperUIDelegate.swift b/Sources/Structures/DataLoading/PaginationDataLoading/PaginationWrapperUIDelegate.swift new file mode 100644 index 00000000..c3c32093 --- /dev/null +++ b/Sources/Structures/DataLoading/PaginationDataLoading/PaginationWrapperUIDelegate.swift @@ -0,0 +1,73 @@ +// +// Copyright (c) 2018 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. +// + +public protocol PaginationWrapperUIDelegate: class { + + /// Returns placeholder view for empty state. + /// + /// - Returns: Configured instace of UIView. + func emptyPlaceholder() -> UIView? + + /// Called when initial loading error is occured. + /// It should return true if error is handled and false if it doesn't. + /// + /// - Parameters: + /// - error: Error that occured due data loading. + /// - Returns: Bool value. If true - then error placeholder wouldn't be shown. + func customInitialLoadingErrorHandling(for error: Error) -> Bool + + /// Returns placeholder view for error state. + /// + /// - Parameters: + /// - error: Error that occured due data loading. + /// - Returns: Configured instace of UIView. + func errorPlaceholder(for error: Error) -> UIView? + + /// Returns loading idicator for initial loading state. + /// This indicator will appear at center of the placeholders container. + /// + /// - Returns: Configured instace of AnyLoadingIndicator. + func initialLoadingIndicator() -> AnyLoadingIndicator? + + /// Returns loading idicator for initial loading state. + /// + /// - Returns: Configured instace of AnyLoadingIndicator. + func loadingMoreIndicator() -> AnyLoadingIndicator? + + /// Returns instance of UIButton for "retry load more" action. + /// + /// - Returns: Configured instace of AnyLoadingIndicator. + func footerRetryButton() -> UIButton? + + /// Returns height for "retry load more" button. + /// + /// - Returns: Height of "retry load more" button. + func footerRetryButtonHeight() -> 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() + + /// Method is called before "retry load more" will be hidden. + /// Typically, it's used when you need to hide custom footer view. + func footerRetryButtonWillDisappear() +} From a6ce1288baad3c9c62322970450100af7c4ce9ce Mon Sep 17 00:00:00 2001 From: Pavel Lukandiy Date: Mon, 21 May 2018 20:44:51 +0300 Subject: [PATCH 07/18] Removed UI delegate generic --- .../PaginationDataLoading/PaginationWrapper.swift | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Sources/Classes/DataLoading/PaginationDataLoading/PaginationWrapper.swift b/Sources/Classes/DataLoading/PaginationDataLoading/PaginationWrapper.swift index 9411263b..7e9792d4 100644 --- a/Sources/Classes/DataLoading/PaginationDataLoading/PaginationWrapper.swift +++ b/Sources/Classes/DataLoading/PaginationDataLoading/PaginationWrapper.swift @@ -25,9 +25,7 @@ import RxCocoa import UIScrollView_InfiniteScroll /// Class that connects PaginationDataLoadingModel with UIScrollView. It handles all non-visual and visual states. -final public class PaginationWrapper +final public class PaginationWrapper // "Segmentation fault: 11" in Xcode 9.2 without redundant same-type constraint :( where Cursor == Delegate.DataSourceType, Cursor.ResultType == [Cursor.Element] { @@ -38,7 +36,7 @@ final public class PaginationWrapper Date: Mon, 21 May 2018 21:09:56 +0300 Subject: [PATCH 08/18] Refactor and fix annotations --- .../PaginationDataLoading/PaginationWrapper.swift | 7 +++---- .../PaginationDataLoading/PaginationWrapperDelegate.swift | 7 +++---- .../PaginationWrapperUIDelegate.swift | 2 ++ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Sources/Classes/DataLoading/PaginationDataLoading/PaginationWrapper.swift b/Sources/Classes/DataLoading/PaginationDataLoading/PaginationWrapper.swift index 7e9792d4..a804d3a3 100644 --- a/Sources/Classes/DataLoading/PaginationDataLoading/PaginationWrapper.swift +++ b/Sources/Classes/DataLoading/PaginationDataLoading/PaginationWrapper.swift @@ -177,15 +177,14 @@ final public class PaginationWrapper Date: Mon, 21 May 2018 21:16:49 +0300 Subject: [PATCH 09/18] Version up --- CHANGELOG.md | 3 +++ LeadKit.podspec | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a16894f3..827cf0d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +### 0.7.14 +- **Update**: `PaginationWrapper` separating state views from data loading. + ### 0.7.13 - **Update**: Migrate from `Variable` to `BehaviorRelay`. - **Fix**: `PaginationWrapper` retry load more after fail. diff --git a/LeadKit.podspec b/LeadKit.podspec index b7b6206d..0a91f9db 100644 --- a/LeadKit.podspec +++ b/LeadKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "LeadKit" - s.version = "0.7.13" + s.version = "0.7.14" 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" From c49a05270f875c41f44642c98ed56cf937f51db2 Mon Sep 17 00:00:00 2001 From: Pavel Lukandiy Date: Mon, 21 May 2018 21:18:10 +0300 Subject: [PATCH 10/18] UI delegate default parameter --- .../DataLoading/PaginationDataLoading/PaginationWrapper.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Classes/DataLoading/PaginationDataLoading/PaginationWrapper.swift b/Sources/Classes/DataLoading/PaginationDataLoading/PaginationWrapper.swift index a804d3a3..9a206fa9 100644 --- a/Sources/Classes/DataLoading/PaginationDataLoading/PaginationWrapper.swift +++ b/Sources/Classes/DataLoading/PaginationDataLoading/PaginationWrapper.swift @@ -76,7 +76,7 @@ final public class PaginationWrapper Date: Tue, 22 May 2018 14:03:40 +0300 Subject: [PATCH 11/18] Review notes --- CHANGELOG.md | 2 +- .../PaginationDataLoading/PaginationWrapperDelegate.swift | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 827cf0d5..44a1875c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Changelog ### 0.7.14 -- **Update**: `PaginationWrapper` separating state views from data loading. +- **[Breaking Change]**: `PaginationWrapper` separating state views from data loading. ### 0.7.13 - **Update**: Migrate from `Variable` to `BehaviorRelay`. diff --git a/Sources/Structures/DataLoading/PaginationDataLoading/PaginationWrapperDelegate.swift b/Sources/Structures/DataLoading/PaginationDataLoading/PaginationWrapperDelegate.swift index c33bde08..8ee35da1 100644 --- a/Sources/Structures/DataLoading/PaginationDataLoading/PaginationWrapperDelegate.swift +++ b/Sources/Structures/DataLoading/PaginationDataLoading/PaginationWrapperDelegate.swift @@ -44,3 +44,11 @@ public protocol PaginationWrapperDelegate: class { /// Handles empty data state. func clearData() } + +public extension PaginationWrapperDelegate + where DataSourceType: ResettableRxDataSourceCursor, + DataSourceType.ResultType == [DataSourceType.Element] { + + /// Convenient typealias. + typealias PaginationWrapperType = PaginationWrapper +} From e3e060eda4a454313051aee8a0b34fcd9ec73e92 Mon Sep 17 00:00:00 2001 From: Igor Kislyuk Date: Tue, 22 May 2018 14:18:32 +0300 Subject: [PATCH 12/18] Update for new flow --- LeadKit.podspec | 2 +- LeadKit.xcodeproj/project.pbxproj | 10 ------- .../Protocols/ConfigurableController.swift | 2 +- Sources/Protocols/ModuleConfigurator.swift | 28 ------------------- 4 files changed, 2 insertions(+), 40 deletions(-) delete mode 100644 Sources/Protocols/ModuleConfigurator.swift diff --git a/LeadKit.podspec b/LeadKit.podspec index b7b6206d..0a91f9db 100644 --- a/LeadKit.podspec +++ b/LeadKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "LeadKit" - s.version = "0.7.13" + s.version = "0.7.14" 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 e7db21a3..4ce881b9 100644 --- a/LeadKit.xcodeproj/project.pbxproj +++ b/LeadKit.xcodeproj/project.pbxproj @@ -159,10 +159,6 @@ 6714633C1EB3396E00EAB194 /* LoadingIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 671462281EB3396E00EAB194 /* LoadingIndicator.swift */; }; 6714633D1EB3396E00EAB194 /* LoadingIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 671462281EB3396E00EAB194 /* LoadingIndicator.swift */; }; 6714633F1EB3396E00EAB194 /* LoadingIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 671462281EB3396E00EAB194 /* LoadingIndicator.swift */; }; - 671463401EB3396E00EAB194 /* ModuleConfigurator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 671462291EB3396E00EAB194 /* ModuleConfigurator.swift */; }; - 671463411EB3396E00EAB194 /* ModuleConfigurator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 671462291EB3396E00EAB194 /* ModuleConfigurator.swift */; }; - 671463421EB3396E00EAB194 /* ModuleConfigurator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 671462291EB3396E00EAB194 /* ModuleConfigurator.swift */; }; - 671463431EB3396E00EAB194 /* ModuleConfigurator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 671462291EB3396E00EAB194 /* ModuleConfigurator.swift */; }; 671463481EB3396E00EAB194 /* ResettableType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6714622B1EB3396E00EAB194 /* ResettableType.swift */; }; 671463491EB3396E00EAB194 /* ResettableType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6714622B1EB3396E00EAB194 /* ResettableType.swift */; }; 6714634A1EB3396E00EAB194 /* ResettableType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6714622B1EB3396E00EAB194 /* ResettableType.swift */; }; @@ -655,7 +651,6 @@ 671462251EB3396E00EAB194 /* CursorType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CursorType.swift; sourceTree = ""; }; 671462261EB3396E00EAB194 /* DrawingOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DrawingOperation.swift; sourceTree = ""; }; 671462281EB3396E00EAB194 /* LoadingIndicator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoadingIndicator.swift; sourceTree = ""; }; - 671462291EB3396E00EAB194 /* ModuleConfigurator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ModuleConfigurator.swift; sourceTree = ""; }; 6714622B1EB3396E00EAB194 /* ResettableType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ResettableType.swift; sourceTree = ""; }; 6714622C1EB3396E00EAB194 /* ReuseIdentifierProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReuseIdentifierProtocol.swift; sourceTree = ""; }; 6714622E1EB3396E00EAB194 /* StaticViewHeightProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StaticViewHeightProtocol.swift; sourceTree = ""; }; @@ -1153,7 +1148,6 @@ 67274783206CD7E500725163 /* DateFormatingService */, 672947E3206EA63200AC6B6B /* Drawing */, 671462281EB3396E00EAB194 /* LoadingIndicator.swift */, - 671462291EB3396E00EAB194 /* ModuleConfigurator.swift */, 67C7B1772068BADA00C9EDA3 /* NumberFormattingService */, A676AE541F981121001F9214 /* ObservableMappable.swift */, 6714622B1EB3396E00EAB194 /* ResettableType.swift */, @@ -2610,7 +2604,6 @@ 671463101EB3396E00EAB194 /* UIViewController+DefaultXibName.swift in Sources */, 67386A8C206CF3F6004EDA6C /* DateFormattingService+DefaultImplementation.swift in Sources */, 674AF55C1EC45B1600038A8F /* UIActivityIndicatorView+LoadingIndicator.swift in Sources */, - 671463401EB3396E00EAB194 /* ModuleConfigurator.swift in Sources */, 67A1FF8F1EBCA09B00D6C89F /* UIImage+Spinner.swift in Sources */, 673564F62068C68D00F0CBED /* NumberFormat.swift in Sources */, EFA4C66420864F9C008C4DD8 /* UniversalMappable.swift in Sources */, @@ -2783,7 +2776,6 @@ 6714626A1EB3396E00EAB194 /* NetworkService.swift in Sources */, 671AD26E206A3E8500EAF887 /* Array+TotalCountCursorListingResult.swift in Sources */, 673CF4132063ABD100C329F6 /* GeneralDataLoadingState+Extensions.swift in Sources */, - 671463421EB3396E00EAB194 /* ModuleConfigurator.swift in Sources */, 671462921EB3396E00EAB194 /* CGImage+Crop.swift in Sources */, 671463861EB3396E00EAB194 /* ResizeDrawingOperation.swift in Sources */, 671463921EB3396E00EAB194 /* TemplateDrawingOperation.swift in Sources */, @@ -2885,7 +2877,6 @@ 6714626B1EB3396E00EAB194 /* NetworkService.swift in Sources */, 673CF43A2063E7CE00C329F6 /* GeneralDataLoadingController+DefaultImplementation.swift in Sources */, 671463131EB3396E00EAB194 /* UIViewController+DefaultXibName.swift in Sources */, - 671463431EB3396E00EAB194 /* ModuleConfigurator.swift in Sources */, 671462931EB3396E00EAB194 /* CGImage+Crop.swift in Sources */, 6727477A206CD0B500725163 /* UILabel+ViewTextConfiguration.swift in Sources */, 67EB7FE720615DE000BDD9FB /* DataSource.swift in Sources */, @@ -3047,7 +3038,6 @@ 671462F11EB3396E00EAB194 /* UIImage+SupportExtensions.swift in Sources */, 671462691EB3396E00EAB194 /* NetworkService.swift in Sources */, 671463111EB3396E00EAB194 /* UIViewController+DefaultXibName.swift in Sources */, - 671463411EB3396E00EAB194 /* ModuleConfigurator.swift in Sources */, EFA4C67020865126008C4DD8 /* UniversalMappable+SwiftStandard.swift in Sources */, 67153E41207DFBA80049D8C0 /* FloatingPoint+DegreesRadiansConvertion.swift in Sources */, 671462911EB3396E00EAB194 /* CGImage+Crop.swift in Sources */, diff --git a/Sources/Protocols/ConfigurableController.swift b/Sources/Protocols/ConfigurableController.swift index fd14a19b..9190f9db 100644 --- a/Sources/Protocols/ConfigurableController.swift +++ b/Sources/Protocols/ConfigurableController.swift @@ -26,7 +26,7 @@ public protocol ConfigurableController { associatedtype ViewModelT - var viewModel: ViewModelT! { get } + var viewModel: ViewModelT { get } func bindViews() diff --git a/Sources/Protocols/ModuleConfigurator.swift b/Sources/Protocols/ModuleConfigurator.swift deleted file mode 100644 index ea59b916..00000000 --- a/Sources/Protocols/ModuleConfigurator.swift +++ /dev/null @@ -1,28 +0,0 @@ -// -// Copyright (c) 2017 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. -// - -public protocol ModuleConfigurator { - - associatedtype ViewControllerT - - func configure(input: ViewControllerT) -} From d7d62a6ee826459c0967d152b2fa128746ed653b Mon Sep 17 00:00:00 2001 From: Igor Kislyuk Date: Tue, 22 May 2018 14:46:12 +0300 Subject: [PATCH 13/18] Update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a16894f3..4d3e53de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +### 0.7.14 +- **[Breaking Chnage]**: Remove `ModuleConfigurator`, change type of `ConfigurableController.viewModel` property from `IUO` to plain `ViewModelT`. + ### 0.7.13 - **Update**: Migrate from `Variable` to `BehaviorRelay`. - **Fix**: `PaginationWrapper` retry load more after fail. From a9536d3cff154e90fd688861f5f6c275e340e688 Mon Sep 17 00:00:00 2001 From: Pavel Lukandiy Date: Tue, 22 May 2018 14:54:18 +0300 Subject: [PATCH 14/18] Targets fix --- LeadKit.xcodeproj/project.pbxproj | 8 ++--- ...rapperDelegate+DefaultImplementation.swift | 29 +++++++++++++++++++ .../PaginationWrapperDelegate.swift | 8 ----- 3 files changed, 33 insertions(+), 12 deletions(-) create mode 100644 Sources/Extensions/DataLoading/PaginationDataLoading/PaginationWrapperDelegate+DefaultImplementation.swift diff --git a/LeadKit.xcodeproj/project.pbxproj b/LeadKit.xcodeproj/project.pbxproj index f0163709..f7430027 100644 --- a/LeadKit.xcodeproj/project.pbxproj +++ b/LeadKit.xcodeproj/project.pbxproj @@ -493,8 +493,6 @@ 67EB7FFE206176C900BDD9FB /* AnyPaginationWrappable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67EB7FFC206176C900BDD9FB /* AnyPaginationWrappable.swift */; }; 67EB7FFF206176C900BDD9FB /* AnyPaginationWrappable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67EB7FFC206176C900BDD9FB /* AnyPaginationWrappable.swift */; }; 67EB8001206177D600BDD9FB /* PaginationWrapperDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67EB8000206177D600BDD9FB /* PaginationWrapperDelegate.swift */; }; - 67EB8002206177D600BDD9FB /* PaginationWrapperDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67EB8000206177D600BDD9FB /* PaginationWrapperDelegate.swift */; }; - 67EB8003206177D600BDD9FB /* PaginationWrapperDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67EB8000206177D600BDD9FB /* PaginationWrapperDelegate.swift */; }; 67FD4382206BD24B005B0C64 /* EqutableOptionalArray.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67FD4381206BD24B005B0C64 /* EqutableOptionalArray.swift */; }; 67FD4383206BD24B005B0C64 /* EqutableOptionalArray.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67FD4381206BD24B005B0C64 /* EqutableOptionalArray.swift */; }; 67FD4384206BD24B005B0C64 /* EqutableOptionalArray.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67FD4381206BD24B005B0C64 /* EqutableOptionalArray.swift */; }; @@ -503,6 +501,7 @@ 67FDC2601FA310EA00C76A77 /* RequestError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67FDC25E1FA310EA00C76A77 /* RequestError.swift */; }; 67FDC2611FA310EA00C76A77 /* RequestError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67FDC25E1FA310EA00C76A77 /* RequestError.swift */; }; 67FDC2621FA310EA00C76A77 /* RequestError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67FDC25E1FA310EA00C76A77 /* RequestError.swift */; }; + 820CAD8420B43B080033EF94 /* PaginationWrapperDelegate+DefaultImplementation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 820CAD8320B43B080033EF94 /* PaginationWrapperDelegate+DefaultImplementation.swift */; }; 825F8F2820B3384C00594857 /* PaginationWrapperUIDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 825F8F2720B3384C00594857 /* PaginationWrapperUIDelegate.swift */; }; 82F8BB181F5DDED100C1061B /* Single+DeferredJust.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82F8BB171F5DDED100C1061B /* Single+DeferredJust.swift */; }; A658E54D1F8CD7790093527A /* TableRow+SeparatorsExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = A658E54C1F8CD7790093527A /* TableRow+SeparatorsExtensions.swift */; }; @@ -769,6 +768,7 @@ 67FD4381206BD24B005B0C64 /* EqutableOptionalArray.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EqutableOptionalArray.swift; sourceTree = ""; }; 67FDC25E1FA310EA00C76A77 /* RequestError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestError.swift; sourceTree = ""; }; 78405D3B3D3C3E17456877FF /* Pods_LeadKit_iOSTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_LeadKit_iOSTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 820CAD8320B43B080033EF94 /* PaginationWrapperDelegate+DefaultImplementation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PaginationWrapperDelegate+DefaultImplementation.swift"; sourceTree = ""; }; 825F8F2720B3384C00594857 /* PaginationWrapperUIDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaginationWrapperUIDelegate.swift; sourceTree = ""; }; 82F8BB171F5DDED100C1061B /* Single+DeferredJust.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Single+DeferredJust.swift"; sourceTree = ""; }; 8590CA7831555C295C5DC572 /* Pods_LeadKit_LeadKit_watchOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_LeadKit_LeadKit_watchOS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -1468,6 +1468,7 @@ isa = PBXGroup; children = ( 6774526F20624A2A0024EEEF /* PaginationWrapperUIDelegate+DefaultImplementation.swift */, + 820CAD8320B43B080033EF94 /* PaginationWrapperDelegate+DefaultImplementation.swift */, 6774526B206249E30024EEEF /* UICollectionView+PaginationWrappable.swift */, 67745267206249360024EEEF /* UITableView+PaginationWrappable.swift */, ); @@ -2720,6 +2721,7 @@ 6714628C1EB3396E00EAB194 /* CGImage+Alpha.swift in Sources */, 671462741EB3396E00EAB194 /* LeadKitError.swift in Sources */, 677452A420625FA90024EEEF /* RxDataSource.swift in Sources */, + 820CAD8420B43B080033EF94 /* PaginationWrapperDelegate+DefaultImplementation.swift in Sources */, 671AD262206A35EC00EAF887 /* UIApplication+Cellular.swift in Sources */, 671462D81EB3396E00EAB194 /* TimeInterval+DateComponents.swift in Sources */, 6714638C1EB3396E00EAB194 /* SolidFillDrawingOperation.swift in Sources */, @@ -2880,7 +2882,6 @@ 678D26A320692BFF00B05B93 /* TextFieldViewEvents.swift in Sources */, 67153E43207DFBA80049D8C0 /* FloatingPoint+DegreesRadiansConvertion.swift in Sources */, 67745283206256A20024EEEF /* RxDataLoadingModel.swift in Sources */, - 67EB8003206177D600BDD9FB /* PaginationWrapperDelegate.swift in Sources */, 671463571EB3396E00EAB194 /* StaticViewHeightProtocol.swift in Sources */, 671463631EB3396E00EAB194 /* SupportProtocol.swift in Sources */, 671462871EB3396E00EAB194 /* CGContext+Initializers.swift in Sources */, @@ -3085,7 +3086,6 @@ 6774526D206249E30024EEEF /* UICollectionView+PaginationWrappable.swift in Sources */, 6714627D1EB3396E00EAB194 /* AlamofireManager+Extensions.swift in Sources */, 673CF4352063E29B00C329F6 /* TextWithButtonPlaceholder.swift in Sources */, - 67EB8002206177D600BDD9FB /* PaginationWrapperDelegate.swift in Sources */, 6727476F206CCDDB00725163 /* ViewBackground+Configuration.swift in Sources */, 673CF4232063D90600C329F6 /* DisposeBagHolder.swift in Sources */, 677452AA206263360024EEEF /* CursorType+RxDataSourceDefaultImplementation.swift in Sources */, diff --git a/Sources/Extensions/DataLoading/PaginationDataLoading/PaginationWrapperDelegate+DefaultImplementation.swift b/Sources/Extensions/DataLoading/PaginationDataLoading/PaginationWrapperDelegate+DefaultImplementation.swift new file mode 100644 index 00000000..7e11893f --- /dev/null +++ b/Sources/Extensions/DataLoading/PaginationDataLoading/PaginationWrapperDelegate+DefaultImplementation.swift @@ -0,0 +1,29 @@ +// +// Copyright (c) 2018 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. +// + +public extension PaginationWrapperDelegate + where DataSourceType: ResettableRxDataSourceCursor, + DataSourceType.ResultType == [DataSourceType.Element] { + + /// Convenient typealias. + typealias PaginationWrapperType = PaginationWrapper +} diff --git a/Sources/Structures/DataLoading/PaginationDataLoading/PaginationWrapperDelegate.swift b/Sources/Structures/DataLoading/PaginationDataLoading/PaginationWrapperDelegate.swift index 8ee35da1..c33bde08 100644 --- a/Sources/Structures/DataLoading/PaginationDataLoading/PaginationWrapperDelegate.swift +++ b/Sources/Structures/DataLoading/PaginationDataLoading/PaginationWrapperDelegate.swift @@ -44,11 +44,3 @@ public protocol PaginationWrapperDelegate: class { /// Handles empty data state. func clearData() } - -public extension PaginationWrapperDelegate - where DataSourceType: ResettableRxDataSourceCursor, - DataSourceType.ResultType == [DataSourceType.Element] { - - /// Convenient typealias. - typealias PaginationWrapperType = PaginationWrapper -} From 11d529f4c05cee85b7fc369800a8d908f28f9622 Mon Sep 17 00:00:00 2001 From: Ivan Smolin Date: Tue, 22 May 2018 16:20:04 +0300 Subject: [PATCH 15/18] InitializableView --- CHANGELOG.md | 5 +- LeadKit.xcodeproj/project.pbxproj | 20 ++++++++ ...dingController+DefaultImplementation.swift | 2 +- ...iewController+ConfigurableController.swift | 18 +------ ...tializableView+DefaultImplementation.swift | 48 +++++++++++++++++++ .../Protocols/ConfigurableController.swift | 10 +--- .../Protocols/Views/InitializableView.swift | 41 ++++++++++++++++ 7 files changed, 116 insertions(+), 28 deletions(-) create mode 100644 Sources/Extensions/Views/InitializableView+DefaultImplementation.swift create mode 100644 Sources/Protocols/Views/InitializableView.swift diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d3e53de..d092f692 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,10 @@ # Changelog ### 0.7.14 -- **[Breaking Chnage]**: Remove `ModuleConfigurator`, change type of `ConfigurableController.viewModel` property from `IUO` to plain `ViewModelT`. +- **[Breaking change]**: Remove `ModuleConfigurator`, change type of `ConfigurableController.viewModel` property from `IUO` to plain `ViewModelT`. +- **Add**: `InitializableView` protocol with default implementation. +- **Update**: `ConfigurableController` protocol now inherit `InitializableView`. +- **[Breaking change]**: `setAppearance` of `ConfigurableController` replaced with `configureAppearance` of `InitializableView`. ### 0.7.13 - **Update**: Migrate from `Variable` to `BehaviorRelay`. diff --git a/LeadKit.xcodeproj/project.pbxproj b/LeadKit.xcodeproj/project.pbxproj index 4ce881b9..931de683 100644 --- a/LeadKit.xcodeproj/project.pbxproj +++ b/LeadKit.xcodeproj/project.pbxproj @@ -491,6 +491,14 @@ 67EB8001206177D600BDD9FB /* PaginationWrapperDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67EB8000206177D600BDD9FB /* PaginationWrapperDelegate.swift */; }; 67EB8002206177D600BDD9FB /* PaginationWrapperDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67EB8000206177D600BDD9FB /* PaginationWrapperDelegate.swift */; }; 67EB8003206177D600BDD9FB /* PaginationWrapperDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67EB8000206177D600BDD9FB /* PaginationWrapperDelegate.swift */; }; + 67ED2BDE20B44DEB00508B3E /* InitializableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67ED2BDD20B44DEB00508B3E /* InitializableView.swift */; }; + 67ED2BDF20B44DEB00508B3E /* InitializableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67ED2BDD20B44DEB00508B3E /* InitializableView.swift */; }; + 67ED2BE020B44DEB00508B3E /* InitializableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67ED2BDD20B44DEB00508B3E /* InitializableView.swift */; }; + 67ED2BE120B44DEB00508B3E /* InitializableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67ED2BDD20B44DEB00508B3E /* InitializableView.swift */; }; + 67ED2BE520B44F4300508B3E /* InitializableView+DefaultImplementation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67ED2BE420B44F4300508B3E /* InitializableView+DefaultImplementation.swift */; }; + 67ED2BE620B44F4300508B3E /* InitializableView+DefaultImplementation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67ED2BE420B44F4300508B3E /* InitializableView+DefaultImplementation.swift */; }; + 67ED2BE720B44F4300508B3E /* InitializableView+DefaultImplementation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67ED2BE420B44F4300508B3E /* InitializableView+DefaultImplementation.swift */; }; + 67ED2BE820B44F4300508B3E /* InitializableView+DefaultImplementation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67ED2BE420B44F4300508B3E /* InitializableView+DefaultImplementation.swift */; }; 67FD4382206BD24B005B0C64 /* EqutableOptionalArray.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67FD4381206BD24B005B0C64 /* EqutableOptionalArray.swift */; }; 67FD4383206BD24B005B0C64 /* EqutableOptionalArray.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67FD4381206BD24B005B0C64 /* EqutableOptionalArray.swift */; }; 67FD4384206BD24B005B0C64 /* EqutableOptionalArray.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67FD4381206BD24B005B0C64 /* EqutableOptionalArray.swift */; }; @@ -760,6 +768,8 @@ 67EB7FF7206175F700BDD9FB /* PaginationWrappable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaginationWrappable.swift; sourceTree = ""; }; 67EB7FFC206176C900BDD9FB /* AnyPaginationWrappable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnyPaginationWrappable.swift; sourceTree = ""; }; 67EB8000206177D600BDD9FB /* PaginationWrapperDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaginationWrapperDelegate.swift; sourceTree = ""; }; + 67ED2BDD20B44DEB00508B3E /* InitializableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InitializableView.swift; sourceTree = ""; }; + 67ED2BE420B44F4300508B3E /* InitializableView+DefaultImplementation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "InitializableView+DefaultImplementation.swift"; sourceTree = ""; }; 67FD4381206BD24B005B0C64 /* EqutableOptionalArray.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EqutableOptionalArray.swift; sourceTree = ""; }; 67FDC25E1FA310EA00C76A77 /* RequestError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestError.swift; sourceTree = ""; }; 78405D3B3D3C3E17456877FF /* Pods_LeadKit_iOSTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_LeadKit_iOSTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -1306,6 +1316,7 @@ isa = PBXGroup; children = ( 6792623A206EB0D800308E62 /* SeparatorCell */, + 67ED2BE420B44F4300508B3E /* InitializableView+DefaultImplementation.swift */, 6727476D206CCDDB00725163 /* ViewBackground+Configuration.swift */, 6727477E206CD3BD00725163 /* ViewText+Extensions.swift */, ); @@ -1556,6 +1567,7 @@ children = ( 67926234206EB08400308E62 /* SeparatorCell */, 678D269D20692BFF00B05B93 /* TextField */, + 67ED2BDD20B44DEB00508B3E /* InitializableView.swift */, ); path = Views; sourceTree = ""; @@ -2593,6 +2605,7 @@ 671463541EB3396E00EAB194 /* StaticViewHeightProtocol.swift in Sources */, 673CF4112063ABD100C329F6 /* GeneralDataLoadingState+Extensions.swift in Sources */, 673CF42C2063DE5900C329F6 /* TextPlaceholderView.swift in Sources */, + 67ED2BDE20B44DEB00508B3E /* InitializableView.swift in Sources */, 671463601EB3396E00EAB194 /* SupportProtocol.swift in Sources */, 671462841EB3396E00EAB194 /* CGContext+Initializers.swift in Sources */, EFBE57DB1EC361620040E00A /* UIView+Layout.swift in Sources */, @@ -2674,6 +2687,7 @@ 671463081EB3396E00EAB194 /* UIView+Rotation.swift in Sources */, 6714626C1EB3396E00EAB194 /* XibView.swift in Sources */, 67274778206CD0B500725163 /* UILabel+ViewTextConfiguration.swift in Sources */, + 67ED2BE520B44F4300508B3E /* InitializableView+DefaultImplementation.swift in Sources */, 6774529220625D170024EEEF /* GeneralDataLoadingModel.swift in Sources */, 6714637C1EB3396E00EAB194 /* ImageDrawingOperation.swift in Sources */, 671463341EB3396E00EAB194 /* DrawingOperation.swift in Sources */, @@ -2790,6 +2804,7 @@ 6714638A1EB3396E00EAB194 /* RoundDrawingOperation.swift in Sources */, 67153E3C207DFADA0049D8C0 /* RotateDrawingOperation.swift in Sources */, 6774529C20625E5B0024EEEF /* PaginationDataLoadingState.swift in Sources */, + 67ED2BE020B44DEB00508B3E /* InitializableView.swift in Sources */, 671463821EB3396E00EAB194 /* PaddingDrawingOperation.swift in Sources */, 6714632A1EB3396E00EAB194 /* BaseViewModel.swift in Sources */, 671462AE1EB3396E00EAB194 /* Observable+DeferredJust.swift in Sources */, @@ -2848,6 +2863,7 @@ 67FDC2611FA310EA00C76A77 /* RequestError.swift in Sources */, 671AD25E206A343300EAF887 /* VoidBlock.swift in Sources */, 671462521EB3396E00EAB194 /* StaticCursor.swift in Sources */, + 67ED2BE720B44F4300508B3E /* InitializableView+DefaultImplementation.swift in Sources */, 6714629E1EB3396E00EAB194 /* CursorType+Slice.swift in Sources */, 6714636A1EB3396E00EAB194 /* ConfigurableView.swift in Sources */, ); @@ -2859,9 +2875,11 @@ files = ( 6714634B1EB3396E00EAB194 /* ResettableType.swift in Sources */, 671462E71EB3396E00EAB194 /* UIColor+Hex.swift in Sources */, + 67ED2BE120B44DEB00508B3E /* InitializableView.swift in Sources */, 67274775206CCF1200725163 /* ViewText.swift in Sources */, 6727476B206CCCA500725163 /* ViewBackground.swift in Sources */, 671462831EB3396E00EAB194 /* AlamofireRequest+Extensions.swift in Sources */, + 67ED2BE820B44F4300508B3E /* InitializableView+DefaultImplementation.swift in Sources */, 677452B820627FE00024EEEF /* PaginationWrappable.swift in Sources */, 673CF40E2063AB7C00C329F6 /* GeneralDataLoadingViewModel.swift in Sources */, 67274770206CCDDB00725163 /* ViewBackground+Configuration.swift in Sources */, @@ -3055,6 +3073,7 @@ 67EB7FEC2061667900BDD9FB /* DefaultTotalCountCursorListingResult.swift in Sources */, 671462991EB3396E00EAB194 /* CGSize+Resize.swift in Sources */, 67274780206CD3BD00725163 /* ViewText+Extensions.swift in Sources */, + 67ED2BE620B44F4300508B3E /* InitializableView+DefaultImplementation.swift in Sources */, 671463311EB3396E00EAB194 /* CursorType.swift in Sources */, 6714624D1EB3396E00EAB194 /* MapCursor.swift in Sources */, 67EB7FD520615D1700BDD9FB /* ResettableCursorType.swift in Sources */, @@ -3083,6 +3102,7 @@ 673CF42D2063DE5900C329F6 /* TextPlaceholderView.swift in Sources */, 671462A11EB3396E00EAB194 /* Double+Rounding.swift in Sources */, 671463091EB3396E00EAB194 /* UIView+Rotation.swift in Sources */, + 67ED2BDF20B44DEB00508B3E /* InitializableView.swift in Sources */, 6714626D1EB3396E00EAB194 /* XibView.swift in Sources */, 6714637D1EB3396E00EAB194 /* ImageDrawingOperation.swift in Sources */, 671463351EB3396E00EAB194 /* DrawingOperation.swift in Sources */, diff --git a/Sources/Extensions/DataLoading/GeneralDataLoading/GeneralDataLoadingController+DefaultImplementation.swift b/Sources/Extensions/DataLoading/GeneralDataLoading/GeneralDataLoadingController+DefaultImplementation.swift index 7a970932..1c651adc 100644 --- a/Sources/Extensions/DataLoading/GeneralDataLoading/GeneralDataLoadingController+DefaultImplementation.swift +++ b/Sources/Extensions/DataLoading/GeneralDataLoading/GeneralDataLoadingController+DefaultImplementation.swift @@ -41,7 +41,7 @@ public extension GeneralDataLoadingController where Self: UIViewController { func initialLoadDataLoadingView() { addViews() - setAppearance() + configureAppearance() setupStateViews() configureBarButtons() localize() diff --git a/Sources/Extensions/UIKit/UIViewController/UIViewController+ConfigurableController.swift b/Sources/Extensions/UIKit/UIViewController/UIViewController+ConfigurableController.swift index 55a3986d..904f38e9 100644 --- a/Sources/Extensions/UIKit/UIViewController/UIViewController+ConfigurableController.swift +++ b/Sources/Extensions/UIKit/UIViewController/UIViewController+ConfigurableController.swift @@ -24,29 +24,13 @@ import UIKit public extension ConfigurableController where Self: UIViewController { - func bindViews() { - // nothing - } - - func addViews() { - // nothing - } - - func setAppearance() { - // nothing - } - func configureBarButtons() { // nothing } - func localize() { - // nothing - } - func initialLoadView() { addViews() - setAppearance() + configureAppearance() configureBarButtons() localize() bindViews() diff --git a/Sources/Extensions/Views/InitializableView+DefaultImplementation.swift b/Sources/Extensions/Views/InitializableView+DefaultImplementation.swift new file mode 100644 index 00000000..c4585978 --- /dev/null +++ b/Sources/Extensions/Views/InitializableView+DefaultImplementation.swift @@ -0,0 +1,48 @@ +// +// Copyright (c) 2018 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. +// + +public extension InitializableView { + + func initializeView() { + addViews() + bindViews() + configureAppearance() + localize() + } + + func addViews() { + // + } + + func bindViews() { + // + } + + func configureAppearance() { + // + } + + func localize() { + // + } + +} diff --git a/Sources/Protocols/ConfigurableController.swift b/Sources/Protocols/ConfigurableController.swift index 9190f9db..d4550061 100644 --- a/Sources/Protocols/ConfigurableController.swift +++ b/Sources/Protocols/ConfigurableController.swift @@ -22,22 +22,14 @@ import Foundation -public protocol ConfigurableController { +public protocol ConfigurableController: InitializableView { associatedtype ViewModelT var viewModel: ViewModelT { get } - func bindViews() - - func addViews() - - func setAppearance() - func configureBarButtons() - func localize() - func initialLoadView() } diff --git a/Sources/Protocols/Views/InitializableView.swift b/Sources/Protocols/Views/InitializableView.swift new file mode 100644 index 00000000..f5229e07 --- /dev/null +++ b/Sources/Protocols/Views/InitializableView.swift @@ -0,0 +1,41 @@ +// +// Copyright (c) 2018 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 with methods that should be called in constructor methods of view. +public protocol InitializableView { + + /// Main method that should call other in particular order. + func initializeView() + + /// Method for adding views to current view. + func addViews() + + /// Method for binding to data or user actions. + func bindViews() + + /// Appearance configuration method. + func configureAppearance() + + /// Localization method. + func localize() + +} From 62240cc59160a0c4acf1678e818ec5c798876a83 Mon Sep 17 00:00:00 2001 From: Igor Kislyuk Date: Tue, 22 May 2018 16:20:46 +0300 Subject: [PATCH 16/18] Fix typo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1643b22..2ce6f971 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Changelog ### 0.7.15 -- **[Breaking Chnage]**: Remove `ModuleConfigurator`, change type of `ConfigurableController.viewModel` property from `IUO` to plain `ViewModelT`. +- **[Breaking Change]**: Remove `ModuleConfigurator`, change type of `ConfigurableController.viewModel` property from `IUO` to plain `ViewModelT`. ### 0.7.14 - **[Breaking Change]**: `PaginationWrapper` separating state views from data loading. From 9004c5f5532d4dd4d25e19f6208e2edeb30b6be9 Mon Sep 17 00:00:00 2001 From: Igor Kislyuk Date: Tue, 22 May 2018 16:41:19 +0300 Subject: [PATCH 17/18] Update empty characters --- Sources/Extensions/Double/Double+Rounding.swift | 5 ++--- Tests/Extensions/Double+RoundingTests.swift | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Sources/Extensions/Double/Double+Rounding.swift b/Sources/Extensions/Double/Double+Rounding.swift index 88f275ff..9cb3d3e5 100644 --- a/Sources/Extensions/Double/Double+Rounding.swift +++ b/Sources/Extensions/Double/Double+Rounding.swift @@ -44,7 +44,7 @@ public extension Double { func roundValue(withPrecision precision: UInt, roundType: RoundingType = .normal) -> Double { let divider = pow(10.0, Double(precision)) - + switch roundType { case .normal: return (self * divider).rounded(.toNearestOrEven) / divider @@ -52,6 +52,5 @@ public extension Double { return (self * divider).rounded(.down) / divider } } - -} +} diff --git a/Tests/Extensions/Double+RoundingTests.swift b/Tests/Extensions/Double+RoundingTests.swift index f77d732c..13de970a 100644 --- a/Tests/Extensions/Double+RoundingTests.swift +++ b/Tests/Extensions/Double+RoundingTests.swift @@ -19,6 +19,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // + import XCTest class Double_RoundingTests: XCTestCase { @@ -50,5 +51,4 @@ class Double_RoundingTests: XCTestCase { XCTAssertTrue(some.roundValue(withPrecision: 1, roundType: .down) == -1.8) XCTAssertTrue(some.roundValue(withPrecision: 2, roundType: .down) == -1.78) } - } From 53c9e23b21838ae325e4a8c89a674884cc2adb76 Mon Sep 17 00:00:00 2001 From: Igor Kislyuk Date: Tue, 22 May 2018 16:47:17 +0300 Subject: [PATCH 18/18] Remove empty lines --- Sources/Extensions/Double/Double+Rounding.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/Sources/Extensions/Double/Double+Rounding.swift b/Sources/Extensions/Double/Double+Rounding.swift index 9cb3d3e5..f6f9d54a 100644 --- a/Sources/Extensions/Double/Double+Rounding.swift +++ b/Sources/Extensions/Double/Double+Rounding.swift @@ -35,10 +35,8 @@ public extension Double { /** Rounding of double value - - parameter precision: significant digits after decimal point - parameter roundType: rounding type - - returns: rounded value */ func roundValue(withPrecision precision: UInt,