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
30598cc5
Commit
30598cc5
authored
Sep 26, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added MaterialRadiusType
parent
286cf1e9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
123 additions
and
17 deletions
+123
-17
MaterialKit.xcodeproj/project.pbxproj
+4
-0
Source/FlatButton.swift
+1
-0
Source/MaterialBorder.swift
+50
-0
Source/MaterialButton.swift
+13
-6
Source/MaterialInsets.swift
+2
-2
Source/MaterialRadius.swift
+26
-1
Source/MaterialShadow.swift
+2
-2
Source/MaterialTheme.swift
+13
-1
Source/MaterialView.swift
+12
-5
No files found.
MaterialKit.xcodeproj/project.pbxproj
View file @
30598cc5
...
...
@@ -29,6 +29,7 @@
65BDD1661BB7111E006F7F2B
/* MaterialView.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65BDD1461BB5B916006F7F2B
/* MaterialView.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
65BDD1671BB7111E006F7F2B
/* MaterialButton.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65BDD1561BB6FC82006F7F2B
/* MaterialButton.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
65BDD1681BB7111E006F7F2B
/* FlatButton.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65BDD1581BB6FE3E006F7F2B
/* FlatButton.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
65BDD16A1BB7146B006F7F2B
/* MaterialBorder.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65BDD1691BB7146B006F7F2B
/* MaterialBorder.swift */
;
settings
=
{
ASSET_TAGS
=
();
};
};
65DBE4201B9A9244000C804F
/* Roboto-Bold.ttf in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65DBE41E1B9A9244000C804F
/* Roboto-Bold.ttf */
;
};
65DBE4211B9A9244000C804F
/* Roboto-Thin.ttf in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65DBE41F1B9A9244000C804F
/* Roboto-Thin.ttf */
;
};
962F3E531BACA68C0004B8AD
/* NavigationBarView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
962F3E521BACA68C0004B8AD
/* NavigationBarView.swift */
;
};
...
...
@@ -63,6 +64,7 @@
65BDD1581BB6FE3E006F7F2B
/* FlatButton.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
FlatButton.swift
;
sourceTree
=
"<group>"
;
};
65BDD15A1BB7095E006F7F2B
/* MaterialRadius.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialRadius.swift
;
sourceTree
=
"<group>"
;
};
65BDD15C1BB70D60006F7F2B
/* MaterialInsets.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialInsets.swift
;
sourceTree
=
"<group>"
;
};
65BDD1691BB7146B006F7F2B
/* MaterialBorder.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialBorder.swift
;
sourceTree
=
"<group>"
;
};
65DBE41E1B9A9244000C804F
/* Roboto-Bold.ttf */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file
;
path
=
"Roboto-Bold.ttf"
;
sourceTree
=
"<group>"
;
};
65DBE41F1B9A9244000C804F
/* Roboto-Thin.ttf */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file
;
path
=
"Roboto-Thin.ttf"
;
sourceTree
=
"<group>"
;
};
962F3E521BACA68C0004B8AD
/* NavigationBarView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
NavigationBarView.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -192,6 +194,7 @@
65BDD1531BB6F473006F7F2B
/* MaterialShadow.swift */
,
65BDD15A1BB7095E006F7F2B
/* MaterialRadius.swift */
,
65BDD15C1BB70D60006F7F2B
/* MaterialInsets.swift */
,
65BDD1691BB7146B006F7F2B
/* MaterialBorder.swift */
,
);
name
=
Theme
;
sourceTree
=
"<group>"
;
...
...
@@ -340,6 +343,7 @@
65BDD1541BB6F473006F7F2B
/* MaterialShadow.swift in Sources */
,
65BDD1571BB6FC82006F7F2B
/* MaterialButton.swift in Sources */
,
65BDD14B1BB5DD02006F7F2B
/* MaterialFont.swift in Sources */
,
65BDD16A1BB7146B006F7F2B
/* MaterialBorder.swift in Sources */
,
65BDD15B1BB7095E006F7F2B
/* MaterialRadius.swift in Sources */
,
65BDD1491BB5DC98006F7F2B
/* MaterialColor.swift in Sources */
,
65BDD14D1BB5ED9F006F7F2B
/* MaterialTheme.swift in Sources */
,
...
...
Source/FlatButton.swift
View file @
30598cc5
...
...
@@ -29,6 +29,7 @@ public class FlatButton : MaterialButton {
backgroundColor
=
MaterialColor
.
red
.
base
//MaterialTheme.button.flat.backgroudColor
cornerRadius
=
MaterialTheme
.
button
.
flat
.
cornerRadius
contentInsets
=
MaterialTheme
.
button
.
flat
.
contentInsets
border
=
MaterialTheme
.
button
.
flat
.
border
}
//
...
...
Source/MaterialBorder.swift
0 → 100644
View file @
30598cc5
//
// Copyright (C) 2015 GraphKit, Inc. <http://graphkit.io> and other GraphKit contributors.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program located at the root of the software package
// in a file called LICENSE. If not, see <http://www.gnu.org/licenses/>.
//
import
UIKit
public
typealias
MaterialBorderType
=
CGFloat
public
enum
MaterialBorder
:
MaterialBorderType
{
case
None
case
Thin
case
Light
case
Regular
case
Medium
case
Thick
}
/**
:name: MaterialBorderToValue
*/
public
func
MaterialBorderToValue
(
border
:
MaterialBorder
)
->
MaterialBorderType
{
switch
border
{
case
.
None
:
return
0
case
.
Thin
:
return
0.5
case
.
Light
:
return
1
case
.
Regular
:
return
2
case
.
Medium
:
return
3
case
.
Thick
:
return
4
}
}
Source/MaterialButton.swift
View file @
30598cc5
...
...
@@ -118,10 +118,8 @@ public class MaterialButton : UIButton {
public
var
cornerRadius
:
MaterialRadius
!
{
didSet
{
switch
cornerRadius
!
{
case
.
Square
:
layer
.
cornerRadius
=
0
case
.
Smooth
:
layer
.
cornerRadius
=
4
case
.
Square
,
.
Light
,
.
Regular
,
.
Medium
,
.
Heavy
:
layer
.
cornerRadius
=
MaterialRadiusToValue
(
cornerRadius
!
)
case
.
Round
:
layer
.
cornerRadius
=
bounds
.
width
/
2
}
...
...
@@ -129,11 +127,20 @@ public class MaterialButton : UIButton {
}
/**
:name: border
*/
public
var
border
:
MaterialBorder
!
{
didSet
{
layer
.
borderWidth
=
MaterialBorderToValue
(
border
)
}
}
/**
:name: shadow
*/
public
var
shadow
:
MaterialShadow
!
{
didSet
{
let
value
:
MaterialShadowType
=
MaterialShadowToValue
s
(
shadow
)
let
value
:
MaterialShadowType
=
MaterialShadowToValue
(
shadow
)
shadowOffset
=
value
.
offset
shadowOpacity
=
value
.
opacity
shadowRadius
=
value
.
radius
...
...
@@ -154,7 +161,7 @@ public class MaterialButton : UIButton {
*/
public
var
contentInsets
:
MaterialInsets
!
{
didSet
{
let
value
:
MaterialInsetsType
=
MaterialInsetsToValue
s
(
contentInsets
)
let
value
:
MaterialInsetsType
=
MaterialInsetsToValue
(
contentInsets
)
contentEdgeInsets
=
UIEdgeInsetsMake
(
value
.
top
,
value
.
left
,
value
.
bottom
,
value
.
right
)
}
}
...
...
Source/MaterialInsets.swift
View file @
30598cc5
...
...
@@ -30,9 +30,9 @@ public enum MaterialInsets {
}
/**
:name: MaterialInsetsToValue
s
:name: MaterialInsetsToValue
*/
public
func
MaterialInsetsToValue
s
(
inset
:
MaterialInsets
)
->
MaterialInsetsType
{
public
func
MaterialInsetsToValue
(
inset
:
MaterialInsets
)
->
MaterialInsetsType
{
switch
inset
{
case
.
Inset0
:
return
(
top
:
0
,
left
:
0
,
bottom
:
0
,
right
:
0
)
...
...
Source/MaterialRadius.swift
View file @
30598cc5
...
...
@@ -16,8 +16,33 @@
// in a file called LICENSE. If not, see <http://www.gnu.org/licenses/>.
//
import
UIKit
public
typealias
MaterialRadiusType
=
CGFloat
public
enum
MaterialRadius
{
case
Square
case
Smooth
case
Light
case
Regular
case
Medium
case
Heavy
case
Round
}
/**
:name: MaterialRadiusToValue
*/
public
func
MaterialRadiusToValue
(
radius
:
MaterialRadius
)
->
MaterialRadiusType
{
switch
radius
{
case
.
Square
,
.
Round
:
return
0
case
.
Light
:
return
4
case
.
Regular
:
return
8
case
.
Medium
:
return
16
case
.
Heavy
:
return
20
}
}
Source/MaterialShadow.swift
View file @
30598cc5
...
...
@@ -30,9 +30,9 @@ public enum MaterialShadow {
}
/**
:name: MaterialShadowToValue
s
:name: MaterialShadowToValue
*/
public
func
MaterialShadowToValue
s
(
shadow
:
MaterialShadow
)
->
MaterialShadowType
{
public
func
MaterialShadowToValue
(
shadow
:
MaterialShadow
)
->
MaterialShadowType
{
switch
shadow
{
case
.
Depth0
:
return
(
offset
:
CGSizeZero
,
opacity
:
0
,
radius
:
0
)
...
...
Source/MaterialTheme.swift
View file @
30598cc5
...
...
@@ -44,6 +44,9 @@ public extension MaterialTheme.view {
public
static
let
masksToBounds
:
Bool
=
false
public
static
let
cornerRadius
:
MaterialRadius
=
.
Square
// border
public
static
let
border
:
MaterialBorder
=
.
None
// color
public
static
let
backgroudColor
:
UIColor
=
MaterialColor
.
white
...
...
@@ -76,6 +79,9 @@ public extension MaterialTheme.navigation {
public
static
let
masksToBounds
:
Bool
=
MaterialTheme
.
view
.
masksToBounds
public
static
let
cornerRadius
:
MaterialRadius
=
MaterialTheme
.
view
.
cornerRadius
// border
public
static
let
border
:
MaterialBorder
=
MaterialTheme
.
view
.
border
// color
public
static
let
backgroudColor
:
UIColor
=
MaterialColor
.
blue
.
accent3
public
static
let
lightContentStatusBar
:
Bool
=
true
...
...
@@ -101,9 +107,12 @@ public extension MaterialTheme.button {
// shape
public
static
let
masksToBounds
:
Bool
=
MaterialTheme
.
view
.
masksToBounds
public
static
let
cornerRadius
:
MaterialRadius
=
.
Smooth
public
static
let
cornerRadius
:
MaterialRadius
=
.
Light
public
static
let
contentInsets
:
MaterialInsets
=
.
Inset2
// border
public
static
let
border
:
MaterialBorder
=
MaterialTheme
.
view
.
border
// color
public
static
let
backgroudColor
:
UIColor
=
MaterialColor
.
clear
public
static
let
titleLabelColorForNormalState
:
UIColor
=
MaterialColor
.
blueGrey
.
darken4
...
...
@@ -129,6 +138,9 @@ public extension MaterialTheme.button.flat {
public
static
let
cornerRadius
:
MaterialRadius
=
MaterialTheme
.
button
.
cornerRadius
public
static
let
contentInsets
:
MaterialInsets
=
MaterialTheme
.
button
.
contentInsets
// border
public
static
let
border
:
MaterialBorder
=
MaterialTheme
.
button
.
border
// color
public
static
let
backgroudColor
:
UIColor
=
MaterialTheme
.
button
.
backgroudColor
public
static
let
titleLabelColorForNormalState
:
UIColor
=
MaterialTheme
.
button
.
titleLabelColorForNormalState
...
...
Source/MaterialView.swift
View file @
30598cc5
...
...
@@ -163,10 +163,8 @@ public class MaterialView: UIView {
public
var
cornerRadius
:
MaterialRadius
!
{
didSet
{
switch
cornerRadius
!
{
case
.
Square
:
layer
.
cornerRadius
=
0
case
.
Smooth
:
layer
.
cornerRadius
=
4
case
.
Square
,
.
Light
,
.
Regular
,
.
Medium
,
.
Heavy
:
layer
.
cornerRadius
=
MaterialRadiusToValue
(
cornerRadius
!
)
case
.
Round
:
layer
.
cornerRadius
=
bounds
.
width
/
2
}
...
...
@@ -174,11 +172,20 @@ public class MaterialView: UIView {
}
/**
:name: border
*/
public
var
border
:
MaterialBorder
!
{
didSet
{
layer
.
borderWidth
=
MaterialBorderToValue
(
border
)
}
}
/**
:name: shadow
*/
public
var
shadow
:
MaterialShadow
!
{
didSet
{
let
value
:
MaterialShadowType
=
MaterialShadowToValue
s
(
shadow
)
let
value
:
MaterialShadowType
=
MaterialShadowToValue
(
shadow
)
shadowOffset
=
value
.
offset
shadowOpacity
=
value
.
opacity
shadowRadius
=
value
.
radius
...
...
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