Skip to content

Commit

Permalink
Renamed DepthPreset.root to rawValue
Browse files Browse the repository at this point in the history
  • Loading branch information
OrkhanAlikhanov committed Sep 12, 2018
1 parent 5566ea5 commit 9707a8f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
28 changes: 15 additions & 13 deletions Sources/iOS/Depth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,17 @@ public enum DepthPreset {
indirect case left(DepthPreset)
indirect case right(DepthPreset)

public var root: DepthPreset {
/// Returns raw depth value without considering direction.
public var rawValue: DepthPreset {
switch self {
case .above(let v):
return v.root
return v.rawValue
case .below(let v):
return v.root
return v.rawValue
case .left(let v):
return v.root
return v.rawValue
case .right(let v):
return v.root
return v.rawValue
default:
return self
}
Expand Down Expand Up @@ -133,17 +134,17 @@ public func DepthPresetToValue(preset: DepthPreset) -> Depth {
if preset.isRoot {
v.offset.vertical *= -1
} else {
let root = DepthPresetToValue(preset: preset.root)
v.offset.vertical -= root.offset.vertical
let value = DepthPresetToValue(preset: preset.rawValue)
v.offset.vertical -= value.offset.vertical
}
return v
case .below(let preset):
var v = DepthPresetToValue(preset: preset)
if preset.isRoot {
return v
} else {
let root = DepthPresetToValue(preset: preset.root)
v.offset.vertical += root.offset.vertical
let value = DepthPresetToValue(preset: preset.rawValue)
v.offset.vertical += value.offset.vertical
}
return v
case .left(let preset):
Expand All @@ -152,8 +153,8 @@ public func DepthPresetToValue(preset: DepthPreset) -> Depth {
v.offset.horizontal = -v.offset.vertical
v.offset.vertical = 0
} else {
let root = DepthPresetToValue(preset: preset.root)
v.offset.horizontal -= root.offset.vertical
let value = DepthPresetToValue(preset: preset.rawValue)
v.offset.horizontal -= value.offset.vertical
}
return v
case .right(let preset):
Expand All @@ -162,14 +163,15 @@ public func DepthPresetToValue(preset: DepthPreset) -> Depth {
v.offset.horizontal = v.offset.vertical
v.offset.vertical = 0
} else {
let root = DepthPresetToValue(preset: preset.root)
v.offset.horizontal += root.offset.vertical
let value = DepthPresetToValue(preset: preset.rawValue)
v.offset.horizontal += value.offset.vertical
}
return v
}
}

fileprivate extension DepthPreset {
/// Checks if the preset is the root value (has no direction).
var isRoot: Bool {
switch self {
case .above(_):
Expand Down
2 changes: 1 addition & 1 deletion Sources/iOS/Material+CALayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ extension CALayer {
return
}

if case .none = depthPreset.root {
if case .none = depthPreset.rawValue {
shadowPath = nil
} else if nil == shadowPath {
shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).cgPath
Expand Down

0 comments on commit 9707a8f

Please sign in to comment.