From 4a076b88652f3549274fe65e67236717fdcde228 Mon Sep 17 00:00:00 2001 From: Ivan Smolin Date: Fri, 20 Oct 2023 20:38:27 +0300 Subject: [PATCH] fix: layout DSL heuristics --- CHANGELOG.md | 4 + Makefile | 2 +- Package.swift | 2 +- TIAppleMapUtils/TIAppleMapUtils.podspec | 2 +- TIApplication/TIApplication.podspec | 2 +- TIAuth/TIAuth.podspec | 2 +- TIBottomSheet/PlaygroundPodfile | 1 + .../TIBottomSheet.app/Contents/MacOS/Podfile | 1 + .../Contents.swift | 6 +- TIBottomSheet/TIBottomSheet.podspec | 2 +- .../TICoreGraphicsUtils.podspec | 2 +- TIDeeplink/TIDeeplink.podspec | 2 +- TIDeveloperUtils/TIDeveloperUtils.podspec | 2 +- TIEcommerce/TIEcommerce.podspec | 2 +- TIFoundationUtils/TIFoundationUtils.podspec | 2 +- TIGoogleMapUtils/TIGoogleMapUtils.podspec | 2 +- TIKeychainUtils/TIKeychainUtils.podspec | 2 +- TILogging/TILogging.podspec | 2 +- TIMapUtils/TIMapUtils.podspec | 2 +- TIMoyaNetworking/TIMoyaNetworking.podspec | 2 +- TINetworking/TINetworking.podspec | 2 +- TINetworkingCache/TINetworkingCache.podspec | 2 +- TIPagination/TIPagination.podspec | 2 +- TISwiftUICore/TISwiftUICore.podspec | 2 +- TISwiftUtils/TISwiftUtils.podspec | 2 +- TITableKitUtils/TITableKitUtils.podspec | 2 +- TITextProcessing/TITextProcessing.podspec | 2 +- TIUIElements/PlaygroundPodfile | 1 + TIUIElements/Sources/TIUIElementsLogger.swift | 34 ++++++ .../Protocols/WrappedViewHolder.swift | 101 +++++++++++++++++- .../TIUIElements.app/Contents/MacOS/Podfile | 1 + TIUIElements/TIUIElements.podspec | 3 +- TIUIKitCore/TIUIKitCore.podspec | 2 +- TIWebView/TIWebView.podspec | 2 +- TIYandexMapUtils/TIYandexMapUtils.podspec | 2 +- docs/tibottomsheet/tibottomsheet.md | 6 +- 36 files changed, 176 insertions(+), 34 deletions(-) create mode 100644 TIUIElements/Sources/TIUIElementsLogger.swift diff --git a/CHANGELOG.md b/CHANGELOG.md index 818957b3..1d2fd9da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +### 1.53.1 + +- **Update**: Insets layout heuristics for `WrappedViewHodler` implementations + ### 1.53.0 - **Added**: Custom string attributes to `BaseTextAttributes` diff --git a/Makefile b/Makefile index fb8080a9..26a04732 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ TIUIKitCore.target: TISwiftUtils.target MODULE_NAME="TIUIKitCore" ./project-scripts/push_to_podspecs.sh touch TIUIKitCore.target -TIUIElements.target: TIUIKitCore.target +TIUIElements.target: TIUIKitCore.target TILogging.target MODULE_NAME="TIUIElements" ./project-scripts/push_to_podspecs.sh touch TIUIElements.target diff --git a/Package.swift b/Package.swift index dbd1be06..47d2f90a 100644 --- a/Package.swift +++ b/Package.swift @@ -79,7 +79,7 @@ let package = Package( .target(name: "TIUIKitCore", dependencies: ["TISwiftUtils"], path: "TIUIKitCore/Sources"), .target(name: "TIUIElements", - dependencies: ["TIUIKitCore", "TISwiftUtils"], + dependencies: ["TIUIKitCore", "TILogging"], path: "TIUIElements/Sources", exclude: ["../TIUIElements.app"], plugins: [.plugin(name: "TISwiftLintPlugin")]), diff --git a/TIAppleMapUtils/TIAppleMapUtils.podspec b/TIAppleMapUtils/TIAppleMapUtils.podspec index ffa12cef..53040412 100644 --- a/TIAppleMapUtils/TIAppleMapUtils.podspec +++ b/TIAppleMapUtils/TIAppleMapUtils.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIAppleMapUtils' - s.version = '1.53.0' + s.version = '1.53.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 bf420d69..f2106d03 100644 --- a/TIApplication/TIApplication.podspec +++ b/TIApplication/TIApplication.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIApplication' - s.version = '1.53.0' + s.version = '1.53.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 e759bcf0..e15cc178 100644 --- a/TIAuth/TIAuth.podspec +++ b/TIAuth/TIAuth.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIAuth' - s.version = '1.53.0' + s.version = '1.53.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/PlaygroundPodfile b/TIBottomSheet/PlaygroundPodfile index beb2a489..bd0d31c8 100644 --- a/TIBottomSheet/PlaygroundPodfile +++ b/TIBottomSheet/PlaygroundPodfile @@ -10,4 +10,5 @@ target 'TIBottomSheet' do pod 'TIUIKitCore', :path => '../../../../TIUIKitCore/TIUIKitCore.podspec' pod 'TISwiftUtils', :path => '../../../../TISwiftUtils/TISwiftUtils.podspec' pod 'TIBottomSheet', :path => '../../../../TIBottomSheet/TIBottomSheet.podspec' + pod 'TILogging', :path => '../../../../TILogging/TILogging.podspec' end diff --git a/TIBottomSheet/TIBottomSheet.app/Contents/MacOS/Podfile b/TIBottomSheet/TIBottomSheet.app/Contents/MacOS/Podfile index beb2a489..bd0d31c8 100644 --- a/TIBottomSheet/TIBottomSheet.app/Contents/MacOS/Podfile +++ b/TIBottomSheet/TIBottomSheet.app/Contents/MacOS/Podfile @@ -10,4 +10,5 @@ target 'TIBottomSheet' do pod 'TIUIKitCore', :path => '../../../../TIUIKitCore/TIUIKitCore.podspec' pod 'TISwiftUtils', :path => '../../../../TISwiftUtils/TISwiftUtils.podspec' pod 'TIBottomSheet', :path => '../../../../TIBottomSheet/TIBottomSheet.podspec' + pod 'TILogging', :path => '../../../../TILogging/TILogging.podspec' end diff --git a/TIBottomSheet/TIBottomSheet.app/Contents/MacOS/TIBottomSheet.playground/Pages/TIBottomSheet.xcplaygroundpage/Contents.swift b/TIBottomSheet/TIBottomSheet.app/Contents/MacOS/TIBottomSheet.playground/Pages/TIBottomSheet.xcplaygroundpage/Contents.swift index e564a6fc..f2e4423f 100644 --- a/TIBottomSheet/TIBottomSheet.app/Contents/MacOS/TIBottomSheet.playground/Pages/TIBottomSheet.xcplaygroundpage/Contents.swift +++ b/TIBottomSheet/TIBottomSheet.app/Contents/MacOS/TIBottomSheet.playground/Pages/TIBottomSheet.xcplaygroundpage/Contents.swift @@ -87,9 +87,9 @@ detentsViewController.viewControllerAppearance.presentationDetents = [.headerOnl let shadowViewController = BaseModalViewController() let dimmedView = PassthroughDimmedView() dimmedView.hitTestHandlerView = shadowViewController.view -dimmedView.configureUIView(appearance: DefaultAppearance(shadow: UIViewShadow(radius: 8, - color: .black, - opacity: 0.3))) +dimmedView.configureUIView(appearance: UIView.DefaultAppearance(shadow: UIViewShadow(radius: 8, + color: .black, + opacity: 0.3))) shadowViewController.dimmedView = dimmedView diff --git a/TIBottomSheet/TIBottomSheet.podspec b/TIBottomSheet/TIBottomSheet.podspec index 28b24659..5094e096 100644 --- a/TIBottomSheet/TIBottomSheet.podspec +++ b/TIBottomSheet/TIBottomSheet.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIBottomSheet' - s.version = '1.53.0' + s.version = '1.53.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 a1fd5618..ad4c9699 100644 --- a/TICoreGraphicsUtils/TICoreGraphicsUtils.podspec +++ b/TICoreGraphicsUtils/TICoreGraphicsUtils.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TICoreGraphicsUtils' - s.version = '1.53.0' + s.version = '1.53.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 5890e810..32e7cf84 100644 --- a/TIDeeplink/TIDeeplink.podspec +++ b/TIDeeplink/TIDeeplink.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIDeeplink' - s.version = '1.53.0' + s.version = '1.53.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 9e21416f..8b524928 100644 --- a/TIDeveloperUtils/TIDeveloperUtils.podspec +++ b/TIDeveloperUtils/TIDeveloperUtils.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIDeveloperUtils' - s.version = '1.53.0' + s.version = '1.53.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 94adc4f9..d8bfc830 100644 --- a/TIEcommerce/TIEcommerce.podspec +++ b/TIEcommerce/TIEcommerce.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIEcommerce' - s.version = '1.53.0' + s.version = '1.53.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 80e40ae6..9176591c 100644 --- a/TIFoundationUtils/TIFoundationUtils.podspec +++ b/TIFoundationUtils/TIFoundationUtils.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIFoundationUtils' - s.version = '1.53.0' + s.version = '1.53.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 9294f593..3ac181d3 100644 --- a/TIGoogleMapUtils/TIGoogleMapUtils.podspec +++ b/TIGoogleMapUtils/TIGoogleMapUtils.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIGoogleMapUtils' - s.version = '1.53.0' + s.version = '1.53.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 1b892461..fea8c8b8 100644 --- a/TIKeychainUtils/TIKeychainUtils.podspec +++ b/TIKeychainUtils/TIKeychainUtils.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIKeychainUtils' - s.version = '1.53.0' + s.version = '1.53.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 d39d9a1c..208c711d 100644 --- a/TILogging/TILogging.podspec +++ b/TILogging/TILogging.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TILogging' - s.version = '1.53.0' + s.version = '1.53.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 d6a957fc..37f43dd4 100644 --- a/TIMapUtils/TIMapUtils.podspec +++ b/TIMapUtils/TIMapUtils.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIMapUtils' - s.version = '1.53.0' + s.version = '1.53.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 690e0b98..908b34bf 100644 --- a/TIMoyaNetworking/TIMoyaNetworking.podspec +++ b/TIMoyaNetworking/TIMoyaNetworking.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIMoyaNetworking' - s.version = '1.53.0' + s.version = '1.53.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 4afc89f2..cce5fa27 100644 --- a/TINetworking/TINetworking.podspec +++ b/TINetworking/TINetworking.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TINetworking' - s.version = '1.53.0' + s.version = '1.53.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 df85df41..4d331ee0 100644 --- a/TINetworkingCache/TINetworkingCache.podspec +++ b/TINetworkingCache/TINetworkingCache.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TINetworkingCache' - s.version = '1.53.0' + s.version = '1.53.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 65e34a80..c6acaabc 100644 --- a/TIPagination/TIPagination.podspec +++ b/TIPagination/TIPagination.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIPagination' - s.version = '1.53.0' + s.version = '1.53.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 bc8dc2e9..24400e8b 100644 --- a/TISwiftUICore/TISwiftUICore.podspec +++ b/TISwiftUICore/TISwiftUICore.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TISwiftUICore' - s.version = '1.53.0' + s.version = '1.53.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 7600727f..affb722d 100644 --- a/TISwiftUtils/TISwiftUtils.podspec +++ b/TISwiftUtils/TISwiftUtils.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TISwiftUtils' - s.version = '1.53.0' + s.version = '1.53.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 769b3648..df9999cb 100644 --- a/TITableKitUtils/TITableKitUtils.podspec +++ b/TITableKitUtils/TITableKitUtils.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TITableKitUtils' - s.version = '1.53.0' + s.version = '1.53.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 1cc2f590..cf98f359 100644 --- a/TITextProcessing/TITextProcessing.podspec +++ b/TITextProcessing/TITextProcessing.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TITextProcessing' - s.version = '1.53.0' + s.version = '1.53.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/PlaygroundPodfile b/TIUIElements/PlaygroundPodfile index 95938d81..c33c155c 100644 --- a/TIUIElements/PlaygroundPodfile +++ b/TIUIElements/PlaygroundPodfile @@ -7,4 +7,5 @@ target 'TIUIElements' do pod 'TIUIElements', :path => '../../../../TIUIElements/TIUIElements.podspec' pod 'TIUIKitCore', :path => '../../../../TIUIKitCore/TIUIKitCore.podspec' pod 'TISwiftUtils', :path => '../../../../TISwiftUtils/TISwiftUtils.podspec' + pod 'TILogging', :path => '../../../../TILogging/TILogging.podspec' end diff --git a/TIUIElements/Sources/TIUIElementsLogger.swift b/TIUIElements/Sources/TIUIElementsLogger.swift new file mode 100644 index 00000000..65f04db3 --- /dev/null +++ b/TIUIElements/Sources/TIUIElementsLogger.swift @@ -0,0 +1,34 @@ +// +// 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 TILogging +import os + +public final class TIUIElementsLogger: DefaultOSLogErrorLogger { + enum Category: String { + case layout + } + + public init(category: String) { + super.init(log: OSLog(subsystem: "TIUIElements", category: category)) + } +} diff --git a/TIUIElements/Sources/Wrappers/Protocols/WrappedViewHolder.swift b/TIUIElements/Sources/Wrappers/Protocols/WrappedViewHolder.swift index cd5d151b..25544a53 100644 --- a/TIUIElements/Sources/Wrappers/Protocols/WrappedViewHolder.swift +++ b/TIUIElements/Sources/Wrappers/Protocols/WrappedViewHolder.swift @@ -22,6 +22,7 @@ import UIKit import TIUIKitCore +import os public protocol WrappedViewHolder: AnyObject { associatedtype View: UIView @@ -71,10 +72,108 @@ public extension WrappedViewHolder { // MARK: - WrappedViewLayout shortcut func updateContentLayout(from layout: some WrappedViewLayout) { - wrappedContentInsets = layout.insets + wrappedContentInsets = adjustInsets(of: layout) wrappedContentSize = layout.size wrappedContentCenterOffset = layout.centerOffset } + + private func adjustInsets(of layout: some WrappedViewLayout) -> UIEdgeInsets { + let logger = TIUIElementsLogger(category: TIUIElementsLogger.Category.layout.rawValue) + + let adjustedHorizontalInsets = adjustHorizontal(insets: layout.insets, + of: layout, + log: logger.log) + + return adjustVertical(insets: adjustedHorizontalInsets, + of: layout, + log: logger.log) + } + + private func adjustHorizontal(insets: UIEdgeInsets, + of layout: some WrappedViewLayout, + log: OSLog) -> UIEdgeInsets { + + let horizontalInsetsDefined = insets.horizontal().isFinite + let horizontalAlignmentDefined = layout.centerOffset.horizontal.isFinite + + switch (horizontalInsetsDefined, horizontalAlignmentDefined) { + case (true, true): + os_log(""" + %{public}s:%{public}d:%{public}s: layout defines + - horizontal insets %{public}s + - horizontal center alignment %{public}s. + This can lead to unpredictable placement of the element. + """, + log: log, + type: .info, + #file, + #line, + String(describing: type(of: self)), + "UIEdgeInsets(left: \(insets.left), right: \(insets.right))", + "UIOffset(horizontal: \(layout.centerOffset.horizontal))") + + case (true, false), (false, true): + break // everything is ok + + case (false, false): + os_log(""" + %{public}s:%{public}d:%{public}s: horizontal insets and horizontal center alignment + is not defined. Falling back to zero insets. + """, + log: log, + type: .info, + #file, + #line, + String(describing: type(of: self))) + + return insets.horizontal(.zero) + } + + return insets + } + + private func adjustVertical(insets: UIEdgeInsets, + of layout: some WrappedViewLayout, + log: OSLog) -> UIEdgeInsets { + + let verticalInsetsDefined = insets.vertical().isFinite + let verticalAlignmentDefined = layout.centerOffset.vertical.isFinite + + switch (verticalInsetsDefined, verticalAlignmentDefined) { + case (true, true): + os_log(""" + %{public}s:%{public}d:%{public}s: layout defines + - vertical insets %{public}s + - vertical center alignment %{public}s + This can lead to unpredictable placement of the element. + """, + log: log, + type: .info, + #file, + #line, + String(describing: type(of: self)), + "UIEdgeInsets(top: \(insets.top), bottom: \(insets.bottom))", + "UIOffset(vertical: \(layout.centerOffset.vertical))") + + case (true, false), (false, true): + break // everything is ok + + case (false, false): + os_log(""" + %{public}s:%{public}d:%{public}s: vertical insets and vertical center alignment + is not defined. Falling back to zero insets. + """, + log: log, + type: .info, + #file, + #line, + String(describing: type(of: self))) + + return insets.vertical(.zero) + } + + return insets + } } public extension WrappedViewHolder where Self: UIView { diff --git a/TIUIElements/TIUIElements.app/Contents/MacOS/Podfile b/TIUIElements/TIUIElements.app/Contents/MacOS/Podfile index ab33d1bc..1de11e76 100644 --- a/TIUIElements/TIUIElements.app/Contents/MacOS/Podfile +++ b/TIUIElements/TIUIElements.app/Contents/MacOS/Podfile @@ -7,4 +7,5 @@ target 'TIUIElements' do pod 'TIUIElements', :path => '../../../../TIUIElements/TIUIElements.podspec' pod 'TISwiftUtils', :path => '../../../../TISwiftUtils/TISwiftUtils.podspec' pod 'TIUIKitCore', :path => '../../../../TIUIKitCore/TIUIKitCore.podspec' + pod 'TILogging', :path => '../../../../TILogging/TILogging.podspec' end diff --git a/TIUIElements/TIUIElements.podspec b/TIUIElements/TIUIElements.podspec index aee14016..452771c7 100644 --- a/TIUIElements/TIUIElements.podspec +++ b/TIUIElements/TIUIElements.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIUIElements' - s.version = '1.53.0' + s.version = '1.53.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' } @@ -22,4 +22,5 @@ Pod::Spec.new do |s| s.dependency 'TIUIKitCore', s.version.to_s s.dependency 'TISwiftUtils', s.version.to_s + s.dependency 'TILogging', s.version.to_s end diff --git a/TIUIKitCore/TIUIKitCore.podspec b/TIUIKitCore/TIUIKitCore.podspec index 1937a07e..9c1757dc 100644 --- a/TIUIKitCore/TIUIKitCore.podspec +++ b/TIUIKitCore/TIUIKitCore.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIUIKitCore' - s.version = '1.53.0' + s.version = '1.53.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 b40abf2b..2a7ef7c6 100644 --- a/TIWebView/TIWebView.podspec +++ b/TIWebView/TIWebView.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIWebView' - s.version = '1.53.0' + s.version = '1.53.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 6ed989a1..0873a96e 100644 --- a/TIYandexMapUtils/TIYandexMapUtils.podspec +++ b/TIYandexMapUtils/TIYandexMapUtils.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIYandexMapUtils' - s.version = '1.53.0' + s.version = '1.53.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' } diff --git a/docs/tibottomsheet/tibottomsheet.md b/docs/tibottomsheet/tibottomsheet.md index d7425a68..7edc5f2b 100644 --- a/docs/tibottomsheet/tibottomsheet.md +++ b/docs/tibottomsheet/tibottomsheet.md @@ -88,9 +88,9 @@ detentsViewController.viewControllerAppearance.presentationDetents = [.headerOnl let shadowViewController = BaseModalViewController() let dimmedView = PassthroughDimmedView() dimmedView.hitTestHandlerView = shadowViewController.view -dimmedView.configureUIView(appearance: DefaultAppearance(shadow: UIViewShadow(radius: 8, - color: .black, - opacity: 0.3))) +dimmedView.configureUIView(appearance: UIView.DefaultAppearance(shadow: UIViewShadow(radius: 8, + color: .black, + opacity: 0.3))) shadowViewController.dimmedView = dimmedView ``` -- 2.40.1