diff --git a/CHANGELOG.md b/CHANGELOG.md index a936054e..a2a44a0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +### 1.1.0 +- **Add**: `BaseInitializeableViewController`, `BaseCustomViewController` and `BaseViewController` to TIUIKitCore. +- **Add**: `TableKitTableView` and `TableDirectorHolder` to TITableKitUtils. + ### 1.0.0 - **API BreakingChanges**: up swift version to 5.1. - **Update**: build scripts. diff --git a/Sources/Structures/NetworkService/NetworkServiceConfiguration.swift b/Sources/Structures/NetworkService/NetworkServiceConfiguration.swift index f55d46a9..4411bc20 100644 --- a/Sources/Structures/NetworkService/NetworkServiceConfiguration.swift +++ b/Sources/Structures/NetworkService/NetworkServiceConfiguration.swift @@ -69,7 +69,7 @@ public extension NetworkServiceConfiguration { /// SessionManager constructed with given parameters (session configuration and trust policies) var sessionManager: SessionManager { SessionManager(configuration: sessionConfiguration, - serverTrustManager: ServerTrustManager(allHostsMustBeEvaluated: !serverTrustPolicies.isEmpty, + serverTrustManager: ServerTrustManager(allHostsMustBeEvaluated: false, evaluators: serverTrustPolicies), acceptableStatusCodes: acceptableStatusCodes, mappingQueue: DispatchQueue(label: .mappingQueueLabel, qos: .default)) diff --git a/TIFoundationUtils/Sources/UserDefaultsBackingStore/UserDefaultsBackingStore.swift b/TIFoundationUtils/Sources/UserDefaultsBackingStore/UserDefaultsBackingStore.swift new file mode 100644 index 00000000..487f9686 --- /dev/null +++ b/TIFoundationUtils/Sources/UserDefaultsBackingStore/UserDefaultsBackingStore.swift @@ -0,0 +1,69 @@ +// +// Copyright (c) 2021 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 TISwiftUtils +import Foundation + +public typealias UserDefaultsBackingStore = BackingStore + +public extension BackingStore where Store: UserDefaults { + typealias GetValueByRawKeyClosure = (Store, String) -> StoreContent + typealias SetValueByRawKeyClosure = (Store, StoreContent, String) -> Void + + init(key: StorageKey, + userDefaultsStorage: Store, + getClosure: @escaping GetValueByRawKeyClosure, + setClosure: @escaping SetValueByRawKeyClosure) + where StoreContent == Value? { + + self.init(store: userDefaultsStorage, + getClosure: { + guard $0.object(forKey: key.rawValue) != nil else { + return nil + } + + return getClosure($0, key.rawValue) + }, + setClosure: { + setClosure($0, $1, key.rawValue) + }) + } + + init(wrappedValue: StoreContent, + key: StorageKey, + userDefaultsStorage: Store, + getClosure: @escaping GetValueByRawKeyClosure, + setClosure: @escaping SetValueByRawKeyClosure) { + + self.init(store: userDefaultsStorage, + getClosure: { + guard $0.object(forKey: key.rawValue) != nil else { + return wrappedValue + } + + return getClosure($0, key.rawValue) + }, + setClosure: { + setClosure($0, $1, key.rawValue) + }) + } +} diff --git a/TIFoundationUtils/TIFoundationUtils.podspec b/TIFoundationUtils/TIFoundationUtils.podspec index 8f71632b..b7f14adb 100644 --- a/TIFoundationUtils/TIFoundationUtils.podspec +++ b/TIFoundationUtils/TIFoundationUtils.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIFoundationUtils' - s.version = '1.0.0' + s.version = '1.1.0' s.summary = 'Set of helpers for Foundation framework classes.' s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TISwiftUtils/TISwiftUtils.podspec b/TISwiftUtils/TISwiftUtils.podspec index 64bbbd5a..ed4a5a5f 100644 --- a/TISwiftUtils/TISwiftUtils.podspec +++ b/TISwiftUtils/TISwiftUtils.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TISwiftUtils' - s.version = '1.0.0' + s.version = '1.1.0' s.summary = 'Bunch of useful helpers for Swift development.' s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TITableKitUtils/Sources/Extensions/ViewControllers/BaseCustomViewController+TableDirectorHolder.swift b/TITableKitUtils/Sources/Extensions/ViewControllers/BaseCustomViewController+TableDirectorHolder.swift new file mode 100644 index 00000000..d96705f0 --- /dev/null +++ b/TITableKitUtils/Sources/Extensions/ViewControllers/BaseCustomViewController+TableDirectorHolder.swift @@ -0,0 +1,29 @@ +// Copyright (c) 2021 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 TIUIKitCore +import TableKit + +extension BaseCustomViewController: TableDirectorHolder where View: TableDirectorHolder { + public var tableDirector: View.TableDirectorType { + customView.tableDirector + } +} diff --git a/TITableKitUtils/Sources/Protocols/TableDirectorHolder.swift b/TITableKitUtils/Sources/Protocols/TableDirectorHolder.swift new file mode 100644 index 00000000..eb9fb638 --- /dev/null +++ b/TITableKitUtils/Sources/Protocols/TableDirectorHolder.swift @@ -0,0 +1,29 @@ +// +// Copyright (c) 2021 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 TableKit + +public protocol TableDirectorHolder { + associatedtype TableDirectorType: TableDirector + + var tableDirector: TableDirectorType { get } +} diff --git a/TITableKitUtils/Sources/Views/TableKitTableView.swift b/TITableKitUtils/Sources/Views/TableKitTableView.swift new file mode 100644 index 00000000..6b011395 --- /dev/null +++ b/TITableKitUtils/Sources/Views/TableKitTableView.swift @@ -0,0 +1,49 @@ +// +// Copyright (c) 2021 Touch Instinct +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the Software), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +import UIKit +import TableKit + +open class TableKitTableView: UITableView, TableDirectorHolder { + + public private(set) lazy var tableDirector = createTableDirector() + + public override init(frame: CGRect, style: UITableView.Style) { + super.init(frame: frame, style: style) + + configureAppearance() + } + + required public init?(coder: NSCoder) { + super.init(coder: coder) + + configureAppearance() + } + + open func createTableDirector() -> TableDirector { + TableDirector(tableView: self) + } + + open func configureAppearance() { + separatorStyle = .none + } +} diff --git a/TITableKitUtils/TITableKitUtils.podspec b/TITableKitUtils/TITableKitUtils.podspec index 36a64631..10d99cb0 100644 --- a/TITableKitUtils/TITableKitUtils.podspec +++ b/TITableKitUtils/TITableKitUtils.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TITableKitUtils' - s.version = '1.0.0' + s.version = '1.1.0' s.summary = 'Set of helpers for TableKit classes.' s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TIUIElements/Sources/Separators/BaseSeparatorCell.swift b/TIUIElements/Sources/Separators/BaseSeparatorCell.swift index fe07b3f5..c426a46c 100644 --- a/TIUIElements/Sources/Separators/BaseSeparatorCell.swift +++ b/TIUIElements/Sources/Separators/BaseSeparatorCell.swift @@ -24,7 +24,7 @@ import UIKit open class BaseSeparatorCell: BaseInitializableCell, SeparatorConfigurable { private lazy var topSeparatorView = createTopSeparator() - private lazy var bottomSeparatorView = UIView() + private lazy var bottomSeparatorView = createBottomSeparator() private var topViewLeftConstraint: NSLayoutConstraint? private var topViewRightConstraint: NSLayoutConstraint? diff --git a/TIUIElements/TIUIElements.podspec b/TIUIElements/TIUIElements.podspec index 83fd9313..d082279b 100644 --- a/TIUIElements/TIUIElements.podspec +++ b/TIUIElements/TIUIElements.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIUIElements' - s.version = '1.0.0' + s.version = '1.1.0' s.summary = 'Bunch of useful protocols and views.' s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TIUIKitCore/Sources/Protocols/InitializeableViewController/InitializeableViewController.swift b/TIUIKitCore/Sources/Protocols/InitializeableViewController/InitializeableViewController.swift new file mode 100644 index 00000000..1f22f07b --- /dev/null +++ b/TIUIKitCore/Sources/Protocols/InitializeableViewController/InitializeableViewController.swift @@ -0,0 +1,42 @@ +// +// Copyright (c) 2021 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 InitializeableViewController: InitializableViewProtocol { + + func configureBarButtons() +} + +public extension InitializeableViewController { + func initializeView() { + assertionFailure("Use \(String(describing: initializeController)) for UIViewController instead!") + } + + /// Method that should be called in viewDidLoad method of UIViewController. + func initializeController() { + addViews() + configureLayout() + configureAppearance() + configureBarButtons() + localize() + bindViews() + } +} diff --git a/TIUIKitCore/Sources/ViewControllers/BaseCustomViewController.swift b/TIUIKitCore/Sources/ViewControllers/BaseCustomViewController.swift new file mode 100644 index 00000000..927352cf --- /dev/null +++ b/TIUIKitCore/Sources/ViewControllers/BaseCustomViewController.swift @@ -0,0 +1,45 @@ +// +// Copyright (c) 2021 Touch Instinct +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the Software), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +import UIKit + +open class BaseCustomViewController: BaseInitializeableViewController { + + public private(set) lazy var customView = createView() + + public init() { + super.init(nibName: nil, bundle: nil) + } + + @available(*, unavailable) + required public init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented. Use init()") + } + + override open func loadView() { + view = customView + } + + open func createView() -> View { + return View() + } +} diff --git a/TIUIKitCore/Sources/ViewControllers/BaseInitializeableViewController.swift b/TIUIKitCore/Sources/ViewControllers/BaseInitializeableViewController.swift new file mode 100644 index 00000000..48b4a7b6 --- /dev/null +++ b/TIUIKitCore/Sources/ViewControllers/BaseInitializeableViewController.swift @@ -0,0 +1,62 @@ +// +// Copyright (c) 2021 Touch Instinct +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the Software), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +import UIKit.UIViewController + +open class BaseInitializeableViewController: UIViewController, InitializeableViewController { + + override open func viewDidLoad() { + super.viewDidLoad() + + onViewDidLoad() + } + + open func onViewDidLoad() { + initializeController() + } + + // MARK: - InitializeableController + + open func addViews() { + // override in subclass + } + + open func configureLayout() { + // override in subclass + } + + open func bindViews() { + // override in subclass + } + + open func configureAppearance() { + // override in subclass + } + + open func localize() { + // override in subclass + } + + open func configureBarButtons() { + // override in subclass + } +} diff --git a/TIUIKitCore/Sources/ViewControllers/BaseViewController.swift b/TIUIKitCore/Sources/ViewControllers/BaseViewController.swift new file mode 100644 index 00000000..0060e636 --- /dev/null +++ b/TIUIKitCore/Sources/ViewControllers/BaseViewController.swift @@ -0,0 +1,33 @@ +// +// Copyright (c) 2021 Touch Instinct +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the Software), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +import UIKit + +open class BaseViewController: BaseCustomViewController { + public let viewModel: ViewModel + + public init(viewModel: ViewModel) { + self.viewModel = viewModel + + super.init() + } +} diff --git a/TIUIKitCore/TIUIKitCore.podspec b/TIUIKitCore/TIUIKitCore.podspec index 71a0c9da..ae1ed28a 100644 --- a/TIUIKitCore/TIUIKitCore.podspec +++ b/TIUIKitCore/TIUIKitCore.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIUIKitCore' - s.version = '1.0.0' + s.version = '1.1.0' s.summary = 'Core UI elements: protocols, views and helpers.' s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' }