From 8cb1771e5d428ca15d7183dcdfa54420f8d24c25 Mon Sep 17 00:00:00 2001 From: Artur Date: Tue, 5 Mar 2019 14:23:58 +0300 Subject: [PATCH] Issues resolved --- Cartfile | 6 +-- LeadKit.xcodeproj/project.pbxproj | 4 ++ .../Search/BaseSearchViewController.swift | 5 --- .../Classes/Search/BaseSearchViewModel.swift | 18 -------- Sources/Protocols/OptionalType.swift | 41 +++++++++++++++++++ 5 files changed, 48 insertions(+), 26 deletions(-) create mode 100644 Sources/Protocols/OptionalType.swift diff --git a/Cartfile b/Cartfile index e25b4aef..affbd483 100644 --- a/Cartfile +++ b/Cartfile @@ -1,6 +1,6 @@ -binary "https://raw.github.com/petropavel13/CarthageBinaries/master/SwiftDate/SwiftDate.json" +binary "https://raw.github.com/TouchInstinct/CarthageBinaries/master/SwiftDate/SwiftDate.json" github "ReactiveX/RxSwift" -binary "https://raw.github.com/petropavel13/CarthageBinaries/master/RxAlamofire/RxAlamofire.json" +binary "https://raw.github.com/TouchInstinct/CarthageBinaries/master/RxAlamofire/RxAlamofire.json" github "maxsokolov/TableKit" github "pronebird/UIScrollView-InfiniteScroll" -GitHub "Alamofire/Alamofire" "4.8.1" \ No newline at end of file +gitHub "Alamofire/Alamofire" "4.8.1" \ No newline at end of file diff --git a/LeadKit.xcodeproj/project.pbxproj b/LeadKit.xcodeproj/project.pbxproj index 19d1febc..d4c5e058 100644 --- a/LeadKit.xcodeproj/project.pbxproj +++ b/LeadKit.xcodeproj/project.pbxproj @@ -473,6 +473,7 @@ 72039CE0220899E600875DD4 /* SearchResultsViewControllerState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 72039CDF220899E600875DD4 /* SearchResultsViewControllerState.swift */; }; 72039CE122089A3D00875DD4 /* SearchResultsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7284087522079A4600A20F47 /* SearchResultsViewController.swift */; }; 72039CE222089A3D00875DD4 /* SearchResultsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7284087522079A4600A20F47 /* SearchResultsViewController.swift */; }; + 72527D27222E934100CA26BE /* OptionalType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 72527D26222E934100CA26BE /* OptionalType.swift */; }; 7284087422078EB800A20F47 /* BaseSearchViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7284087322078EB800A20F47 /* BaseSearchViewModel.swift */; }; 7284087622079A4600A20F47 /* SearchResultsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7284087522079A4600A20F47 /* SearchResultsViewController.swift */; }; 7295473F21E661E6009558E7 /* TitleType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7295473E21E661E6009558E7 /* TitleType.swift */; }; @@ -770,6 +771,7 @@ 6B5B62E7942E5AEE68A95449 /* Array+RowExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Array+RowExtensions.swift"; sourceTree = ""; }; 6B5B66503F2C42D009DEA011 /* TableKitViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableKitViewModel.swift; sourceTree = ""; }; 72039CDF220899E600875DD4 /* SearchResultsViewControllerState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchResultsViewControllerState.swift; sourceTree = ""; }; + 72527D26222E934100CA26BE /* OptionalType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OptionalType.swift; sourceTree = ""; }; 7284087322078EB800A20F47 /* BaseSearchViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseSearchViewModel.swift; sourceTree = ""; }; 7284087522079A4600A20F47 /* SearchResultsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchResultsViewController.swift; sourceTree = ""; }; 7295473E21E661E6009558E7 /* TitleType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TitleType.swift; sourceTree = ""; }; @@ -1191,6 +1193,7 @@ 678D269C20692BFF00B05B93 /* Views */, 671462341EB3396E00EAB194 /* XibNameProtocol.swift */, 6B5B625D01107D0A6F4E14D2 /* TableKit */, + 72527D26222E934100CA26BE /* OptionalType.swift */, ); path = Protocols; sourceTree = ""; @@ -2519,6 +2522,7 @@ 6714627C1EB3396E00EAB194 /* SessionManager+Extensions.swift in Sources */, 671462D41EB3396E00EAB194 /* TableDirector+Extensions.swift in Sources */, 67E352572119ACF30035BDDB /* ViewTextConfigurable+Extensions.swift in Sources */, + 72527D27222E934100CA26BE /* OptionalType.swift in Sources */, 67990AC5213EA4DB0040D195 /* PlaceholderConfigurable.swift in Sources */, 6741CEBE20E242FA00FEC4D9 /* UIScrollView+RxBindings.swift in Sources */, 67E902572125B66E008EDF45 /* UIImageView+ExpandCollapseDisclosure.swift in Sources */, diff --git a/Sources/Classes/Search/BaseSearchViewController.swift b/Sources/Classes/Search/BaseSearchViewController.swift index 276777cc..7cb7a81f 100644 --- a/Sources/Classes/Search/BaseSearchViewController.swift +++ b/Sources/Classes/Search/BaseSearchViewController.swift @@ -53,11 +53,6 @@ where ViewModel: BaseSearchViewModel { // MARK: - Configurable Controller - open override func configureBarButtons() { - super.configureBarButtons() - // override in subclass - } - open override func bindViews() { super.bindViews() diff --git a/Sources/Classes/Search/BaseSearchViewModel.swift b/Sources/Classes/Search/BaseSearchViewModel.swift index 30cc1801..6d9a7e60 100644 --- a/Sources/Classes/Search/BaseSearchViewModel.swift +++ b/Sources/Classes/Search/BaseSearchViewModel.swift @@ -23,24 +23,6 @@ import RxSwift import RxCocoa -private protocol OptionalType { - associatedtype Wrapped - - var optional: Wrapped? { get } -} - -extension Optional: OptionalType { - public var optional: Wrapped? { return self } -} - -private extension Observable where Element: OptionalType { - func filterNil() -> Observable { - return flatMap { value -> Observable in - value.optional.map { .just($0) } ?? .empty() - } - } -} - open class BaseSearchViewModel: GeneralDataLoadingViewModel<[Item]> { public typealias ItemsList = [Item] diff --git a/Sources/Protocols/OptionalType.swift b/Sources/Protocols/OptionalType.swift new file mode 100644 index 00000000..065cdcfe --- /dev/null +++ b/Sources/Protocols/OptionalType.swift @@ -0,0 +1,41 @@ +// +// Copyright (c) 2019 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 RxSwift + +protocol OptionalType { + associatedtype Wrapped + + var optional: Wrapped? { get } +} + +extension Optional: OptionalType { + public var optional: Wrapped? { return self } +} + +extension Observable where Element: OptionalType { + func filterNil() -> Observable { + return flatMap { value -> Observable in + value.optional.map { .just($0) } ?? .empty() + } + } +}