ok.
This commit is contained in:
parent
9a578fc6b1
commit
4a5fd4f539
@ -23,7 +23,15 @@ import UIKit
|
|||||||
|
|
||||||
private var borderStrokeColor: UIColor = UIColor.mfSilver()
|
private var borderStrokeColor: UIColor = UIColor.mfSilver()
|
||||||
private var borderPath: UIBezierPath = UIBezierPath()
|
private var borderPath: UIBezierPath = UIBezierPath()
|
||||||
public var bottomBar: UIView?
|
|
||||||
|
public var bottomBar: CAShapeLayer = {
|
||||||
|
let layer = CAShapeLayer()
|
||||||
|
layer.backgroundColor = UIColor.black.cgColor
|
||||||
|
layer.drawsAsynchronously = true
|
||||||
|
layer.anchorPoint = CGPoint(x: 0.5, y: 1.0);
|
||||||
|
|
||||||
|
return layer
|
||||||
|
}()
|
||||||
|
|
||||||
var delegateObject: MVMCoreUIDelegateObject?
|
var delegateObject: MVMCoreUIDelegateObject?
|
||||||
|
|
||||||
@ -181,6 +189,8 @@ import UIKit
|
|||||||
feedbackLabelTrailing?.isActive = true
|
feedbackLabelTrailing?.isActive = true
|
||||||
layoutMarginsGuide.bottomAnchor.constraint(equalTo: feedbackLabel.bottomAnchor).isActive = true
|
layoutMarginsGuide.bottomAnchor.constraint(equalTo: feedbackLabel.bottomAnchor).isActive = true
|
||||||
|
|
||||||
|
fieldContainer.layer.addSublayer(bottomBar)
|
||||||
|
|
||||||
setNeedsLayout()
|
setNeedsLayout()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,21 +204,7 @@ import UIKit
|
|||||||
|
|
||||||
/// Configuration for the field container view.
|
/// Configuration for the field container view.
|
||||||
private func setupFieldContainer(_ parentView: UIView) {
|
private func setupFieldContainer(_ parentView: UIView) {
|
||||||
|
|
||||||
setupFieldContainerContent(parentView)
|
setupFieldContainerContent(parentView)
|
||||||
|
|
||||||
let bottomBar = UIView(frame: .zero)
|
|
||||||
self.bottomBar = bottomBar
|
|
||||||
bottomBar.translatesAutoresizingMaskIntoConstraints = false
|
|
||||||
bottomBar.backgroundColor = .black
|
|
||||||
|
|
||||||
parentView.addSubview(bottomBar)
|
|
||||||
|
|
||||||
bottomBarHeightConstraint = bottomBar.heightAnchor.constraint(equalToConstant: 1)
|
|
||||||
bottomBarHeightConstraint?.isActive = true
|
|
||||||
bottomBar.leadingAnchor.constraint(equalTo: parentView.leadingAnchor).isActive = true
|
|
||||||
parentView.trailingAnchor.constraint(equalTo: bottomBar.trailingAnchor).isActive = true
|
|
||||||
parentView.bottomAnchor.constraint(equalTo: bottomBar.bottomAnchor).isActive = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func updateView(_ size: CGFloat) {
|
open override func updateView(_ size: CGFloat) {
|
||||||
@ -220,6 +216,14 @@ import UIKit
|
|||||||
refreshUI()
|
refreshUI()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open override func layoutSubviews() {
|
||||||
|
super.layoutSubviews()
|
||||||
|
|
||||||
|
if let fieldHeight = fieldContainer?.bounds.height {
|
||||||
|
bottomBar.frame = CGRect(x: 0, y: fieldHeight, width: fieldHeight, height: 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Drawing
|
// MARK: - Drawing
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -233,7 +237,6 @@ import UIKit
|
|||||||
|
|
||||||
// Brings the other half of the line inside the view to prevent thinness from cropping.
|
// Brings the other half of the line inside the view to prevent thinness from cropping.
|
||||||
let insetLean: CGFloat = 0.5
|
let insetLean: CGFloat = 0.5
|
||||||
|
|
||||||
borderPath.lineWidth = 1
|
borderPath.lineWidth = 1
|
||||||
|
|
||||||
borderPath.move(to: CGPoint(x: frame.origin.x + insetLean, y: frame.origin.y + frame.size.height))
|
borderPath.move(to: CGPoint(x: frame.origin.x + insetLean, y: frame.origin.y + frame.size.height))
|
||||||
@ -246,6 +249,19 @@ import UIKit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func resizeBottomBar(from: CGFloat, to: CGFloat, duration: CFTimeInterval) {
|
||||||
|
|
||||||
|
let bottomBarHeight = CABasicAnimation(keyPath: "bounds.size.height")
|
||||||
|
bottomBarHeight.fromValue = from
|
||||||
|
bottomBarHeight.toValue = to
|
||||||
|
bottomBarHeight.duration = 0.1
|
||||||
|
bottomBarHeight.isRemovedOnCompletion = false
|
||||||
|
bottomBar.add(bottomBarHeight, forKey: "bottomBarHeight")
|
||||||
|
if let fieldBounds = fieldContainer?.bounds {
|
||||||
|
bottomBar.frame = CGRect(x: 0, y: fieldBounds.height, width: fieldBounds.width, height: to)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Constraint Methods
|
// MARK: - Constraint Methods
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -283,7 +299,7 @@ import UIKit
|
|||||||
hideBorder = false
|
hideBorder = false
|
||||||
showErrorMessage = false
|
showErrorMessage = false
|
||||||
borderStrokeColor = .mfSilver()
|
borderStrokeColor = .mfSilver()
|
||||||
bottomBar?.backgroundColor = .black
|
bottomBar.backgroundColor = UIColor.black.cgColor
|
||||||
descriptionLabel?.textColor = .mfBattleshipGrey()
|
descriptionLabel?.textColor = .mfBattleshipGrey()
|
||||||
|
|
||||||
refreshUI()
|
refreshUI()
|
||||||
@ -295,13 +311,15 @@ import UIKit
|
|||||||
hideBorder = false
|
hideBorder = false
|
||||||
bottomBarHeightConstraint?.constant = 4
|
bottomBarHeightConstraint?.constant = 4
|
||||||
borderStrokeColor = .mfPumpkin()
|
borderStrokeColor = .mfPumpkin()
|
||||||
bottomBar?.backgroundColor = .mfPumpkin()
|
bottomBar.backgroundColor = UIColor.mfPumpkin().cgColor
|
||||||
|
|
||||||
if showError {
|
if showError {
|
||||||
showErrorMessage = true
|
showErrorMessage = true
|
||||||
feedback = errorMessage
|
feedback = errorMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resizeBottomBar(from: 1, to: 4, duration: 5)
|
||||||
|
|
||||||
refreshUI()
|
refreshUI()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,7 +328,7 @@ import UIKit
|
|||||||
isUserInteractionEnabled = false
|
isUserInteractionEnabled = false
|
||||||
bottomBarHeightConstraint?.constant = 1
|
bottomBarHeightConstraint?.constant = 1
|
||||||
hideBorder = true
|
hideBorder = true
|
||||||
bottomBar?.backgroundColor = .clear
|
bottomBar.backgroundColor = UIColor.clear.cgColor
|
||||||
|
|
||||||
refreshUI()
|
refreshUI()
|
||||||
}
|
}
|
||||||
@ -321,7 +339,7 @@ import UIKit
|
|||||||
bottomBarHeightConstraint?.constant = 1
|
bottomBarHeightConstraint?.constant = 1
|
||||||
hideBorder = false
|
hideBorder = false
|
||||||
borderStrokeColor = .black
|
borderStrokeColor = .black
|
||||||
bottomBar?.backgroundColor = .black
|
bottomBar.backgroundColor = UIColor.black.cgColor
|
||||||
|
|
||||||
refreshUI()
|
refreshUI()
|
||||||
}
|
}
|
||||||
@ -333,7 +351,7 @@ import UIKit
|
|||||||
hideBorder = false
|
hideBorder = false
|
||||||
feedback = nil
|
feedback = nil
|
||||||
descriptionLabel?.textColor = self.isEnabled ? UIColor.mfBattleshipGrey() : UIColor.mfSilver()
|
descriptionLabel?.textColor = self.isEnabled ? UIColor.mfBattleshipGrey() : UIColor.mfSilver()
|
||||||
bottomBar?.backgroundColor = self.isEnabled ? (self.showErrorMessage ? UIColor.mfPumpkin() : .black) : UIColor.mfSilver()
|
bottomBar.backgroundColor = self.isEnabled ? (self.showErrorMessage ? UIColor.mfPumpkin().cgColor : UIColor.black.cgColor) : UIColor.mfSilver().cgColor
|
||||||
|
|
||||||
refreshUI()
|
refreshUI()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -192,7 +192,7 @@ import UIKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objc func dismissTextFieldResponder(_ sender: Any?) {
|
@objc func dismissTextFieldResponder(_ sender: Any?) {
|
||||||
|
originalAppearance()
|
||||||
textField?.resignFirstResponder()
|
textField?.resignFirstResponder()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ import UIKit
|
|||||||
|
|
||||||
if isValid {
|
if isValid {
|
||||||
clearError()
|
clearError()
|
||||||
bottomBar?.backgroundColor = .black
|
bottomBar.backgroundColor = UIColor.black.cgColor
|
||||||
} else if let errMessage = errorMessage {
|
} else if let errMessage = errorMessage {
|
||||||
feedback = errMessage
|
feedback = errMessage
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user