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 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> {
|
||||
var shadowLightColor: UIColor.VDSColor = .backgroundPrimaryDark { didSet { updateView() }}
|
||||
var shadowDarkColor: UIColor.VDSColor = .backgroundPrimaryLight { didSet { updateView() }}
|
||||
@ -110,26 +66,21 @@ class DropShadowViewController: BaseViewController<View> {
|
||||
super.viewDidLoad()
|
||||
|
||||
wrappedHelper = UIView.makeWrappedView(for: component, isTrailing: false)
|
||||
contentTopView.addSubview(wrappedHelper.view)
|
||||
contentTopView.addSubview(secondView)
|
||||
contentTopView.addSubview(thirdView)
|
||||
contentTopView.addSubview(wrappedHelper.view)
|
||||
|
||||
component.widthAnchor.constraint(equalToConstant: viewSize).isActive = true
|
||||
component.heightAnchor.constraint(equalToConstant: viewSize).isActive = true
|
||||
|
||||
secondView.widthAnchor.constraint(equalToConstant: viewSize).isActive = true
|
||||
secondView.heightAnchor.constraint(equalToConstant: viewSize).isActive = true
|
||||
component.width(viewSize).height(viewSize)
|
||||
secondView.width(viewSize).height(viewSize)
|
||||
thirdView.width(viewSize).height(viewSize)
|
||||
|
||||
thirdView.widthAnchor.constraint(equalToConstant: viewSize).isActive = true
|
||||
thirdView.heightAnchor.constraint(equalToConstant: viewSize).isActive = true
|
||||
|
||||
wrappedHelper.view.pinTop().pinLeading()
|
||||
secondView.pinTop()
|
||||
thirdView.pinLeading().pinBottom()
|
||||
|
||||
secondView.trailingAnchor.constraint(lessThanOrEqualTo: contentTopView.trailingAnchor).isActive = true
|
||||
secondView.bottomAnchor.constraint(lessThanOrEqualTo: contentTopView.bottomAnchor).isActive = true
|
||||
thirdView.trailingAnchor.constraint(lessThanOrEqualTo: contentTopView.trailingAnchor).isActive = true
|
||||
secondView.pinTrailingLessThanOrEqualTo(contentTopView.trailingAnchor)
|
||||
secondView.pinBottomLessThanOrEqualTo(contentTopView.bottomAnchor)
|
||||
thirdView.pinTrailingLessThanOrEqualTo(contentTopView.trailingAnchor)
|
||||
|
||||
spacings.append(thirdView.topAnchor.constraint(equalTo: wrappedHelper.view.bottomAnchor))
|
||||
spacings.append(secondView.leadingAnchor.constraint(equalTo: wrappedHelper.view.trailingAnchor))
|
||||
@ -234,7 +185,6 @@ class DropShadowViewController: BaseViewController<View> {
|
||||
|
||||
secondView.backgroundColor = .red
|
||||
thirdView.backgroundColor = .purple
|
||||
view.bringSubviewToFront(wrappedHelper.view)
|
||||
component.layer.cornerRadius = CGFloat(viewRadiusRange.value)
|
||||
component.layer.masksToBounds = false
|
||||
component.backgroundColor = viewColor
|
||||
|
||||
Loading…
Reference in New Issue
Block a user