managing hidden border

This commit is contained in:
Kevin G Christiano 2020-04-29 10:55:10 -04:00
parent 62678e33cd
commit 19f912512b
2 changed files with 14 additions and 9 deletions

View File

@ -35,9 +35,6 @@ import UIKit
// MARK: - Drawing Properties
//--------------------------------------------------
/// Total control over the drawn top, bottom, left and right borders.
public var disableAllBorders = false
private(set) var fieldState: FieldState = .original {
didSet (oldState) {
// Will not update if new state is the same as old.
@ -221,7 +218,7 @@ import UIKit
borderPath.removeAllPoints()
bottomPath.removeAllPoints()
if !disableAllBorders && !hideBorders {
if !hideBorders {
// Brings the other half of the line inside the view to prevent cropping.
let origin = bounds.origin
let size = frame.size
@ -284,7 +281,7 @@ import UIKit
isEditable = textViewModel?.isEditable ?? true
isUserInteractionEnabled = true
hideBorders = false
hideBorders = textViewModel?.hideBorders ?? false
borderStrokeColor = .mvmCoolGray3
bottomStrokeColor = .mvmBlack
textColor = textViewModel?.enabledTextColor.uiColor
@ -294,7 +291,7 @@ import UIKit
isEditable = textViewModel?.isEditable ?? true
isUserInteractionEnabled = true
hideBorders = false
hideBorders = textViewModel?.hideBorders ?? false
borderStrokeColor = .mvmOrange
bottomStrokeColor = .mvmOrange
textColor = textViewModel?.enabledTextColor.uiColor
@ -304,7 +301,7 @@ import UIKit
isEditable = textViewModel?.isEditable ?? true
isUserInteractionEnabled = true
hideBorders = false
hideBorders = textViewModel?.hideBorders ?? false
borderStrokeColor = .mvmBlack
bottomStrokeColor = .mvmOrange
textColor = textViewModel?.enabledTextColor.uiColor
@ -314,7 +311,7 @@ import UIKit
isEditable = textViewModel?.isEditable ?? true
isUserInteractionEnabled = true
hideBorders = false
hideBorders = textViewModel?.hideBorders ?? false
borderStrokeColor = .mvmBlack
bottomStrokeColor = .mvmBlack
textColor = textViewModel?.enabledTextColor.uiColor
@ -324,7 +321,7 @@ import UIKit
isEditable = textViewModel?.isEditable ?? false
isUserInteractionEnabled = false
hideBorders = false
hideBorders = textViewModel?.hideBorders ?? false
borderStrokeColor = .mvmCoolGray3
bottomStrokeColor = .mvmCoolGray3
textColor = textViewModel?.disabledTextColor.uiColor
@ -442,6 +439,7 @@ extension TextView: MoleculeViewProtocol {
isEditable = model.isEditable
textAlignment = model.textAlignment
textColor = model.enabledTextColor.uiColor
hideBorders = model.hideBorders
text = model.text
uiTextViewDelegate = delegateObject?.uiTextViewDelegate

View File

@ -25,6 +25,7 @@ open class TextViewModel: TextEntryFieldModel {
public var placeholderTextColor: Color = Color(uiColor: .mvmCoolGray3)
public var placeholderFontStyle: Styler.Font = Styler.Font.RegularMicro
public var showsPlaceholder: Bool = false
public var hideBorders: Bool = false
public var isEditable: Bool = true
//--------------------------------------------------
@ -37,6 +38,7 @@ open class TextViewModel: TextEntryFieldModel {
case fontStyle
case textAlignment
case height
case hideBorders
case placeholderFontStyle
case isEditable = "editable"
}
@ -57,6 +59,10 @@ open class TextViewModel: TextEntryFieldModel {
self.textAlignment = textAlignment
}
if let hideBorders = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideBorders) {
self.hideBorders = hideBorders
}
if let isEditable = try typeContainer.decodeIfPresent(Bool.self, forKey: .isEditable) {
self.isEditable = isEditable
}
@ -74,6 +80,7 @@ open class TextViewModel: TextEntryFieldModel {
try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText)
try container.encodeIfPresent(fontStyle, forKey: .fontStyle)
try container.encodeIfPresent(height, forKey: .height)
try container.encodeIfPresent(hideBorders, forKey: .hideBorders)
try container.encode(text, forKey: .text)
try container.encode(placeholderFontStyle, forKey: .placeholderFontStyle)
try container.encode(textAlignment, forKey: .textAlignment)