diff --git a/CHANGELOG.md b/CHANGELOG.md index efa04a5e..179ddb7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +### 1.54.1 + +- **Added**: `BaseTitleSubtitleView` which can be inherited for fine-tuning skeletons and other behavior. +- **Update**: Changed lines number calculation method in `TextSkeletonsConfiguration`. + + ### 1.54.0 - **Added**: `maxWidth` parameter to `BaseViewSkeletonsConfiguration`. diff --git a/TIAppleMapUtils/TIAppleMapUtils.podspec b/TIAppleMapUtils/TIAppleMapUtils.podspec index ef091860..c2e46a39 100644 --- a/TIAppleMapUtils/TIAppleMapUtils.podspec +++ b/TIAppleMapUtils/TIAppleMapUtils.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIAppleMapUtils' - s.version = '1.54.0' + s.version = '1.54.1' s.summary = 'Set of helpers for map objects clustering and interacting using Apple MapKit.' s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/src/tag/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TIApplication/TIApplication.podspec b/TIApplication/TIApplication.podspec index a2f31525..4beee10b 100644 --- a/TIApplication/TIApplication.podspec +++ b/TIApplication/TIApplication.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIApplication' - s.version = '1.54.0' + s.version = '1.54.1' s.summary = 'Application architecture.' s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/src/tag/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TIAuth/TIAuth.podspec b/TIAuth/TIAuth.podspec index e5dbfb76..f887e781 100644 --- a/TIAuth/TIAuth.podspec +++ b/TIAuth/TIAuth.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIAuth' - s.version = '1.54.0' + s.version = '1.54.1' s.summary = 'Login, registration, confirmation and other related actions' s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/src/tag/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TIBottomSheet/TIBottomSheet.podspec b/TIBottomSheet/TIBottomSheet.podspec index befe01e1..0cbcbedb 100644 --- a/TIBottomSheet/TIBottomSheet.podspec +++ b/TIBottomSheet/TIBottomSheet.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIBottomSheet' - s.version = '1.54.0' + s.version = '1.54.1' s.summary = 'Base models for creating bottom sheet view controllers' s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/src/tag/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TICoreGraphicsUtils/TICoreGraphicsUtils.podspec b/TICoreGraphicsUtils/TICoreGraphicsUtils.podspec index 3e2b9950..f3c84ae1 100644 --- a/TICoreGraphicsUtils/TICoreGraphicsUtils.podspec +++ b/TICoreGraphicsUtils/TICoreGraphicsUtils.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TICoreGraphicsUtils' - s.version = '1.54.0' + s.version = '1.54.1' s.summary = 'CoreGraphics drawing helpers' s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/src/tag/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TIDeeplink/TIDeeplink.podspec b/TIDeeplink/TIDeeplink.podspec index 0c2a4fc4..815211a7 100644 --- a/TIDeeplink/TIDeeplink.podspec +++ b/TIDeeplink/TIDeeplink.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIDeeplink' - s.version = '1.54.0' + s.version = '1.54.1' s.summary = 'Deeplink service API' s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/src/tag/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TIDeveloperUtils/TIDeveloperUtils.podspec b/TIDeveloperUtils/TIDeveloperUtils.podspec index 704552d2..50347fb4 100644 --- a/TIDeveloperUtils/TIDeveloperUtils.podspec +++ b/TIDeveloperUtils/TIDeveloperUtils.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIDeveloperUtils' - s.version = '1.54.0' + s.version = '1.54.1' s.summary = 'Universal web view API' s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/src/tag/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TIEcommerce/TIEcommerce.podspec b/TIEcommerce/TIEcommerce.podspec index f8bbd893..407d521c 100644 --- a/TIEcommerce/TIEcommerce.podspec +++ b/TIEcommerce/TIEcommerce.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIEcommerce' - s.version = '1.54.0' + s.version = '1.54.1' s.summary = 'Cart, products, promocodes, bonuses and other related actions' s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/src/tag/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TIFoundationUtils/TIFoundationUtils.podspec b/TIFoundationUtils/TIFoundationUtils.podspec index 9fe349c7..a8d47dc8 100644 --- a/TIFoundationUtils/TIFoundationUtils.podspec +++ b/TIFoundationUtils/TIFoundationUtils.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIFoundationUtils' - s.version = '1.54.0' + s.version = '1.54.1' s.summary = 'Set of helpers for Foundation framework classes.' s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/src/tag/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TIGoogleMapUtils/TIGoogleMapUtils.podspec b/TIGoogleMapUtils/TIGoogleMapUtils.podspec index 610299c9..97d97d52 100644 --- a/TIGoogleMapUtils/TIGoogleMapUtils.podspec +++ b/TIGoogleMapUtils/TIGoogleMapUtils.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIGoogleMapUtils' - s.version = '1.54.0' + s.version = '1.54.1' s.summary = 'Set of helpers for map objects clustering and interacting using Google Maps SDK.' s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/src/tag/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TIKeychainUtils/TIKeychainUtils.podspec b/TIKeychainUtils/TIKeychainUtils.podspec index 43cab733..a5112aa4 100644 --- a/TIKeychainUtils/TIKeychainUtils.podspec +++ b/TIKeychainUtils/TIKeychainUtils.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIKeychainUtils' - s.version = '1.54.0' + s.version = '1.54.1' s.summary = 'Set of helpers for Keychain classes.' s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/src/tag/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TILogging/TILogging.podspec b/TILogging/TILogging.podspec index f1d3c81d..a7d8ed38 100644 --- a/TILogging/TILogging.podspec +++ b/TILogging/TILogging.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TILogging' - s.version = '1.54.0' + s.version = '1.54.1' s.summary = 'Logging for TI libraries.' s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/src/tag/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TIMapUtils/TIMapUtils.podspec b/TIMapUtils/TIMapUtils.podspec index a8ae9dc7..68d46673 100644 --- a/TIMapUtils/TIMapUtils.podspec +++ b/TIMapUtils/TIMapUtils.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIMapUtils' - s.version = '1.54.0' + s.version = '1.54.1' s.summary = 'Set of helpers for map objects clustering and interacting.' s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/src/tag/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TIMoyaNetworking/TIMoyaNetworking.podspec b/TIMoyaNetworking/TIMoyaNetworking.podspec index 269cd14f..919145c2 100644 --- a/TIMoyaNetworking/TIMoyaNetworking.podspec +++ b/TIMoyaNetworking/TIMoyaNetworking.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIMoyaNetworking' - s.version = '1.54.0' + s.version = '1.54.1' s.summary = 'Moya + Swagger network service.' s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/src/tag/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TINetworking/TINetworking.podspec b/TINetworking/TINetworking.podspec index 812191a3..86a10845 100644 --- a/TINetworking/TINetworking.podspec +++ b/TINetworking/TINetworking.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TINetworking' - s.version = '1.54.0' + s.version = '1.54.1' s.summary = 'Swagger-frendly networking layer helpers.' s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/src/tag/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TINetworkingCache/TINetworkingCache.podspec b/TINetworkingCache/TINetworkingCache.podspec index b8ef2d10..2d7bfd08 100644 --- a/TINetworkingCache/TINetworkingCache.podspec +++ b/TINetworkingCache/TINetworkingCache.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TINetworkingCache' - s.version = '1.54.0' + s.version = '1.54.1' s.summary = 'Caching results of EndpointRequests.' s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/src/tag/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TIPagination/TIPagination.podspec b/TIPagination/TIPagination.podspec index 36ee1cec..4e71ccf3 100644 --- a/TIPagination/TIPagination.podspec +++ b/TIPagination/TIPagination.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIPagination' - s.version = '1.54.0' + s.version = '1.54.1' s.summary = 'Generic pagination component.' s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/src/tag/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TISwiftUICore/TISwiftUICore.podspec b/TISwiftUICore/TISwiftUICore.podspec index 5e224585..07d17d84 100644 --- a/TISwiftUICore/TISwiftUICore.podspec +++ b/TISwiftUICore/TISwiftUICore.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TISwiftUICore' - s.version = '1.54.0' + s.version = '1.54.1' s.summary = 'Core UI elements: protocols, views and helpers.' s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/src/tag/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TISwiftUtils/TISwiftUtils.podspec b/TISwiftUtils/TISwiftUtils.podspec index c3e7fc40..648bb4c7 100644 --- a/TISwiftUtils/TISwiftUtils.podspec +++ b/TISwiftUtils/TISwiftUtils.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TISwiftUtils' - s.version = '1.54.0' + s.version = '1.54.1' s.summary = 'Bunch of useful helpers for Swift development.' s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/src/tag/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TITableKitUtils/TITableKitUtils.podspec b/TITableKitUtils/TITableKitUtils.podspec index 1626ddea..6b53f6be 100644 --- a/TITableKitUtils/TITableKitUtils.podspec +++ b/TITableKitUtils/TITableKitUtils.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TITableKitUtils' - s.version = '1.54.0' + s.version = '1.54.1' s.summary = 'Set of helpers for TableKit classes.' s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/src/tag/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TITextProcessing/TITextProcessing.podspec b/TITextProcessing/TITextProcessing.podspec index 11d0cbb1..12161218 100644 --- a/TITextProcessing/TITextProcessing.podspec +++ b/TITextProcessing/TITextProcessing.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TITextProcessing' - s.version = '1.54.0' + s.version = '1.54.1' s.summary = 'A text processing service helping to get a text mask and a placeholder from incoming regex.' s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/src/tag/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TIUIElements/Sources/Views/Skeletons/Configuration/TextSkeletonsConfiguration.swift b/TIUIElements/Sources/Views/Skeletons/Configuration/TextSkeletonsConfiguration.swift index 29f039f8..b591891d 100644 --- a/TIUIElements/Sources/Views/Skeletons/Configuration/TextSkeletonsConfiguration.swift +++ b/TIUIElements/Sources/Views/Skeletons/Configuration/TextSkeletonsConfiguration.swift @@ -44,12 +44,12 @@ open class TextSkeletonsConfiguration: BaseViewSkeletonsConfiguration { } } - public var numberOfLines: Int + public var numberOfLines: Int? public var linesWidthFraction: [CGFloat] public var lineHeight: CGFloat? public var lineSpacing: CGFloat? - public init(numberOfLines: Int = Defaults.numberOfLines, + public init(numberOfLines: Int? = nil, linesWidthFraction: [CGFloat] = Defaults.linesWidthFraction, lineHeight: CGFloat? = nil, lineSpacing: CGFloat? = nil, @@ -68,7 +68,7 @@ open class TextSkeletonsConfiguration: BaseViewSkeletonsConfiguration { open func createConfiguration(for label: UILabel) -> TextSkeletonsConfiguration { let labelFont = getFont(from: label) - return copyWith(numberOfLines: label.numberOfLines, + return copyWith(numberOfLines: getLinesCount(viewNumberOfLines: label.numberOfLines), lineHeight: calculateLineHeight(for: labelFont), lineSpacing: calculateLineSpacing(for: labelFont), padding: padding, @@ -79,7 +79,7 @@ open class TextSkeletonsConfiguration: BaseViewSkeletonsConfiguration { open func createConfiguration(for textView: UITextView) -> TextSkeletonsConfiguration { let labelFont = getFont(from: textView) - return copyWith(numberOfLines: textView.textContainer.maximumNumberOfLines, + return copyWith(numberOfLines: getLinesCount(viewNumberOfLines: textView.textContainer.maximumNumberOfLines), lineHeight: calculateLineHeight(for: labelFont), lineSpacing: calculateLineSpacing(for: labelFont), padding: padding, @@ -108,7 +108,7 @@ open class TextSkeletonsConfiguration: BaseViewSkeletonsConfiguration { cornerRadius = radius / 2 } - for lineNumber in 0.. Int { + if let numberOfLines { + return numberOfLines + } else { + return viewNumberOfLines == 0 + ? Defaults.multilineNumberOfLines + : viewNumberOfLines + } + } } diff --git a/TIUIElements/Sources/Views/TitleSubtitleView/DefaultTitleSubtitleView+Appearance.swift b/TIUIElements/Sources/Views/TitleSubtitleView/BaseTitleSubtitleView/BaseTitleSubtitleView+Appearance.swift similarity index 73% rename from TIUIElements/Sources/Views/TitleSubtitleView/DefaultTitleSubtitleView+Appearance.swift rename to TIUIElements/Sources/Views/TitleSubtitleView/BaseTitleSubtitleView/BaseTitleSubtitleView+Appearance.swift index bdc0ea6c..0be2da17 100644 --- a/TIUIElements/Sources/Views/TitleSubtitleView/DefaultTitleSubtitleView+Appearance.swift +++ b/TIUIElements/Sources/Views/TitleSubtitleView/BaseTitleSubtitleView/BaseTitleSubtitleView+Appearance.swift @@ -23,23 +23,20 @@ import TIUIKitCore import UIKit -public extension DefaultTitleSubtitleView { +extension BaseTitleSubtitleView { + open class Appearance: + UIView.BaseAppearance { - final class Appearance: UIView.BaseAppearance, WrappedViewAppearance { + public var titleAppearance: TitleAppearance + public var subtitleAppearance: SubtitleAppearance - public static var defaultAppearance: Appearance { - Self() - } - - public var titleAppearance: UILabel.DefaultAppearance - public var subtitleAppearance: UILabel.DefaultAppearance - - public init(layout: Layout = .defaultLayout, + public init(layout: UIView.DefaultSpacedWrappedLayout = .defaultLayout, background: UIViewBackground = UIViewColorBackground(color: .clear), border: UIViewBorder = BaseUIViewBorder(), shadow: UIViewShadow? = nil, - titleAppearance: UILabel.DefaultAppearance = .defaultAppearance, - subtitleAppearance: UILabel.DefaultAppearance = .defaultAppearance) { + titleAppearance: TitleAppearance = .defaultAppearance, + subtitleAppearance: SubtitleAppearance = .defaultAppearance) { self.titleAppearance = titleAppearance self.subtitleAppearance = subtitleAppearance diff --git a/TIUIElements/Sources/Views/TitleSubtitleView/DefaultTitleSubtitleView.swift b/TIUIElements/Sources/Views/TitleSubtitleView/BaseTitleSubtitleView/BaseTitleSubtitleView.swift similarity index 57% rename from TIUIElements/Sources/Views/TitleSubtitleView/DefaultTitleSubtitleView.swift rename to TIUIElements/Sources/Views/TitleSubtitleView/BaseTitleSubtitleView/BaseTitleSubtitleView.swift index b93a6210..ec40cf9c 100644 --- a/TIUIElements/Sources/Views/TitleSubtitleView/DefaultTitleSubtitleView.swift +++ b/TIUIElements/Sources/Views/TitleSubtitleView/BaseTitleSubtitleView/BaseTitleSubtitleView.swift @@ -23,57 +23,60 @@ import TIUIKitCore import UIKit -public final class DefaultTitleSubtitleView: BaseInitializableView, - ConfigurableView, - AppearanceConfigurable { +open class BaseTitleSubtitleView: BaseInitializableView { + internal let titleView = TitleView() + internal let subtitleView = SubtitleView() - private let titleLabel = UILabel() - private let subtitleLabel = UILabel() - - private var appearance: Appearance = .defaultAppearance - - public private(set) lazy var titleBottomToSuperviewConstraint: NSLayoutConstraint = { - titleLabel.bottomAnchor.constraint(equalTo: bottomAnchor) + public internal(set) lazy var titleBottomToSuperviewConstraint: NSLayoutConstraint = { + titleView.bottomAnchor.constraint(equalTo: bottomAnchor) }() - public private(set) lazy var titleBottomToSubtitleConstraint: NSLayoutConstraint = { - titleLabel.bottomAnchor.constraint(equalTo: subtitleLabel.topAnchor) + public internal(set) lazy var titleBottomToSubtitleConstraint: NSLayoutConstraint = { + titleView.bottomAnchor.constraint(equalTo: subtitleView.topAnchor) }() - public private(set) lazy var titleConstraints: SubviewConstraints = { - let edgeConstraints = EdgeConstraints(leadingConstraint: titleLabel.leadingAnchor.constraint(equalTo: leadingAnchor), - trailingConstraint: titleLabel.trailingAnchor.constraint(equalTo: trailingAnchor), - topConstraint: titleLabel.topAnchor.constraint(equalTo: topAnchor), + public internal(set) lazy var titleConstraints: SubviewConstraints = { + let leadingConstraint = titleView.leadingAnchor.constraint(equalTo: leadingAnchor) + let trailingConstraint = titleView.trailingAnchor.constraint(equalTo: trailingAnchor) + let topConstraint = titleView.topAnchor.constraint(equalTo: topAnchor) + + let edgeConstraints = EdgeConstraints(leadingConstraint: leadingConstraint, + trailingConstraint: trailingConstraint, + topConstraint: topConstraint, bottomConstraint: titleBottomToSubtitleConstraint) - let centerXConstraint = titleLabel.centerXAnchor.constraint(equalTo: centerXAnchor) - let centerYConstraint = titleLabel.centerYAnchor.constraint(equalTo: centerYAnchor) + let centerXConstraint = titleView.centerXAnchor.constraint(equalTo: centerXAnchor) + let centerYConstraint = titleView.centerYAnchor.constraint(equalTo: centerYAnchor) let centerConstraints = CenterConstraints(centerXConstraint: centerXConstraint, centerYConstraint: centerYConstraint) - let sizeConstraints = SizeConstraints(widthConstraint: titleLabel.widthAnchor.constraint(equalToConstant: .zero), - heightConstraint: titleLabel.heightAnchor.constraint(equalToConstant: .zero)) + let sizeConstraints = SizeConstraints(widthConstraint: titleView.widthAnchor.constraint(equalToConstant: .zero), + heightConstraint: titleView.heightAnchor.constraint(equalToConstant: .zero)) return SubviewConstraints(edgeConstraints: edgeConstraints, centerConstraints: centerConstraints, sizeConstraints: sizeConstraints) }() - public private(set) lazy var subtitleConstraints: SubviewConstraints = { - let edgeConstraints = EdgeConstraints(leadingConstraint: subtitleLabel.leadingAnchor.constraint(equalTo: leadingAnchor), - trailingConstraint: subtitleLabel.trailingAnchor.constraint(equalTo: trailingAnchor), - topConstraint: titleBottomToSubtitleConstraint, - bottomConstraint: subtitleLabel.bottomAnchor.constraint(equalTo: bottomAnchor)) + public internal(set) lazy var subtitleConstraints: SubviewConstraints = { + let leadingConstraint = subtitleView.leadingAnchor.constraint(equalTo: leadingAnchor) + let trailingConstraint = subtitleView.trailingAnchor.constraint(equalTo: trailingAnchor) + let bottomConstraint = subtitleView.bottomAnchor.constraint(equalTo: bottomAnchor) - let centerXConstraint = subtitleLabel.centerXAnchor.constraint(equalTo: centerXAnchor) - let centerYConstraint = subtitleLabel.centerYAnchor.constraint(equalTo: centerYAnchor) + let edgeConstraints = EdgeConstraints(leadingConstraint: leadingConstraint, + trailingConstraint: trailingConstraint, + topConstraint: titleBottomToSubtitleConstraint, + bottomConstraint: bottomConstraint) + + let centerXConstraint = subtitleView.centerXAnchor.constraint(equalTo: centerXAnchor) + let centerYConstraint = subtitleView.centerYAnchor.constraint(equalTo: centerYAnchor) let centerConstraints = CenterConstraints(centerXConstraint: centerXConstraint, centerYConstraint: centerYConstraint) - let sizeConstraints = SizeConstraints(widthConstraint: subtitleLabel.widthAnchor.constraint(equalToConstant: .zero), - heightConstraint: subtitleLabel.heightAnchor.constraint(equalToConstant: .zero)) + let sizeConstraints = SizeConstraints(widthConstraint: subtitleView.widthAnchor.constraint(equalToConstant: .zero), + heightConstraint: subtitleView.heightAnchor.constraint(equalToConstant: .zero)) return SubviewConstraints(edgeConstraints: edgeConstraints, centerConstraints: centerConstraints, @@ -82,59 +85,40 @@ public final class DefaultTitleSubtitleView: BaseInitializableView, // MARK: - InitializableViewProtocol - public override func addViews() { + open override func addViews() { super.addViews() - addSubviews(titleLabel, subtitleLabel) + addSubviews(titleView, subtitleView) } - public override func configureLayout() { + open override func configureLayout() { super.configureLayout() - [titleLabel, subtitleLabel] + [titleView, subtitleView] .forEach { $0.translatesAutoresizingMaskIntoConstraints = false } - - configure(appearance: appearance) - } - - // MARK: - ConfigurableView - - public func configure(with viewModel: DefaultTitleSubtitleViewModel) { - titleLabel.text = viewModel.title - titleLabel.configureUILabel(appearance: appearance.titleAppearance) - - subtitleLabel.text = viewModel.subtitle - subtitleLabel.configureUILabel(appearance: appearance.subtitleAppearance) - - setSubtitle(hidden: viewModel.isSubtitleHidden) } // MARK: - Public methods - public func setSubtitle(hidden: Bool) { - guard subtitleLabel.isHidden != hidden else { + open func setSubtitle(hidden: Bool) { + guard subtitleView.isHidden != hidden else { return } - subtitleLabel.isHidden = hidden - - configure(appearance: appearance) + subtitleView.isHidden = hidden } // MARK: - AppearanceConfigurable - public func configure(appearance: Appearance) { - self.appearance = appearance + open func configureBaseTitleSubtitle(appearance: Appearance) { configureUIView(appearance: appearance) - titleLabel.configureUILabel(appearance: appearance.titleAppearance) - subtitleLabel.configureUILabel(appearance: appearance.subtitleAppearance) - configure(layout: appearance.layout, titleLayout: appearance.titleAppearance.layout, subtitleLayout: appearance.subtitleAppearance.layout, - subtitleHidden: subtitleLabel.isHidden) + subtitleHidden: subtitleView.isHidden) } public func configure(layout: some SpacedWrappedViewLayout, @@ -148,7 +132,7 @@ public final class DefaultTitleSubtitleView: BaseInitializableView, ? titleBottomToSuperviewConstraint : titleBottomToSubtitleConstraint - titleConstraints.update(from: appearance.titleAppearance.layout) + titleConstraints.update(from: titleLayout) let spacing: CGFloat @@ -158,17 +142,18 @@ public final class DefaultTitleSubtitleView: BaseInitializableView, spacing = titleBottomInset.isFinite ? layout.spacing + titleBottomInset : layout.spacing + subtitleConstraints.deactivate() } else { let verticalInsets = titleLayout.insets.add(\.bottom, - to: \.top, - of: subtitleLayout.insets) + to: \.top, + of: subtitleLayout.insets) spacing = verticalInsets.isFinite ? layout.spacing + verticalInsets : layout.spacing - subtitleConstraints.update(from: appearance.subtitleAppearance.layout) + subtitleConstraints.update(from: subtitleLayout) } titleBottomToSubtitleConstraint.constant = -spacing diff --git a/TIUIElements/Sources/Views/TitleSubtitleView/DefaultTitleSubtitleView/DefaultTitleSubtitleView+Appearance.swift b/TIUIElements/Sources/Views/TitleSubtitleView/DefaultTitleSubtitleView/DefaultTitleSubtitleView+Appearance.swift new file mode 100644 index 00000000..f70dac78 --- /dev/null +++ b/TIUIElements/Sources/Views/TitleSubtitleView/DefaultTitleSubtitleView/DefaultTitleSubtitleView+Appearance.swift @@ -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 TIUIKitCore +import UIKit + +public extension DefaultTitleSubtitleView { + final class Appearance: BaseTitleSubtitleView + .Appearance, + WrappedViewAppearance { + + public static var defaultAppearance: Appearance { + Self() + } + } +} diff --git a/TIUIElements/Sources/Views/TitleSubtitleView/DefaultTitleSubtitleView/DefaultTitleSubtitleView.swift b/TIUIElements/Sources/Views/TitleSubtitleView/DefaultTitleSubtitleView/DefaultTitleSubtitleView.swift new file mode 100644 index 00000000..af1b2432 --- /dev/null +++ b/TIUIElements/Sources/Views/TitleSubtitleView/DefaultTitleSubtitleView/DefaultTitleSubtitleView.swift @@ -0,0 +1,70 @@ +// +// 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 DefaultTitleSubtitleView: BaseTitleSubtitleView, + ConfigurableView, + AppearanceConfigurable { + + private var appearance: Appearance = .defaultAppearance + + // MARK: - InitializableViewProtocol + + public override func configureLayout() { + super.configureLayout() + + configure(appearance: appearance) + } + + // MARK: - ConfigurableView + + public func configure(with viewModel: DefaultTitleSubtitleViewModel) { + titleView.text = viewModel.title + titleView.configureUILabel(appearance: appearance.titleAppearance) + + subtitleView.text = viewModel.subtitle + subtitleView.configureUILabel(appearance: appearance.subtitleAppearance) + + setSubtitle(hidden: viewModel.isSubtitleHidden) + } + + // MARK: - Public methods + + public override func setSubtitle(hidden: Bool) { + super.setSubtitle(hidden: hidden) + + configure(appearance: appearance) + } + + // MARK: - AppearanceConfigurable + + public func configure(appearance: Appearance) { + self.appearance = appearance + + configureBaseTitleSubtitle(appearance: appearance) + + titleView.configureUILabel(appearance: appearance.titleAppearance) + subtitleView.configureUILabel(appearance: appearance.subtitleAppearance) + } +} diff --git a/TIUIElements/TIUIElements.podspec b/TIUIElements/TIUIElements.podspec index 3f4d7893..864397d6 100644 --- a/TIUIElements/TIUIElements.podspec +++ b/TIUIElements/TIUIElements.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIUIElements' - s.version = '1.54.0' + s.version = '1.54.1' s.summary = 'Bunch of useful protocols and views.' s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/src/tag/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TIUIKitCore/TIUIKitCore.podspec b/TIUIKitCore/TIUIKitCore.podspec index 968df282..600e562e 100644 --- a/TIUIKitCore/TIUIKitCore.podspec +++ b/TIUIKitCore/TIUIKitCore.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIUIKitCore' - s.version = '1.54.0' + s.version = '1.54.1' s.summary = 'Core UI elements: protocols, views and helpers.' s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/src/tag/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TIWebView/TIWebView.podspec b/TIWebView/TIWebView.podspec index ba1981b7..d1eaa9fd 100644 --- a/TIWebView/TIWebView.podspec +++ b/TIWebView/TIWebView.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIWebView' - s.version = '1.54.0' + s.version = '1.54.1' s.summary = 'Universal web view API' s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/src/tag/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TIYandexMapUtils/TIYandexMapUtils.podspec b/TIYandexMapUtils/TIYandexMapUtils.podspec index 018adb0c..db9b527f 100644 --- a/TIYandexMapUtils/TIYandexMapUtils.podspec +++ b/TIYandexMapUtils/TIYandexMapUtils.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIYandexMapUtils' - s.version = '1.54.0' + s.version = '1.54.1' s.summary = 'Set of helpers for map objects clustering and interacting using Yandex Maps SDK.' s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/src/tag/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' }