From 815e074ae5b099eb5d1b0ec7d1427a9ccb578146 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 15 Jun 2023 10:27:27 -0500 Subject: [PATCH] updated dropshadow Signed-off-by: Matt Bruce --- .../DropShawdowViewController.swift | 64 ++----------------- 1 file changed, 7 insertions(+), 57 deletions(-) diff --git a/VDSSample/ViewControllers/DropShawdowViewController.swift b/VDSSample/ViewControllers/DropShawdowViewController.swift index f4a71d1..13daff4 100644 --- a/VDSSample/ViewControllers/DropShawdowViewController.swift +++ b/VDSSample/ViewControllers/DropShawdowViewController.swift @@ -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 { var shadowLightColor: UIColor.VDSColor = .backgroundPrimaryDark { didSet { updateView() }} var shadowDarkColor: UIColor.VDSColor = .backgroundPrimaryLight { didSet { updateView() }} @@ -110,26 +66,21 @@ class DropShadowViewController: BaseViewController { 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 { secondView.backgroundColor = .red thirdView.backgroundColor = .purple - view.bringSubviewToFront(wrappedHelper.view) component.layer.cornerRadius = CGFloat(viewRadiusRange.value) component.layer.masksToBounds = false component.backgroundColor = viewColor