ok.
This commit is contained in:
parent
9a578fc6b1
commit
4a5fd4f539
@ -23,7 +23,15 @@ import UIKit
|
||||
|
||||
private var borderStrokeColor: UIColor = UIColor.mfSilver()
|
||||
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?
|
||||
|
||||
@ -181,6 +189,8 @@ import UIKit
|
||||
feedbackLabelTrailing?.isActive = true
|
||||
layoutMarginsGuide.bottomAnchor.constraint(equalTo: feedbackLabel.bottomAnchor).isActive = true
|
||||
|
||||
fieldContainer.layer.addSublayer(bottomBar)
|
||||
|
||||
setNeedsLayout()
|
||||
}
|
||||
|
||||
@ -194,21 +204,7 @@ import UIKit
|
||||
|
||||
/// Configuration for the field container view.
|
||||
private func setupFieldContainer(_ parentView: UIView) {
|
||||
|
||||
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) {
|
||||
@ -220,6 +216,14 @@ import UIKit
|
||||
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
|
||||
//--------------------------------------------------
|
||||
@ -233,7 +237,6 @@ import UIKit
|
||||
|
||||
// Brings the other half of the line inside the view to prevent thinness from cropping.
|
||||
let insetLean: CGFloat = 0.5
|
||||
|
||||
borderPath.lineWidth = 1
|
||||
|
||||
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
|
||||
//--------------------------------------------------
|
||||
@ -283,7 +299,7 @@ import UIKit
|
||||
hideBorder = false
|
||||
showErrorMessage = false
|
||||
borderStrokeColor = .mfSilver()
|
||||
bottomBar?.backgroundColor = .black
|
||||
bottomBar.backgroundColor = UIColor.black.cgColor
|
||||
descriptionLabel?.textColor = .mfBattleshipGrey()
|
||||
|
||||
refreshUI()
|
||||
@ -295,13 +311,15 @@ import UIKit
|
||||
hideBorder = false
|
||||
bottomBarHeightConstraint?.constant = 4
|
||||
borderStrokeColor = .mfPumpkin()
|
||||
bottomBar?.backgroundColor = .mfPumpkin()
|
||||
bottomBar.backgroundColor = UIColor.mfPumpkin().cgColor
|
||||
|
||||
if showError {
|
||||
showErrorMessage = true
|
||||
feedback = errorMessage
|
||||
}
|
||||
|
||||
resizeBottomBar(from: 1, to: 4, duration: 5)
|
||||
|
||||
refreshUI()
|
||||
}
|
||||
|
||||
@ -310,7 +328,7 @@ import UIKit
|
||||
isUserInteractionEnabled = false
|
||||
bottomBarHeightConstraint?.constant = 1
|
||||
hideBorder = true
|
||||
bottomBar?.backgroundColor = .clear
|
||||
bottomBar.backgroundColor = UIColor.clear.cgColor
|
||||
|
||||
refreshUI()
|
||||
}
|
||||
@ -321,7 +339,7 @@ import UIKit
|
||||
bottomBarHeightConstraint?.constant = 1
|
||||
hideBorder = false
|
||||
borderStrokeColor = .black
|
||||
bottomBar?.backgroundColor = .black
|
||||
bottomBar.backgroundColor = UIColor.black.cgColor
|
||||
|
||||
refreshUI()
|
||||
}
|
||||
@ -333,7 +351,7 @@ import UIKit
|
||||
hideBorder = false
|
||||
feedback = nil
|
||||
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()
|
||||
}
|
||||
|
||||
@ -192,7 +192,7 @@ import UIKit
|
||||
}
|
||||
|
||||
@objc func dismissTextFieldResponder(_ sender: Any?) {
|
||||
|
||||
originalAppearance()
|
||||
textField?.resignFirstResponder()
|
||||
}
|
||||
|
||||
@ -228,7 +228,7 @@ import UIKit
|
||||
|
||||
if isValid {
|
||||
clearError()
|
||||
bottomBar?.backgroundColor = .black
|
||||
bottomBar.backgroundColor = UIColor.black.cgColor
|
||||
} else if let errMessage = errorMessage {
|
||||
feedback = errMessage
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user