Merge pull request #339 from TouchInstinct/feature/appearance_customization_model

feat: api for configuration Views' appearance and layout
This commit is contained in:
Nikita Semenov 2023-02-14 11:51:55 +03:00 committed by GitHub
commit f67005df71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
52 changed files with 1152 additions and 110 deletions

View File

@ -1,5 +1,13 @@
# Changelog
### 1.33.0
- **Added**: `ViewAppearance` and `ViewLayout` models for setting up Views' appearance and layout
- **Added**: `TableKit.Row` extension for configuration inner View's appearance and layout
- **Added**: `WrappableView` with typealiases for creating wrapped in the container views
- **Added**: `CollectionTableViewCell` and `ContainerView`
- **Update**: Separator appearance configureation for table views
### 1.32.0
- **Added**: `BaseInitializableWebView` with navigation and error handling api.

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "LeadKit"
s.version = "1.32.0"
s.version = "1.33.0"
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"

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TIAppleMapUtils'
s.version = '1.32.0'
s.version = '1.33.0'
s.summary = 'Set of helpers for map objects clustering and interacting using Apple MapKit.'
s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TIAuth'
s.version = '1.32.0'
s.version = '1.33.0'
s.summary = 'Login, registration, confirmation and other related actions'
s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TIEcommerce'
s.version = '1.32.0'
s.version = '1.33.0'
s.summary = 'Cart, products, promocodes, bonuses and other related actions'
s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TIFoundationUtils'
s.version = '1.32.0'
s.version = '1.33.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' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TIGoogleMapUtils'
s.version = '1.32.0'
s.version = '1.33.0'
s.summary = 'Set of helpers for map objects clustering and interacting using Google Maps SDK.'
s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TIKeychainUtils'
s.version = '1.32.0'
s.version = '1.33.0'
s.summary = 'Set of helpers for Keychain classes.'
s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TILogging'
s.version = '1.32.0'
s.version = '1.33.0'
s.summary = 'Logging API'
s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TIMapUtils'
s.version = '1.32.0'
s.version = '1.33.0'
s.summary = 'Set of helpers for map objects clustering and interacting.'
s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TIMoyaNetworking'
s.version = '1.32.0'
s.version = '1.33.0'
s.summary = 'Moya + Swagger network service.'
s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TINetworking'
s.version = '1.32.0'
s.version = '1.33.0'
s.summary = 'Swagger-frendly networking layer helpers.'
s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TINetworkingCache'
s.version = '1.32.0'
s.version = '1.33.0'
s.summary = 'Caching results of EndpointRequests.'
s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TIPagination'
s.version = '1.32.0'
s.version = '1.33.0'
s.summary = 'Generic pagination component.'
s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TISwiftUICore'
s.version = '1.32.0'
s.version = '1.33.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' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TISwiftUtils'
s.version = '1.32.0'
s.version = '1.33.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' }

View File

@ -0,0 +1,46 @@
//
// Copyright (c) 2023 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
import TIUIKitCore
extension TableRow: AppearanceConfigurable where CellType: AppearanceConfigurable {
private static var configureAppearanceActionId: String {
"TableRowConfigureAppearanceActionId"
}
public func with(appearance: CellType.Appearance) -> Self {
configure(appearance: appearance)
return self
}
public func configure(appearance: CellType.Appearance) {
removeAction(forActionId: Self.configureAppearanceActionId)
let action = TableRowAction<CellType>(.configure) { options in
options.cell?.configure(appearance: appearance)
}
action.id = Self.configureAppearanceActionId
on(action)
}
}

View File

@ -0,0 +1,35 @@
//
// Copyright (c) 2023 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
import TIUIElements
import TIUIKitCore
import UIKit
public extension WrappableView where Self: ConfigurableView {
typealias InTableRow = TableKit.TableRow<Self.InTableCell>
typealias InSeparatableRow = TableKit.TableRow<Self.InSeparatableTableCell>
}
public extension WrappableView where Self: UITableViewCell & ConfigurableCell {
typealias TableRow = TableKit.TableRow<Self>
}

View File

