updated dropshadow
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
200203ade7
commit
815e074ae5
@ -11,50 +11,6 @@ import VDS
|
|||||||
import VDSColorTokens
|
import VDSColorTokens
|
||||||
import Combine
|
import Combine
|
||||||
|
|
||||||
class Slider: Control, UITextFieldDelegate {
|
|
||||||
var textField = NumericField().with { $0.translatesAutoresizingMaskIntoConstraints = false }
|
|
||||||
var range = UISlider().with { $0.translatesAutoresizingMaskIntoConstraints = false }
|
|
||||||
var maximumValue: Float = 0.0 { didSet { range.maximumValue = maximumValue }}
|
|
||||||
var minimumValue: Float = 0.0 { didSet { range.minimumValue = minimumValue }}
|
|
||||||
var value: Float = 0.0 { didSet { range.value = value; setNeedsUpdate() }}
|
|
||||||
override func setup() {
|
|
||||||
addSubview(textField)
|
|
||||||
addSubview(range)
|
|
||||||
textField.delegate = self
|
|
||||||
textField.pinTop()
|
|
||||||
textField.pinBottom()
|
|
||||||
textField.pinLeading()
|
|
||||||
textField.heightAnchor.constraint(equalToConstant: 44).isActive = true
|
|
||||||
textField.widthAnchor.constraint(equalToConstant: 75).isActive = true
|
|
||||||
textField.pinTrailing(range.leadingAnchor, 10)
|
|
||||||
range.pinTop()
|
|
||||||
range.pinBottom()
|
|
||||||
range.pinTrailing()
|
|
||||||
|
|
||||||
range.thumbTintColor = .systemBlue
|
|
||||||
range.publisher(for: .valueChanged).sink { [weak self] slider in
|
|
||||||
self?.valueChanged(newValue: slider.value)
|
|
||||||
}.store(in: &subscribers)
|
|
||||||
}
|
|
||||||
|
|
||||||
override func updateView() {
|
|
||||||
textField.text = String(format: "%.2f", value)
|
|
||||||
}
|
|
||||||
|
|
||||||
private func valueChanged(newValue: Float) {
|
|
||||||
value = newValue
|
|
||||||
sendActions(for: .valueChanged)
|
|
||||||
}
|
|
||||||
|
|
||||||
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
|
||||||
textField.resignFirstResponder()
|
|
||||||
if let text = textField.text, let n = NumberFormatter().number(from: text) {
|
|
||||||
valueChanged(newValue: n.floatValue)
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class DropShadowViewController: BaseViewController<View> {
|
class DropShadowViewController: BaseViewController<View> {
|
||||||
var shadowLightColor: UIColor.VDSColor = .backgroundPrimaryDark { didSet { updateView() }}
|
var shadowLightColor: UIColor.VDSColor = .backgroundPrimaryDark { didSet { updateView() }}
|
||||||
var shadowDarkColor: UIColor.VDSColor = .backgroundPrimaryLight { didSet { updateView() }}
|
var shadowDarkColor: UIColor.VDSColor = .backgroundPrimaryLight { didSet { updateView() }}
|
||||||
@ -110,26 +66,21 @@ class DropShadowViewController: BaseViewController<View> {
|
|||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
wrappedHelper = UIView.makeWrappedView(for: component, isTrailing: false)
|
wrappedHelper = UIView.makeWrappedView(for: component, isTrailing: false)
|
||||||
contentTopView.addSubview(wrappedHelper.view)
|
|
||||||
contentTopView.addSubview(secondView)
|
contentTopView.addSubview(secondView)
|
||||||
contentTopView.addSubview(thirdView)
|
contentTopView.addSubview(thirdView)
|
||||||
|
contentTopView.addSubview(wrappedHelper.view)
|
||||||
|
|
||||||
component.widthAnchor.constraint(equalToConstant: viewSize).isActive = true
|
component.width(viewSize).height(viewSize)
|
||||||
component.heightAnchor.constraint(equalToConstant: viewSize).isActive = true
|
secondView.width(viewSize).height(viewSize)
|
||||||
|
thirdView.width(viewSize).height(viewSize)
|
||||||
secondView.widthAnchor.constraint(equalToConstant: viewSize).isActive = true
|
|
||||||
secondView.heightAnchor.constraint(equalToConstant: viewSize).isActive = true
|
|
||||||
|
|
||||||
thirdView.widthAnchor.constraint(equalToConstant: viewSize).isActive = true
|
|
||||||
thirdView.heightAnchor.constraint(equalToConstant: viewSize).isActive = true
|
|
||||||
|
|
||||||
wrappedHelper.view.pinTop().pinLeading()
|
wrappedHelper.view.pinTop().pinLeading()
|
||||||
secondView.pinTop()
|
secondView.pinTop()
|
||||||
thirdView.pinLeading().pinBottom()
|
thirdView.pinLeading().pinBottom()
|
||||||
|
|
||||||
secondView.trailingAnchor.constraint(lessThanOrEqualTo: contentTopView.trailingAnchor).isActive = true
|
secondView.pinTrailingLessThanOrEqualTo(contentTopView.trailingAnchor)
|
||||||
secondView.bottomAnchor.constraint(lessThanOrEqualTo: contentTopView.bottomAnchor).isActive = true
|
secondView.pinBottomLessThanOrEqualTo(contentTopView.bottomAnchor)
|
||||||
thirdView.trailingAnchor.constraint(lessThanOrEqualTo: contentTopView.trailingAnchor).isActive = true
|
thirdView.pinTrailingLessThanOrEqualTo(contentTopView.trailingAnchor)
|
||||||
|
|
||||||
spacings.append(thirdView.topAnchor.constraint(equalTo: wrappedHelper.view.bottomAnchor))
|
spacings.append(thirdView.topAnchor.constraint(equalTo: wrappedHelper.view.bottomAnchor))
|
||||||
spacings.append(secondView.leadingAnchor.constraint(equalTo: wrappedHelper.view.trailingAnchor))
|
spacings.append(secondView.leadingAnchor.constraint(equalTo: wrappedHelper.view.trailingAnchor))
|
||||||
@ -234,7 +185,6 @@ class DropShadowViewController: BaseViewController<View> {
|
|||||||
|
|
||||||
secondView.backgroundColor = .red
|
secondView.backgroundColor = .red
|
||||||
thirdView.backgroundColor = .purple
|
thirdView.backgroundColor = .purple
|
||||||
view.bringSubviewToFront(wrappedHelper.view)
|
|
||||||
component.layer.cornerRadius = CGFloat(viewRadiusRange.value)
|
component.layer.cornerRadius = CGFloat(viewRadiusRange.value)
|
||||||
component.layer.masksToBounds = false
|
component.layer.masksToBounds = false
|
||||||
component.backgroundColor = viewColor
|
component.backgroundColor = viewColor
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user