From 19f912512b4ac1310d99f8af601d912e46eba1d2 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 29 Apr 2020 10:55:10 -0400 Subject: [PATCH] managing hidden border --- MVMCoreUI/BaseClasses/TextView.swift | 16 +++++++--------- MVMCoreUI/BaseClasses/TextViewModel.swift | 7 +++++++ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/MVMCoreUI/BaseClasses/TextView.swift b/MVMCoreUI/BaseClasses/TextView.swift index 95781aba..fc8695a1 100644 --- a/MVMCoreUI/BaseClasses/TextView.swift +++ b/MVMCoreUI/BaseClasses/TextView.swift @@ -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 diff --git a/MVMCoreUI/BaseClasses/TextViewModel.swift b/MVMCoreUI/BaseClasses/TextViewModel.swift index e3a8df59..48b14754 100644 --- a/MVMCoreUI/BaseClasses/TextViewModel.swift +++ b/MVMCoreUI/BaseClasses/TextViewModel.swift @@ -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)