feat: DefaultTitleSubtitleView support for separated configuration of title and subtitle labels layout. #17

Merged
ivan.smolin merged 1 commits from feature/layout_improvenments into master 2023-10-30 16:36:32 +03:00
29 changed files with 127 additions and 48 deletions

View File

@ -1,5 +1,10 @@
# Changelog
### 1.53.2
- **Update**: `DefaultTitleSubtitleView` support for separated configuration of title and subtitle labels layout.
- **Update**: `BaseListItemView` fixed trailing insets when trailing view is hidden.
### 1.53.1
- **Update**: Insets layout heuristics for `WrappedViewHodler` implementations

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -210,7 +210,7 @@ open class BaseListItemView<LeadingView: UIView,
if isTrailingViewHidden {
leadingViewConstraints.edgeConstraints.trailingConstraint = leadingViewTrailingToSuperviewConstraint
return leadingViewLayout.insets.right
return -leadingViewLayout.insets.right
} else {
leadingViewConstraints.edgeConstraints.trailingConstraint = leadingToTrailingViewConstraint
@ -287,7 +287,7 @@ open class BaseListItemView<LeadingView: UIView,
case (false, true):
trailingViewConstraints.deactivate()
return middleViewLayout.insets.right
return -middleViewLayout.insets.right
case (false, false):
trailingViewConstraints.edgeConstraints.leadingConstraint.isActive = false

View File

@ -101,7 +101,7 @@ open class BasePlaceholderImageView<Placeholder: UIView>: UIImageView,
}
open func configureLayout() {
// override in subclass
update(subviewConstraints: placeholderConstraints)
}
open func bindViews() {

View File

@ -32,8 +32,53 @@ public final class DefaultTitleSubtitleView: BaseInitializableView,
private var appearance: Appearance = .defaultAppearance
public var titleLableBottomConstraint: NSLayoutConstraint?
public var spacingConstraint: NSLayoutConstraint?
public private(set) lazy var titleBottomToSuperviewConstraint: NSLayoutConstraint = {
titleLabel.bottomAnchor.constraint(equalTo: bottomAnchor)
}()
public private(set) lazy var titleBottomToSubtitleConstraint: NSLayoutConstraint = {
titleLabel.bottomAnchor.constraint(equalTo: subtitleLabel.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),
bottomConstraint: titleBottomToSubtitleConstraint)
let centerXConstraint = titleLabel.centerXAnchor.constraint(equalTo: centerXAnchor)
let centerYConstraint = titleLabel.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))
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))
let centerXConstraint = subtitleLabel.centerXAnchor.constraint(equalTo: centerXAnchor)
let centerYConstraint = subtitleLabel.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))
return SubviewConstraints(edgeConstraints: edgeConstraints,
centerConstraints: centerConstraints,
sizeConstraints: sizeConstraints)
}()
// MARK: - InitializableViewProtocol
@ -49,19 +94,7 @@ public final class DefaultTitleSubtitleView: BaseInitializableView,
[titleLabel, subtitleLabel]
.forEach { $0.translatesAutoresizingMaskIntoConstraints = false }
titleLableBottomConstraint = titleLabel.bottomAnchor.constraint(equalTo: bottomAnchor)
spacingConstraint = subtitleLabel.topAnchor.constraint(equalTo: titleLabel.bottomAnchor)
NSLayoutConstraint.activate([
titleLabel.leadingAnchor.constraint(equalTo: leadingAnchor),
titleLabel.topAnchor.constraint(equalTo: topAnchor),
titleLabel.trailingAnchor.constraint(equalTo: trailingAnchor),
subtitleLabel.leadingAnchor.constraint(equalTo: leadingAnchor),
spacingConstraint,
subtitleLabel.trailingAnchor.constraint(equalTo: trailingAnchor),
subtitleLabel.bottomAnchor.constraint(equalTo: bottomAnchor)
].compactMap { $0 })
configure(appearance: appearance)
}
// MARK: - ConfigurableView
@ -79,9 +112,13 @@ public final class DefaultTitleSubtitleView: BaseInitializableView,
// MARK: - Public methods
public func setSubtitle(hidden: Bool) {
guard subtitleLabel.isHidden != hidden else {
return
}
subtitleLabel.isHidden = hidden
spacingConstraint?.isActive = !hidden
titleLableBottomConstraint?.isActive = hidden
configure(appearance: appearance)
}
// MARK: - AppearanceConfigurable
@ -90,13 +127,50 @@ public final class DefaultTitleSubtitleView: BaseInitializableView,
self.appearance = appearance
configureUIView(appearance: appearance)
titleLabel.configureUILabel(appearance: appearance.titleAppearance)
subtitleLabel.configureUILabel(appearance: appearance.subtitleAppearance)
configure(layout: appearance.layout)
configure(layout: appearance.layout,
titleLayout: appearance.titleAppearance.layout,
subtitleLayout: appearance.subtitleAppearance.layout,
subtitleHidden: subtitleLabel.isHidden)
}
public func configure(layout: UIView.DefaultSpacedWrappedLayout) {
spacingConstraint?.constant = layout.spacing
public func configure(layout: some SpacedWrappedViewLayout,
titleLayout: some WrappedViewLayout,
subtitleLayout: some WrappedViewLayout,
subtitleHidden: Bool) {
titleConstraints.edgeConstraints.bottomConstraint.isActive = false
titleConstraints.edgeConstraints.bottomConstraint = subtitleHidden
? titleBottomToSuperviewConstraint
: titleBottomToSubtitleConstraint
titleConstraints.update(from: appearance.titleAppearance.layout)
let spacing: CGFloat
let titleBottomInset = titleLayout.insets.bottom
if subtitleHidden {
spacing = titleBottomInset.isFinite
? layout.spacing + titleBottomInset
: layout.spacing
subtitleConstraints.deactivate()
} else {
let verticalInsets = titleLayout.insets.add(\.bottom,
to: \.top,
of: subtitleLayout.insets)
spacing = verticalInsets.isFinite
? layout.spacing + verticalInsets
: layout.spacing
subtitleConstraints.update(from: appearance.subtitleAppearance.layout)
}
titleBottomToSubtitleConstraint.constant = -spacing
}
}

View File

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

View File

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

View File

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

View File

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