@ -31,23 +31,23 @@ public extension Array where Element == SeparatorRowBox {
}
/// Configure separators from SeparatorRowBox array
/// - parameter extreme: Configuration that will be used for extreme values, for first or last row
/// - parameter middle: Configuration for intermediate rows
func configureSeparators(extreme extremeSeparatorConfiguration: SeparatorConfiguration,
middle middleSeparatorConfiguration: SeparatorConfiguration) {
/// - parameter extreme: Appearance that will be used for extreme values, for first or last row
/// - parameter middle: Apearance for intermediate rows
func configureSeparators(extreme extremeSeparatorsAppearance: SeparatorAppearance,
middle middleSeparatorsAppearance: SeparatorAppearance) {
configureSeparators(first: extremeSeparatorConfiguration,
middle: middleSeparatorConfiguration,
last: extremeSeparatorConfiguration)
configureSeparators(first: extremeSeparatorsAppearance,
middle: middleSeparatorsAppearance,
last: extremeSeparatorsAppearance)
}
/// Configure separators from SeparatorRowBox array
/// - parameter first: Configuration of the top separator of the first row
/// - parameter middle: Configuration of the separators between the rows
/// - parameter last: Configuration of the bottom separator of the last row
func configureSeparators(first firstSeparatorConfiguration: SeparatorConfiguration,
middle middleSeparatorConfiguration: SeparatorConfiguration,
last lastSeparatorConfiguration: SeparatorConfiguration) {
/// - parameter first: Appearance of the top separator of the first row
/// - parameter middle: Appearance of the separators between the rows
/// - parameter last: Appearance of the bottom separator of the last row
func configureSeparators(first firstSeparatorsAppearance: SeparatorAppearance,
middle middleSeparatorsAppearance: SeparatorAppearance,
last lastSeparatorsAppearance: SeparatorAppearance) {
if isEmpty {
return
@ -55,12 +55,12 @@ public extension Array where Element == SeparatorRowBox {
switch count {
case 1:
first?.set(separatorType: .full(firstSeparatorConfiguration, lastSeparatorConfiguration))
first?.set(separatorType: .full(top: firstSeparatorsAppearance, bottom: lastSeparatorsAppearance))
default:
dropFirst().dropLast().forEach { $0.set(separatorType: .bottom(middleSeparatorConfiguration)) }
first?.set(separatorType: .full(firstSeparatorConfiguration, middleSeparatorConfiguration))
last?.set(separatorType: .bottom(lastSeparatorConfiguration))
dropFirst().dropLast().forEach { $0.set(separatorType: .bottom(middleSeparatorsAppearance)) }
first?.set(separatorType: .full(top: firstSeparatorsAppearance, bottom: middleSeparatorsAppearance))
last?.set(separatorType: .bottom(lastSeparatorsAppearance))
}
}
}

View File

@ -0,0 +1,31 @@
//
// Copyright (c) 2023 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
import TIUIElements
import TIUIKitCore
extension ContainerTableViewCell: ConfigurableCell where View: ConfigurableView {
public func configure(with viewModel: View.ViewModelType) {
wrappedView.configure(with: viewModel)
}
}

View File

@ -23,28 +23,29 @@
import TableKit
import TIUIElements
private let configureSeparatorActionId = "TableRowConfigureSeparatorActionId"
extension TableRow: SeparatorsConfigurable where CellType: SeparatorsConfigurable {
private static var configureSeparatorsActionId: String {
"TableRowConfigureSeparatorsActionId"
}
public extension TableRow where CellType: SeparatorConfigurable {
func with(separatorType: ViewSeparatorType) -> Self {
set(separatorType: separatorType)
public func with(separators: SeparatorsConfiguration) -> Self {
configureSeparators(with: separators)
return self
}
func set(separatorType: ViewSeparatorType) {
removeAction(forActionId: configureSeparatorActionId)
public func configureSeparators(with separatorsConfiguration: SeparatorsConfiguration) {
removeAction(forActionId: Self.configureSeparatorsActionId)
let action = TableRowAction<CellType>(.configure) {
$0.cell?.configureSeparators(with: separatorType)
let action = TableRowAction<CellType>(.configure) { options in
options.cell?.configureSeparators(with: separatorsConfiguration)
}
action.id = configureSeparatorActionId
action.id = Self.configureSeparatorsActionId
on(action)
}
}
public extension TableRow where CellType: SeparatorConfigurable {
public extension TableRow where CellType: SeparatorsConfigurable {
/// TableRow typed as SeparatorRowBox
var separatorRowBox: SeparatorRowBox {

View File

@ -21,21 +21,21 @@
//
import TableKit
import TIUIElements
import TISwiftUtils
import TIUIElements
/// Class that used to configure separators when multiply cells presented in one section
public final class SeparatorRowBox {
private let setSeparatorHandler: ParameterClosure<ViewSeparatorType>
private let setSeparatorHandler: ParameterClosure<SeparatorsConfiguration>
public func set(separatorType: ViewSeparatorType) {
public func set(separatorType: SeparatorsConfiguration) {
setSeparatorHandler(separatorType)
}
public let row: Row
public init<T>(row: TableRow<T>) where T: SeparatorConfigurable {
public init<T>(row: TableRow<T>) where T: SeparatorsConfigurable {
self.row = row
setSeparatorHandler = row.set
setSeparatorHandler = row.configureSeparators(with:)
}
}

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TITableKitUtils'
s.version = '1.32.0'
s.version = '1.33.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' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TITransitions'
s.version = '1.32.0'
s.version = '1.33.0'
s.summary = 'Set of custom transitions to present controller. '
s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -0,0 +1,52 @@
//
// Copyright (c) 2023 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 UIKit
extension UILabel {
open class BaseAppearance<Layout: ViewLayout>: UIView.BaseAppearance<Layout> {
public var textAttributes: BaseTextAttributes?
public init(layout: Layout = .defaultLayout,
backgroundColor: UIColor = .clear,
roundedCorners: CACornerMask = [],
cornerRadius: CGFloat = .zero,
shadow: UIViewShadow? = nil,
textAttributes: BaseTextAttributes? = nil) {
self.textAttributes = textAttributes
super.init(layout: layout,
backgroundColor: backgroundColor,
roundedCorners: roundedCorners,
cornerRadius: cornerRadius,
shadow: shadow)
}
}
public final class DefaultAppearance: BaseAppearance<UIView.DefaultWrappedLayout>, WrappedViewAppearance {
public static var defaultAppearance: DefaultAppearance {
DefaultAppearance()
}
}
}

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2020 Touch Instinct
// Copyright (c) 2023 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
@ -20,17 +20,15 @@
// THE SOFTWARE.
//
import TIUIKitCore
import UIKit
public struct SeparatorConfiguration {
extension UILabel {
public func configureUILabel<L: ViewLayout>(appearance: BaseAppearance<L>) {
appearance.textAttributes?
.configure(label: self,
with: attributedText?.string ?? text)
public let color: UIColor
public let insets: UIEdgeInsets
public let height: CGFloat
public init(color: UIColor, insets: UIEdgeInsets = .zero, height: CGFloat = 1) {
self.color = color
self.insets = insets
self.height = height
super.configureUIView(appearance: appearance)
}
}

View File

@ -0,0 +1,43 @@
//
// Copyright (c) 2023 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 UIKit
extension UIView {
public func configureUIView(appearance: BaseAppearance<some ViewLayout>) {
backgroundColor = appearance.backgroundColor
layer.masksToBounds = true
layer.maskedCorners = appearance.roundedCorners
layer.cornerRadius = appearance.cornerRadius
guard let shadow = appearance.shadow else {
return
}
layer.shadowOpacity = shadow.opacity
layer.shadowOffset = shadow.offset
layer.shadowColor = shadow.color.cgColor
layer.shadowRadius = shadow.radius
clipsToBounds = false
}
}

View File

@ -0,0 +1,144 @@
//
// Copyright (c) 2023 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 UIKit
extension UIView {
// MARK: - Layout Variations
public struct NoLayout: ViewLayout {
public static var defaultLayout: Self {
Self()
}
}
open class BaseSizeLayout {
public var size: CGSize
public init(size: CGSize = .infinity) {
self.size = size
}
}
public final class DefaultLayout: BaseSizeLayout, SizeViewLayout {
public static var defaultLayout: Self {
Self()
}
}
// MARK: - WrappedView Layout
open class BaseWrappedLayout: BaseSizeLayout {
public var centerOffset: UIOffset
public var insets: UIEdgeInsets
public init(insets: UIEdgeInsets = .zero,
size: CGSize = .infinity,
centerOffset: UIOffset = .nan) {
self.centerOffset = centerOffset
self.insets = insets
super.init(size: size)
}
}
public final class DefaultWrappedLayout: BaseWrappedLayout, WrappedViewLayout {
public static var defaultLayout: Self {
Self()
}
}
// MARK: - Appearance Variations
open class BaseAppearance<Layout: ViewLayout> {
public var layout: Layout
public var backgroundColor: UIColor
public var roundedCorners: CACornerMask
public var cornerRadius: CGFloat
public var shadow: UIViewShadow?
public init(layout: Layout = .defaultLayout,
backgroundColor: UIColor = .clear,
roundedCorners: CACornerMask = [],
cornerRadius: CGFloat = .zero,
shadow: UIViewShadow? = nil) {
self.layout = layout
self.backgroundColor = backgroundColor
self.roundedCorners = roundedCorners
self.cornerRadius = cornerRadius
self.shadow = shadow
}
}
public final class DefaultAppearance: BaseAppearance<DefaultLayout>, ViewAppearance {
public static var defaultAppearance: Self {
Self()
}
}
// MARK: - WrappedView Appearance
open class BaseWrappedViewHolderAppearance<SubviewAppearance: WrappedViewAppearance,
Layout: ViewLayout>: BaseAppearance<Layout> {
public var subviewAppearance: SubviewAppearance
public init(layout: Layout = .defaultLayout,
backgroundColor: UIColor = .clear,
roundedCorners: CACornerMask = [],
cornerRadius: CGFloat = .zero,
shadow: UIViewShadow? = nil,
subviewAppearance: SubviewAppearance = .defaultAppearance) {
self.subviewAppearance = subviewAppearance
super.init(layout: layout,
backgroundColor: backgroundColor,
roundedCorners: roundedCorners,
cornerRadius: cornerRadius,
shadow: shadow)
}
}
public final class DefaultWrappedViewHolderAppearance<SubviewAppearance: WrappedViewAppearance,
Layout: ViewLayout>: BaseWrappedViewHolderAppearance<SubviewAppearance, Layout>,
WrappedViewHolderAppearance {
public static var defaultAppearance: Self {
Self()
}
}
public final class DefaultWrappedAppearance: BaseAppearance<DefaultWrappedLayout>, WrappedViewAppearance {
public static var defaultAppearance: Self {
Self()
}
}
}
extension UIView.DefaultWrappedViewHolderAppearance: WrappedViewAppearance where Layout: WrappedViewLayout {
}

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2020 Touch Instinct
// Copyright (c) 2023 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
@ -22,7 +22,8 @@
import UIKit
open class BaseSeparatorCell: BaseInitializableCell, SeparatorConfigurable {
open class ContainerSeparatorTableViewCell<View: UIView>: ContainerTableViewCell<View>, SeparatorsConfigurable {
private lazy var topSeparatorView = createTopSeparator()
private lazy var bottomSeparatorView = createBottomSeparator()
@ -52,23 +53,25 @@ open class BaseSeparatorCell: BaseInitializableCell, SeparatorConfigurable {
contentView.addSubview(bottomSeparatorView)
}
public func configureSeparators(with separatorType: ViewSeparatorType) {
topSeparatorView.isHidden = separatorType.topIsHidden
bottomSeparatorView.isHidden = separatorType.bottomIsHidden
// MARK: - SeparatorsConfigurable
switch separatorType {
public func configureSeparators(with separatorsConfiguration: SeparatorsConfiguration) {
topSeparatorView.isHidden = separatorsConfiguration.topIsHidden
bottomSeparatorView.isHidden = separatorsConfiguration.bottomIsHidden
switch separatorsConfiguration {
case .none:
break
case let .bottom(configuration):
updateBottomSeparator(with: configuration)
case let .bottom(appearance):
updateBottomSeparator(with: appearance)
case let .top(configuration):
updateTopSeparator(with: configuration)
case let .top(appearance):
updateTopSeparator(with: appearance)
case let .full(topConfiguration, bottomConfiguration):
updateTopSeparator(with: topConfiguration)
updateBottomSeparator(with: bottomConfiguration)
case let .full(topAppearance, bottomAppearance):
updateTopSeparator(with: topAppearance)
updateBottomSeparator(with: bottomAppearance)
}
}
@ -127,26 +130,26 @@ open class BaseSeparatorCell: BaseInitializableCell, SeparatorConfigurable {
$0.translatesAutoresizingMaskIntoConstraints = false
}
}
}
private extension BaseSeparatorCell {
func updateTopSeparator(with configuration: SeparatorConfiguration) {
topSeparatorView.backgroundColor = configuration.color
// MARK: - Private
topViewHeightConstraint?.constant = configuration.height
private func updateTopSeparator(with appearance: SeparatorAppearance) {
topSeparatorView.configureUIView(appearance: appearance)
topViewTopConstraint?.constant = configuration.insets.top
topViewLeftConstraint?.constant = configuration.insets.left
topViewRightConstraint?.constant = configuration.insets.right
topViewHeightConstraint?.constant = appearance.layout.size.height
topViewTopConstraint?.constant = appearance.layout.insets.top
topViewLeftConstraint?.constant = appearance.layout.insets.left
topViewRightConstraint?.constant = appearance.layout.insets.right
}
func updateBottomSeparator(with configuration: SeparatorConfiguration) {
bottomSeparatorView.backgroundColor = configuration.color
private func updateBottomSeparator(with appearance: SeparatorAppearance) {
bottomSeparatorView.configureUIView(appearance: appearance)
bottomViewHeightConstraint?.constant = configuration.height
bottomViewHeightConstraint?.constant = appearance.layout.size.height
bottomViewBottomConstraint?.constant = configuration.insets.bottom
bottomViewLeftConstraint?.constant = configuration.insets.left
bottomViewRightConstraint?.constant = configuration.insets.right
bottomViewBottomConstraint?.constant = appearance.layout.insets.bottom
bottomViewLeftConstraint?.constant = appearance.layout.insets.left
bottomViewRightConstraint?.constant = appearance.layout.insets.right
}
}

View File

@ -0,0 +1,44 @@
//
// Copyright (c) 2023 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 UIKit
public final class SeparatorLayout: UIView.BaseWrappedLayout, WrappedViewLayout {
public static var defaultLayout: Self {
Self()
}
public init(insets: UIEdgeInsets = .zero,
size: CGSize = .fixedHeight(0.5)) {
super.init(insets: insets,
size: size,
centerOffset: .nan)
}
}
public final class SeparatorAppearance: UIView.BaseAppearance<SeparatorLayout>, ViewAppearance {
public static var defaultAppearance: Self {
Self(backgroundColor: .lightGray)
}
}

View File

@ -20,6 +20,6 @@
// THE SOFTWARE.
//
public protocol SeparatorConfigurable {
func configureSeparators(with separatorType: ViewSeparatorType)
public protocol SeparatorsConfigurable {
func configureSeparators(with separatorsConfiguration: SeparatorsConfiguration)
}

View File

@ -20,22 +20,14 @@
// THE SOFTWARE.
//
public enum ViewSeparatorType {
/// All separators for view is hidden
public enum SeparatorsConfiguration {
case none
/// Show only top separator
case top(SeparatorConfiguration)
/// Show only bottom separator
case bottom(SeparatorConfiguration)
/// First configuration for top, second for bottom
case full(SeparatorConfiguration, SeparatorConfiguration)
case top(SeparatorAppearance)
case bottom(SeparatorAppearance)
case full(top: SeparatorAppearance, bottom: SeparatorAppearance)
}
public extension ViewSeparatorType {
public extension SeparatorsConfiguration {
/// Determine if bottom separator is hidden.
var bottomIsHidden: Bool {
@ -48,7 +40,7 @@ public extension ViewSeparatorType {
}
/// Returns top configuration if type is top or full.
var topConfiguration: SeparatorConfiguration? {
var topConfiguration: SeparatorAppearance? {
switch self {
case let .top(configuration), let .full(configuration, _):
return configuration
@ -59,7 +51,7 @@ public extension ViewSeparatorType {
}
/// Returns bottom configuration if type is bottom or full.
var bottomConfiguration: SeparatorConfiguration? {
var bottomConfiguration: SeparatorAppearance? {
switch self {
case let .bottom(configuration), let .full(_, configuration):
return configuration

View File

@ -0,0 +1,50 @@
//
// Copyright (c) 2023 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 CollectionTableViewCell<CollectionView: UICollectionView>: ContainerTableViewCell<CollectionView> {
// MARK: - UIView Overrides
open override func systemLayoutSizeFitting(_ targetSize: CGSize,
withHorizontalFittingPriority horizontalFittingPriority: UILayoutPriority,
verticalFittingPriority: UILayoutPriority) -> CGSize {
let cachedCollectionFrame = wrappedView.frame
wrappedView.frame.size.width = targetSize.width - contentInsets.left - contentInsets.right
let collectionContentHeight = wrappedView.collectionViewLayout.collectionViewContentSize.height
wrappedView.frame = cachedCollectionFrame
return CGSize(width: targetSize.width,
height: collectionContentHeight + contentInsets.top + contentInsets.bottom)
}
// MARK: - Open methods
open func createCollectionLayout() -> UICollectionViewLayout {
UICollectionViewFlowLayout()
}
open override func createView() -> CollectionView {
CollectionView(frame: .zero, collectionViewLayout: createCollectionLayout())
}
}

View File

@ -53,4 +53,22 @@ open class ContainerTableViewCell<View: UIView>: BaseInitializableCell, WrappedV
open func createView() -> View {
return View()
}
// MARK: - Open methods
public func configureContainerTableViewCell(appearance: BaseWrappedViewHolderAppearance<some WrappedViewAppearance, some ViewLayout>) {
contentInsets = appearance.subviewAppearance.layout.insets
configureUIView(appearance: appearance)
}
}
// MARK: - AppearanceConfigurable
extension ContainerTableViewCell: AppearanceConfigurable where View: AppearanceConfigurable,
View.Appearance: WrappedViewAppearance {
public func configure(appearance: DefaultWrappedViewHolderAppearance<View.Appearance, UIView.NoLayout>) {
configureContainerTableViewCell(appearance: appearance)
wrappedView.configure(appearance: appearance.subviewAppearance)
}
}

View File

@ -0,0 +1,74 @@
//
// Copyright (c) 2023 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 UIKit
public final class ContainerView<View: UIView>: BaseInitializableView, WrappedViewHolder {
public var wrappedView = View()
public var contentInsets: UIEdgeInsets = .zero {
didSet {
contentEdgeConstraints?.update(from: contentInsets)
}
}
private var contentEdgeConstraints: EdgeConstraints?
// MARK: - InitializableView
public override func addViews() {
super.addViews()
addSubview(wrappedView)
}
public override func configureLayout() {
super.configureLayout()
contentEdgeConstraints = configureWrappedViewLayout()
}
}
// MARK: - ConfigurableView
extension ContainerView: ConfigurableView where View: ConfigurableView {
public func configure(with viewModel: View.ViewModelType) {
wrappedView.configure(with: viewModel)
}
}
// MARK: - AppearanceConfigurable
extension ContainerView: AppearanceConfigurable where View: AppearanceConfigurable,
View.Appearance: WrappedViewAppearance {
public typealias Appearance = UIView.DefaultWrappedViewHolderAppearance<View.Appearance, UIView.DefaultWrappedLayout>
public func configure(appearance: Appearance) {
wrappedView.configure(appearance: appearance.subviewAppearance)
configureUIView(appearance: appearance)
contentInsets = appearance.subviewAppearance.layout.insets
}
}

View File

@ -0,0 +1,27 @@
//
// Copyright (c) 2023 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 WrappableView {
typealias InContainerView = ContainerView<Self>
typealias InTableCell = ContainerTableViewCell<Self>
typealias InSeparatableTableCell = ContainerSeparatorTableViewCell<Self>
}

View File

@ -0,0 +1,27 @@
//
// Copyright (c) 2023 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
public protocol WrappableView: UIView {}
extension UIView: WrappableView {}

View File

@ -1,10 +1,11 @@
Pod::Spec.new do |s|
s.name = 'TIUIElements'
s.version = '1.32.0'
s.version = '1.33.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' }
s.author = { 'petropavel13' => 'ivan.smolin@touchin.ru' }
s.author = { 'petropavel13' => 'ivan.smolin@touchin.ru',
'castlele' => 'nikita.semenov@touchin.ru' }
s.source = { :git => 'https://github.com/TouchInstinct/LeadKit.git', :tag => s.version.to_s }
s.ios.deployment_target = '11.0'

View File

@ -0,0 +1,41 @@
//
// Copyright (c) 2023 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
public protocol AppearanceConfigurable {
associatedtype Appearance: ViewAppearance
func configure(appearance: Appearance)
}
// MARK: - Creation methods
extension AppearanceConfigurable {
@discardableResult
public func appearance(builder: ParameterClosure<Appearance>) -> Self {
let appearance = Appearance.defaultAppearance
builder(appearance)
configure(appearance: appearance)
return self
}
}

View File

@ -0,0 +1,137 @@
//
// Copyright (c) 2023 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
public struct UIViewShadow {
public var radius: CGFloat
public var offset: CGSize
public var color: UIColor
public var opacity: Float
public init(radius: CGFloat = .zero,
offset: CGSize = .zero,
color: UIColor = .clear,
opacity: Float = .zero) {
self.radius = radius
self.offset = offset
self.color = color
self.opacity = opacity
}
public init(@UIViewShadowBuilder builder: () -> [ShadowComponent]) {
let components: [ShadowComponent] = builder()
var radius: CGFloat = .zero
var offset: CGSize = .zero
var color: UIColor = .clear
var opacity: Float = .zero
for component in components {
switch component {
case let component as Radius:
radius = component.radius
case let component as Offset:
offset = component.offset
case let component as RGBA:
color = component.uiColor
case let component as Color:
color = component.color
case let component as Opacity:
opacity = component.opacity
default:
continue
}
}
if opacity == .zero, color != .clear {
opacity = Float(color.cgColor.alpha)
}
self.init(radius: radius, offset: offset, color: color, opacity: opacity)
}
}
// MARK: - UIViewShadowBuilder
@resultBuilder
public struct UIViewShadowBuilder {
public static func buildBlock(_ components: ShadowComponent...) -> [ShadowComponent] {
components
}
}
// MARK: - ShadowComponents
public protocol ShadowComponent {
}
public struct Radius: ShadowComponent {
public let radius: CGFloat
public init(_ radius: CGFloat) {
self.radius = radius
}
}
public struct Offset: ShadowComponent {
public let offset: CGSize
public init(_ offset: CGSize) {
self.offset = offset
}
public init(_ x: CGFloat, _ y: CGFloat) {
self.offset = .init(width: x, height: y)
}
}
public struct Color: ShadowComponent {
public let color: UIColor
public init(_ color: UIColor) {
self.color = color
}
}
public struct RGBA: ShadowComponent {
public let uiColor: UIColor
public init(_ r: CGFloat, _ g: CGFloat, _ b: CGFloat, _ a: CGFloat) {
self.uiColor = .init(red: r, green: g, blue: b, alpha: a)
}
}
public struct Opacity: ShadowComponent {
public let opacity: Float
public init(_ opacity: Float) {
self.opacity = opacity
}
}

View File

@ -0,0 +1,73 @@
//
// Copyright (c) 2023 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
public protocol ViewAppearance {
associatedtype Layout: ViewLayout
static var defaultAppearance: Self { get }
var layout: Layout { get }
var backgroundColor: UIColor { get }
var roundedCorners: CACornerMask { get }
var cornerRadius: CGFloat { get }
var shadow: UIViewShadow? { get }
}
// MARK: - ViewAppearance Variations
public protocol WrappedViewAppearance: ViewAppearance where Layout: WrappedViewLayout {}
public protocol WrappedViewHolderAppearance: ViewAppearance {
associatedtype SubviewAppearance: WrappedViewAppearance
var subviewAppearance: SubviewAppearance { get }
}
// MARK: - Creation methods
extension ViewAppearance {
public static func make(builder: (Self) -> Void) -> Self {
let appearance = Self.defaultAppearance
builder(appearance)
return appearance
}
public static func callAsFunction(builder: (Self) -> Void) -> Self {
let appearance = Self.defaultAppearance
builder(appearance)
return appearance
}
@discardableResult
public func update(builder: (Self) -> Void) -> Self {
builder(self)
return self
}
@discardableResult
public func callAsFunction(builder: (Self) -> Void) -> Self {
builder(self)
return self
}
}

View File

@ -0,0 +1,55 @@
//
// Copyright (c) 2023 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 UIKit
public protocol ViewLayout {
static var defaultLayout: Self { get }
}
// MARK: - ViewLayout Variations
public protocol SizeViewLayout: ViewLayout {
var size: CGSize { get }
}
public protocol WrappedViewLayout: SizeViewLayout {
var insets: UIEdgeInsets { get }
var centerOffset: UIOffset { get }
}
// MARK: - Creation methods
extension ViewLayout {
@discardableResult
public func update(builder: ParameterClosure<Self>) -> Self {
builder(self)
return self
}
@discardableResult
public func callAsFunction(builder: ParameterClosure<Self>) -> Self {
builder(self)
return self
}
}

View File

@ -0,0 +1,38 @@
//
// Copyright (c) 2023 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 CoreGraphics.CGBase
public extension CGSize {
static var infinity: Self {
Self(width: CGFloat.infinity, height: CGFloat.infinity)
}
static func fixedWidth(_ width: CGFloat) -> Self {
Self(width: width, height: CGFloat.infinity)
}
static func fixedHeight(_ height: CGFloat) -> Self {
Self(width: CGFloat.infinity, height: height)
}
}

View File

@ -0,0 +1,66 @@
//
// Copyright (c) 2023 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
public extension UIEdgeInsets {
// MARK: - Factory methods
static func edges(_ insets: CGFloat) -> UIEdgeInsets {
.init(top: insets, left: insets, bottom: insets, right: insets)
}
static func horizontal(_ insets: CGFloat) -> UIEdgeInsets {
.init(top: .zero, left: insets, bottom: .zero, right: insets)
}
static func vertical(_ insets: CGFloat) -> UIEdgeInsets {
.init(top: insets, left: .zero, bottom: insets, right: .zero)
}
static func horizontal(left: CGFloat = .zero, right: CGFloat = .zero) -> UIEdgeInsets {
.init(top: .zero, left: left, bottom: .zero, right: right)
}
static func vertical(top: CGFloat = .zero, bottom: CGFloat = .zero) -> UIEdgeInsets {
.init(top: top, left: .zero, bottom: bottom, right: .zero)
}
// MARK: - Instance methods
func horizontal(_ insets: CGFloat) -> UIEdgeInsets {
.init(top: top, left: insets, bottom: bottom, right: insets)
}
func vertical(_ insets: CGFloat) -> UIEdgeInsets {
.init(top: insets, left: left, bottom: insets, right: right)
}
func horizontal(left: CGFloat = .zero, right: CGFloat = .zero) -> UIEdgeInsets {
.init(top: top, left: left, bottom: bottom, right: right)
}
func vertical(top: CGFloat = .zero, bottom: CGFloat = .zero) -> UIEdgeInsets {
.init(top: top, left: left, bottom: bottom, right: right)
}
}

View File

@ -0,0 +1,37 @@
//
// Copyright (c) 2023 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
public extension UIOffset {
static var nan: Self {
Self(horizontal: .nan, vertical: .nan)
}
static func centerVertical(_ verticalOffset: CGFloat = .zero) -> Self {
Self(horizontal: .nan, vertical: verticalOffset)
}
static func centerHorizontal(_ horizontalOffset: CGFloat = .zero) -> Self {
Self(horizontal: horizontalOffset, vertical: .nan)
}
}

View File

@ -1,10 +1,11 @@
Pod::Spec.new do |s|
s.name = 'TIUIKitCore'
s.version = '1.32.0'
s.version = '1.33.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' }
s.author = { 'petropavel13' => 'ivan.smolin@touchin.ru' }
s.author = { 'petropavel13' => 'ivan.smolin@touchin.ru',
'castlele' => 'nikita.semenov@touchin.ru' }
s.source = { :git => 'https://github.com/TouchInstinct/LeadKit.git', :tag => s.version.to_s }
s.ios.deployment_target = '11.0'

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TIWebView'
s.version = '1.32.0'
s.version = '1.33.0'
s.summary = 'Universal web view API'
s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TIYandexMapUtils'
s.version = '1.32.0'
s.version = '1.33.0'
s.summary = 'Set of helpers for map objects clustering and interacting using Yandex Maps SDK.'
s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }