Ditch pod in favor of own implementation
This commit is contained in:
parent
618c73b07f
commit
9b527424e6
1
Podfile
1
Podfile
|
@ -77,7 +77,6 @@ target 'Signal' do
|
||||||
pod 'FeedKit', '~> 8.1', :inhibit_warnings => true
|
pod 'FeedKit', '~> 8.1', :inhibit_warnings => true
|
||||||
pod 'CryptoSwift', '~> 1.3', :inhibit_warnings => true
|
pod 'CryptoSwift', '~> 1.3', :inhibit_warnings => true
|
||||||
pod 'NVActivityIndicatorView', '~> 4.7', :inhibit_warnings => true
|
pod 'NVActivityIndicatorView', '~> 4.7', :inhibit_warnings => true
|
||||||
pod 'UITextView+Placeholder', '~> 1.4', :inhibit_warnings => true
|
|
||||||
|
|
||||||
target 'SignalTests' do
|
target 'SignalTests' do
|
||||||
inherit! :search_paths
|
inherit! :search_paths
|
||||||
|
|
|
@ -130,7 +130,6 @@ PODS:
|
||||||
- SSZipArchive (2.2.3)
|
- SSZipArchive (2.2.3)
|
||||||
- Starscream (3.0.6)
|
- Starscream (3.0.6)
|
||||||
- SwiftProtobuf (1.5.0)
|
- SwiftProtobuf (1.5.0)
|
||||||
- "UITextView+Placeholder (1.4.0)"
|
|
||||||
- YapDatabase/SQLCipher (3.1.1):
|
- YapDatabase/SQLCipher (3.1.1):
|
||||||
- YapDatabase/SQLCipher/Core (= 3.1.1)
|
- YapDatabase/SQLCipher/Core (= 3.1.1)
|
||||||
- YapDatabase/SQLCipher/Extensions (= 3.1.1)
|
- YapDatabase/SQLCipher/Extensions (= 3.1.1)
|
||||||
|
@ -223,7 +222,6 @@ DEPENDENCIES:
|
||||||
- SQLCipher (>= 4.0.1)
|
- SQLCipher (>= 4.0.1)
|
||||||
- SSZipArchive
|
- SSZipArchive
|
||||||
- Starscream (from `https://github.com/signalapp/Starscream.git`, branch `signal-release`)
|
- Starscream (from `https://github.com/signalapp/Starscream.git`, branch `signal-release`)
|
||||||
- "UITextView+Placeholder (~> 1.4)"
|
|
||||||
- YapDatabase/SQLCipher (from `https://github.com/signalapp/YapDatabase.git`, branch `signal-release`)
|
- YapDatabase/SQLCipher (from `https://github.com/signalapp/YapDatabase.git`, branch `signal-release`)
|
||||||
- YYImage
|
- YYImage
|
||||||
|
|
||||||
|
@ -243,7 +241,6 @@ SPEC REPOS:
|
||||||
- SQLCipher
|
- SQLCipher
|
||||||
- SSZipArchive
|
- SSZipArchive
|
||||||
- SwiftProtobuf
|
- SwiftProtobuf
|
||||||
- "UITextView+Placeholder"
|
|
||||||
- YYImage
|
- YYImage
|
||||||
|
|
||||||
EXTERNAL SOURCES:
|
EXTERNAL SOURCES:
|
||||||
|
@ -325,10 +322,9 @@ SPEC CHECKSUMS:
|
||||||
SSZipArchive: 62d4947b08730e4cda640473b0066d209ff033c9
|
SSZipArchive: 62d4947b08730e4cda640473b0066d209ff033c9
|
||||||
Starscream: 8aaf1a7feb805c816d0e7d3190ef23856f6665b9
|
Starscream: 8aaf1a7feb805c816d0e7d3190ef23856f6665b9
|
||||||
SwiftProtobuf: 241400280f912735c1e1b9fe675fdd2c6c4d42e2
|
SwiftProtobuf: 241400280f912735c1e1b9fe675fdd2c6c4d42e2
|
||||||
"UITextView+Placeholder": d7b0c400921f66523f3a85d74f774512e14f6502
|
|
||||||
YapDatabase: b418a4baa6906e8028748938f9159807fd039af4
|
YapDatabase: b418a4baa6906e8028748938f9159807fd039af4
|
||||||
YYImage: 1e1b62a9997399593e4b9c4ecfbbabbf1d3f3b54
|
YYImage: 1e1b62a9997399593e4b9c4ecfbbabbf1d3f3b54
|
||||||
|
|
||||||
PODFILE CHECKSUM: 0d59a208ed95a7e5640a3e89cff48cd0a5b51e0b
|
PODFILE CHECKSUM: b4f88816a817cc27f499940c644c0449ef5d7cc7
|
||||||
|
|
||||||
COCOAPODS: 1.9.3
|
COCOAPODS: 1.9.3
|
||||||
|
|
2
Pods
2
Pods
|
@ -1 +1 @@
|
||||||
Subproject commit 5d61962cd5848660e72017012f20caab92289f48
|
Subproject commit 71f54b041ff9b9a77fecea805aa42ac536392c40
|
|
@ -3417,7 +3417,6 @@
|
||||||
"${BUILT_PRODUCTS_DIR}/SessionServiceKit/SessionServiceKit.framework",
|
"${BUILT_PRODUCTS_DIR}/SessionServiceKit/SessionServiceKit.framework",
|
||||||
"${BUILT_PRODUCTS_DIR}/Starscream/Starscream.framework",
|
"${BUILT_PRODUCTS_DIR}/Starscream/Starscream.framework",
|
||||||
"${BUILT_PRODUCTS_DIR}/SwiftProtobuf/SwiftProtobuf.framework",
|
"${BUILT_PRODUCTS_DIR}/SwiftProtobuf/SwiftProtobuf.framework",
|
||||||
"${BUILT_PRODUCTS_DIR}/UITextView+Placeholder/UITextView_Placeholder.framework",
|
|
||||||
"${BUILT_PRODUCTS_DIR}/YYImage/YYImage.framework",
|
"${BUILT_PRODUCTS_DIR}/YYImage/YYImage.framework",
|
||||||
"${BUILT_PRODUCTS_DIR}/YapDatabase/YapDatabase.framework",
|
"${BUILT_PRODUCTS_DIR}/YapDatabase/YapDatabase.framework",
|
||||||
"${BUILT_PRODUCTS_DIR}/libPhoneNumber-iOS/libPhoneNumber_iOS.framework",
|
"${BUILT_PRODUCTS_DIR}/libPhoneNumber-iOS/libPhoneNumber_iOS.framework",
|
||||||
|
@ -3446,7 +3445,6 @@
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SessionServiceKit.framework",
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SessionServiceKit.framework",
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Starscream.framework",
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Starscream.framework",
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftProtobuf.framework",
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftProtobuf.framework",
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/UITextView_Placeholder.framework",
|
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YYImage.framework",
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YYImage.framework",
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YapDatabase.framework",
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YapDatabase.framework",
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libPhoneNumber_iOS.framework",
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libPhoneNumber_iOS.framework",
|
||||||
|
|
|
@ -1,20 +1,28 @@
|
||||||
import UITextView_Placeholder
|
|
||||||
|
|
||||||
final class TextView : UITextView {
|
final class TextView : UITextView, UITextViewDelegate {
|
||||||
private let usesDefaultHeight: Bool
|
private let usesDefaultHeight: Bool
|
||||||
private let height: CGFloat
|
private let height: CGFloat
|
||||||
private let horizontalInset: CGFloat
|
private let horizontalInset: CGFloat
|
||||||
private let verticalInset: CGFloat
|
private let verticalInset: CGFloat
|
||||||
|
private let placeholder: String
|
||||||
|
|
||||||
override var contentSize: CGSize { didSet { centerTextVertically() } }
|
override var contentSize: CGSize { didSet { centerTextVertically() } }
|
||||||
|
|
||||||
|
private lazy var placeholderLabel: UILabel = {
|
||||||
|
let result = UILabel()
|
||||||
|
result.font = .systemFont(ofSize: Values.smallFontSize)
|
||||||
|
result.textColor = Colors.text.withAlphaComponent(Values.unimportantElementOpacity)
|
||||||
|
return result
|
||||||
|
}()
|
||||||
|
|
||||||
init(placeholder: String, usesDefaultHeight: Bool = true, customHeight: CGFloat? = nil, customHorizontalInset: CGFloat? = nil, customVerticalInset: CGFloat? = nil) {
|
init(placeholder: String, usesDefaultHeight: Bool = true, customHeight: CGFloat? = nil, customHorizontalInset: CGFloat? = nil, customVerticalInset: CGFloat? = nil) {
|
||||||
self.usesDefaultHeight = usesDefaultHeight
|
self.usesDefaultHeight = usesDefaultHeight
|
||||||
self.height = customHeight ?? Values.textFieldHeight
|
self.height = customHeight ?? Values.textFieldHeight
|
||||||
self.horizontalInset = customHorizontalInset ?? (isIPhone5OrSmaller ? Values.mediumSpacing : Values.largeSpacing)
|
self.horizontalInset = customHorizontalInset ?? (isIPhone5OrSmaller ? Values.mediumSpacing : Values.largeSpacing)
|
||||||
self.verticalInset = customVerticalInset ?? (isIPhone5OrSmaller ? Values.smallSpacing : Values.largeSpacing)
|
self.verticalInset = customVerticalInset ?? (isIPhone5OrSmaller ? Values.smallSpacing : Values.largeSpacing)
|
||||||
super.init(frame: CGRect.zero, textContainer: nil)
|
|
||||||
self.placeholder = placeholder
|
self.placeholder = placeholder
|
||||||
|
super.init(frame: CGRect.zero, textContainer: nil)
|
||||||
|
self.delegate = self
|
||||||
setUpStyle()
|
setUpStyle()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,12 +37,7 @@ final class TextView : UITextView {
|
||||||
private func setUpStyle() {
|
private func setUpStyle() {
|
||||||
showsHorizontalScrollIndicator = false
|
showsHorizontalScrollIndicator = false
|
||||||
showsVerticalScrollIndicator = false
|
showsVerticalScrollIndicator = false
|
||||||
let placeholder = NSMutableAttributedString(string: self.placeholder!)
|
placeholderLabel.text = placeholder
|
||||||
self.placeholder = nil
|
|
||||||
let placeholderColor = Colors.text.withAlphaComponent(Values.unimportantElementOpacity)
|
|
||||||
placeholder.addAttribute(.foregroundColor, value: placeholderColor, range: NSRange(location: 0, length: placeholder.length))
|
|
||||||
placeholder.addAttribute(.font, value: UIFont.systemFont(ofSize: Values.smallFontSize), range: NSRange(location: 0, length: placeholder.length))
|
|
||||||
attributedPlaceholder = placeholder
|
|
||||||
backgroundColor = .clear
|
backgroundColor = .clear
|
||||||
textColor = Colors.text
|
textColor = Colors.text
|
||||||
font = .systemFont(ofSize: Values.smallFontSize)
|
font = .systemFont(ofSize: Values.smallFontSize)
|
||||||
|
@ -48,6 +51,15 @@ final class TextView : UITextView {
|
||||||
layer.cornerRadius = Values.textFieldCornerRadius
|
layer.cornerRadius = Values.textFieldCornerRadius
|
||||||
let horizontalInset = usesDefaultHeight ? self.horizontalInset : Values.mediumSpacing
|
let horizontalInset = usesDefaultHeight ? self.horizontalInset : Values.mediumSpacing
|
||||||
textContainerInset = UIEdgeInsets(top: 0, leading: horizontalInset, bottom: 0, trailing: horizontalInset)
|
textContainerInset = UIEdgeInsets(top: 0, leading: horizontalInset, bottom: 0, trailing: horizontalInset)
|
||||||
|
addSubview(placeholderLabel)
|
||||||
|
placeholderLabel.pin(.leading, to: .leading, of: self, withInset: horizontalInset + 3) // Slight visual adjustment
|
||||||
|
placeholderLabel.pin(.top, to: .top, of: self)
|
||||||
|
pin(.trailing, to: .trailing, of: placeholderLabel, withInset: horizontalInset)
|
||||||
|
pin(.bottom, to: .bottom, of: placeholderLabel)
|
||||||
|
}
|
||||||
|
|
||||||
|
func textViewDidChange(_ textView: UITextView) {
|
||||||
|
placeholderLabel.isHidden = !text.isEmpty
|
||||||
}
|
}
|
||||||
|
|
||||||
private func centerTextVertically() {
|
private func centerTextVertically() {
|
||||||
|
|
Loading…
Reference in New Issue