mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Make new private chat screen use a UITextView
This commit is contained in:
parent
b5f5ffec7d
commit
cd761d2687
5 changed files with 73 additions and 5 deletions
1
Podfile
1
Podfile
|
@ -77,6 +77,7 @@ 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,6 +130,7 @@ 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)
|
||||||
|
@ -222,6 +223,7 @@ 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
|
||||||
|
|
||||||
|
@ -241,6 +243,7 @@ SPEC REPOS:
|
||||||
- SQLCipher
|
- SQLCipher
|
||||||
- SSZipArchive
|
- SSZipArchive
|
||||||
- SwiftProtobuf
|
- SwiftProtobuf
|
||||||
|
- "UITextView+Placeholder"
|
||||||
- YYImage
|
- YYImage
|
||||||
|
|
||||||
EXTERNAL SOURCES:
|
EXTERNAL SOURCES:
|
||||||
|
@ -322,9 +325,10 @@ 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: b4f88816a817cc27f499940c644c0449ef5d7cc7
|
PODFILE CHECKSUM: 0d59a208ed95a7e5640a3e89cff48cd0a5b51e0b
|
||||||
|
|
||||||
COCOAPODS: 1.9.3
|
COCOAPODS: 1.9.3
|
||||||
|
|
|
@ -585,6 +585,7 @@
|
||||||
C3638C0524C7F0B500AF29BC /* LK002RemoveFriendRequests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3638C0424C7F0B500AF29BC /* LK002RemoveFriendRequests.swift */; };
|
C3638C0524C7F0B500AF29BC /* LK002RemoveFriendRequests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3638C0424C7F0B500AF29BC /* LK002RemoveFriendRequests.swift */; };
|
||||||
C369549D24D27A3500CEB4E3 /* MultiDeviceRemovalSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = C369549C24D27A3500CEB4E3 /* MultiDeviceRemovalSheet.swift */; };
|
C369549D24D27A3500CEB4E3 /* MultiDeviceRemovalSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = C369549C24D27A3500CEB4E3 /* MultiDeviceRemovalSheet.swift */; };
|
||||||
C36B8707243C50C60049991D /* SignalMessaging.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 453518921FC63DBF00210559 /* SignalMessaging.framework */; };
|
C36B8707243C50C60049991D /* SignalMessaging.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 453518921FC63DBF00210559 /* SignalMessaging.framework */; };
|
||||||
|
C3C3CF8924D8EED300E1CCE7 /* TextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3C3CF8824D8EED300E1CCE7 /* TextView.swift */; };
|
||||||
C3DAB3242480CB2B00725F25 /* SRCopyableLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3DAB3232480CB2A00725F25 /* SRCopyableLabel.swift */; };
|
C3DAB3242480CB2B00725F25 /* SRCopyableLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3DAB3232480CB2A00725F25 /* SRCopyableLabel.swift */; };
|
||||||
C3DFFAC623E96F0D0058DAF8 /* Sheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3DFFAC523E96F0D0058DAF8 /* Sheet.swift */; };
|
C3DFFAC623E96F0D0058DAF8 /* Sheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3DFFAC523E96F0D0058DAF8 /* Sheet.swift */; };
|
||||||
C3DFFAC823E970080058DAF8 /* OpenGroupSuggestionSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3DFFAC723E970080058DAF8 /* OpenGroupSuggestionSheet.swift */; };
|
C3DFFAC823E970080058DAF8 /* OpenGroupSuggestionSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3DFFAC723E970080058DAF8 /* OpenGroupSuggestionSheet.swift */; };
|
||||||
|
@ -1373,6 +1374,7 @@
|
||||||
C3638C0424C7F0B500AF29BC /* LK002RemoveFriendRequests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LK002RemoveFriendRequests.swift; sourceTree = "<group>"; };
|
C3638C0424C7F0B500AF29BC /* LK002RemoveFriendRequests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LK002RemoveFriendRequests.swift; sourceTree = "<group>"; };
|
||||||
C369549C24D27A3500CEB4E3 /* MultiDeviceRemovalSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiDeviceRemovalSheet.swift; sourceTree = "<group>"; };
|
C369549C24D27A3500CEB4E3 /* MultiDeviceRemovalSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiDeviceRemovalSheet.swift; sourceTree = "<group>"; };
|
||||||
C3AA6BB824CE8F1B002358B6 /* Migrating Translations from Android.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = "Migrating Translations from Android.md"; sourceTree = "<group>"; };
|
C3AA6BB824CE8F1B002358B6 /* Migrating Translations from Android.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = "Migrating Translations from Android.md"; sourceTree = "<group>"; };
|
||||||
|
C3C3CF8824D8EED300E1CCE7 /* TextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextView.swift; sourceTree = "<group>"; };
|
||||||
C3DAB3232480CB2A00725F25 /* SRCopyableLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SRCopyableLabel.swift; sourceTree = "<group>"; };
|
C3DAB3232480CB2A00725F25 /* SRCopyableLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SRCopyableLabel.swift; sourceTree = "<group>"; };
|
||||||
C3DFFAC523E96F0D0058DAF8 /* Sheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Sheet.swift; sourceTree = "<group>"; };
|
C3DFFAC523E96F0D0058DAF8 /* Sheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Sheet.swift; sourceTree = "<group>"; };
|
||||||
C3DFFAC723E970080058DAF8 /* OpenGroupSuggestionSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenGroupSuggestionSheet.swift; sourceTree = "<group>"; };
|
C3DFFAC723E970080058DAF8 /* OpenGroupSuggestionSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenGroupSuggestionSheet.swift; sourceTree = "<group>"; };
|
||||||
|
@ -2673,6 +2675,7 @@
|
||||||
2400888D239F30A600305217 /* SessionRestorationView.swift */,
|
2400888D239F30A600305217 /* SessionRestorationView.swift */,
|
||||||
B8CCF638239721E20091D419 /* TabBar.swift */,
|
B8CCF638239721E20091D419 /* TabBar.swift */,
|
||||||
B8BB82B423947F2D00BA5194 /* TextField.swift */,
|
B8BB82B423947F2D00BA5194 /* TextField.swift */,
|
||||||
|
C3C3CF8824D8EED300E1CCE7 /* TextView.swift */,
|
||||||
);
|
);
|
||||||
path = Components;
|
path = Components;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@ -3414,6 +3417,7 @@
|
||||||
"${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",
|
||||||
|
@ -3442,6 +3446,7 @@
|
||||||
"${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",
|
||||||
|
@ -3767,6 +3772,7 @@
|
||||||
EF764C351DB67CC5000D9A87 /* UIViewController+Permissions.m in Sources */,
|
EF764C351DB67CC5000D9A87 /* UIViewController+Permissions.m in Sources */,
|
||||||
45CD81EF1DC030E7004C9430 /* SyncPushTokensJob.swift in Sources */,
|
45CD81EF1DC030E7004C9430 /* SyncPushTokensJob.swift in Sources */,
|
||||||
34D2CCE0206939B400CB1A14 /* DebugUIMessagesAssetLoader.m in Sources */,
|
34D2CCE0206939B400CB1A14 /* DebugUIMessagesAssetLoader.m in Sources */,
|
||||||
|
C3C3CF8924D8EED300E1CCE7 /* TextView.swift in Sources */,
|
||||||
4CEB78C92178EBAB00F315D2 /* OWSSessionResetJobRecord.m in Sources */,
|
4CEB78C92178EBAB00F315D2 /* OWSSessionResetJobRecord.m in Sources */,
|
||||||
45794E861E00620000066731 /* CallUIAdapter.swift in Sources */,
|
45794E861E00620000066731 /* CallUIAdapter.swift in Sources */,
|
||||||
340FC8BA204DAC8D007AEB0F /* FingerprintViewScanController.m in Sources */,
|
340FC8BA204DAC8D007AEB0F /* FingerprintViewScanController.m in Sources */,
|
||||||
|
|
57
Signal/src/Loki/Components/TextView.swift
Normal file
57
Signal/src/Loki/Components/TextView.swift
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
import UITextView_Placeholder
|
||||||
|
|
||||||
|
final class TextView : UITextView {
|
||||||
|
private let usesDefaultHeight: Bool
|
||||||
|
private let height: CGFloat
|
||||||
|
private let horizontalInset: CGFloat
|
||||||
|
private let verticalInset: CGFloat
|
||||||
|
|
||||||
|
override var contentSize: CGSize { didSet { centerTextVertically() } }
|
||||||
|
|
||||||
|
init(placeholder: String, usesDefaultHeight: Bool = true, customHeight: CGFloat? = nil, customHorizontalInset: CGFloat? = nil, customVerticalInset: CGFloat? = nil) {
|
||||||
|
self.usesDefaultHeight = usesDefaultHeight
|
||||||
|
self.height = customHeight ?? Values.textFieldHeight
|
||||||
|
self.horizontalInset = customHorizontalInset ?? (isIPhone5OrSmaller ? Values.mediumSpacing : Values.largeSpacing)
|
||||||
|
self.verticalInset = customVerticalInset ?? (isIPhone5OrSmaller ? Values.smallSpacing : Values.largeSpacing)
|
||||||
|
super.init(frame: CGRect.zero, textContainer: nil)
|
||||||
|
self.placeholder = placeholder
|
||||||
|
setUpStyle()
|
||||||
|
}
|
||||||
|
|
||||||
|
override init(frame: CGRect, textContainer: NSTextContainer?) {
|
||||||
|
preconditionFailure("Use init(placeholder:) instead.")
|
||||||
|
}
|
||||||
|
|
||||||
|
required init?(coder: NSCoder) {
|
||||||
|
preconditionFailure("Use init(placeholder:) instead.")
|
||||||
|
}
|
||||||
|
|
||||||
|
private func setUpStyle() {
|
||||||
|
showsHorizontalScrollIndicator = false
|
||||||
|
showsVerticalScrollIndicator = false
|
||||||
|
let placeholder = NSMutableAttributedString(string: self.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
|
||||||
|
textColor = Colors.text
|
||||||
|
font = .systemFont(ofSize: Values.smallFontSize)
|
||||||
|
tintColor = Colors.accent
|
||||||
|
keyboardAppearance = isLightMode ? .light : .dark
|
||||||
|
if usesDefaultHeight {
|
||||||
|
set(.height, to: height)
|
||||||
|
}
|
||||||
|
layer.borderColor = isLightMode ? Colors.text.cgColor : Colors.border.withAlphaComponent(Values.textFieldBorderOpacity).cgColor
|
||||||
|
layer.borderWidth = Values.borderThickness
|
||||||
|
layer.cornerRadius = Values.textFieldCornerRadius
|
||||||
|
let horizontalInset = usesDefaultHeight ? self.horizontalInset : Values.mediumSpacing
|
||||||
|
textContainerInset = UIEdgeInsets(top: 0, leading: horizontalInset, bottom: 0, trailing: horizontalInset)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func centerTextVertically() {
|
||||||
|
let topInset = max(0, (bounds.size.height - contentSize.height * zoomScale) / 2)
|
||||||
|
contentInset = UIEdgeInsets(top: topInset, left: 0, bottom: 0, right: 0)
|
||||||
|
}
|
||||||
|
}
|
|
@ -149,7 +149,7 @@ private final class EnterPublicKeyVC : UIViewController {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// MARK: Components
|
// MARK: Components
|
||||||
private lazy var publicKeyTextField = TextField(placeholder: NSLocalizedString("vc_enter_public_key_text_field_hint", comment: ""))
|
private let publicKeyTextView = TextView(placeholder: NSLocalizedString("vc_enter_public_key_text_field_hint", comment: ""))
|
||||||
|
|
||||||
private lazy var copyButton: Button = {
|
private lazy var copyButton: Button = {
|
||||||
let result = Button(style: .unimportant, size: .medium)
|
let result = Button(style: .unimportant, size: .medium)
|
||||||
|
@ -200,7 +200,7 @@ private final class EnterPublicKeyVC : UIViewController {
|
||||||
nextButtonContainer.pin(.trailing, to: .trailing, of: nextButton, withInset: 80)
|
nextButtonContainer.pin(.trailing, to: .trailing, of: nextButton, withInset: 80)
|
||||||
nextButtonContainer.pin(.bottom, to: .bottom, of: nextButton)
|
nextButtonContainer.pin(.bottom, to: .bottom, of: nextButton)
|
||||||
// Set up stack view
|
// Set up stack view
|
||||||
let stackView = UIStackView(arrangedSubviews: [ publicKeyTextField, UIView.spacer(withHeight: Values.smallSpacing), explanationLabel, UIView.spacer(withHeight: Values.largeSpacing), separator, UIView.spacer(withHeight: Values.largeSpacing), userPublicKeyLabel, UIView.spacer(withHeight: Values.largeSpacing), buttonContainer, UIView.vStretchingSpacer(), nextButtonContainer ])
|
let stackView = UIStackView(arrangedSubviews: [ publicKeyTextView, UIView.spacer(withHeight: Values.smallSpacing), explanationLabel, UIView.spacer(withHeight: Values.largeSpacing), separator, UIView.spacer(withHeight: Values.largeSpacing), userPublicKeyLabel, UIView.spacer(withHeight: Values.largeSpacing), buttonContainer, UIView.vStretchingSpacer(), nextButtonContainer ])
|
||||||
stackView.axis = .vertical
|
stackView.axis = .vertical
|
||||||
stackView.alignment = .fill
|
stackView.alignment = .fill
|
||||||
stackView.layoutMargins = UIEdgeInsets(top: Values.largeSpacing, left: Values.largeSpacing, bottom: Values.largeSpacing, right: Values.largeSpacing)
|
stackView.layoutMargins = UIEdgeInsets(top: Values.largeSpacing, left: Values.largeSpacing, bottom: Values.largeSpacing, right: Values.largeSpacing)
|
||||||
|
@ -220,7 +220,7 @@ private final class EnterPublicKeyVC : UIViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc private func dismissKeyboard() {
|
@objc private func dismissKeyboard() {
|
||||||
publicKeyTextField.resignFirstResponder()
|
publicKeyTextView.resignFirstResponder()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc private func enableCopyButton() {
|
@objc private func enableCopyButton() {
|
||||||
|
@ -246,7 +246,7 @@ private final class EnterPublicKeyVC : UIViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc private func startNewPrivateChatIfPossible() {
|
@objc private func startNewPrivateChatIfPossible() {
|
||||||
let hexEncodedPublicKey = publicKeyTextField.text?.trimmingCharacters(in: .whitespaces) ?? ""
|
let hexEncodedPublicKey = publicKeyTextView.text?.trimmingCharacters(in: .whitespaces) ?? ""
|
||||||
newPrivateChatVC.startNewPrivateChatIfPossible(with: hexEncodedPublicKey)
|
newPrivateChatVC.startNewPrivateChatIfPossible(with: hexEncodedPublicKey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue