feat: new appearance configurations
This commit is contained in:
parent
332e895659
commit
e2c9c6c102
|
|
@ -1,5 +1,11 @@
|
|||
# Changelog
|
||||
|
||||
### 1.38.1
|
||||
|
||||
- **Added**: UIButton Appearance model
|
||||
- **Added**: `SpacedWrappedViewLayout` for spacing configurations
|
||||
- **Update**: UIView appearance model with border configurations
|
||||
|
||||
### 1.38.0
|
||||
|
||||
- **Added**: Placemarks states for icon updating
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = 'TIAppleMapUtils'
|
||||
s.version = '1.38.0'
|
||||
s.version = '1.38.1'
|
||||
s.summary = 'Set of helpers for map objects clustering and interacting using Apple MapKit.'
|
||||
s.homepage = 'https://gitlab.ti/touchinstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = 'TIAuth'
|
||||
s.version = '1.38.0'
|
||||
s.version = '1.38.1'
|
||||
s.summary = 'Login, registration, confirmation and other related actions'
|
||||
s.homepage = 'https://gitlab.ti/touchinstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = 'TIDeveloperUtils'
|
||||
s.version = '1.38.0'
|
||||
s.version = '1.38.1'
|
||||
s.summary = 'Universal web view API'
|
||||
s.homepage = 'https://gitlab.ti/touchinstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = 'TIEcommerce'
|
||||
s.version = '1.38.0'
|
||||
s.version = '1.38.1'
|
||||
s.summary = 'Cart, products, promocodes, bonuses and other related actions'
|
||||
s.homepage = 'https://gitlab.ti/touchinstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = 'TIFoundationUtils'
|
||||
s.version = '1.38.0'
|
||||
s.version = '1.38.1'
|
||||
s.summary = 'Set of helpers for Foundation framework classes.'
|
||||
s.homepage = 'https://gitlab.ti/touchinstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = 'TIGoogleMapUtils'
|
||||
s.version = '1.38.0'
|
||||
s.version = '1.38.1'
|
||||
s.summary = 'Set of helpers for map objects clustering and interacting using Google Maps SDK.'
|
||||
s.homepage = 'https://gitlab.ti/touchinstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = 'TIKeychainUtils'
|
||||
s.version = '1.38.0'
|
||||
s.version = '1.38.1'
|
||||
s.summary = 'Set of helpers for Keychain classes.'
|
||||
s.homepage = 'https://gitlab.ti/touchinstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = 'TIMapUtils'
|
||||
s.version = '1.38.0'
|
||||
s.version = '1.38.1'
|
||||
s.summary = 'Set of helpers for map objects clustering and interacting.'
|
||||
s.homepage = 'https://gitlab.ti/touchinstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = 'TIMoyaNetworking'
|
||||
s.version = '1.38.0'
|
||||
s.version = '1.38.1'
|
||||
s.summary = 'Moya + Swagger network service.'
|
||||
s.homepage = 'https://gitlab.ti/touchinstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = 'TINetworking'
|
||||
s.version = '1.38.0'
|
||||
s.version = '1.38.1'
|
||||
s.summary = 'Swagger-frendly networking layer helpers.'
|
||||
s.homepage = 'https://gitlab.ti/touchinstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = 'TINetworkingCache'
|
||||
s.version = '1.38.0'
|
||||
s.version = '1.38.1'
|
||||
s.summary = 'Caching results of EndpointRequests.'
|
||||
s.homepage = 'https://gitlab.ti/touchinstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = 'TIPagination'
|
||||
s.version = '1.38.0'
|
||||
s.version = '1.38.1'
|
||||
s.summary = 'Generic pagination component.'
|
||||
s.homepage = 'https://gitlab.ti/touchinstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = 'TISwiftUICore'
|
||||
s.version = '1.38.0'
|
||||
s.version = '1.38.1'
|
||||
s.summary = 'Core UI elements: protocols, views and helpers.'
|
||||
s.homepage = 'https://gitlab.ti/touchinstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = 'TISwiftUtils'
|
||||
s.version = '1.38.0'
|
||||
s.version = '1.38.1'
|
||||
s.summary = 'Bunch of useful helpers for Swift development.'
|
||||
s.homepage = 'https://gitlab.ti/touchinstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = 'TITableKitUtils'
|
||||
s.version = '1.38.0'
|
||||
s.version = '1.38.1'
|
||||
s.summary = 'Set of helpers for TableKit classes.'
|
||||
s.homepage = 'https://gitlab.ti/touchinstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
|
|
|
|||
|
|
@ -0,0 +1,64 @@
|
|||
//
|
||||
// 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 UIButton {
|
||||
open class BaseAppearance<Layout: ViewLayout>: UILabel.BaseAppearance<Layout> {
|
||||
|
||||
public var contentInsets: UIEdgeInsets
|
||||
public var titleInsets: UIEdgeInsets
|
||||
public var imageInsets: UIEdgeInsets
|
||||
|
||||
public init(layout: Layout = .defaultLayout,
|
||||
backgroundColor: UIColor = .clear,
|
||||
roundedCorners: CACornerMask = [],
|
||||
cornerRadius: CGFloat = .zero,
|
||||
borderColor: UIColor = .clear,
|
||||
borderWidth: CGFloat = .zero,
|
||||
shadow: UIViewShadow? = nil,
|
||||
textAttributes: BaseTextAttributes? = nil,
|
||||
contentInsets: UIEdgeInsets = .zero,
|
||||
titleInsets: UIEdgeInsets = .zero,
|
||||
imageInsets: UIEdgeInsets = .zero) {
|
||||
|
||||
self.contentInsets = contentInsets
|
||||
self.titleInsets = titleInsets
|
||||
self.imageInsets = imageInsets
|
||||
|
||||
super.init(layout: layout,
|
||||
backgroundColor: backgroundColor,
|
||||
roundedCorners: roundedCorners,
|
||||
cornerRadius: cornerRadius,
|
||||
borderColor: borderColor,
|
||||
borderWidth: borderWidth,
|
||||
shadow: shadow)
|
||||
}
|
||||
}
|
||||
|
||||
public final class DefaultAppearance: BaseAppearance<UIView.DefaultWrappedLayout>, WrappedViewAppearance {
|
||||
public static var defaultAppearance: Self {
|
||||
Self()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -24,11 +24,30 @@ import TIUIKitCore
|
|||
import UIKit
|
||||
|
||||
extension UIButton {
|
||||
public func configureUIButton(appearance: UILabel.BaseAppearance<some ViewLayout>) {
|
||||
public func configureUIButton(appearance: UIButton.BaseAppearance<some ViewLayout>) {
|
||||
appearance.textAttributes?
|
||||
.configure(button: self,
|
||||
with: titleLabel?.attributedText?.string ?? titleLabel?.text)
|
||||
|
||||
if #available(iOS 15, *) {
|
||||
configuration?.contentInsets = .init(insets: appearance.contentInsets)
|
||||
|
||||
if configuration?.imagePlacement == .leading {
|
||||
let padding = appearance.titleInsets.left + appearance.imageInsets.right
|
||||
configuration?.imagePadding = padding
|
||||
}
|
||||
|
||||
if configuration?.imagePlacement == .trailing {
|
||||
let padding = appearance.titleInsets.right + appearance.imageInsets.left
|
||||
configuration?.imagePadding = padding
|
||||
}
|
||||
|
||||
} else {
|
||||
contentEdgeInsets = appearance.contentInsets
|
||||
titleEdgeInsets = appearance.titleInsets
|
||||
imageEdgeInsets = appearance.imageInsets
|
||||
}
|
||||
|
||||
super.configureUIView(appearance: appearance)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ extension UILabel {
|
|||
backgroundColor: UIColor = .clear,
|
||||
roundedCorners: CACornerMask = [],
|
||||
cornerRadius: CGFloat = .zero,
|
||||
borderColor: UIColor = .clear,
|
||||
borderWidth: CGFloat = .zero,
|
||||
shadow: UIViewShadow? = nil,
|
||||
textAttributes: BaseTextAttributes? = nil) {
|
||||
|
||||
|
|
@ -41,6 +43,8 @@ extension UILabel {
|
|||
backgroundColor: backgroundColor,
|
||||
roundedCorners: roundedCorners,
|
||||
cornerRadius: cornerRadius,
|
||||
borderColor: borderColor,
|
||||
borderWidth: borderWidth,
|
||||
shadow: shadow)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ extension UIView {
|
|||
layer.masksToBounds = true
|
||||
layer.maskedCorners = appearance.roundedCorners
|
||||
layer.cornerRadius = appearance.cornerRadius
|
||||
layer.borderWidth = appearance.borderWidth
|
||||
layer.borderColor = appearance.borderColor.cgColor
|
||||
|
||||
guard let shadow = appearance.shadow else {
|
||||
return
|
||||
|
|
|
|||
|
|
@ -64,12 +64,31 @@ extension UIView {
|
|||
}
|
||||
}
|
||||
|
||||
open class BaseSpecedWrappedLayout: BaseWrappedLayout {
|
||||
public var spacing: CGFloat
|
||||
|
||||
public init(insets: UIEdgeInsets = .zero,
|
||||
size: CGSize = .infinity,
|
||||
centerOffset: UIOffset = .nan,
|
||||
spacing: CGFloat = .zero) {
|
||||
self.spacing = spacing
|
||||
|
||||
super.init(insets: insets, size: size, centerOffset: centerOffset)
|
||||
}
|
||||
}
|
||||
|
||||
public final class DefaultWrappedLayout: BaseWrappedLayout, WrappedViewLayout {
|
||||
public static var defaultLayout: Self {
|
||||
Self()
|
||||
}
|
||||
}
|
||||
|
||||
public final class DefaultSpacedWrappedLayout: BaseSpecedWrappedLayout, SpacedWrappedViewLayout {
|
||||
public static var defaultLayout: Self {
|
||||
Self()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Appearance Variations
|
||||
|
||||
open class BaseAppearance<Layout: ViewLayout> {
|
||||
|
|
@ -78,18 +97,24 @@ extension UIView {
|
|||
public var backgroundColor: UIColor
|
||||
public var roundedCorners: CACornerMask
|
||||
public var cornerRadius: CGFloat
|
||||
public var borderColor: UIColor
|
||||
public var borderWidth: CGFloat
|
||||
public var shadow: UIViewShadow?
|
||||
|
||||
public init(layout: Layout = .defaultLayout,
|
||||
backgroundColor: UIColor = .clear,
|
||||
roundedCorners: CACornerMask = [],
|
||||
cornerRadius: CGFloat = .zero,
|
||||
borderColor: UIColor = .clear,
|
||||
borderWidth: CGFloat = .zero,
|
||||
shadow: UIViewShadow? = nil) {
|
||||
|
||||
self.layout = layout
|
||||
self.backgroundColor = backgroundColor
|
||||
self.roundedCorners = roundedCorners
|
||||
self.cornerRadius = cornerRadius
|
||||
self.borderColor = borderColor
|
||||
self.borderWidth = borderWidth
|
||||
self.shadow = shadow
|
||||
}
|
||||
}
|
||||
|
|
@ -137,6 +162,12 @@ extension UIView {
|
|||
Self()
|
||||
}
|
||||
}
|
||||
|
||||
public final class DefaultSpacedWrappedAppearance: BaseAppearance<DefaultSpacedWrappedLayout>, WrappedViewAppearance {
|
||||
public static var defaultAppearance: Self {
|
||||
Self()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension UIView.DefaultWrappedViewHolderAppearance: WrappedViewAppearance where Layout: WrappedViewLayout {
|
||||
|
|
|
|||
|
|
@ -199,14 +199,12 @@ open class BaseListItemView<LeadingView: UIView,
|
|||
middleViewLeadingConstraint?.isActive = true
|
||||
middleViewLeadingToSuperViewConstraint?.isActive = false
|
||||
|
||||
setupCenterYOffset(layout: leadingViewLayout,
|
||||
centerYConstraint: leadingViewCenterYConstraint,
|
||||
topConstraint: leadingViewTopConstraint,
|
||||
bottomContraint: leadingViewBottomConstraint)
|
||||
leadingViewLayout.setupCenterYOffset(centerYConstraint: leadingViewCenterYConstraint,
|
||||
topConstraint: leadingViewTopConstraint,
|
||||
bottomConstraint: leadingViewBottomConstraint)
|
||||
|
||||
setup(size: leadingViewLayout.size,
|
||||
widthConstraint: leadingViewWidthConstraint,
|
||||
heightConstraint: leadingViewHeightConstraint)
|
||||
leadingViewLayout.setupSize(widthConstraint: leadingViewWidthConstraint,
|
||||
heightConstraint: leadingViewHeightConstraint)
|
||||
|
||||
leadingToSuperviewContraint = leadingViewLeadingToSuperviewConstraint
|
||||
leadingViewLeftInset = leadingViewLayout.insets.left
|
||||
|
|
@ -218,14 +216,12 @@ open class BaseListItemView<LeadingView: UIView,
|
|||
private func updateMiddleViewLayout(containerLayout: ViewLayout,
|
||||
middleViewLayout: WrappedViewLayout) {
|
||||
|
||||
setupCenterYOffset(layout: middleViewLayout,
|
||||
centerYConstraint: middleViewCenterYConstraint,
|
||||
topConstraint: middleViewTopConstraint,
|
||||
bottomContraint: middleViewBottomConstraint)
|
||||
middleViewLayout.setupCenterYOffset(centerYConstraint: middleViewCenterYConstraint,
|
||||
topConstraint: middleViewTopConstraint,
|
||||
bottomConstraint: middleViewBottomConstraint)
|
||||
|
||||
setup(size: middleViewLayout.size,
|
||||
widthConstraint: middleViewWidthConstraint,
|
||||
heightConstraint: middleViewHeightConstraint)
|
||||
middleViewLayout.setupSize(widthConstraint: middleViewWidthConstraint,
|
||||
heightConstraint: middleViewHeightConstraint)
|
||||
}
|
||||
|
||||
private func updateTrailingViewLayout(trailingViewLayout: WrappedViewLayout,
|
||||
|
|
@ -246,14 +242,12 @@ open class BaseListItemView<LeadingView: UIView,
|
|||
trailingViewLeadingToMiddleViewConstraint?.isActive = true
|
||||
middleViewTrailingToSuperViewConstraint?.isActive = false
|
||||
|
||||
setupCenterYOffset(layout: trailingViewLayout,
|
||||
centerYConstraint: trailingViewCenterYConstraint,
|
||||
topConstraint: trailingViewTopConstraint,
|
||||
bottomContraint: trailingViewBottomConstraint)
|
||||
trailingViewLayout.setupCenterYOffset(centerYConstraint: trailingViewCenterYConstraint,
|
||||
topConstraint: trailingViewTopConstraint,
|
||||
bottomConstraint: trailingViewBottomConstraint)
|
||||
|
||||
setup(size: trailingViewLayout.size,
|
||||
widthConstraint: trailingViewWidthConstraint,
|
||||
heightConstraint: trailingViewWidthConstraint)
|
||||
trailingViewLayout.setupSize(widthConstraint: trailingViewWidthConstraint,
|
||||
heightConstraint: trailingViewWidthConstraint)
|
||||
|
||||
trailingToSuperviewConstraint = trailingViewTrailingToSuperviewConstraint
|
||||
trailingViewRightInset = trailingViewLayout.insets.right
|
||||
|
|
@ -261,44 +255,4 @@ open class BaseListItemView<LeadingView: UIView,
|
|||
|
||||
trailingToSuperviewConstraint?.constant = -trailingViewRightInset
|
||||
}
|
||||
|
||||
private func setupCenterYOffset(layout: WrappedViewLayout,
|
||||
centerYConstraint: NSLayoutConstraint?,
|
||||
topConstraint: NSLayoutConstraint?,
|
||||
bottomContraint: NSLayoutConstraint?) {
|
||||
|
||||
let centerYOffset = layout.centerOffset.vertical
|
||||
|
||||
if centerYOffset.isFinite {
|
||||
centerYConstraint?.constant = centerYOffset
|
||||
centerYConstraint?.isActive = true
|
||||
topConstraint?.isActive = false
|
||||
bottomContraint?.isActive = false
|
||||
} else {
|
||||
topConstraint?.constant = layout.insets.top
|
||||
bottomContraint?.constant = -layout.insets.bottom
|
||||
centerYConstraint?.isActive = false
|
||||
topConstraint?.isActive = true
|
||||
bottomContraint?.isActive = true
|
||||
}
|
||||
}
|
||||
|
||||
private func setup(size: CGSize,
|
||||
widthConstraint: NSLayoutConstraint?,
|
||||
heightConstraint: NSLayoutConstraint?) {
|
||||
|
||||
if size.width.isFinite {
|
||||
widthConstraint?.constant = size.width
|
||||
widthConstraint?.isActive = true
|
||||
} else {
|
||||
widthConstraint?.isActive = false
|
||||
}
|
||||
|
||||
if size.height.isFinite {
|
||||
heightConstraint?.constant = size.height
|
||||
heightConstraint?.isActive = true
|
||||
} else {
|
||||
heightConstraint?.isActive = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ open class StatefulButton: UIButton {
|
|||
}
|
||||
}
|
||||
|
||||
public typealias Appearance = UILabel.BaseAppearance<UIView.DefaultWrappedLayout>
|
||||
public typealias Appearance = UIButton.BaseAppearance<UIView.DefaultWrappedLayout>
|
||||
public typealias StateAppearance = [State: Appearance]
|
||||
public typealias StateEventPropagations = [State: Bool]
|
||||
|
||||
|
|
|
|||
|
|
@ -24,25 +24,8 @@ import TIUIKitCore
|
|||
import UIKit
|
||||
|
||||
extension DefaultTitleSubtitleView {
|
||||
public final class Layout: UIView.BaseWrappedLayout, WrappedViewLayout {
|
||||
|
||||
public static var defaultLayout: Layout {
|
||||
Self()
|
||||
}
|
||||
|
||||
public var spacing: CGFloat
|
||||
|
||||
public init(insets: UIEdgeInsets = .zero,
|
||||
centerOffset: UIOffset = .zero,
|
||||
spacing: CGFloat = .zero) {
|
||||
|
||||
self.spacing = spacing
|
||||
|
||||
super.init(insets: insets, centerOffset: centerOffset)
|
||||
}
|
||||
}
|
||||
|
||||
public final class Appearance: UIView.BaseAppearance<Layout>, WrappedViewAppearance {
|
||||
public final class Appearance: UIView.BaseAppearance<UIView.DefaultSpacedWrappedLayout>, WrappedViewAppearance {
|
||||
|
||||
public static var defaultAppearance: Appearance {
|
||||
Self()
|
||||
|
|
@ -55,6 +38,8 @@ extension DefaultTitleSubtitleView {
|
|||
backgroundColor: UIColor = .clear,
|
||||
roundedCorners: CACornerMask = [],
|
||||
cornerRadius: CGFloat = .zero,
|
||||
borderColor: UIColor = .clear,
|
||||
borderWidth: CGFloat = .zero,
|
||||
shadow: UIViewShadow? = nil,
|
||||
titleAppearance: UILabel.DefaultAppearance = .defaultAppearance,
|
||||
subtitleAppearance: UILabel.DefaultAppearance = .defaultAppearance) {
|
||||
|
|
@ -66,6 +51,8 @@ extension DefaultTitleSubtitleView {
|
|||
backgroundColor: backgroundColor,
|
||||
roundedCorners: roundedCorners,
|
||||
cornerRadius: cornerRadius,
|
||||
borderColor: borderColor,
|
||||
borderWidth: borderWidth,
|
||||
shadow: shadow)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ public final class DefaultTitleSubtitleView: BaseInitializableView,
|
|||
configure(layout: appearance.layout)
|
||||
}
|
||||
|
||||
public func configure(layout: Layout) {
|
||||
public func configure(layout: UIView.DefaultSpacedWrappedLayout) {
|
||||
spacingConstraint?.constant = layout.spacing
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = 'TIUIElements'
|
||||
s.version = '1.38.0'
|
||||
s.version = '1.38.1'
|
||||
s.summary = 'Bunch of useful protocols and views.'
|
||||
s.homepage = 'https://gitlab.ti/touchinstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
|
|
|
|||
|
|
@ -0,0 +1,85 @@
|
|||
//
|
||||
// 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 WrappedViewLayout {
|
||||
func setupSize(widthConstraint: NSLayoutConstraint?,
|
||||
heightConstraint: NSLayoutConstraint?) {
|
||||
|
||||
if size.width.isFinite {
|
||||
widthConstraint?.constant = size.width
|
||||
widthConstraint?.isActive = true
|
||||
} else {
|
||||
widthConstraint?.isActive = false
|
||||
}
|
||||
|
||||
if size.height.isFinite {
|
||||
heightConstraint?.constant = size.height
|
||||
heightConstraint?.isActive = true
|
||||
} else {
|
||||
heightConstraint?.isActive = false
|
||||
}
|
||||
}
|
||||
|
||||
func setupCenterYOffset(centerYConstraint: NSLayoutConstraint?,
|
||||
topConstraint: NSLayoutConstraint?,
|
||||
bottomConstraint: NSLayoutConstraint?) {
|
||||
|
||||
let centerYOffset = centerOffset.vertical
|
||||
|
||||
if centerYOffset.isFinite {
|
||||
centerYConstraint?.constant = centerYOffset
|
||||
centerYConstraint?.isActive = true
|
||||
topConstraint?.isActive = false
|
||||
bottomConstraint?.isActive = false
|
||||
|
||||
} else {
|
||||
topConstraint?.constant = insets.top
|
||||
bottomConstraint?.constant = -insets.bottom
|
||||
centerYConstraint?.isActive = false
|
||||
topConstraint?.isActive = true
|
||||
bottomConstraint?.isActive = true
|
||||
}
|
||||
}
|
||||
|
||||
func setupCenterXOffset(centerXConstraint: NSLayoutConstraint?,
|
||||
leadingConstraint: NSLayoutConstraint?,
|
||||
trailingConstraint: NSLayoutConstraint?) {
|
||||
|
||||
let centerXOffset = centerOffset.horizontal
|
||||
|
||||
if centerXOffset.isFinite {
|
||||
centerXConstraint?.constant = centerXOffset
|
||||
centerXConstraint?.isActive = true
|
||||
leadingConstraint?.isActive = false
|
||||
trailingConstraint?.isActive = false
|
||||
|
||||
} else {
|
||||
leadingConstraint?.constant = insets.left
|
||||
trailingConstraint?.constant = -insets.right
|
||||
centerXConstraint?.isActive = false
|
||||
leadingConstraint?.isActive = true
|
||||
trailingConstraint?.isActive = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -31,6 +31,8 @@ public protocol ViewAppearance {
|
|||
var backgroundColor: UIColor { get }
|
||||
var roundedCorners: CACornerMask { get }
|
||||
var cornerRadius: CGFloat { get }
|
||||
var borderColor: UIColor { get }
|
||||
var borderWidth: CGFloat { get }
|
||||
var shadow: UIViewShadow? { get }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,10 @@ public protocol WrappedViewLayout: SizeViewLayout {
|
|||
var centerOffset: UIOffset { get }
|
||||
}
|
||||
|
||||
public protocol SpacedWrappedViewLayout: WrappedViewLayout {
|
||||
var spacing: CGFloat { get }
|
||||
}
|
||||
|
||||
// MARK: - Creation methods
|
||||
|
||||
extension ViewLayout {
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ open class BaseTextAttributes {
|
|||
|
||||
open func configure(button: UIButton, with string: String? = nil) {
|
||||
if #available(iOS 15, *) {
|
||||
var configuration = UIButton.Configuration.plain()
|
||||
var configuration = button.configuration ?? UIButton.Configuration.plain()
|
||||
|
||||
if let title = string {
|
||||
button.setTitle(nil, for: .normal)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = 'TIUIKitCore'
|
||||
s.version = '1.38.0'
|
||||
s.version = '1.38.1'
|
||||
s.summary = 'Core UI elements: protocols, views and helpers.'
|
||||
s.homepage = 'https://gitlab.ti/touchinstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = 'TIWebView'
|
||||
s.version = '1.38.0'
|
||||
s.version = '1.38.1'
|
||||
s.summary = 'Universal web view API'
|
||||
s.homepage = 'https://gitlab.ti/touchinstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = 'TIYandexMapUtils'
|
||||
s.version = '1.38.0'
|
||||
s.version = '1.38.1'
|
||||
s.summary = 'Set of helpers for map objects clustering and interacting using Yandex Maps SDK.'
|
||||
s.homepage = 'https://gitlab.ti/touchinstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
|
|
|
|||
Loading…
Reference in New Issue