From 8e1c044abc7ec9956c98b52489910567c92eeb38 Mon Sep 17 00:00:00 2001 From: Alexander Rutsman Date: Mon, 1 Nov 2021 23:05:27 +0300 Subject: [PATCH 1/7] feat: added TIScrollLabel --- .../Views/BaseInitializableScrollView.swift | 37 ++++++++ .../TIScrollLabel/LabeledScrollView.swift | 92 +++++++++++++++++++ .../Views/TIScrollLabel/TIScrollLabel.swift | 26 ++++++ 3 files changed, 155 insertions(+) create mode 100644 TIUIElements/Sources/Views/BaseInitializableScrollView.swift create mode 100644 TIUIElements/Sources/Views/TIScrollLabel/LabeledScrollView.swift create mode 100644 TIUIElements/Sources/Views/TIScrollLabel/TIScrollLabel.swift diff --git a/TIUIElements/Sources/Views/BaseInitializableScrollView.swift b/TIUIElements/Sources/Views/BaseInitializableScrollView.swift new file mode 100644 index 00000000..dbdf0b3b --- /dev/null +++ b/TIUIElements/Sources/Views/BaseInitializableScrollView.swift @@ -0,0 +1,37 @@ +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/LabeledScrollView.swift b/TIUIElements/Sources/Views/TIScrollLabel/LabeledScrollView.swift new file mode 100644 index 00000000..2dcbe123 --- /dev/null +++ b/TIUIElements/Sources/Views/TIScrollLabel/LabeledScrollView.swift @@ -0,0 +1,92 @@ +import UIKit +import SnapKit + +open class LabeledScrollView: BaseInitializableScrollView { + + private let textLabel = UILabel() + private let contentView = UIView() + + // MARK: - Configurable Properties + + public var text: String = "" { + didSet { + textLabel.text = text + } + } + + public var textColor: UIColor = .black { + didSet { + textLabel.textColor = textColor + } + } + + public var font: UIFont = UIFont.systemFont(ofSize: 13) { + didSet { + textLabel.font = font + } + } + + public var textAligment: NSTextAlignment = .center { + didSet { + textLabel.textAlignment = textAligment + } + } + + // 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 = textAligment + 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/Sources/Views/TIScrollLabel/TIScrollLabel.swift b/TIUIElements/Sources/Views/TIScrollLabel/TIScrollLabel.swift new file mode 100644 index 00000000..96a43aa0 --- /dev/null +++ b/TIUIElements/Sources/Views/TIScrollLabel/TIScrollLabel.swift @@ -0,0 +1,26 @@ +import UIKit +import TIUIElements + +open class TIScrollLabel: BaseInitializableView { + + private let labeledScrollView = LabeledScrollView() + + open override func addViews() { + super.addViews() + + addSubview(labeledScrollView) + } + + open override func configureLayout() { + super.configureLayout() + + labeledScrollView.translatesAutoresizingMaskIntoConstraints = false + + NSLayoutConstraint.activate([ + labeledScrollView.leadingAnchor.constraint(equalTo: leadingAnchor), + labeledScrollView.trailingAnchor.constraint(equalTo: trailingAnchor), + labeledScrollView.topAnchor.constraint(equalTo: topAnchor), + labeledScrollView.bottomAnchor.constraint(equalTo: bottomAnchor) + ]) + } +} From a667e3adf21fc499edb3a87e8f1a51b4fe33a386 Mon Sep 17 00:00:00 2001 From: Alexander Rutsman Date: Mon, 1 Nov 2021 23:12:50 +0300 Subject: [PATCH 2/7] chore: bump version 1.8.0 --- CHANGELOG.md | 3 +++ LeadKit.podspec | 2 +- TIFoundationUtils/TIFoundationUtils.podspec | 2 +- TIKeychainUtils/TIKeychainUtils.podspec | 2 +- TINetworking/TINetworking.podspec | 2 +- TISwiftUtils/TISwiftUtils.podspec | 2 +- TITableKitUtils/TITableKitUtils.podspec | 2 +- TITransitions/TITransitions.podspec | 2 +- TIUIElements/TIUIElements.podspec | 2 +- TIUIKitCore/TIUIKitCore.podspec | 2 +- 10 files changed, 12 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f9e5dc30..4a489d0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +### 1.7.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/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' } From f64301376080efa547f3b5ebce0ba51266671fa2 Mon Sep 17 00:00:00 2001 From: Alexander Rutsman Date: Mon, 1 Nov 2021 23:16:42 +0300 Subject: [PATCH 3/7] refactor: added copyrights --- .../Views/BaseInitializableScrollView.swift | 22 ++++++++++++++++++ .../TIScrollLabel/LabeledScrollView.swift | 23 ++++++++++++++++++- .../Views/TIScrollLabel/TIScrollLabel.swift | 22 ++++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-) diff --git a/TIUIElements/Sources/Views/BaseInitializableScrollView.swift b/TIUIElements/Sources/Views/BaseInitializableScrollView.swift index dbdf0b3b..81bba55e 100644 --- a/TIUIElements/Sources/Views/BaseInitializableScrollView.swift +++ b/TIUIElements/Sources/Views/BaseInitializableScrollView.swift @@ -1,3 +1,25 @@ +// +// 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 diff --git a/TIUIElements/Sources/Views/TIScrollLabel/LabeledScrollView.swift b/TIUIElements/Sources/Views/TIScrollLabel/LabeledScrollView.swift index 2dcbe123..870857c3 100644 --- a/TIUIElements/Sources/Views/TIScrollLabel/LabeledScrollView.swift +++ b/TIUIElements/Sources/Views/TIScrollLabel/LabeledScrollView.swift @@ -1,5 +1,26 @@ +// +// 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 SnapKit open class LabeledScrollView: BaseInitializableScrollView { diff --git a/TIUIElements/Sources/Views/TIScrollLabel/TIScrollLabel.swift b/TIUIElements/Sources/Views/TIScrollLabel/TIScrollLabel.swift index 96a43aa0..b9ca0ded 100644 --- a/TIUIElements/Sources/Views/TIScrollLabel/TIScrollLabel.swift +++ b/TIUIElements/Sources/Views/TIScrollLabel/TIScrollLabel.swift @@ -1,3 +1,25 @@ +// +// 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 From 47b2119cfd3e3f1a7c45eea6ffa6c7226f5ba06b Mon Sep 17 00:00:00 2001 From: Alexander Rutsman Date: Tue, 2 Nov 2021 00:12:26 +0300 Subject: [PATCH 4/7] docs: update docs --- TIUIElements/README.md | 1 + .../Sources/Views/TIScrollLabel/README.md | 17 +++++++++++++++++ .../{ => TIScrollLabel}/LabeledScrollView.swift | 0 .../{ => TIScrollLabel}/TIScrollLabel.swift | 0 4 files changed, 18 insertions(+) create mode 100644 TIUIElements/Sources/Views/TIScrollLabel/README.md rename TIUIElements/Sources/Views/TIScrollLabel/{ => TIScrollLabel}/LabeledScrollView.swift (100%) rename TIUIElements/Sources/Views/TIScrollLabel/{ => TIScrollLabel}/TIScrollLabel.swift (100%) 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/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/LabeledScrollView.swift b/TIUIElements/Sources/Views/TIScrollLabel/TIScrollLabel/LabeledScrollView.swift similarity index 100% rename from TIUIElements/Sources/Views/TIScrollLabel/LabeledScrollView.swift rename to TIUIElements/Sources/Views/TIScrollLabel/TIScrollLabel/LabeledScrollView.swift diff --git a/TIUIElements/Sources/Views/TIScrollLabel/TIScrollLabel.swift b/TIUIElements/Sources/Views/TIScrollLabel/TIScrollLabel/TIScrollLabel.swift similarity index 100% rename from TIUIElements/Sources/Views/TIScrollLabel/TIScrollLabel.swift rename to TIUIElements/Sources/Views/TIScrollLabel/TIScrollLabel/TIScrollLabel.swift From 22a2f76752e5ae63897449be2fd010b9355962ba Mon Sep 17 00:00:00 2001 From: Alexander Rutsman Date: Tue, 2 Nov 2021 00:16:00 +0300 Subject: [PATCH 5/7] refactor: added properties --- .../TIScrollLabel/TIScrollLabel.swift | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/TIUIElements/Sources/Views/TIScrollLabel/TIScrollLabel/TIScrollLabel.swift b/TIUIElements/Sources/Views/TIScrollLabel/TIScrollLabel/TIScrollLabel.swift index b9ca0ded..716e147e 100644 --- a/TIUIElements/Sources/Views/TIScrollLabel/TIScrollLabel/TIScrollLabel.swift +++ b/TIUIElements/Sources/Views/TIScrollLabel/TIScrollLabel/TIScrollLabel.swift @@ -27,6 +27,30 @@ open class TIScrollLabel: BaseInitializableView { private let labeledScrollView = LabeledScrollView() + public var text: String = "" { + didSet { + labeledScrollView.text = text + } + } + + public var textColor: UIColor = .black { + didSet { + labeledScrollView.textColor = textColor + } + } + + public var font: UIFont = UIFont.systemFont(ofSize: 13) { + didSet { + labeledScrollView.font = font + } + } + + public var textAlignment: NSTextAlignment = .center { + didSet { + labeledScrollView.textAlignment = textAlignment + } + } + open override func addViews() { super.addViews() From 9c5c6262239f9f665d8b173ffe0a023e9eb61018 Mon Sep 17 00:00:00 2001 From: Alexander Rutsman Date: Tue, 2 Nov 2021 00:33:06 +0300 Subject: [PATCH 6/7] fix: changelog text --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a489d0b..c6724c36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -### 1.7.0 +### 1.8.0 - **Add**: `TIScrollLabel` - the scroll view with label - TIScrollLabel ### 1.7.0 From 657e0bfbef62572eed178aa7c5f6da6d95dc3f13 Mon Sep 17 00:00:00 2001 From: Alexander Rutsman Date: Wed, 15 Dec 2021 10:55:35 +0300 Subject: [PATCH 7/7] fix: removed LabeledScrollView, added attributedText --- .../TIScrollLabel/LabeledScrollView.swift | 113 ------------------ .../TIScrollLabel/TIScrollLabel.swift | 74 ++++++++++-- 2 files changed, 61 insertions(+), 126 deletions(-) delete mode 100644 TIUIElements/Sources/Views/TIScrollLabel/TIScrollLabel/LabeledScrollView.swift diff --git a/TIUIElements/Sources/Views/TIScrollLabel/TIScrollLabel/LabeledScrollView.swift b/TIUIElements/Sources/Views/TIScrollLabel/TIScrollLabel/LabeledScrollView.swift deleted file mode 100644 index 870857c3..00000000 --- a/TIUIElements/Sources/Views/TIScrollLabel/TIScrollLabel/LabeledScrollView.swift +++ /dev/null @@ -1,113 +0,0 @@ -// -// 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 - -open class LabeledScrollView: BaseInitializableScrollView { - - private let textLabel = UILabel() - private let contentView = UIView() - - // MARK: - Configurable Properties - - public var text: String = "" { - didSet { - textLabel.text = text - } - } - - public var textColor: UIColor = .black { - didSet { - textLabel.textColor = textColor - } - } - - public var font: UIFont = UIFont.systemFont(ofSize: 13) { - didSet { - textLabel.font = font - } - } - - public var textAligment: NSTextAlignment = .center { - didSet { - textLabel.textAlignment = textAligment - } - } - - // 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 = textAligment - 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/Sources/Views/TIScrollLabel/TIScrollLabel/TIScrollLabel.swift b/TIUIElements/Sources/Views/TIScrollLabel/TIScrollLabel/TIScrollLabel.swift index 716e147e..f358ea7a 100644 --- a/TIUIElements/Sources/Views/TIScrollLabel/TIScrollLabel/TIScrollLabel.swift +++ b/TIUIElements/Sources/Views/TIScrollLabel/TIScrollLabel/TIScrollLabel.swift @@ -23,50 +23,98 @@ import UIKit import TIUIElements -open class TIScrollLabel: BaseInitializableView { +open class TIScrollLabel: BaseInitializableScrollView { - private let labeledScrollView = LabeledScrollView() + private let textLabel = UILabel() + private let contentView = UIView() + + // MARK: - Configurable Properties public var text: String = "" { didSet { - labeledScrollView.text = text + textLabel.text = text + } + } + + public var attributedText: NSAttributedString? = nil { + didSet { + textLabel.attributedText = attributedText } } public var textColor: UIColor = .black { didSet { - labeledScrollView.textColor = textColor + textLabel.textColor = textColor } } - + public var font: UIFont = UIFont.systemFont(ofSize: 13) { didSet { - labeledScrollView.font = font + textLabel.font = font } } public var textAlignment: NSTextAlignment = .center { didSet { - labeledScrollView.textAlignment = textAlignment + textLabel.textAlignment = textAlignment } } + // MARK: - Initialization + open override func addViews() { super.addViews() - addSubview(labeledScrollView) + 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() - labeledScrollView.translatesAutoresizingMaskIntoConstraints = false + 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([ - labeledScrollView.leadingAnchor.constraint(equalTo: leadingAnchor), - labeledScrollView.trailingAnchor.constraint(equalTo: trailingAnchor), - labeledScrollView.topAnchor.constraint(equalTo: topAnchor), - labeledScrollView.bottomAnchor.constraint(equalTo: bottomAnchor) + 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) ]) } }