managing hidden border
This commit is contained in:
parent
62678e33cd
commit
19f912512b
@ -35,9 +35,6 @@ import UIKit
|
|||||||
// MARK: - Drawing Properties
|
// MARK: - Drawing Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
/// Total control over the drawn top, bottom, left and right borders.
|
|
||||||
public var disableAllBorders = false
|
|
||||||
|
|
||||||
private(set) var fieldState: FieldState = .original {
|
private(set) var fieldState: FieldState = .original {
|
||||||
didSet (oldState) {
|
didSet (oldState) {
|
||||||
// Will not update if new state is the same as old.
|
// Will not update if new state is the same as old.
|
||||||
@ -221,7 +218,7 @@ import UIKit
|
|||||||
borderPath.removeAllPoints()
|
borderPath.removeAllPoints()
|
||||||
bottomPath.removeAllPoints()
|
bottomPath.removeAllPoints()
|
||||||
|
|
||||||
if !disableAllBorders && !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 cropping.
|
||||||
let origin = bounds.origin
|
let origin = bounds.origin
|
||||||
let size = frame.size
|
let size = frame.size
|
||||||
@ -284,7 +281,7 @@ import UIKit
|
|||||||
|
|
||||||
isEditable = textViewModel?.isEditable ?? true
|
isEditable = textViewModel?.isEditable ?? true
|
||||||
isUserInteractionEnabled = true
|
isUserInteractionEnabled = true
|
||||||
hideBorders = false
|
hideBorders = textViewModel?.hideBorders ?? false
|
||||||
borderStrokeColor = .mvmCoolGray3
|
borderStrokeColor = .mvmCoolGray3
|
||||||
bottomStrokeColor = .mvmBlack
|
bottomStrokeColor = .mvmBlack
|
||||||
textColor = textViewModel?.enabledTextColor.uiColor
|
textColor = textViewModel?.enabledTextColor.uiColor
|
||||||
@ -294,7 +291,7 @@ import UIKit
|
|||||||
|
|
||||||
isEditable = textViewModel?.isEditable ?? true
|
isEditable = textViewModel?.isEditable ?? true
|
||||||
isUserInteractionEnabled = true
|
isUserInteractionEnabled = true
|
||||||
hideBorders = false
|
hideBorders = textViewModel?.hideBorders ?? false
|
||||||
borderStrokeColor = .mvmOrange
|
borderStrokeColor = .mvmOrange
|
||||||
bottomStrokeColor = .mvmOrange
|
bottomStrokeColor = .mvmOrange
|
||||||
textColor = textViewModel?.enabledTextColor.uiColor
|
textColor = textViewModel?.enabledTextColor.uiColor
|
||||||
@ -304,7 +301,7 @@ import UIKit
|
|||||||
|
|
||||||
isEditable = textViewModel?.isEditable ?? true
|
isEditable = textViewModel?.isEditable ?? true
|
||||||
isUserInteractionEnabled = true
|
isUserInteractionEnabled = true
|
||||||
hideBorders = false
|
hideBorders = textViewModel?.hideBorders ?? false
|
||||||
borderStrokeColor = .mvmBlack
|
borderStrokeColor = .mvmBlack
|
||||||
bottomStrokeColor = .mvmOrange
|
bottomStrokeColor = .mvmOrange
|
||||||
textColor = textViewModel?.enabledTextColor.uiColor
|
textColor = textViewModel?.enabledTextColor.uiColor
|
||||||
@ -314,7 +311,7 @@ import UIKit
|
|||||||
|
|
||||||
isEditable = textViewModel?.isEditable ?? true
|
isEditable = textViewModel?.isEditable ?? true
|
||||||
isUserInteractionEnabled = true
|
isUserInteractionEnabled = true
|
||||||
hideBorders = false
|
hideBorders = textViewModel?.hideBorders ?? false
|
||||||
borderStrokeColor = .mvmBlack
|
borderStrokeColor = .mvmBlack
|
||||||
bottomStrokeColor = .mvmBlack
|
bottomStrokeColor = .mvmBlack
|
||||||
textColor = textViewModel?.enabledTextColor.uiColor
|
textColor = textViewModel?.enabledTextColor.uiColor
|
||||||
@ -324,7 +321,7 @@ import UIKit
|
|||||||
|
|
||||||
isEditable = textViewModel?.isEditable ?? false
|
isEditable = textViewModel?.isEditable ?? false
|
||||||
isUserInteractionEnabled = false
|
isUserInteractionEnabled = false
|
||||||
hideBorders = false
|
hideBorders = textViewModel?.hideBorders ?? false
|
||||||
borderStrokeColor = .mvmCoolGray3
|
borderStrokeColor = .mvmCoolGray3
|
||||||
bottomStrokeColor = .mvmCoolGray3
|
bottomStrokeColor = .mvmCoolGray3
|
||||||
textColor = textViewModel?.disabledTextColor.uiColor
|
textColor = textViewModel?.disabledTextColor.uiColor
|
||||||
@ -442,6 +439,7 @@ extension TextView: MoleculeViewProtocol {
|
|||||||
isEditable = model.isEditable
|
isEditable = model.isEditable
|
||||||
textAlignment = model.textAlignment
|
textAlignment = model.textAlignment
|
||||||
textColor = model.enabledTextColor.uiColor
|
textColor = model.enabledTextColor.uiColor
|
||||||
|
hideBorders = model.hideBorders
|
||||||
text = model.text
|
text = model.text
|
||||||
uiTextViewDelegate = delegateObject?.uiTextViewDelegate
|
uiTextViewDelegate = delegateObject?.uiTextViewDelegate
|
||||||
|
|
||||||
|
|||||||
@ -25,6 +25,7 @@ open class TextViewModel: TextEntryFieldModel {
|
|||||||
public var placeholderTextColor: Color = Color(uiColor: .mvmCoolGray3)
|
public var placeholderTextColor: Color = Color(uiColor: .mvmCoolGray3)
|
||||||
public var placeholderFontStyle: Styler.Font = Styler.Font.RegularMicro
|
public var placeholderFontStyle: Styler.Font = Styler.Font.RegularMicro
|
||||||
public var showsPlaceholder: Bool = false
|
public var showsPlaceholder: Bool = false
|
||||||
|
public var hideBorders: Bool = false
|
||||||
public var isEditable: Bool = true
|
public var isEditable: Bool = true
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -37,6 +38,7 @@ open class TextViewModel: TextEntryFieldModel {
|
|||||||
case fontStyle
|
case fontStyle
|
||||||
case textAlignment
|
case textAlignment
|
||||||
case height
|
case height
|
||||||
|
case hideBorders
|
||||||
case placeholderFontStyle
|
case placeholderFontStyle
|
||||||
case isEditable = "editable"
|
case isEditable = "editable"
|
||||||
}
|
}
|
||||||
@ -57,6 +59,10 @@ open class TextViewModel: TextEntryFieldModel {
|
|||||||
self.textAlignment = textAlignment
|
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) {
|
if let isEditable = try typeContainer.decodeIfPresent(Bool.self, forKey: .isEditable) {
|
||||||
self.isEditable = isEditable
|
self.isEditable = isEditable
|
||||||
}
|
}
|
||||||
@ -74,6 +80,7 @@ open class TextViewModel: TextEntryFieldModel {
|
|||||||
try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText)
|
try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText)
|
||||||
try container.encodeIfPresent(fontStyle, forKey: .fontStyle)
|
try container.encodeIfPresent(fontStyle, forKey: .fontStyle)
|
||||||
try container.encodeIfPresent(height, forKey: .height)
|
try container.encodeIfPresent(height, forKey: .height)
|
||||||
|
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(textAlignment, forKey: .textAlignment)
|
try container.encode(textAlignment, forKey: .textAlignment)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user