further developmet of textView.
This commit is contained in:
parent
67b8656d63
commit
5f38596994
@ -38,7 +38,6 @@
|
||||
//--------------------------------------------------
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case moleculeName
|
||||
case placeholder
|
||||
case enabledTextColor
|
||||
case disabledTextColor
|
||||
@ -67,7 +66,6 @@
|
||||
public override func encode(to encoder: Encoder) throws {
|
||||
try super.encode(to: encoder)
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encode(moleculeName, forKey: .moleculeName)
|
||||
try container.encodeIfPresent(placeholder, forKey: .placeholder)
|
||||
try container.encode(enabledTextColor, forKey: .enabledTextColor)
|
||||
try container.encode(disabledTextColor, forKey: .disabledTextColor)
|
||||
|
||||
@ -19,7 +19,10 @@ import UIKit
|
||||
private var initialSetupPerformed = false
|
||||
|
||||
/// If true then text textView is currently displaying the stored placeholder text as there is not content to display.
|
||||
public var isShowingPlaceholder = true
|
||||
public var isShowingPlaceholder: Bool {
|
||||
get { return textViewModel?.showsPlaceholder ?? false }
|
||||
set { textViewModel?.showsPlaceholder = newValue }
|
||||
}
|
||||
|
||||
/// Set to true to hide the blinking textField cursor.
|
||||
public var hideBlinkingCaret = false
|
||||
@ -62,7 +65,6 @@ import UIKit
|
||||
|
||||
private var _isEnabled: Bool = true
|
||||
private var _showError: Bool = false
|
||||
private var _isLocked: Bool = false
|
||||
private var _isSelected: Bool = false
|
||||
|
||||
public var isEnabled: Bool {
|
||||
@ -70,7 +72,6 @@ import UIKit
|
||||
set (enabled) {
|
||||
|
||||
_isEnabled = enabled
|
||||
_isLocked = false
|
||||
_isSelected = false
|
||||
_showError = false
|
||||
|
||||
@ -84,32 +85,17 @@ import UIKit
|
||||
|
||||
_showError = error
|
||||
_isEnabled = true
|
||||
_isLocked = false
|
||||
_isSelected = false
|
||||
|
||||
fieldState = error ? .error : .original
|
||||
}
|
||||
}
|
||||
|
||||
public var isLocked: Bool {
|
||||
get { return _isLocked }
|
||||
set (locked) {
|
||||
|
||||
_isLocked = locked
|
||||
_isEnabled = true
|
||||
_isSelected = false
|
||||
_showError = false
|
||||
|
||||
fieldState = locked ? .locked : .original
|
||||
}
|
||||
}
|
||||
|
||||
public var isSelected: Bool {
|
||||
get { return _isSelected }
|
||||
set (selected) {
|
||||
|
||||
_isSelected = selected
|
||||
_isLocked = false
|
||||
_isEnabled = true
|
||||
|
||||
if _showError {
|
||||
@ -269,7 +255,6 @@ import UIKit
|
||||
case error
|
||||
case selectedError
|
||||
case selected
|
||||
case locked
|
||||
case disabled
|
||||
|
||||
public func setStateUI(for inputField: TextView) {
|
||||
@ -287,9 +272,6 @@ import UIKit
|
||||
case .selected:
|
||||
inputField.selectedUI()
|
||||
|
||||
case .locked:
|
||||
inputField.lockedUI()
|
||||
|
||||
case .disabled:
|
||||
inputField.disabledUI()
|
||||
}
|
||||
@ -300,50 +282,52 @@ import UIKit
|
||||
|
||||
open func originalUI() {
|
||||
|
||||
isEditable = true
|
||||
isEditable = textViewModel?.isEditable ?? true
|
||||
isUserInteractionEnabled = true
|
||||
hideBorders = false
|
||||
borderStrokeColor = .mvmCoolGray3
|
||||
bottomStrokeColor = .mvmBlack
|
||||
textColor = textViewModel?.enabledTextColor.uiColor
|
||||
}
|
||||
|
||||
open func errorUI() {
|
||||
|
||||
isEditable = true
|
||||
isEditable = textViewModel?.isEditable ?? true
|
||||
isUserInteractionEnabled = true
|
||||
hideBorders = false
|
||||
borderStrokeColor = .mvmOrange
|
||||
bottomStrokeColor = .mvmOrange
|
||||
textColor = textViewModel?.enabledTextColor.uiColor
|
||||
}
|
||||
|
||||
open func selectedErrorUI() {
|
||||
|
||||
isEditable = true
|
||||
isEditable = textViewModel?.isEditable ?? true
|
||||
isUserInteractionEnabled = true
|
||||
hideBorders = false
|
||||
borderStrokeColor = .mvmBlack
|
||||
bottomStrokeColor = .mvmOrange
|
||||
textColor = textViewModel?.enabledTextColor.uiColor
|
||||
}
|
||||
|
||||
open func selectedUI() {
|
||||
|
||||
isEditable = true
|
||||
isEditable = textViewModel?.isEditable ?? true
|
||||
isUserInteractionEnabled = true
|
||||
hideBorders = false
|
||||
borderStrokeColor = .mvmBlack
|
||||
bottomStrokeColor = .mvmBlack
|
||||
}
|
||||
|
||||
open func lockedUI() {
|
||||
|
||||
isEditable = false
|
||||
hideBorders = true
|
||||
borderStrokeColor = .clear
|
||||
bottomStrokeColor = .clear
|
||||
textColor = textViewModel?.enabledTextColor.uiColor
|
||||
}
|
||||
|
||||
open func disabledUI() {
|
||||
|
||||
isEditable = false
|
||||
isEditable = textViewModel?.isEditable ?? false
|
||||
isUserInteractionEnabled = false
|
||||
hideBorders = false
|
||||
borderStrokeColor = .mvmCoolGray3
|
||||
bottomStrokeColor = .mvmCoolGray3
|
||||
textColor = textViewModel?.disabledTextColor.uiColor
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -385,7 +369,7 @@ import UIKit
|
||||
isShowingPlaceholder = false
|
||||
text = ""
|
||||
font = textViewModel?.fontStyle.getFont()
|
||||
textColor = textViewModel?.textColor.uiColor
|
||||
textColor = textViewModel?.enabledTextColor.uiColor
|
||||
}
|
||||
|
||||
public func setPlaceholderContentTraits() {
|
||||
@ -457,10 +441,9 @@ extension TextView: MoleculeViewProtocol {
|
||||
|
||||
isEditable = model.isEditable
|
||||
textAlignment = model.textAlignment
|
||||
textColor = model.textColor.uiColor
|
||||
textColor = model.enabledTextColor.uiColor
|
||||
text = model.text
|
||||
uiTextViewDelegate = delegateObject?.uiTextViewDelegate
|
||||
isShowingPlaceholder = model.text?.isEmpty ?? false
|
||||
|
||||
if let accessibilityText = model.accessibilityText {
|
||||
accessibilityLabel = accessibilityText
|
||||
@ -480,5 +463,9 @@ extension TextView: MoleculeViewProtocol {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !model.enabled {
|
||||
isEnabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,13 +19,12 @@ open class TextViewModel: TextEntryFieldModel {
|
||||
}
|
||||
|
||||
public var accessibilityText: String?
|
||||
public var textColor: Color = Color(uiColor: .mvmBlack)
|
||||
public var fontStyle: Styler.Font = Styler.Font.RegularBodySmall
|
||||
public var textAlignment: NSTextAlignment = .left
|
||||
public var height: CGFloat?
|
||||
public var placeholderTextColor: Color = Color(uiColor: .mvmCoolGray3)
|
||||
public var placeholderFontStyle: Styler.Font = Styler.Font.RegularMicro
|
||||
public var showsPlaceholder: Bool = true
|
||||
public var showsPlaceholder: Bool = false
|
||||
public var isEditable: Bool = true
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -33,11 +32,8 @@ open class TextViewModel: TextEntryFieldModel {
|
||||
//--------------------------------------------------
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case moleculeName
|
||||
case backgroundColor
|
||||
case text
|
||||
case accessibilityText
|
||||
case textColor
|
||||
case fontStyle
|
||||
case textAlignment
|
||||
case height
|
||||
@ -61,10 +57,6 @@ open class TextViewModel: TextEntryFieldModel {
|
||||
self.textAlignment = textAlignment
|
||||
}
|
||||
|
||||
if let textColor = try typeContainer.decodeIfPresent(Color.self, forKey: .textColor) {
|
||||
self.textColor = textColor
|
||||
}
|
||||
|
||||
if let isEditable = try typeContainer.decodeIfPresent(Bool.self, forKey: .isEditable) {
|
||||
self.isEditable = isEditable
|
||||
}
|
||||
@ -79,9 +71,7 @@ open class TextViewModel: TextEntryFieldModel {
|
||||
|
||||
public override func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(moleculeName, forKey: .moleculeName)
|
||||
try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText)
|
||||
try container.encodeIfPresent(textColor, forKey: .textColor)
|
||||
try container.encodeIfPresent(fontStyle, forKey: .fontStyle)
|
||||
try container.encodeIfPresent(height, forKey: .height)
|
||||
try container.encode(text, forKey: .text)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user