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
5876288b
Unverified
Commit
5876288b
authored
Sep 13, 2018
by
Daniel Dahan
Committed by
GitHub
Sep 13, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1151 from OrkhanAlikhanov/new-features
New features
parents
d82a9cd3
9707a8f6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
140 additions
and
18 deletions
+140
-18
Sources/iOS/BottomNavigationController.swift
+22
-0
Sources/iOS/Depth.swift
+77
-2
Sources/iOS/HeightPreset.swift
+39
-12
Sources/iOS/Material+CALayer.swift
+2
-2
Sources/iOS/Material+UIView.swift
+0
-2
No files found.
Sources/iOS/BottomNavigationController.swift
View file @
5876288b
...
@@ -41,6 +41,15 @@ extension UIViewController {
...
@@ -41,6 +41,15 @@ extension UIViewController {
}
}
}
}
private
class
MaterialTabBar
:
UITabBar
{
override
func
sizeThatFits
(
_
size
:
CGSize
)
->
CGSize
{
var
v
=
super
.
sizeThatFits
(
size
)
let
offset
=
v
.
height
-
HeightPreset
.
normal
.
rawValue
v
.
height
=
heightPreset
.
rawValue
+
offset
return
v
}
}
open
class
BottomNavigationController
:
UITabBarController
{
open
class
BottomNavigationController
:
UITabBarController
{
/// A Boolean that indicates if the swipe feature is enabled..
/// A Boolean that indicates if the swipe feature is enabled..
open
var
isSwipeEnabled
=
false
{
open
var
isSwipeEnabled
=
false
{
...
@@ -60,6 +69,7 @@ open class BottomNavigationController: UITabBarController {
...
@@ -60,6 +69,7 @@ open class BottomNavigationController: UITabBarController {
*/
*/
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
super
.
init
(
coder
:
aDecoder
)
setTabBarClass
()
}
}
/**
/**
...
@@ -69,6 +79,7 @@ open class BottomNavigationController: UITabBarController {
...
@@ -69,6 +79,7 @@ open class BottomNavigationController: UITabBarController {
*/
*/
public
override
init
(
nibName
nibNameOrNil
:
String
?,
bundle
nibBundleOrNil
:
Bundle
?)
{
public
override
init
(
nibName
nibNameOrNil
:
String
?,
bundle
nibBundleOrNil
:
Bundle
?)
{
super
.
init
(
nibName
:
nibNameOrNil
,
bundle
:
nibBundleOrNil
)
super
.
init
(
nibName
:
nibNameOrNil
,
bundle
:
nibBundleOrNil
)
setTabBarClass
()
}
}
/// An initializer that accepts no parameters.
/// An initializer that accepts no parameters.
...
@@ -144,6 +155,17 @@ open class BottomNavigationController: UITabBarController {
...
@@ -144,6 +155,17 @@ open class BottomNavigationController: UITabBarController {
}
}
private
extension
BottomNavigationController
{
private
extension
BottomNavigationController
{
/// Sets tabBar class to MaterialTabBar.
func
setTabBarClass
()
{
guard
object_getClass
(
tabBar
)
===
UITabBar
.
self
else
{
return
}
object_setClass
(
tabBar
,
MaterialTabBar
.
self
)
}
}
private
extension
BottomNavigationController
{
/**
/**
Selects a view controller at a given index.
Selects a view controller at a given index.
- Parameter at index: An Int.
- Parameter at index: An Int.
...
...
Sources/iOS/Depth.swift
View file @
5876288b
...
@@ -30,14 +30,33 @@
...
@@ -30,14 +30,33 @@
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
)
/// Returns raw depth value without considering direction.
public
var
rawValue
:
DepthPreset
{
switch
self
{
case
.
above
(
let
v
):
return
v
.
rawValue
case
.
below
(
let
v
):
return
v
.
rawValue
case
.
left
(
let
v
):
return
v
.
rawValue
case
.
right
(
let
v
):
return
v
.
rawValue
default
:
return
self
}
}
}
}
public
struct
Depth
{
public
struct
Depth
{
...
@@ -110,5 +129,61 @@ public func DepthPresetToValue(preset: DepthPreset) -> Depth {
...
@@ -110,5 +129,61 @@ 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
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
value
=
DepthPresetToValue
(
preset
:
preset
.
rawValue
)
v
.
offset
.
vertical
+=
value
.
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
value
=
DepthPresetToValue
(
preset
:
preset
.
rawValue
)
v
.
offset
.
horizontal
-=
value
.
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
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
(
_
):
return
false
case
.
below
(
_
):
return
false
case
.
left
(
_
):
return
false
case
.
right
(
_
):
return
false
default
:
return
true
}
}
}
}
}
Sources/iOS/HeightPreset.swift
View file @
5876288b
...
@@ -30,16 +30,43 @@
...
@@ -30,16 +30,43 @@
import
UIKit
import
UIKit
@objc(HeightPreset)
public
enum
HeightPreset
{
public
enum
HeightPreset
:
Int
{
case
none
case
none
=
0
case
tiny
case
tiny
=
20
case
xsmall
case
xsmall
=
28
case
small
case
small
=
36
case
`
default
`
case
`
default
`
=
44
case
normal
case
normal
=
49
case
medium
case
medium
=
52
case
large
case
large
=
60
case
xlarge
case
xlarge
=
68
case
xxlarge
case
xxlarge
=
104
case
custom
(
CGFloat
)
public
var
rawValue
:
CGFloat
{
switch
self
{
case
.
none
:
return
0
case
.
tiny
:
return
20
case
.
xsmall
:
return
28
case
.
small
:
return
36
case
.
`
default
`
:
return
44
case
.
normal
:
return
49
case
.
medium
:
return
52
case
.
large
:
return
60
case
.
xlarge
:
return
68
case
.
xxlarge
:
return
104
case
.
custom
(
let
v
):
return
v
}
}
}
}
Sources/iOS/Material+CALayer.swift
View file @
5876288b
...
@@ -38,7 +38,7 @@ fileprivate class MaterialLayer {
...
@@ -38,7 +38,7 @@ fileprivate class MaterialLayer {
/// A property that sets the height of the layer's frame.
/// A property that sets the height of the layer's frame.
fileprivate
var
heightPreset
=
HeightPreset
.
default
{
fileprivate
var
heightPreset
=
HeightPreset
.
default
{
didSet
{
didSet
{
layer
?
.
height
=
CGFloat
(
heightPreset
.
rawValue
)
layer
?
.
height
=
heightPreset
.
rawValue
}
}
}
}
...
@@ -281,7 +281,7 @@ extension CALayer {
...
@@ -281,7 +281,7 @@ extension CALayer {
return
return
}
}
if
.
none
==
depthPreset
{
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
...
...
Sources/iOS/Material+UIView.swift
View file @
5876288b
...
@@ -61,7 +61,6 @@ extension UIView {
...
@@ -61,7 +61,6 @@ extension UIView {
}
}
/// HeightPreset value.
/// HeightPreset value.
@objc
open
var
heightPreset
:
HeightPreset
{
open
var
heightPreset
:
HeightPreset
{
get
{
get
{
return
layer
.
heightPreset
return
layer
.
heightPreset
...
@@ -87,7 +86,6 @@ extension UIView {
...
@@ -87,7 +86,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