feat: Set reasonable defaults for SkeletonConfiguration #22

Merged
ivan.smolin merged 1 commits from feature/skeleton_configuration_defaults into master 2023-11-07 16:39:56 +03:00
32 changed files with 69 additions and 39 deletions

View File

@ -1,5 +1,9 @@
# Changelog
### 1.54.3
- **Update**: Set reasonable defaults for `SkeletonConfiguration`.
### 1.54.2
- **Update**: Changed access level from internal to public of title and subtitle view in `BaseTitleSubtitleView`.

View File

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

@ -25,6 +25,12 @@ import UIKit
open class BaseViewSkeletonsConfiguration {
open class Defaults {
public static var cornerRadius: CGFloat {
16
}
}
public enum Shape {
case rectangle(cornerRadius: CGFloat)
case circle
@ -37,7 +43,7 @@ open class BaseViewSkeletonsConfiguration {
public init(padding: UIEdgeInsets = .edges(5),
maxWidth: CGFloat = .infinity,
shape: Shape = .rectangle(cornerRadius: .zero)) {
shape: Shape = .rectangle(cornerRadius: Defaults.cornerRadius)) {
self.shape = shape
self.maxWidth = maxWidth

View File

@ -24,12 +24,18 @@ import UIKit
open class ContainerViewSkeletonsConfiguration: BaseViewSkeletonsConfiguration {
open class Defaults: BaseViewSkeletonsConfiguration.Defaults {
public static var borderWidth: CGFloat {
1
}
}
public var borderWidth: CGFloat
public init(borderWidth: CGFloat = .zero,
public init(borderWidth: CGFloat = Defaults.borderWidth,
padding: UIEdgeInsets = .zero,
maxWidth: CGFloat = .infinity,
shape: Shape = .rectangle(cornerRadius: .zero)) {
shape: Shape = .rectangle(cornerRadius: Defaults.cornerRadius)) {
self.borderWidth = borderWidth

View File

@ -25,6 +25,15 @@ import UIKit
open class SkeletonsConfiguration {
open class Defaults {
public static var animation: Closure<SkeletonLayer, CAAnimationGroup> {
{ _ in
let animConfig = DirectionalSkeletonsAnimationConfiguration(direction: .leftToRight, duration: 3)
return SkeletonsAnimationBuilder.createDirectionalGradientAnimation(animConfig)
}
}
}
public var viewConfiguration: BaseViewSkeletonsConfiguration
public var containerViewConfiguration: ContainerViewSkeletonsConfiguration
public var labelConfiguration: TextSkeletonsConfiguration
@ -47,7 +56,7 @@ open class SkeletonsConfiguration {
containerViewConfiguration: ContainerViewSkeletonsConfiguration = .init(),
labelConfiguration: TextSkeletonsConfiguration = .init(),
imageViewConfiguration: BaseViewSkeletonsConfiguration = .init(shape: .circle),
animation: Closure<SkeletonLayer, CAAnimationGroup>? = nil,
animation: Closure<SkeletonLayer, CAAnimationGroup>? = Defaults.animation,
baseSkeletonBackgroundColor: UIColor? = nil,
skeletonsBackgroundColor: UIColor = .lightGray.withAlphaComponent(0.7),
configurationDelegate: SkeletonsConfigurationDelegate? = nil) {

View File

@ -26,7 +26,7 @@ import UIKit
open class TextSkeletonsConfiguration: BaseViewSkeletonsConfiguration {
public enum Defaults {
open class Defaults: BaseViewSkeletonsConfiguration.Defaults {
public static var numberOfLines: Int {
1
}
@ -55,7 +55,7 @@ open class TextSkeletonsConfiguration: BaseViewSkeletonsConfiguration {
lineSpacing: CGFloat? = nil,
padding: UIEdgeInsets = .edges(5),
maxWidth: CGFloat = .infinity,
shape: Shape = .rectangle(cornerRadius: .zero)) {
shape: Shape = .rectangle(cornerRadius: Defaults.cornerRadius)) {
self.numberOfLines = numberOfLines
self.linesWidthFraction = linesWidthFraction

View File

@ -51,6 +51,10 @@ extension SkeletonsPresenter {
}
public func showSkeletons() {
if !isSkeletonLayerHidden {
hideSkeletons()
}
skeletonsHolder.showSkeletons(viewsToSkeletons: viewsToSkeletons,
skeletonsConfiguration)
}

View File

@ -24,7 +24,7 @@ import UIKit
open class SkeletonLayer: CAShapeLayer {
private enum Constants {
public enum Defaults {
static var animationKeyPath: String {
"skeletonAnimation"
}
@ -72,7 +72,7 @@ open class SkeletonLayer: CAShapeLayer {
public var isSkeletonsHolder: Bool = false
public var isAnimating: Bool {
animationLayer.animation(forKey: Constants.animationKeyPath) != nil
animationLayer.animation(forKey: Defaults.animationKeyPath) != nil
}
// MARK: - Init
@ -100,17 +100,18 @@ open class SkeletonLayer: CAShapeLayer {
// MARK: - Open methods
open func bind(to viewType: ViewType) {
layerOwnerView = viewType.view
let view = viewType.view
layerOwnerView = view
configureAppearance(viewType)
updateGeometry(viewType: viewType)
if let skeletonableView = viewType.view as? Skeletonable {
if let skeletonableView = view as? Skeletonable {
geometryChangeObservation = skeletonableView.observeGeometryChange { [weak self] view in
self?.updateGeometry(viewType: view.viewType)
}
} else {
geometryChangeObservation = viewType.view.observe(\.frame, options: [.new]) { [weak self] view, _ in
geometryChangeObservation = view.observe(\.frame, options: [.new]) { [weak self] view, _ in
self?.updateGeometry(viewType: view.viewType)
}
}
@ -155,7 +156,7 @@ open class SkeletonLayer: CAShapeLayer {
return
}
animationLayer.add(animation, forKey: Constants.animationKeyPath)
animationLayer.add(animation, forKey: Defaults.animationKeyPath)
mask = animationLayer
}
@ -171,9 +172,9 @@ open class SkeletonLayer: CAShapeLayer {
case .parentView(_):
configuration.configureContainerAppearance(layer: self)
case .skeletonsHolderView(_):
case let .skeletonsHolderView(view):
isSkeletonsHolder = true
configuration.configureBaseViewAppearance(layer: self, view: type.view)
configuration.configureBaseViewAppearance(layer: self, view: view)
default:
configuration.configureAppearance(layer: self)

View File

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