Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Material
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
Material
Commits
76e60ab6
Commit
76e60ab6
authored
Sep 12, 2018
by
Orkhan Alikhanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added direction to DepthPreset
parent
d82a9cd3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
4 deletions
+76
-4
Sources/iOS/Depth.swift
+75
-2
Sources/iOS/Material+CALayer.swift
+1
-1
Sources/iOS/Material+UIView.swift
+0
-1
No files found.
Sources/iOS/Depth.swift
View file @
76e60ab6
...
@@ -30,14 +30,32 @@
...
@@ -30,14 +30,32 @@
import
UIKit
import
UIKit
@objc(DepthPreset)
public
enum
DepthPreset
{
public
enum
DepthPreset
:
Int
{
case
none
case
none
case
depth1
case
depth1
case
depth2
case
depth2
case
depth3
case
depth3
case
depth4
case
depth4
case
depth5
case
depth5
indirect
case
above
(
DepthPreset
)
indirect
case
below
(
DepthPreset
)
indirect
case
left
(
DepthPreset
)
indirect
case
right
(
DepthPreset
)
public
var
root
:
DepthPreset
{
switch
self
{
case
.
above
(
let
v
):
return
v
.
root
case
.
below
(
let
v
):
return
v
.
root
case
.
left
(
let
v
):
return
v
.
root
case
.
right
(
let
v
):
return
v
.
root
default
:
return
self
}
}
}
}
public
struct
Depth
{
public
struct
Depth
{
...
@@ -110,5 +128,60 @@ public func DepthPresetToValue(preset: DepthPreset) -> Depth {
...
@@ -110,5 +128,60 @@ public func DepthPresetToValue(preset: DepthPreset) -> Depth {
return
Depth
(
offset
:
Offset
(
horizontal
:
0
,
vertical
:
4
),
opacity
:
0.3
,
radius
:
4
)
return
Depth
(
offset
:
Offset
(
horizontal
:
0
,
vertical
:
4
),
opacity
:
0.3
,
radius
:
4
)
case
.
depth5
:
case
.
depth5
:
return
Depth
(
offset
:
Offset
(
horizontal
:
0
,
vertical
:
8
),
opacity
:
0.3
,
radius
:
8
)
return
Depth
(
offset
:
Offset
(
horizontal
:
0
,
vertical
:
8
),
opacity
:
0.3
,
radius
:
8
)
case
.
above
(
let
preset
):
var
v
=
DepthPresetToValue
(
preset
:
preset
)
if
preset
.
isRoot
{
v
.
offset
.
vertical
*=
-
1
}
else
{
let
root
=
DepthPresetToValue
(
preset
:
preset
.
root
)
v
.
offset
.
vertical
-=
root
.
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
}
return
v
case
.
left
(
let
preset
):
var
v
=
DepthPresetToValue
(
preset
:
preset
)
if
preset
.
isRoot
{
v
.
offset
.
horizontal
=
-
v
.
offset
.
vertical
v
.
offset
.
vertical
=
0
}
else
{
let
root
=
DepthPresetToValue
(
preset
:
preset
.
root
)
v
.
offset
.
horizontal
-=
root
.
offset
.
vertical
}
return
v
case
.
right
(
let
preset
):
var
v
=
DepthPresetToValue
(
preset
:
preset
)
if
preset
.
isRoot
{
v
.
offset
.
horizontal
=
v
.
offset
.
vertical
v
.
offset
.
vertical
=
0
}
else
{
let
root
=
DepthPresetToValue
(
preset
:
preset
.
root
)
v
.
offset
.
horizontal
+=
root
.
offset
.
vertical
}
return
v
}
}
fileprivate
extension
DepthPreset
{
var
isRoot
:
Bool
{
switch
self
{
case
.
above
(
_
):
return
false
case
.
below
(
_
):
return
false
case
.
left
(
_
):
return
false
case
.
right
(
_
):
return
false
default
:
return
true
}
}
}
}
}
Sources/iOS/Material+CALayer.swift
View file @
76e60ab6
...
@@ -281,7 +281,7 @@ extension CALayer {
...
@@ -281,7 +281,7 @@ extension CALayer {
return
return
}
}
if
.
none
==
depthPrese
t
{
if
case
.
none
=
depthPreset
.
roo
t
{
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
...
...
Sources/iOS/Material+UIView.swift
View file @
76e60ab6
...
@@ -87,7 +87,6 @@ extension UIView {
...
@@ -87,7 +87,6 @@ extension UIView {
}
}
/// A preset value for Depth.
/// A preset value for Depth.
@objc
open
var
depthPreset
:
DepthPreset
{
open
var
depthPreset
:
DepthPreset
{
get
{
get
{
return
layer
.
depthPreset
return
layer
.
depthPreset
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment