added drop shadow tester
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
f3acbfe007
commit
8467e3ed13
@ -77,6 +77,7 @@
|
||||
EAB5FEEF2927E28400998C17 /* ButtonGroupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB5FEEE2927E28400998C17 /* ButtonGroupViewController.swift */; };
|
||||
EAB5FEF32928153D00998C17 /* Helper.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB5FEF22928153D00998C17 /* Helper.swift */; };
|
||||
EAC9258029119FC400091998 /* TextLinkViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAC9257F29119FC400091998 /* TextLinkViewController.swift */; };
|
||||
EAD062A32A3913920015965D /* DropShawdowViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAD062A22A3913920015965D /* DropShawdowViewController.swift */; };
|
||||
EAF7F07D2899698800B287F5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EAF7F07B2899698800B287F5 /* Assets.xcassets */; };
|
||||
EAF7F09C2899B92400B287F5 /* CheckboxViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F09B2899B92400B287F5 /* CheckboxViewController.swift */; };
|
||||
EAF7F0CA289DA24F00B287F5 /* ArtifactoryItems.txt in Resources */ = {isa = PBXBuildFile; fileRef = EAF7F0C5289DA24F00B287F5 /* ArtifactoryItems.txt */; };
|
||||
@ -166,6 +167,7 @@
|
||||
EAB5FEEE2927E28400998C17 /* ButtonGroupViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ButtonGroupViewController.swift; sourceTree = "<group>"; };
|
||||
EAB5FEF22928153D00998C17 /* Helper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Helper.swift; sourceTree = "<group>"; };
|
||||
EAC9257F29119FC400091998 /* TextLinkViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextLinkViewController.swift; sourceTree = "<group>"; };
|
||||
EAD062A22A3913920015965D /* DropShawdowViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DropShawdowViewController.swift; sourceTree = "<group>"; };
|
||||
EAF7F07B2899698800B287F5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
EAF7F09B2899B92400B287F5 /* CheckboxViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxViewController.swift; sourceTree = "<group>"; };
|
||||
EAF7F0C5289DA24F00B287F5 /* ArtifactoryItems.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ArtifactoryItems.txt; sourceTree = "<group>"; };
|
||||
@ -292,6 +294,7 @@
|
||||
children = (
|
||||
EA89203E28B66CE2006B9984 /* ScrollViewController */,
|
||||
EA3C3BB228996775000CA526 /* MenuViewController.swift */,
|
||||
EAD062A22A3913920015965D /* DropShawdowViewController.swift */,
|
||||
EAB1D2C828AAAA1D00DAE764 /* BaseViewController.swift */,
|
||||
EA4DB30328DCD25B00103EE3 /* BadgeViewController.swift */,
|
||||
EA81410D2A0ED8DC004F60D2 /* ButtonIconViewController.swift */,
|
||||
@ -484,6 +487,7 @@
|
||||
EAB2376C29E9E74900AABE9A /* TrailingTooltipLabel.swift in Sources */,
|
||||
EAB1D2C928AAAA1D00DAE764 /* BaseViewController.swift in Sources */,
|
||||
EA5E305C295111050082B959 /* TileletViewController.swift in Sources */,
|
||||
EAD062A32A3913920015965D /* DropShawdowViewController.swift in Sources */,
|
||||
EAB5FEF32928153D00998C17 /* Helper.swift in Sources */,
|
||||
EA89204728B66CE2006B9984 /* KeyboardFrameChangeListener.swift in Sources */,
|
||||
EA4DB30428DCD25B00103EE3 /* BadgeViewController.swift in Sources */,
|
||||
@ -651,7 +655,7 @@
|
||||
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 21;
|
||||
CURRENT_PROJECT_VERSION = 22;
|
||||
DEVELOPMENT_TEAM = 59V5935DHZ;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_FILE = VDSSample/Info.plist;
|
||||
@ -683,7 +687,7 @@
|
||||
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 21;
|
||||
CURRENT_PROJECT_VERSION = 22;
|
||||
DEVELOPMENT_TEAM = 59V5935DHZ;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_FILE = VDSSample/Info.plist;
|
||||
|
||||
@ -249,7 +249,7 @@ public class BaseViewController<Component: UIView>: UIViewController, Initable {
|
||||
}
|
||||
|
||||
open func updateView() {
|
||||
print("\(Self.self) updateView()")
|
||||
//print("\(Self.self) updateView()")
|
||||
}
|
||||
|
||||
open func allTextFields() -> [TextField]? { nil }
|
||||
|
||||
190
VDSSample/ViewControllers/DropShawdowViewController.swift
Normal file
190
VDSSample/ViewControllers/DropShawdowViewController.swift
Normal file
@ -0,0 +1,190 @@
|
||||
//
|
||||
// DropShawdowViewController.swift
|
||||
// VDSSample
|
||||
//
|
||||
// Created by Matt Bruce on 6/13/23.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
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.publisher(for: .valueChanged).sink { [weak self] slider in
|
||||
self?.value = slider.value
|
||||
self?.sendActions(for: .valueChanged)
|
||||
}.store(in: &subscribers)
|
||||
}
|
||||
|
||||
override func updateView() {
|
||||
textField.text = String(format: "%.2f", value)
|
||||
}
|
||||
|
||||
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
||||
textField.resignFirstResponder()
|
||||
if let text = textField.text, let n = NumberFormatter().number(from: text) {
|
||||
self.value = n.floatValue
|
||||
print(self.value)
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
class DropShadowViewController: BaseViewController<View> {
|
||||
var shadowLightColor: UIColor.VDSColor = .backgroundPrimaryDark { didSet { updateView() }}
|
||||
var shadowDarkColor: UIColor.VDSColor = .backgroundPrimaryLight { didSet { updateView() }}
|
||||
var viewLightColor: UIColor.VDSColor = .paletteGray65 { didSet { updateView() }}
|
||||
var viewDarkColor: UIColor.VDSColor = .backgroundPrimaryLight { didSet { updateView() }}
|
||||
|
||||
var opacityRange = Slider()
|
||||
var radiusRange = Slider()
|
||||
var offsetXRange = Slider()
|
||||
var offsetYRange = Slider()
|
||||
|
||||
lazy var dropShadowLightColorPickerSelectorView = {
|
||||
PickerSelectorView(title: "",
|
||||
picker: self.picker,
|
||||
items: UIColor.VDSColor.allCases)
|
||||
}()
|
||||
|
||||
lazy var dropShadowDarkColorPickerSelectorView = {
|
||||
PickerSelectorView(title: "",
|
||||
picker: self.picker,
|
||||
items: UIColor.VDSColor.allCases)
|
||||
}()
|
||||
|
||||
lazy var viewLightColorPickerSelectorView = {
|
||||
PickerSelectorView(title: "",
|
||||
picker: self.picker,
|
||||
items: UIColor.VDSColor.allCases)
|
||||
}()
|
||||
|
||||
lazy var viewDarkColorPickerSelectorView = {
|
||||
PickerSelectorView(title: "",
|
||||
picker: self.picker,
|
||||
items: UIColor.VDSColor.allCases)
|
||||
}()
|
||||
|
||||
let spacer: Float = 50
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
component.widthAnchor.constraint(equalToConstant: 100).isActive = true
|
||||
component.heightAnchor.constraint(equalToConstant: 100).isActive = true
|
||||
addContentTopView(view: .makeWrapper(for: component, edgeSpacing: Double(spacer)), edgeSpacing: 0.0)
|
||||
setupPicker()
|
||||
setupModel()
|
||||
updateView()
|
||||
}
|
||||
|
||||
override func setupForm(){
|
||||
super.setupForm()
|
||||
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
||||
addFormRow(label: "View Light", view: viewLightColorPickerSelectorView)
|
||||
addFormRow(label: "View Dark", view: viewDarkColorPickerSelectorView)
|
||||
addFormRow(label: "Shawdow Light", view: dropShadowLightColorPickerSelectorView)
|
||||
addFormRow(label: "Shawdow Dark", view: dropShadowDarkColorPickerSelectorView)
|
||||
|
||||
addFormRow(label: "Opacity", view: opacityRange)
|
||||
addFormRow(label: "Radius (Blur)", view: radiusRange)
|
||||
addFormRow(label: "Width (OffSet X)", view: offsetXRange)
|
||||
addFormRow(label: "Height (Offset Y)", view: offsetYRange)
|
||||
|
||||
opacityRange.maximumValue = 1.0
|
||||
opacityRange.minimumValue = 0.0
|
||||
opacityRange.value = 1.0
|
||||
opacityRange.publisher(for: .valueChanged).sink(receiveValue: { [weak self] slider in
|
||||
self?.updateView()
|
||||
}).store(in: &subscribers)
|
||||
|
||||
radiusRange.maximumValue = 20.0
|
||||
radiusRange.minimumValue = 0.0
|
||||
radiusRange.value = 2.0
|
||||
radiusRange.publisher(for: .valueChanged).sink(receiveValue: { [weak self] slider in
|
||||
self?.updateView()
|
||||
}).store(in: &subscribers)
|
||||
|
||||
offsetXRange.maximumValue = spacer
|
||||
offsetXRange.minimumValue = -spacer
|
||||
offsetXRange.value = 2.0
|
||||
offsetXRange.publisher(for: .valueChanged).sink(receiveValue: { [weak self] slider in
|
||||
self?.updateView()
|
||||
}).store(in: &subscribers)
|
||||
|
||||
offsetYRange.maximumValue = spacer
|
||||
offsetYRange.minimumValue = -spacer
|
||||
offsetYRange.value = 2.0
|
||||
offsetYRange.publisher(for: .valueChanged).sink(receiveValue: { [weak self] slider in
|
||||
self?.updateView()
|
||||
}).store(in: &subscribers)
|
||||
|
||||
|
||||
dropShadowLightColorPickerSelectorView.text = shadowLightColor.rawValue
|
||||
dropShadowDarkColorPickerSelectorView.text = shadowDarkColor.rawValue
|
||||
viewLightColorPickerSelectorView.text = viewLightColor.rawValue
|
||||
viewDarkColorPickerSelectorView.text = viewDarkColor.rawValue
|
||||
}
|
||||
|
||||
func setupModel() {
|
||||
//setup UI
|
||||
surfacePickerSelectorView.text = component.surface.rawValue
|
||||
}
|
||||
|
||||
override func updateView() {
|
||||
let surface = surfacePickerSelectorView.selectedItem
|
||||
let dropshadowColorConfiguration = SurfaceColorConfiguration(shadowLightColor.uiColor, shadowDarkColor.uiColor)
|
||||
let viewColorConfiguration = SurfaceColorConfiguration(viewLightColor.uiColor, viewDarkColor.uiColor)
|
||||
|
||||
component.layer.masksToBounds = false
|
||||
component.backgroundColor = viewColorConfiguration.getColor(surface)
|
||||
component.layer.shadowColor = dropshadowColorConfiguration.getColor(surface).cgColor
|
||||
component.layer.shadowOpacity = Float(opacityRange.value)
|
||||
component.layer.shadowOffset = .init(width: CGFloat(offsetXRange.value), height: CGFloat(offsetYRange.value))
|
||||
component.layer.shadowRadius = CGFloat(radiusRange.value)
|
||||
component.layer.cornerRadius = 8
|
||||
}
|
||||
|
||||
func setupPicker(){
|
||||
|
||||
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||
self?.contentTopView.backgroundColor = item.color
|
||||
self?.updateView()
|
||||
}
|
||||
|
||||
dropShadowDarkColorPickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||
self?.shadowDarkColor = item
|
||||
}
|
||||
|
||||
dropShadowLightColorPickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||
self?.shadowLightColor = item
|
||||
}
|
||||
|
||||
viewLightColorPickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||
self?.viewLightColor = item
|
||||
}
|
||||
|
||||
viewDarkColorPickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||
self?.viewDarkColor = item
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -77,6 +77,7 @@ class MenuViewController: UITableViewController, TooltipLaunchable {
|
||||
}
|
||||
|
||||
let items: [MenuComponent] = [
|
||||
MenuComponent(title: "DropShadow Tester", completed: true, viewController: DropShadowViewController.self),
|
||||
MenuComponent(title: "Badge", completed: true, viewController: BadgeViewController.self),
|
||||
MenuComponent(title: "Button", completed: true, viewController: ButtonViewController.self),
|
||||
MenuComponent(title: "ButtonGroup", completed: true, viewController: ButtonGroupViewController.self),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user