From f51d26311de0745ad509eeb5b2952d4a6bf0d3e0 Mon Sep 17 00:00:00 2001 From: Maxim Sorokin Date: Tue, 18 Aug 2020 11:55:48 +0300 Subject: [PATCH 1/8] [Add] BaseTableViewCell and ContainerTableCell --- LeadKit.xcodeproj/project.pbxproj | 24 ++++++ .../BaseTableViewCell/BaseTableViewCell.swift | 73 +++++++++++++++++ .../ContainerTableCell.swift | 78 +++++++++++++++++++ 3 files changed, 175 insertions(+) create mode 100644 Sources/Classes/Views/BaseTableViewCell/BaseTableViewCell.swift create mode 100644 Sources/Classes/Views/ContainerTableCell/ContainerTableCell.swift diff --git a/LeadKit.xcodeproj/project.pbxproj b/LeadKit.xcodeproj/project.pbxproj index b5340cff..0f07a772 100644 --- a/LeadKit.xcodeproj/project.pbxproj +++ b/LeadKit.xcodeproj/project.pbxproj @@ -19,6 +19,8 @@ 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 */; }; + 52421F8D24EAB52E00948DD1 /* ContainerTableCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52421F8C24EAB52E00948DD1 /* ContainerTableCell.swift */; }; + 52421F8F24EAB84900948DD1 /* BaseTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52421F8E24EAB84900948DD1 /* BaseTableViewCell.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 */; }; @@ -556,6 +558,8 @@ 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 = ""; }; + 52421F8C24EAB52E00948DD1 /* ContainerTableCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContainerTableCell.swift; sourceTree = ""; }; + 52421F8E24EAB84900948DD1 /* BaseTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseTableViewCell.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 = ""; }; @@ -874,6 +878,22 @@ path = ButtonHolder; sourceTree = ""; }; + 52421F8B24EAB52E00948DD1 /* ContainerTableCell */ = { + isa = PBXGroup; + children = ( + 52421F8C24EAB52E00948DD1 /* ContainerTableCell.swift */, + ); + path = ContainerTableCell; + sourceTree = ""; + }; + 52421F9024EAB84E00948DD1 /* BaseTableViewCell */ = { + isa = PBXGroup; + children = ( + 52421F8E24EAB84900948DD1 /* BaseTableViewCell.swift */, + ); + path = BaseTableViewCell; + sourceTree = ""; + }; 671461C41EB3396E00EAB194 /* Classes */ = { isa = PBXGroup; children = ( @@ -919,6 +939,8 @@ 671461D41EB3396E00EAB194 /* Views */ = { isa = PBXGroup; children = ( + 52421F9024EAB84E00948DD1 /* BaseTableViewCell */, + 52421F8B24EAB52E00948DD1 /* ContainerTableCell */, 72005A1A2266226800ECE090 /* CustomizableButton */, 677B06B6211873E7006C947D /* BasePlaceholderView */, 67DB77672108714A001CB56B /* CollectionViewWrapperView */, @@ -2559,6 +2581,7 @@ 6741CEA920E2418B00FEC4D9 /* CollectionViewHolder.swift in Sources */, 67745279206252020024EEEF /* DataLoadingState.swift in Sources */, 671463641EB3396E00EAB194 /* ViewHeightProtocol.swift in Sources */, + 52421F8F24EAB84900948DD1 /* BaseTableViewCell.swift in Sources */, 67EB7FDA20615D5B00BDD9FB /* ResettableRxCursorDataSource.swift in Sources */, 671462481EB3396E00EAB194 /* FixedPageCursor.swift in Sources */, 671462C81EB3396E00EAB194 /* String+Localization.swift in Sources */, @@ -2606,6 +2629,7 @@ 678D267920691D8200B05B93 /* DataModelFieldBinding.swift in Sources */, 72AECC71224A97F100D12E7C /* SearchResultsViewController.swift in Sources */, 673CF4342063E29B00C329F6 /* TextWithButtonPlaceholder.swift in Sources */, + 52421F8D24EAB52E00948DD1 /* ContainerTableCell.swift in Sources */, 673CF4222063D90600C329F6 /* DisposeBagHolder.swift in Sources */, 67DB776D210871E8001CB56B /* BaseCollectionContentController.swift in Sources */, 82B4F8DB223903B800F6708C /* Block.swift in Sources */, diff --git a/Sources/Classes/Views/BaseTableViewCell/BaseTableViewCell.swift b/Sources/Classes/Views/BaseTableViewCell/BaseTableViewCell.swift new file mode 100644 index 00000000..4ff04e71 --- /dev/null +++ b/Sources/Classes/Views/BaseTableViewCell/BaseTableViewCell.swift @@ -0,0 +1,73 @@ +// +// 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 RxSwift + +open class BaseTableViewCell: UITableViewCell, InitializableView { + + // MARK: - Properties + + open var disposeBag = DisposeBag() + + // MARK: - Initialization + + override public init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + super.init(style: .default, reuseIdentifier: reuseIdentifier) + + initializeView() + } + + @available(*, unavailable) + required public init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + } + + // MARK: - Override + + override open func prepareForReuse() { + super.prepareForReuse() + + disposeBag = DisposeBag() + } + + // MARK: - InitializableView + + open func addViews() { + // empty for subclasses overriding + } + + open func bindViews() { + // empty for subclasses overriding + } + + open func configureLayout() { + // empty for subclasses overriding + } + + open func configureAppearance() { + selectionStyle = .none + } + + open func localize() { + // empty for subclasses overriding + } +} diff --git a/Sources/Classes/Views/ContainerTableCell/ContainerTableCell.swift b/Sources/Classes/Views/ContainerTableCell/ContainerTableCell.swift new file mode 100644 index 00000000..3c7daf90 --- /dev/null +++ b/Sources/Classes/Views/ContainerTableCell/ContainerTableCell.swift @@ -0,0 +1,78 @@ +// +// 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 RxSwift +import TableKit + +open class ContainerTableCell: BaseTableViewCell, ConfigurableCell where TView: ConfigurableView { + + // MARK: - Properties + + public let view = TView() + + open var shouldConfigureDefaultConstraints: Bool { + true + } + + open var contentInsets: UIEdgeInsets { + .zero + } + + open var contentViewBackgroundColor: UIColor { + .clear + } + + // MARK: - ConfigurableCell + + open func configure(with viewModel: TView.ViewModelType) { + view.configure(with: viewModel) + } + + // MARK: - InitializableView + + override open func addViews() { + super.addViews() + + contentView.addSubview(view) + } + + override open func configureLayout() { + super.configureLayout() + + if shouldConfigureDefaultConstraints { + view.snp.makeConstraints { make in + make.edges.equalToSuperview().inset(contentInsets) + } + } else { + configureCustomConstraints(forView: view) + } + } + + override open func configureAppearance() { + super.configureAppearance() + + contentView.backgroundColor = contentViewBackgroundColor + backgroundColor = contentViewBackgroundColor + } + + open func configureCustomConstraints(forView view: UIView) { } +} From 7924886b70d11d0ff4bc52528f4601248764379d Mon Sep 17 00:00:00 2001 From: Maxim Sorokin Date: Tue, 18 Aug 2020 12:06:33 +0300 Subject: [PATCH 2/8] [Add] BaseTappableViewModel and VoidTappableViewModel --- LeadKit.xcodeproj/project.pbxproj | 24 ++++++++++ .../BaseTappableViewModel.swift | 44 +++++++++++++++++++ .../VoidTappableViewModel.swift | 27 ++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 Sources/Classes/ViewModels/TappableViewModel/BaseTappableViewModel.swift create mode 100644 Sources/Classes/ViewModels/TappableViewModel/VoidTappableViewModel.swift diff --git a/LeadKit.xcodeproj/project.pbxproj b/LeadKit.xcodeproj/project.pbxproj index 0f07a772..c02b6e74 100644 --- a/LeadKit.xcodeproj/project.pbxproj +++ b/LeadKit.xcodeproj/project.pbxproj @@ -21,6 +21,8 @@ 4CF65D1824DD6C080006B001 /* ButtonHolderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CF65D1724DD6C080006B001 /* ButtonHolderView.swift */; }; 52421F8D24EAB52E00948DD1 /* ContainerTableCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52421F8C24EAB52E00948DD1 /* ContainerTableCell.swift */; }; 52421F8F24EAB84900948DD1 /* BaseTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52421F8E24EAB84900948DD1 /* BaseTableViewCell.swift */; }; + 52421F9424EBCFAE00948DD1 /* VoidTappableViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52421F9324EBCFAE00948DD1 /* VoidTappableViewModel.swift */; }; + 52421F9624EBCFBB00948DD1 /* BaseTappableViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52421F9524EBCFBB00948DD1 /* BaseTappableViewModel.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 */; }; @@ -560,6 +562,8 @@ 4CF65D1724DD6C080006B001 /* ButtonHolderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonHolderView.swift; sourceTree = ""; }; 52421F8C24EAB52E00948DD1 /* ContainerTableCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContainerTableCell.swift; sourceTree = ""; }; 52421F8E24EAB84900948DD1 /* BaseTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseTableViewCell.swift; sourceTree = ""; }; + 52421F9324EBCFAE00948DD1 /* VoidTappableViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VoidTappableViewModel.swift; sourceTree = ""; }; + 52421F9524EBCFBB00948DD1 /* BaseTappableViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseTappableViewModel.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 = ""; }; @@ -894,6 +898,23 @@ path = BaseTableViewCell; sourceTree = ""; }; + 52421F9124EBCF6E00948DD1 /* ViewModels */ = { + isa = PBXGroup; + children = ( + 52421F9224EBCF8600948DD1 /* TappableViewModel */, + ); + path = ViewModels; + sourceTree = ""; + }; + 52421F9224EBCF8600948DD1 /* TappableViewModel */ = { + isa = PBXGroup; + children = ( + 52421F9524EBCFBB00948DD1 /* BaseTappableViewModel.swift */, + 52421F9324EBCFAE00948DD1 /* VoidTappableViewModel.swift */, + ); + path = TappableViewModel; + sourceTree = ""; + }; 671461C41EB3396E00EAB194 /* Classes */ = { isa = PBXGroup; children = ( @@ -902,6 +923,7 @@ 6774527E2062566D0024EEEF /* DataLoading */, 671461D21EB3396E00EAB194 /* Services */, 671461D41EB3396E00EAB194 /* Views */, + 52421F9124EBCF6E00948DD1 /* ViewModels */, ); path = Classes; sourceTree = ""; @@ -2434,6 +2456,7 @@ 678D26A420692BFF00B05B93 /* TextFieldViewModelEvents.swift in Sources */, 671462801EB3396E00EAB194 /* DataRequest+Extensions.swift in Sources */, 67EB7FF8206175F700BDD9FB /* PaginationWrappable.swift in Sources */, + 52421F9624EBCFBB00948DD1 /* BaseTappableViewModel.swift in Sources */, 67990AD6213EA6A50040D195 /* ContentLoadingViewModel+Extensions.swift in Sources */, 671463541EB3396E00EAB194 /* StaticViewHeightProtocol.swift in Sources */, 4CF65D1824DD6C080006B001 /* ButtonHolderView.swift in Sources */, @@ -2579,6 +2602,7 @@ 411073AF23466B41002DD9B9 /* UIViewController+PresentFullScreen.swift in Sources */, 671462941EB3396E00EAB194 /* CGSize+CGContextSize.swift in Sources */, 6741CEA920E2418B00FEC4D9 /* CollectionViewHolder.swift in Sources */, + 52421F9424EBCFAE00948DD1 /* VoidTappableViewModel.swift in Sources */, 67745279206252020024EEEF /* DataLoadingState.swift in Sources */, 671463641EB3396E00EAB194 /* ViewHeightProtocol.swift in Sources */, 52421F8F24EAB84900948DD1 /* BaseTableViewCell.swift in Sources */, diff --git a/Sources/Classes/ViewModels/TappableViewModel/BaseTappableViewModel.swift b/Sources/Classes/ViewModels/TappableViewModel/BaseTappableViewModel.swift new file mode 100644 index 00000000..c0d58183 --- /dev/null +++ b/Sources/Classes/ViewModels/TappableViewModel/BaseTappableViewModel.swift @@ -0,0 +1,44 @@ +// +// 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 RxCocoa +import RxSwift + +open class BaseTappableViewModel { + private let tapRelay = PublishRelay() + + public var tapDriver: Driver { + tapRelay.asDriver(onErrorDriveWith: .empty()) + } + + public var tapObservable: Observable { + tapRelay.asObservable() + } + + public func bind(tapObservable: Observable) -> Disposable { + tapObservable.bind(to: tapRelay) + } + + public func tap(payload: PayloadType) { + tapRelay.accept(payload) + } +} diff --git a/Sources/Classes/ViewModels/TappableViewModel/VoidTappableViewModel.swift b/Sources/Classes/ViewModels/TappableViewModel/VoidTappableViewModel.swift new file mode 100644 index 00000000..589ab45f --- /dev/null +++ b/Sources/Classes/ViewModels/TappableViewModel/VoidTappableViewModel.swift @@ -0,0 +1,27 @@ +// +// 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. +// + +open class VoidTappableViewModel: BaseTappableViewModel { + public func tap() { + tap(payload: ()) + } +} From f3cd8bec97b49ca0d5349d6e33c58b1ba1db9619 Mon Sep 17 00:00:00 2001 From: Maxim Sorokin Date: Tue, 18 Aug 2020 12:12:48 +0300 Subject: [PATCH 3/8] Refactoring BaseTableViewCell --- .../Views/BaseTableViewCell/BaseTableViewCell.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Sources/Classes/Views/BaseTableViewCell/BaseTableViewCell.swift b/Sources/Classes/Views/BaseTableViewCell/BaseTableViewCell.swift index 4ff04e71..57035d0f 100644 --- a/Sources/Classes/Views/BaseTableViewCell/BaseTableViewCell.swift +++ b/Sources/Classes/Views/BaseTableViewCell/BaseTableViewCell.swift @@ -22,11 +22,11 @@ import RxSwift -open class BaseTableViewCell: UITableViewCell, InitializableView { +open class BaseTableViewCell: UITableViewCell, InitializableView, DisposeBagHolder { // MARK: - Properties - open var disposeBag = DisposeBag() + public var disposeBag = DisposeBag() // MARK: - Initialization @@ -52,15 +52,15 @@ open class BaseTableViewCell: UITableViewCell, InitializableView { // MARK: - InitializableView open func addViews() { - // empty for subclasses overriding + // overriding } open func bindViews() { - // empty for subclasses overriding + // overriding } open func configureLayout() { - // empty for subclasses overriding + // overriding } open func configureAppearance() { @@ -68,6 +68,6 @@ open class BaseTableViewCell: UITableViewCell, InitializableView { } open func localize() { - // empty for subclasses overriding + // overriding } } From b273d2c1181ef56577922873d4e79019689ac239 Mon Sep 17 00:00:00 2001 From: Maxim Sorokin Date: Tue, 18 Aug 2020 12:42:23 +0300 Subject: [PATCH 4/8] Up version and update change log --- CHANGELOG.md | 6 ++++++ LeadKit.podspec | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6066e2f7..d5d6934b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +### 0.9.37 +- **Add**: `BaseTableViewCell` is subclass of `UITableViewCell` class with support `InitializableView` and `DisposeBagHolder` protocols. +- **Add**: `ContainerTableCell` is container class that provides wrapping any `UIView` into `UITableViewCell`. +- **Add**: `BaseTappableViewModel` is simplifies interaction between view and viewModel for events of tapping. +- **Add**: `VoidTappableViewModel` is subclass of `BaseTappableViewModel` class with void payload type. + ### 0.9.36 - **Add**: SPM Package.swift. - **Add**: TITransitions via SPM. diff --git a/LeadKit.podspec b/LeadKit.podspec index 3014238d..047c7558 100644 --- a/LeadKit.podspec +++ b/LeadKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "LeadKit" - s.version = "0.9.36" + s.version = "0.9.37" 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 dfa4a7c0f9cba3a9335d0777ebedc269db06578b Mon Sep 17 00:00:00 2001 From: Maxim Sorokin Date: Tue, 18 Aug 2020 13:48:17 +0300 Subject: [PATCH 5/8] fix naming --- CHANGELOG.md | 2 +- LeadKit.xcodeproj/project.pbxproj | 14 +++++++------- .../BaseRxTableViewCell.swift} | 2 +- .../ContainerTableCell/ContainerTableCell.swift | 16 ++++++++-------- 4 files changed, 17 insertions(+), 17 deletions(-) rename Sources/Classes/Views/{BaseTableViewCell/BaseTableViewCell.swift => BaseRxTableViewCell/BaseRxTableViewCell.swift} (95%) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5d6934b..a63effb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Changelog ### 0.9.37 -- **Add**: `BaseTableViewCell` is subclass of `UITableViewCell` class with support `InitializableView` and `DisposeBagHolder` protocols. +- **Add**: `BaseRxTableViewCell` is subclass of `UITableViewCell` class with support `InitializableView` and `DisposeBagHolder` protocols. - **Add**: `ContainerTableCell` is container class that provides wrapping any `UIView` into `UITableViewCell`. - **Add**: `BaseTappableViewModel` is simplifies interaction between view and viewModel for events of tapping. - **Add**: `VoidTappableViewModel` is subclass of `BaseTappableViewModel` class with void payload type. diff --git a/LeadKit.xcodeproj/project.pbxproj b/LeadKit.xcodeproj/project.pbxproj index c02b6e74..66fb2a14 100644 --- a/LeadKit.xcodeproj/project.pbxproj +++ b/LeadKit.xcodeproj/project.pbxproj @@ -20,7 +20,7 @@ 4CF65D1624DD69250006B001 /* UIButton+ButtonHolder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CF65D1524DD69250006B001 /* UIButton+ButtonHolder.swift */; }; 4CF65D1824DD6C080006B001 /* ButtonHolderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CF65D1724DD6C080006B001 /* ButtonHolderView.swift */; }; 52421F8D24EAB52E00948DD1 /* ContainerTableCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52421F8C24EAB52E00948DD1 /* ContainerTableCell.swift */; }; - 52421F8F24EAB84900948DD1 /* BaseTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52421F8E24EAB84900948DD1 /* BaseTableViewCell.swift */; }; + 52421F8F24EAB84900948DD1 /* BaseRxTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52421F8E24EAB84900948DD1 /* BaseRxTableViewCell.swift */; }; 52421F9424EBCFAE00948DD1 /* VoidTappableViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52421F9324EBCFAE00948DD1 /* VoidTappableViewModel.swift */; }; 52421F9624EBCFBB00948DD1 /* BaseTappableViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52421F9524EBCFBB00948DD1 /* BaseTappableViewModel.swift */; }; 67051ADB1EBC7C36008EADC0 /* SpinnerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67051ADA1EBC7C36008EADC0 /* SpinnerView.swift */; }; @@ -561,7 +561,7 @@ 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 = ""; }; 52421F8C24EAB52E00948DD1 /* ContainerTableCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContainerTableCell.swift; sourceTree = ""; }; - 52421F8E24EAB84900948DD1 /* BaseTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseTableViewCell.swift; sourceTree = ""; }; + 52421F8E24EAB84900948DD1 /* BaseRxTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseRxTableViewCell.swift; sourceTree = ""; }; 52421F9324EBCFAE00948DD1 /* VoidTappableViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VoidTappableViewModel.swift; sourceTree = ""; }; 52421F9524EBCFBB00948DD1 /* BaseTappableViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseTappableViewModel.swift; sourceTree = ""; }; 67051ADA1EBC7C36008EADC0 /* SpinnerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpinnerView.swift; sourceTree = ""; }; @@ -890,12 +890,12 @@ path = ContainerTableCell; sourceTree = ""; }; - 52421F9024EAB84E00948DD1 /* BaseTableViewCell */ = { + 52421F9024EAB84E00948DD1 /* BaseRxTableViewCell */ = { isa = PBXGroup; children = ( - 52421F8E24EAB84900948DD1 /* BaseTableViewCell.swift */, + 52421F8E24EAB84900948DD1 /* BaseRxTableViewCell.swift */, ); - path = BaseTableViewCell; + path = BaseRxTableViewCell; sourceTree = ""; }; 52421F9124EBCF6E00948DD1 /* ViewModels */ = { @@ -961,7 +961,7 @@ 671461D41EB3396E00EAB194 /* Views */ = { isa = PBXGroup; children = ( - 52421F9024EAB84E00948DD1 /* BaseTableViewCell */, + 52421F9024EAB84E00948DD1 /* BaseRxTableViewCell */, 52421F8B24EAB52E00948DD1 /* ContainerTableCell */, 72005A1A2266226800ECE090 /* CustomizableButton */, 677B06B6211873E7006C947D /* BasePlaceholderView */, @@ -2605,7 +2605,7 @@ 52421F9424EBCFAE00948DD1 /* VoidTappableViewModel.swift in Sources */, 67745279206252020024EEEF /* DataLoadingState.swift in Sources */, 671463641EB3396E00EAB194 /* ViewHeightProtocol.swift in Sources */, - 52421F8F24EAB84900948DD1 /* BaseTableViewCell.swift in Sources */, + 52421F8F24EAB84900948DD1 /* BaseRxTableViewCell.swift in Sources */, 67EB7FDA20615D5B00BDD9FB /* ResettableRxCursorDataSource.swift in Sources */, 671462481EB3396E00EAB194 /* FixedPageCursor.swift in Sources */, 671462C81EB3396E00EAB194 /* String+Localization.swift in Sources */, diff --git a/Sources/Classes/Views/BaseTableViewCell/BaseTableViewCell.swift b/Sources/Classes/Views/BaseRxTableViewCell/BaseRxTableViewCell.swift similarity index 95% rename from Sources/Classes/Views/BaseTableViewCell/BaseTableViewCell.swift rename to Sources/Classes/Views/BaseRxTableViewCell/BaseRxTableViewCell.swift index 57035d0f..4ec4ff74 100644 --- a/Sources/Classes/Views/BaseTableViewCell/BaseTableViewCell.swift +++ b/Sources/Classes/Views/BaseRxTableViewCell/BaseRxTableViewCell.swift @@ -22,7 +22,7 @@ import RxSwift -open class BaseTableViewCell: UITableViewCell, InitializableView, DisposeBagHolder { +open class BaseRxTableViewCell: UITableViewCell, InitializableView, DisposeBagHolder { // MARK: - Properties diff --git a/Sources/Classes/Views/ContainerTableCell/ContainerTableCell.swift b/Sources/Classes/Views/ContainerTableCell/ContainerTableCell.swift index 3c7daf90..438979ce 100644 --- a/Sources/Classes/Views/ContainerTableCell/ContainerTableCell.swift +++ b/Sources/Classes/Views/ContainerTableCell/ContainerTableCell.swift @@ -23,11 +23,11 @@ import RxSwift import TableKit -open class ContainerTableCell: BaseTableViewCell, ConfigurableCell where TView: ConfigurableView { +open class ContainerTableCell: BaseRxTableViewCell, ConfigurableCell where TView: ConfigurableView { // MARK: - Properties - public let view = TView() + public let wrappedView = TView() open var shouldConfigureDefaultConstraints: Bool { true @@ -44,7 +44,7 @@ open class ContainerTableCell: BaseTableViewCell, ConfigurableCel // MARK: - ConfigurableCell open func configure(with viewModel: TView.ViewModelType) { - view.configure(with: viewModel) + wrappedView.configure(with: viewModel) } // MARK: - InitializableView @@ -52,18 +52,18 @@ open class ContainerTableCell: BaseTableViewCell, ConfigurableCel override open func addViews() { super.addViews() - contentView.addSubview(view) + contentView.addSubview(wrappedView) } override open func configureLayout() { super.configureLayout() if shouldConfigureDefaultConstraints { - view.snp.makeConstraints { make in - make.edges.equalToSuperview().inset(contentInsets) + wrappedView.snp.makeConstraints { + $0.edges.equalToSuperview().inset(contentInsets) } } else { - configureCustomConstraints(forView: view) + configureCustomConstraints(forWrappedView: wrappedView) } } @@ -74,5 +74,5 @@ open class ContainerTableCell: BaseTableViewCell, ConfigurableCel backgroundColor = contentViewBackgroundColor } - open func configureCustomConstraints(forView view: UIView) { } + open func configureCustomConstraints(forWrappedView view: TView) { } } From dd4e8e2c7b99bd6c1784f419304777ae01ae422f Mon Sep 17 00:00:00 2001 From: Maxim Sorokin Date: Tue, 18 Aug 2020 17:44:58 +0300 Subject: [PATCH 6/8] up version --- LeadKit.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LeadKit.podspec b/LeadKit.podspec index 047c7558..e3b2ae6b 100644 --- a/LeadKit.podspec +++ b/LeadKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "LeadKit" - s.version = "0.9.37" + s.version = "0.9.38" 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 058f50215da43066a71078b19e56d390338d590c Mon Sep 17 00:00:00 2001 From: Maxim Sorokin Date: Tue, 18 Aug 2020 18:01:13 +0300 Subject: [PATCH 7/8] =?UTF-8?q?fix=20public=20=E2=80=93>=20private=20for?= =?UTF-8?q?=20wrappedView?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Classes/Views/ContainerTableCell/ContainerTableCell.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Classes/Views/ContainerTableCell/ContainerTableCell.swift b/Sources/Classes/Views/ContainerTableCell/ContainerTableCell.swift index 438979ce..3885391f 100644 --- a/Sources/Classes/Views/ContainerTableCell/ContainerTableCell.swift +++ b/Sources/Classes/Views/ContainerTableCell/ContainerTableCell.swift @@ -27,7 +27,7 @@ open class ContainerTableCell: BaseRxTableViewCell, ConfigurableC // MARK: - Properties - public let wrappedView = TView() + private let wrappedView = TView() open var shouldConfigureDefaultConstraints: Bool { true From a227d74db522a245e28129dea06aef865d30cde3 Mon Sep 17 00:00:00 2001 From: Maxim Sorokin Date: Wed, 19 Aug 2020 11:04:27 +0300 Subject: [PATCH 8/8] added disposeBag --- .../Classes/Views/ContainerTableCell/ContainerTableCell.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/Classes/Views/ContainerTableCell/ContainerTableCell.swift b/Sources/Classes/Views/ContainerTableCell/ContainerTableCell.swift index 3885391f..c30752d0 100644 --- a/Sources/Classes/Views/ContainerTableCell/ContainerTableCell.swift +++ b/Sources/Classes/Views/ContainerTableCell/ContainerTableCell.swift @@ -44,6 +44,7 @@ open class ContainerTableCell: BaseRxTableViewCell, ConfigurableC // MARK: - ConfigurableCell open func configure(with viewModel: TView.ViewModelType) { + disposeBag = DisposeBag() wrappedView.configure(with: viewModel) }