Commit 9707a8f6 by Orkhan Alikhanov

Renamed DepthPreset.root to rawValue

parent 5566ea5b
...@@ -42,16 +42,17 @@ public enum DepthPreset { ...@@ -42,16 +42,17 @@ public enum DepthPreset {
indirect case left(DepthPreset) indirect case left(DepthPreset)
indirect case right(DepthPreset) indirect case right(DepthPreset)
public var root: DepthPreset { /// Returns raw depth value without considering direction.
public var rawValue: DepthPreset {
switch self { switch self {
case .above(let v): case .above(let v):
return v.root return v.rawValue
case .below(let v): case .below(let v):
return v.root return v.rawValue
case .left(let v): case .left(let v):
return v.root return v.rawValue
case .right(let v): case .right(let v):
return v.root return v.rawValue
default: default:
return self return self
} }
...@@ -133,8 +134,8 @@ public func DepthPresetToValue(preset: DepthPreset) -> Depth { ...@@ -133,8 +134,8 @@ public func DepthPresetToValue(preset: DepthPreset) -> Depth {
if preset.isRoot { if preset.isRoot {
v.offset.vertical *= -1 v.offset.vertical *= -1
} else { } else {
let root = DepthPresetToValue(preset: preset.root) let value = DepthPresetToValue(preset: preset.rawValue)
v.offset.vertical -= root.offset.vertical v.offset.vertical -= value.offset.vertical
} }
return v return v
case .below(let preset): case .below(let preset):
...@@ -142,8 +143,8 @@ public func DepthPresetToValue(preset: DepthPreset) -> Depth { ...@@ -142,8 +143,8 @@ public func DepthPresetToValue(preset: DepthPreset) -> Depth {
if preset.isRoot { if preset.isRoot {
return v return v
} else { } else {
let root = DepthPresetToValue(preset: preset.root) let value = DepthPresetToValue(preset: preset.rawValue)
v.offset.vertical += root.offset.vertical v.offset.vertical += value.offset.vertical
} }
return v return v
case .left(let preset): case .left(let preset):
...@@ -152,8 +153,8 @@ public func DepthPresetToValue(preset: DepthPreset) -> Depth { ...@@ -152,8 +153,8 @@ public func DepthPresetToValue(preset: DepthPreset) -> Depth {
v.offset.horizontal = -v.offset.vertical v.offset.horizontal = -v.offset.vertical
v.offset.vertical = 0 v.offset.vertical = 0
} else { } else {
let root = DepthPresetToValue(preset: preset.root) let value = DepthPresetToValue(preset: preset.rawValue)
v.offset.horizontal -= root.offset.vertical v.offset.horizontal -= value.offset.vertical
} }
return v return v
case .right(let preset): case .right(let preset):
...@@ -162,14 +163,15 @@ public func DepthPresetToValue(preset: DepthPreset) -> Depth { ...@@ -162,14 +163,15 @@ public func DepthPresetToValue(preset: DepthPreset) -> Depth {
v.offset.horizontal = v.offset.vertical v.offset.horizontal = v.offset.vertical
v.offset.vertical = 0 v.offset.vertical = 0
} else { } else {
let root = DepthPresetToValue(preset: preset.root) let value = DepthPresetToValue(preset: preset.rawValue)
v.offset.horizontal += root.offset.vertical v.offset.horizontal += value.offset.vertical
} }
return v return v
} }
} }
fileprivate extension DepthPreset { fileprivate extension DepthPreset {
/// Checks if the preset is the root value (has no direction).
var isRoot: Bool { var isRoot: Bool {
switch self { switch self {
case .above(_): case .above(_):
......
...@@ -281,7 +281,7 @@ extension CALayer { ...@@ -281,7 +281,7 @@ extension CALayer {
return return
} }
if case .none = depthPreset.root { if case .none = depthPreset.rawValue {
shadowPath = nil shadowPath = nil
} else if nil == shadowPath { } else if nil == shadowPath {
shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).cgPath shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).cgPath
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment