diff --git a/CHANGELOG.md b/CHANGELOG.md index f9e5dc30..c6724c36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +### 1.8.0 +- **Add**: `TIScrollLabel` - the scroll view with label - TIScrollLabel + ### 1.7.0 - **Add**: `TINetworking` - Swagger-frendly networking layer helpers diff --git a/LeadKit.podspec b/LeadKit.podspec index dc8548be..6c6ca909 100644 --- a/LeadKit.podspec +++ b/LeadKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "LeadKit" - s.version = "1.7.0" + s.version = "1.8.0" s.summary = "iOS framework with a bunch of tools for rapid development" s.homepage = "https://github.com/TouchInstinct/LeadKit" s.license = "Apache License, Version 2.0" diff --git a/TIFoundationUtils/TIFoundationUtils.podspec b/TIFoundationUtils/TIFoundationUtils.podspec index 557d461e..a98907d0 100644 --- a/TIFoundationUtils/TIFoundationUtils.podspec +++ b/TIFoundationUtils/TIFoundationUtils.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIFoundationUtils' - s.version = '1.7.0' + s.version = '1.8.0' s.summary = 'Set of helpers for Foundation framework classes.' s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TIKeychainUtils/TIKeychainUtils.podspec b/TIKeychainUtils/TIKeychainUtils.podspec index 8fe917f7..2cd8099c 100644 --- a/TIKeychainUtils/TIKeychainUtils.podspec +++ b/TIKeychainUtils/TIKeychainUtils.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIKeychainUtils' - s.version = '1.7.0' + s.version = '1.8.0' s.summary = 'Set of helpers for Keychain classes.' s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TINetworking/TINetworking.podspec b/TINetworking/TINetworking.podspec index 1c025fb1..fe82b221 100644 --- a/TINetworking/TINetworking.podspec +++ b/TINetworking/TINetworking.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TINetworking' - s.version = '1.7.0' + s.version = '1.8.0' s.summary = 'Swagger-frendly networking layer helpers.' s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TISwiftUtils/TISwiftUtils.podspec b/TISwiftUtils/TISwiftUtils.podspec index b89b2c68..d9c2a975 100644 --- a/TISwiftUtils/TISwiftUtils.podspec +++ b/TISwiftUtils/TISwiftUtils.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TISwiftUtils' - s.version = '1.7.0' + s.version = '1.8.0' s.summary = 'Bunch of useful helpers for Swift development.' s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TITableKitUtils/TITableKitUtils.podspec b/TITableKitUtils/TITableKitUtils.podspec index c56eca20..9c1d528a 100644 --- a/TITableKitUtils/TITableKitUtils.podspec +++ b/TITableKitUtils/TITableKitUtils.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TITableKitUtils' - s.version = '1.7.0' + s.version = '1.8.0' s.summary = 'Set of helpers for TableKit classes.' s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TITransitions/TITransitions.podspec b/TITransitions/TITransitions.podspec index af42244b..dfe548e7 100644 --- a/TITransitions/TITransitions.podspec +++ b/TITransitions/TITransitions.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TITransitions' - s.version = '1.7.0' + s.version = '1.8.0' s.summary = 'Set of custom transitions to present controller. ' s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TIUIElements/README.md b/TIUIElements/README.md index 0bafa5af..e6b73b57 100644 --- a/TIUIElements/README.md +++ b/TIUIElements/README.md @@ -3,6 +3,7 @@ Bunch of useful protocols and views: - `RefreshControl` - a basic UIRefreshControl with fixed refresh action. +- `TIScrollLabel` - a basic scroll view with label. # HeaderTransitionDelegate Use for transition table header to navigationBar view while scrolling diff --git a/TIUIElements/Sources/Views/BaseInitializableScrollView.swift b/TIUIElements/Sources/Views/BaseInitializableScrollView.swift new file mode 100644 index 00000000..81bba55e --- /dev/null +++ b/TIUIElements/Sources/Views/BaseInitializableScrollView.swift @@ -0,0 +1,59 @@ +// +// Copyright (c) 2021 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 + +open class BaseInitializableScrollView: UIScrollView, InitializableViewProtocol { + override public init(frame: CGRect) { + super.init(frame: frame) + + initializeView() + } + + required public init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + + initializeView() + } + + // MARK: - InitializableView + open func addViews() { + // override in subclass + } + + open func configureLayout() { + // override in subclass + } + + open func bindViews() { + // override in subclass + } + + open func configureAppearance() { + // override in subclass + } + + open func localize() { + // override in subclass + } +} diff --git a/TIUIElements/Sources/Views/TIScrollLabel/README.md b/TIUIElements/Sources/Views/TIScrollLabel/README.md new file mode 100644 index 00000000..6508a159 --- /dev/null +++ b/TIUIElements/Sources/Views/TIScrollLabel/README.md @@ -0,0 +1,17 @@ +# TIScrollLabel + +Позволяет скролить текст, если его размер больше чем размер вью. + +### Особенности + +- Если размер текста будет меньше, чем размер вью, то текст будет отображаться в центре + +### Пример использования + +```swift +label = TIScrollLabel() +label.text = // установка текста +label.font = // установка шрифта +label.textColor = // установка цвета текста +label.textAligment = // установка расположения текста +``` diff --git a/TIUIElements/Sources/Views/TIScrollLabel/TIScrollLabel/TIScrollLabel.swift b/TIUIElements/Sources/Views/TIScrollLabel/TIScrollLabel/TIScrollLabel.swift new file mode 100644 index 00000000..f358ea7a --- /dev/null +++ b/TIUIElements/Sources/Views/TIScrollLabel/TIScrollLabel/TIScrollLabel.swift @@ -0,0 +1,120 @@ +// +// Copyright (c) 2021 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 +import TIUIElements + +open class TIScrollLabel: BaseInitializableScrollView { + + private let textLabel = UILabel() + private let contentView = UIView() + + // MARK: - Configurable Properties + + public var text: String = "" { + didSet { + textLabel.text = text + } + } + + public var attributedText: NSAttributedString? = nil { + didSet { + textLabel.attributedText = attributedText + } + } + + public var textColor: UIColor = .black { + didSet { + textLabel.textColor = textColor + } + } + + public var font: UIFont = UIFont.systemFont(ofSize: 13) { + didSet { + textLabel.font = font + } + } + + public var textAlignment: NSTextAlignment = .center { + didSet { + textLabel.textAlignment = textAlignment + } + } + + // MARK: - Initialization + + open override func addViews() { + super.addViews() + + addSubview(contentView) + contentView.addSubview(textLabel) + } + + open override func configureAppearance() { + super.configureAppearance() + + showsVerticalScrollIndicator = false + showsHorizontalScrollIndicator = false + backgroundColor = .clear + clipsToBounds = true + + textLabel.numberOfLines = 0 + textLabel.textAlignment = textAlignment + textLabel.textColor = textColor + textLabel.font = font + } + + open override func configureLayout() { + super.configureLayout() + + contentView.translatesAutoresizingMaskIntoConstraints = false + textLabel.translatesAutoresizingMaskIntoConstraints = false + + let contentViewBottomConstraint = contentView.bottomAnchor.constraint(equalTo: bottomAnchor) + let contentViewCenterYConstraint = contentView.centerYAnchor.constraint(equalTo: centerYAnchor) + let contentViewHeightConstraint = contentView.heightAnchor.constraint(equalTo: heightAnchor) + + [ + contentViewBottomConstraint, + contentViewCenterYConstraint, + contentViewHeightConstraint + ].forEach { $0.priority = .defaultLow } + + NSLayoutConstraint.activate([ + contentView.leadingAnchor.constraint(equalTo: leadingAnchor), + contentView.trailingAnchor.constraint(equalTo: trailingAnchor), + contentView.topAnchor.constraint(equalTo: topAnchor), + contentView.centerXAnchor.constraint(equalTo: centerXAnchor), + contentViewBottomConstraint, + contentViewCenterYConstraint, + contentViewHeightConstraint + ]) + + NSLayoutConstraint.activate([ + textLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor), + textLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor), + textLabel.topAnchor.constraint(equalTo: contentView.topAnchor), + textLabel.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), + textLabel.heightAnchor.constraint(equalTo: contentView.heightAnchor) + ]) + } +} diff --git a/TIUIElements/TIUIElements.podspec b/TIUIElements/TIUIElements.podspec index dc40a6f3..549b400a 100644 --- a/TIUIElements/TIUIElements.podspec +++ b/TIUIElements/TIUIElements.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIUIElements' - s.version = '1.7.0' + s.version = '1.8.0' s.summary = 'Bunch of useful protocols and views.' s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/TIUIKitCore/TIUIKitCore.podspec b/TIUIKitCore/TIUIKitCore.podspec index 88340b88..c33b9d91 100644 --- a/TIUIKitCore/TIUIKitCore.podspec +++ b/TIUIKitCore/TIUIKitCore.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TIUIKitCore' - s.version = '1.7.0' + s.version = '1.8.0' s.summary = 'Core UI elements: protocols, views and helpers.' s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name s.license = { :type => 'MIT', :file => 'LICENSE' }