Skip to content
This repository was archived by the owner on Jun 17, 2023. It is now read-only.

Commit 10b1541

Browse files
author
Amir Khorsandi
committed
Add options for stack options
1 parent 84a0d62 commit 10b1541

File tree

3 files changed

+69
-3
lines changed

3 files changed

+69
-3
lines changed

Samples/PagingLayoutSamples/Modules/LayoutDesigner/LayoutDesignerViewModel.swift

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,77 @@ class LayoutDesignerViewModel {
8787
self?.update(options: &options, closure: $0)
8888
}
8989

90+
optionViewModels = [
91+
.init(title: "Scale factor", kind: .singleSlider(current: options.scaleFactor) { n in
92+
update { $0.scaleFactor = n }
93+
}),
94+
.init(title: "Min scale", kind: .singleSlider(current: options.minScale) { n in
95+
update { $0.minScale = n }
96+
}),
97+
.init(title: "Max scale", kind: .singleSlider(current: options.maxScale) { n in
98+
update { $0.maxScale = n }
99+
}),
100+
.init(title: "Spacing factor", kind: .singleSlider(current: options.spacingFactor) { n in
101+
update { $0.spacingFactor = n }
102+
}),
103+
.init(title: "Max spacing", kind: .singleSlider(current: options.maxSpacing) { n in
104+
update { $0.maxSpacing = n }
105+
}),
106+
.init(title: "Alpha factor", kind: .singleSlider(current: options.alphaFactor) { n in
107+
update { $0.alphaFactor = n }
108+
}),
109+
.init(title: "Bottom stack alpha speed factor", kind: .singleSlider(current: options.bottomStackAlphaSpeedFactor) { n in
110+
update { $0.bottomStackAlphaSpeedFactor = n }
111+
}),
112+
.init(title: "Top stack alpha speed factor", kind: .singleSlider(current: options.topStackAlphaSpeedFactor) { n in
113+
update { $0.topStackAlphaSpeedFactor = n }
114+
}),
115+
.init(title: "Perspective ratio", kind: .singleSlider(current: options.perspectiveRatio) { n in
116+
update { $0.perspectiveRatio = n }
117+
}),
118+
.init(title: "Shadow enabled", kind: .toggleSwitch(current: options.shadowEnabled) { n in
119+
update { $0.shadowEnabled = n }
120+
}),
121+
.init(title: "Shadow opacity", kind: .singleSlider(current: CGFloat(options.shadowOpacity)) { n in
122+
update { $0.shadowOpacity = Float(n) }
123+
}),
124+
.init(title: "Shadow offset", kind: .doubleSlider(current: options.shadowOffset.pair) { n in
125+
update { $0.shadowOffset = .by(pair: n) }
126+
}),
127+
.init(title: "Shadow radius", kind: .singleSlider(current: options.shadowRadius) { n in
128+
update { $0.shadowRadius = n }
129+
}),
130+
.init(title: "Rotate angel", kind: .singleSlider(current: options.stackRotateAngel) { n in
131+
update { $0.stackRotateAngel = n }
132+
}),
133+
.init(title: "Pop angle", kind: .singleSlider(current: options.popAngle) { n in
134+
update { $0.popAngle = n }
135+
}),
136+
.init(title: "Pop offset ratio", kind: .doubleSlider(current: options.popOffsetRatio.pair) { n in
137+
update { $0.popOffsetRatio = .by(pair: n) }
138+
}),
139+
.init(title: "Stack position", kind: .doubleSlider(current: options.stackPosition.pair) { n in
140+
update { $0.stackPosition = .by(pair: n) }
141+
}),
142+
.init(title: "Reverse", kind: .toggleSwitch(current: options.reverse) { n in
143+
update { $0.reverse = n }
144+
}),
145+
.init(title: "Blur effect enabled", kind: .toggleSwitch(current: options.blurEffectEnabled) { n in
146+
update { $0.blurEffectEnabled = n }
147+
}),
148+
.init(title: "Max blur radius", kind: .singleSlider(current: options.maxBlurEffectRadius) { n in
149+
update { $0.maxBlurEffectRadius = n }
150+
}),
151+
.init(title: "Blur effect style", kind: .segmented(options: UIBlurEffect.Style.all.map(\.name), current: options.blurEffectStyle.name) { n in
152+
update { $0.blurEffectStyle = .by(name: n)! }
153+
})
154+
]
90155
} else if var options = selectedLayout.snapshotOptions {
91156
updateCodePreview(options: options)
92157
let update: ((inout SnapshotTransformViewOptions) -> Void) -> Void = { [weak self] in
93158
self?.update(options: &options, closure: $0)
94159
}
95160
}
96161
}
162+
97163
}

Samples/PagingLayoutSamples/Modules/LayoutDesigner/Options/cell/LayoutDesignerOptionCell.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ class LayoutDesignerOptionCell: UITableViewCell, NibBased {
135135
case let .singleSlider(current, onChange):
136136
slider1.isHidden = false
137137
input1.isHidden = false
138-
input1.set(value: current)
139-
slider1.value = Float(current)
138+
input1.set(value: current ?? 0)
139+
slider1.value = Float(current ?? 0)
140140
onSlider1Change = onChange
141141

142142
case let .doubleSlider(current, onChange):

Samples/PagingLayoutSamples/Modules/LayoutDesigner/Options/cell/LayoutDesignerOptionCellViewModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class LayoutDesignerOptionCellViewModel {
1414
// MARK: Constants
1515

1616
enum Kind {
17-
case singleSlider(current: CGFloat, onChange: (CGFloat) -> Void)
17+
case singleSlider(current: CGFloat?, onChange: (CGFloat) -> Void)
1818
case doubleSlider(current: (CGFloat, CGFloat)?, onChange: ((CGFloat, CGFloat)) -> Void)
1919
case toggleSwitch(current: Bool, onChange: (Bool) -> Void)
2020
case segmented(options: [String], current: String?, onChange: (String) -> Void)

0 commit comments

Comments
 (0)