latest state of text view
This commit is contained in:
parent
19f912512b
commit
8bb6a7fb1d
@ -19,9 +19,8 @@ import UIKit
|
|||||||
private var initialSetupPerformed = false
|
private var initialSetupPerformed = false
|
||||||
|
|
||||||
/// If true then text textView is currently displaying the stored placeholder text as there is not content to display.
|
/// If true then text textView is currently displaying the stored placeholder text as there is not content to display.
|
||||||
public var isShowingPlaceholder: Bool {
|
public var isShowingPlaceholder: Bool = false {
|
||||||
get { return textViewModel?.showsPlaceholder ?? false }
|
didSet { textViewModel?.showsPlaceholder = isShowingPlaceholder }
|
||||||
set { textViewModel?.showsPlaceholder = newValue }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set to true to hide the blinking textField cursor.
|
/// Set to true to hide the blinking textField cursor.
|
||||||
@ -183,6 +182,7 @@ import UIKit
|
|||||||
insetsLayoutMarginsFromSafeArea = false
|
insetsLayoutMarginsFromSafeArea = false
|
||||||
showsVerticalScrollIndicator = false
|
showsVerticalScrollIndicator = false
|
||||||
showsHorizontalScrollIndicator = false
|
showsHorizontalScrollIndicator = false
|
||||||
|
isSecureTextEntry = false
|
||||||
textContainerInset = UIEdgeInsets(top: Padding.Three, left: Padding.Three, bottom: Padding.Three, right: Padding.Three)
|
textContainerInset = UIEdgeInsets(top: Padding.Three, left: Padding.Three, bottom: Padding.Three, right: Padding.Three)
|
||||||
backgroundColor = .mvmWhite
|
backgroundColor = .mvmWhite
|
||||||
clipsToBounds = true
|
clipsToBounds = true
|
||||||
@ -219,12 +219,13 @@ import UIKit
|
|||||||
bottomPath.removeAllPoints()
|
bottomPath.removeAllPoints()
|
||||||
|
|
||||||
if !hideBorders {
|
if !hideBorders {
|
||||||
// Brings the other half of the line inside the view to prevent cropping.
|
// Brings the other half of the line inside the view to prevent line cropping.
|
||||||
let origin = bounds.origin
|
let origin = bounds.origin
|
||||||
let size = frame.size
|
let size = frame.size
|
||||||
let insetLean: CGFloat = 0.5
|
let insetLean: CGFloat = 0.5
|
||||||
borderPath.lineWidth = 1
|
borderPath.lineWidth = 1
|
||||||
|
|
||||||
|
// Drawing begins and ends from the bottom left.
|
||||||
borderPath.move(to: CGPoint(x: origin.x + insetLean, y: origin.y + size.height))
|
borderPath.move(to: CGPoint(x: origin.x + insetLean, y: origin.y + size.height))
|
||||||
borderPath.addLine(to: CGPoint(x: origin.x + insetLean, y: origin.y + insetLean))
|
borderPath.addLine(to: CGPoint(x: origin.x + insetLean, y: origin.y + insetLean))
|
||||||
borderPath.addLine(to: CGPoint(x: origin.x + size.width - insetLean, y: origin.y + insetLean))
|
borderPath.addLine(to: CGPoint(x: origin.x + size.width - insetLean, y: origin.y + insetLean))
|
||||||
@ -284,7 +285,7 @@ import UIKit
|
|||||||
hideBorders = textViewModel?.hideBorders ?? false
|
hideBorders = textViewModel?.hideBorders ?? false
|
||||||
borderStrokeColor = .mvmCoolGray3
|
borderStrokeColor = .mvmCoolGray3
|
||||||
bottomStrokeColor = .mvmBlack
|
bottomStrokeColor = .mvmBlack
|
||||||
textColor = textViewModel?.enabledTextColor.uiColor
|
textColor = isShowingPlaceholder ? textViewModel?.placeholderTextColor.uiColor : textViewModel?.enabledTextColor.uiColor
|
||||||
}
|
}
|
||||||
|
|
||||||
open func errorUI() {
|
open func errorUI() {
|
||||||
@ -388,8 +389,8 @@ import UIKit
|
|||||||
|
|
||||||
@objc public func textViewDidBeginEditing(_ textView: UITextView) {
|
@objc public func textViewDidBeginEditing(_ textView: UITextView) {
|
||||||
|
|
||||||
isSelected = true
|
|
||||||
setTextAppearance()
|
setTextAppearance()
|
||||||
|
isSelected = true
|
||||||
proprietorTextDelegate?.textViewDidBeginEditing?(textView)
|
proprietorTextDelegate?.textViewDidBeginEditing?(textView)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,8 +412,8 @@ import UIKit
|
|||||||
|
|
||||||
@objc public func textViewDidEndEditing(_ textView: UITextView) {
|
@objc public func textViewDidEndEditing(_ textView: UITextView) {
|
||||||
|
|
||||||
isSelected = false
|
|
||||||
setPlaceholderIfAvailable()
|
setPlaceholderIfAvailable()
|
||||||
|
isSelected = false
|
||||||
proprietorTextDelegate?.textViewDidEndEditing?(textView)
|
proprietorTextDelegate?.textViewDidEndEditing?(textView)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -447,6 +448,17 @@ extension TextView: MoleculeViewProtocol {
|
|||||||
accessibilityLabel = accessibilityText
|
accessibilityLabel = accessibilityText
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch model.type {
|
||||||
|
case .secure, .password:
|
||||||
|
isSecureTextEntry = true
|
||||||
|
case .number:
|
||||||
|
keyboardType = .numberPad
|
||||||
|
case .email:
|
||||||
|
keyboardType = .emailAddress
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
font = model.fontStyle.getFont()
|
font = model.fontStyle.getFont()
|
||||||
setPlaceholderIfAvailable()
|
setPlaceholderIfAvailable()
|
||||||
|
|
||||||
|
|||||||
@ -40,6 +40,7 @@ open class TextViewModel: TextEntryFieldModel {
|
|||||||
case height
|
case height
|
||||||
case hideBorders
|
case hideBorders
|
||||||
case placeholderFontStyle
|
case placeholderFontStyle
|
||||||
|
case placeholderTextColor
|
||||||
case isEditable = "editable"
|
case isEditable = "editable"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,6 +56,10 @@ open class TextViewModel: TextEntryFieldModel {
|
|||||||
self.placeholderFontStyle = placeholderFontStyle
|
self.placeholderFontStyle = placeholderFontStyle
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let placeholderTextColor = try typeContainer.decodeIfPresent(Color.self, forKey: .placeholderTextColor) {
|
||||||
|
self.placeholderTextColor = placeholderTextColor
|
||||||
|
}
|
||||||
|
|
||||||
if let textAlignment = try typeContainer.decodeIfPresent(NSTextAlignment.self, forKey: .textAlignment) {
|
if let textAlignment = try typeContainer.decodeIfPresent(NSTextAlignment.self, forKey: .textAlignment) {
|
||||||
self.textAlignment = textAlignment
|
self.textAlignment = textAlignment
|
||||||
}
|
}
|
||||||
@ -83,6 +88,7 @@ open class TextViewModel: TextEntryFieldModel {
|
|||||||
try container.encodeIfPresent(hideBorders, forKey: .hideBorders)
|
try container.encodeIfPresent(hideBorders, forKey: .hideBorders)
|
||||||
try container.encode(text, forKey: .text)
|
try container.encode(text, forKey: .text)
|
||||||
try container.encode(placeholderFontStyle, forKey: .placeholderFontStyle)
|
try container.encode(placeholderFontStyle, forKey: .placeholderFontStyle)
|
||||||
|
try container.encode(placeholderTextColor, forKey: .placeholderTextColor)
|
||||||
try container.encode(textAlignment, forKey: .textAlignment)
|
try container.encode(textAlignment, forKey: .textAlignment)
|
||||||
try container.encode(isEditable, forKey: .isEditable)
|
try container.encode(isEditable, forKey: .isEditable)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user