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
ac53a489
Commit
ac53a489
authored
Jul 14, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
progression commit
parent
e1fdce7a
Hide whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
301 additions
and
286 deletions
+301
-286
Material.xcodeproj/project.pbxproj
+18
-18
Sources/iOS/Button.swift
+28
-24
Sources/iOS/Capture.swift
+39
-39
Sources/iOS/CaptureSession.swift
+8
-8
Sources/iOS/Card.swift
+20
-20
Sources/iOS/ControlView.swift
+2
-2
Sources/iOS/Depth.swift
+5
-0
Sources/iOS/ErrorTextField.swift
+1
-1
Sources/iOS/FabButton.swift
+7
-7
Sources/iOS/FlatButton.swift
+8
-9
Sources/iOS/Grid.swift
+30
-30
Sources/iOS/IconButton.swift
+7
-9
Sources/iOS/ImageCard.swift
+25
-25
Sources/iOS/Insets.swift
+40
-36
Sources/iOS/Material+UIImage+FilterBlur.swift
+3
-3
Sources/iOS/Material+UIImage+TintColor.swift
+1
-1
Sources/iOS/MaterialCollectionReusableView.swift
+1
-1
Sources/iOS/MaterialCollectionViewCell.swift
+2
-2
Sources/iOS/MaterialCollectionViewLayout.swift
+3
-3
Sources/iOS/Menu.swift
+9
-9
Sources/iOS/NavigationBar.swift
+3
-3
Sources/iOS/NavigationDrawerController.swift
+4
-4
Sources/iOS/RaisedButton.swift
+8
-8
Sources/iOS/StatusBarController.swift
+1
-1
Sources/iOS/TextView.swift
+9
-9
Sources/iOS/ToolbarController.swift
+2
-2
Sources/iOS/View.swift
+17
-12
No files found.
Material.xcodeproj/project.pbxproj
View file @
ac53a489
...
...
@@ -22,13 +22,13 @@
96BCB7A21CB40DC500C806FE
/* BottomTabBar.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7591CB40DC500C806FE
/* BottomTabBar.swift */
;
};
96BCB7A31CB40DC500C806FE
/* CapturePreview.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB75A1CB40DC500C806FE
/* CapturePreview.swift */
;
};
96BCB7A41CB40DC500C806FE
/* CaptureSession.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB75B1CB40DC500C806FE
/* CaptureSession.swift */
;
};
96BCB7A51CB40DC500C806FE
/* Capture
View.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB75C1CB40DC500C806FE
/* CaptureView
.swift */
;
};
96BCB7A61CB40DC500C806FE
/* Card
View.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB75D1CB40DC500C806FE
/* CardView
.swift */
;
};
96BCB7A51CB40DC500C806FE
/* Capture
.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB75C1CB40DC500C806FE
/* Capture
.swift */
;
};
96BCB7A61CB40DC500C806FE
/* Card
.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB75D1CB40DC500C806FE
/* Card
.swift */
;
};
96BCB7A71CB40DC500C806FE
/* ControlView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB75E1CB40DC500C806FE
/* ControlView.swift */
;
};
96BCB7A81CB40DC500C806FE
/* FabButton.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB75F1CB40DC500C806FE
/* FabButton.swift */
;
};
96BCB7A91CB40DC500C806FE
/* FlatButton.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7601CB40DC500C806FE
/* FlatButton.swift */
;
};
96BCB7AA1CB40DC500C806FE
/* Grid.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7611CB40DC500C806FE
/* Grid.swift */
;
};
96BCB7AB1CB40DC500C806FE
/* ImageCard
View.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7621CB40DC500C806FE
/* ImageCardView
.swift */
;
};
96BCB7AB1CB40DC500C806FE
/* ImageCard
.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7621CB40DC500C806FE
/* ImageCard
.swift */
;
};
96BCB7AC1CB40DC500C806FE
/* Material+Obj-C.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7631CB40DC500C806FE
/* Material+Obj-C.swift */
;
};
96BCB7AD1CB40DC500C806FE
/* Material+String.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7641CB40DC500C806FE
/* Material+String.swift */
;
};
96BCB7AE1CB40DC500C806FE
/* Material+UIFont.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7651CB40DC500C806FE
/* Material+UIFont.swift */
;
};
...
...
@@ -110,11 +110,11 @@
96BCB8161CB4115200C806FE
/* FlatButton.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7601CB40DC500C806FE
/* FlatButton.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8171CB4115200C806FE
/* Button.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7701CB40DC500C806FE
/* Button.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8181CB4115200C806FE
/* RaisedButton.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7931CB40DC500C806FE
/* RaisedButton.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8191CB4115200C806FE
/* Card
View.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB75D1CB40DC500C806FE
/* CardView
.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB81A1CB4115200C806FE
/* ImageCard
View.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7621CB40DC500C806FE
/* ImageCardView
.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8191CB4115200C806FE
/* Card
.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB75D1CB40DC500C806FE
/* Card
.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB81A1CB4115200C806FE
/* ImageCard
.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7621CB40DC500C806FE
/* ImageCard
.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB81B1CB4115200C806FE
/* CapturePreview.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB75A1CB40DC500C806FE
/* CapturePreview.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB81C1CB4115200C806FE
/* CaptureSession.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB75B1CB40DC500C806FE
/* CaptureSession.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB81D1CB4115200C806FE
/* Capture
View.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB75C1CB40DC500C806FE
/* CaptureView
.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB81D1CB4115200C806FE
/* Capture
.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB75C1CB40DC500C806FE
/* Capture
.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB81E1CB4115200C806FE
/* MaterialDataSourceItem.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7771CB40DC500C806FE
/* MaterialDataSourceItem.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB81F1CB4115200C806FE
/* MaterialCollectionView.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7711CB40DC500C806FE
/* MaterialCollectionView.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8201CB4115200C806FE
/* MaterialCollectionViewCell.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7721CB40DC500C806FE
/* MaterialCollectionViewCell.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
...
...
@@ -213,13 +213,13 @@
96BCB7591CB40DC500C806FE
/* BottomTabBar.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
BottomTabBar.swift
;
sourceTree
=
"<group>"
;
};
96BCB75A1CB40DC500C806FE
/* CapturePreview.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
CapturePreview.swift
;
sourceTree
=
"<group>"
;
};
96BCB75B1CB40DC500C806FE
/* CaptureSession.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
CaptureSession.swift
;
sourceTree
=
"<group>"
;
};
96BCB75C1CB40DC500C806FE
/* Capture
View.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
CaptureView
.swift
;
sourceTree
=
"<group>"
;
};
96BCB75D1CB40DC500C806FE
/* Card
View.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
CardView
.swift
;
sourceTree
=
"<group>"
;
};
96BCB75C1CB40DC500C806FE
/* Capture
.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Capture
.swift
;
sourceTree
=
"<group>"
;
};
96BCB75D1CB40DC500C806FE
/* Card
.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Card
.swift
;
sourceTree
=
"<group>"
;
};
96BCB75E1CB40DC500C806FE
/* ControlView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ControlView.swift
;
sourceTree
=
"<group>"
;
};
96BCB75F1CB40DC500C806FE
/* FabButton.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
FabButton.swift
;
sourceTree
=
"<group>"
;
};
96BCB7601CB40DC500C806FE
/* FlatButton.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
FlatButton.swift
;
sourceTree
=
"<group>"
;
};
96BCB7611CB40DC500C806FE
/* Grid.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Grid.swift
;
sourceTree
=
"<group>"
;
};
96BCB7621CB40DC500C806FE
/* ImageCard
View.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ImageCardView
.swift
;
sourceTree
=
"<group>"
;
};
96BCB7621CB40DC500C806FE
/* ImageCard
.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ImageCard
.swift
;
sourceTree
=
"<group>"
;
};
96BCB7631CB40DC500C806FE
/* Material+Obj-C.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+Obj-C.swift"
;
sourceTree
=
"<group>"
;
};
96BCB7641CB40DC500C806FE
/* Material+String.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+String.swift"
;
sourceTree
=
"<group>"
;
};
96BCB7651CB40DC500C806FE
/* Material+UIFont.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+UIFont.swift"
;
sourceTree
=
"<group>"
;
};
...
...
@@ -447,7 +447,7 @@
children
=
(
96BCB75A1CB40DC500C806FE
/* CapturePreview.swift */
,
96BCB75B1CB40DC500C806FE
/* CaptureSession.swift */
,
96BCB75C1CB40DC500C806FE
/* Capture
View
.swift */
,
96BCB75C1CB40DC500C806FE
/* Capture.swift */
,
);
name
=
Capture
;
sourceTree
=
"<group>"
;
...
...
@@ -487,8 +487,8 @@
96BCB8021CB40F3B00C806FE
/* Card */
=
{
isa
=
PBXGroup
;
children
=
(
96BCB75D1CB40DC500C806FE
/* Card
View
.swift */
,
96BCB7621CB40DC500C806FE
/* ImageCard
View
.swift */
,
96BCB75D1CB40DC500C806FE
/* Card.swift */
,
96BCB7621CB40DC500C806FE
/* ImageCard.swift */
,
);
name
=
Card
;
sourceTree
=
"<group>"
;
...
...
@@ -667,11 +667,11 @@
96BCB8161CB4115200C806FE
/* FlatButton.swift in Headers */
,
96BCB8171CB4115200C806FE
/* Button.swift in Headers */
,
96BCB8181CB4115200C806FE
/* RaisedButton.swift in Headers */
,
96BCB8191CB4115200C806FE
/* Card
View
.swift in Headers */
,
96BCB81A1CB4115200C806FE
/* ImageCard
View
.swift in Headers */
,
96BCB8191CB4115200C806FE
/* Card.swift in Headers */
,
96BCB81A1CB4115200C806FE
/* ImageCard.swift in Headers */
,
96BCB81B1CB4115200C806FE
/* CapturePreview.swift in Headers */
,
96BCB81C1CB4115200C806FE
/* CaptureSession.swift in Headers */
,
96BCB81D1CB4115200C806FE
/* Capture
View
.swift in Headers */
,
96BCB81D1CB4115200C806FE
/* Capture.swift in Headers */
,
96BCB81E1CB4115200C806FE
/* MaterialDataSourceItem.swift in Headers */
,
96BCB81F1CB4115200C806FE
/* MaterialCollectionView.swift in Headers */
,
96BCB8201CB4115200C806FE
/* MaterialCollectionViewCell.swift in Headers */
,
...
...
@@ -961,7 +961,7 @@
96BCB7DE1CB40DC500C806FE
/* SearchBar.swift in Sources */
,
96BCB7B11CB40DC500C806FE
/* Material+UIImage+Crop.swift in Sources */
,
96BCB7B81CB40DC500C806FE
/* MaterialBorder.swift in Sources */
,
96BCB7A61CB40DC500C806FE
/* Card
View
.swift in Sources */
,
96BCB7A61CB40DC500C806FE
/* Card.swift in Sources */
,
96BCB7C91CB40DC500C806FE
/* Layer.swift in Sources */
,
96BCB7E21CB40DC500C806FE
/* RootController.swift in Sources */
,
96BCB7DC1CB40DC500C806FE
/* RaisedButton.swift in Sources */
,
...
...
@@ -975,7 +975,7 @@
96BCB7DB1CB40DC500C806FE
/* NavigationItem.swift in Sources */
,
96BCB7E01CB40DC500C806FE
/* NavigationDrawerController.swift in Sources */
,
96BCB7AD1CB40DC500C806FE
/* Material+String.swift in Sources */
,
96BCB7A51CB40DC500C806FE
/* Capture
View
.swift in Sources */
,
96BCB7A51CB40DC500C806FE
/* Capture.swift in Sources */
,
96BCB7B01CB40DC500C806FE
/* Material+UIImage+Color.swift in Sources */
,
96BCB7B91CB40DC500C806FE
/* Button.swift in Sources */
,
96BCB7B51CB40DC500C806FE
/* Material+UIImage.swift in Sources */
,
...
...
@@ -984,7 +984,7 @@
96BCB7DA1CB40DC500C806FE
/* NavigationController.swift in Sources */
,
96BCB7A81CB40DC500C806FE
/* FabButton.swift in Sources */
,
96BCB7E41CB40DC500C806FE
/* Text.swift in Sources */
,
96BCB7AB1CB40DC500C806FE
/* ImageCard
View
.swift in Sources */
,
96BCB7AB1CB40DC500C806FE
/* ImageCard.swift in Sources */
,
96977DA61CBB2E49000BEFC4
/* Material+UIImage+FilterBlur.swift in Sources */
,
96BCB7CB1CB40DC500C806FE
/* MaterialPulseAnimation.swift in Sources */
,
96BCB7B71CB40DC500C806FE
/* MaterialBasicAnimation.swift in Sources */
,
...
...
Sources/iOS/Button.swift
View file @
ac53a489
...
...
@@ -39,7 +39,7 @@ public class Button: UIButton {
allows the dropshadow effect on the backing layer, while clipping
the image to a desired shape within the visualLayer.
*/
public
private(set)
lazy
var
visualLayer
:
CAShapeLayer
=
CAShapeLayer
()
public
private(set)
var
visualLayer
:
CAShapeLayer
!
/**
A base delegate reference used when subclassing View.
...
...
@@ -196,26 +196,23 @@ public class Button: UIButton {
}
}
/**
A property that sets the shadowOffset, shadowOpacity, and shadowRadius
for the backing layer. This is the preferred method of setting depth
in order to maintain consitency across UI objects.
*/
public
var
depthPreset
=
.
none
{
/// A preset value for Depth.
public
var
depthPreset
:
DepthPreset
=
.
none
{
didSet
{
let
v
=
DepthPresetToValue
(
preset
:
depthPreset
)
shadowOffset
=
v
.
offset
shadowOpacity
=
v
.
opacity
shadowRadius
=
v
.
radius
layoutShadowPath
()
depth
=
DepthPresetToValue
(
preset
:
depthPreset
)
}
}
/**
A property that sets the shadowOffset, shadowOpacity, and shadowRadius
for the backing layer.
*/
public
var
depth
=
Depth
.
zero
{
didSet
{
shadowOffset
=
depth
.
offset
shadowOffset
=
depth
.
offset
AsSize
shadowOpacity
=
depth
.
opacity
shadowRadius
=
depth
.
radius
layoutShadowPath
()
}
}
...
...
@@ -312,19 +309,26 @@ public class Button: UIButton {
}
/// A preset property for updated contentEdgeInsets.
public
var
content
EdgeInsetsPreset
:
InsetsPreset
{
public
var
content
InsetPreset
:
InsetPreset
=
.
none
{
didSet
{
let
value
:
Insets
=
InsetsPresetToValue
(
preset
:
contentEdgeInsetsPreset
)
contentEdgeInsets
=
UIEdgeInsetsMake
(
value
.
top
,
value
.
left
,
value
.
bottom
,
value
.
right
)
contentInset
=
InsetPresetToValue
(
preset
:
contentInsetPreset
)
}
}
/**
:name: contentInset
*/
@IBInspectable
public
var
contentInset
=
Inset
.
zero
{
didSet
{
contentEdgeInsets
=
contentInset
.
asEdgeInsets
}
}
/**
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
*/
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
contentEdgeInsetsPreset
=
.
none
super
.
init
(
coder
:
aDecoder
)
prepareView
()
}
...
...
@@ -336,7 +340,6 @@ public class Button: UIButton {
- Parameter frame: A CGRect instance.
*/
public
override
init
(
frame
:
CGRect
)
{
contentEdgeInsetsPreset
=
.
None
super
.
init
(
frame
:
frame
)
prepareView
()
}
...
...
@@ -360,7 +363,7 @@ public class Button: UIButton {
}
public
override
func
alignmentRectInsets
()
->
UIEdgeInsets
{
return
UIEdgeInset
sZ
ero
return
UIEdgeInset
.
z
ero
}
/**
...
...
@@ -473,13 +476,14 @@ public class Button: UIButton {
when subclassing.
*/
public
func
prepareView
()
{
contentScaleFactor
=
Device
.
scale
contentScaleFactor
=
Device
.
scale
prepareVisualLayer
()
}
/// Prepares the visualLayer property.
internal
func
prepareVisualLayer
()
{
visualLayer
.
zPosition
=
0
visualLayer
=
CAShapeLayer
()
visualLayer
.
zPosition
=
0
visualLayer
.
masksToBounds
=
true
layer
.
addSublayer
(
visualLayer
)
}
...
...
@@ -503,12 +507,12 @@ public class Button: UIButton {
/// Sets the shadow path.
internal
func
layoutShadowPath
()
{
if
shadowPathAutoSizeEnabled
{
if
.
None
==
depth
{
if
.
none
==
depthPreset
{
shadowPath
=
nil
}
else
if
nil
==
shadowPath
{
shadowPath
=
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
CG
Path
shadowPath
=
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cg
Path
}
else
{
animate
(
MaterialAnimation
.
shadowPath
(
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
CG
Path
,
duration
:
0
))
animate
(
animation
:
MaterialAnimation
.
shadowPath
(
path
:
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cg
Path
,
duration
:
0
))
}
}
}
...
...
Sources/iOS/Capture
View
.swift
→
Sources/iOS/Capture.swift
View file @
ac53a489
...
...
@@ -36,101 +36,101 @@ public enum CaptureMode {
case
video
}
@objc(Capture
View
Delegate)
public
protocol
Capture
View
Delegate
:
MaterialDelegate
{
@objc(CaptureDelegate)
public
protocol
CaptureDelegate
:
MaterialDelegate
{
/**
A delegation method that is fired when the record timer has started.
- Parameter capture
View: A reference to the calling captureView
.
- Parameter capture
: A reference to the calling capture
.
*/
@objc
optional
func
capture
ViewDidStartRecordTimer
(
captureView
:
CaptureView
)
optional
func
capture
DidStartRecordTimer
(
capture
:
Capture
)
/**
A delegation method that is fired when the record timer was updated.
- Parameter capture
View: A reference to the calling captureView
.
- Parameter capture
: A reference to the calling capture
.
- Parameter hours: An integer representing hours.
- Parameter minutes: An integer representing minutes.
- Parameter seconds: An integer representing seconds.
*/
@objc
optional
func
capture
ViewDidUpdateRecordTimer
(
captureView
:
CaptureView
,
hours
:
Int
,
minutes
:
Int
,
seconds
:
Int
)
optional
func
capture
DidUpdateRecordTimer
(
capture
:
Capture
,
hours
:
Int
,
minutes
:
Int
,
seconds
:
Int
)
/**
A delegation method that is fired when the record timer has stopped.
- Parameter capture
View: A reference to the calling captureView
.
- Parameter capture
: A reference to the calling capture
.
- Parameter hours: An integer representing hours.
- Parameter minutes: An integer representing minutes.
- Parameter seconds: An integer representing seconds.
*/
@objc
optional
func
capture
ViewDidStopRecordTimer
(
captureView
:
CaptureView
,
hours
:
Int
,
minutes
:
Int
,
seconds
:
Int
)
optional
func
capture
DidStopRecordTimer
(
capture
:
Capture
,
hours
:
Int
,
minutes
:
Int
,
seconds
:
Int
)
/**
A delegation method that is fired when the user tapped to adjust the focus.
- Parameter capture
View: A reference to the calling captureView
.
- Parameter capture
: A reference to the calling capture
.
- Parameter point: CGPoint that the user tapped at.
*/
@objc
optional
func
capture
ViewDidTapToFocusAtPoint
(
captureView
:
CaptureView
,
point
:
CGPoint
)
optional
func
capture
DidTapToFocusAtPoint
(
capture
:
Capture
,
point
:
CGPoint
)
/**
A delegation method that is fired when the user tapped to adjust the exposure.
- Parameter capture
View: A reference to the calling captureView
.
- Parameter capture
: A reference to the calling capture
.
- Parameter point: CGPoint that the user tapped at.
*/
@objc
optional
func
capture
ViewDidTapToExposeAtPoint
(
captureView
:
CaptureView
,
point
:
CGPoint
)
optional
func
capture
DidTapToExposeAtPoint
(
capture
:
Capture
,
point
:
CGPoint
)
/**
A delegation method that is fired when the user tapped to reset.
- Parameter capture
View: A reference to the calling captureView
.
- Parameter capture
: A reference to the calling capture
.
- Parameter point: CGPoint that the user tapped at.
*/
@objc
optional
func
capture
ViewDidTapToResetAtPoint
(
captureView
:
CaptureView
,
point
:
CGPoint
)
optional
func
capture
DidTapToResetAtPoint
(
capture
:
Capture
,
point
:
CGPoint
)
/**
A delegation method that is fired when the user pressed the flash button.
- Parameter capture
View: A reference to the calling captureView
.
- Parameter capture
: A reference to the calling capture
.
- Parameter button: A reference to the UIButton that the user pressed.
*/
@objc
optional
func
capture
ViewDidPressFlashButton
(
captureView
:
CaptureView
,
button
:
UIButton
)
optional
func
capture
DidPressFlashButton
(
capture
:
Capture
,
button
:
UIButton
)
/**
A delegation method that is fired when the user pressed the switch camera button.
- Parameter capture
View: A reference to the calling captureView
.
- Parameter capture
: A reference to the calling capture
.
- Parameter button: A reference to the UIButton that the user pressed.
*/
@objc
optional
func
capture
ViewDidPressSwitchCamerasButton
(
captureView
:
CaptureView
,
button
:
UIButton
)
optional
func
capture
DidPressSwitchCamerasButton
(
capture
:
Capture
,
button
:
UIButton
)
/**
A delegation method that is fired when the user pressed capture button.
- Parameter capture
View: A reference to the calling captureView
.
- Parameter capture
: A reference to the calling capture
.
- Parameter button: A reference to the UIButton that the user pressed.
*/
@objc
optional
func
capture
ViewDidPressCaptureButton
(
captureView
:
CaptureView
,
button
:
UIButton
)
optional
func
capture
DidPressCaptureButton
(
capture
:
Capture
,
button
:
UIButton
)
/**
A delegation method that is fired when the user enabled the photo camera.
- Parameter capture
View: A reference to the calling captureView
.
- Parameter capture
: A reference to the calling capture
.
- Parameter button: A reference to the UIButton that the user pressed.
*/
@objc
optional
func
capture
ViewDidPressCameraButton
(
captureView
:
CaptureView
,
button
:
UIButton
)
optional
func
capture
DidPressCameraButton
(
capture
:
Capture
,
button
:
UIButton
)
/**
A delegation method that is fired when the user enabled the video camera.
- Parameter capture
View: A reference to the calling captureView
.
- Parameter capture
: A reference to the calling capture
.
- Parameter button: A reference to the UIButton that the user pressed.
*/
@objc
optional
func
capture
ViewDidPressVideoButton
(
captureView
:
CaptureView
,
button
:
UIButton
)
optional
func
capture
DidPressVideoButton
(
capture
:
Capture
,
button
:
UIButton
)
}
public
class
Capture
View
:
View
,
UIGestureRecognizerDelegate
{
public
class
Capture
:
View
,
UIGestureRecognizerDelegate
{
/// A Timer reference for when recording is enabled.
private
var
timer
:
Timer
?
...
...
@@ -203,14 +203,14 @@ public class CaptureView : View, UIGestureRecognizerDelegate {
}
/// Insets preset value for content.
public
var
contentInsetPreset
:
Inset
s
Preset
=
.
none
{
public
var
contentInsetPreset
:
InsetPreset
=
.
none
{
didSet
{
contentInset
=
Inset
s
PresetToValue
(
preset
:
contentInsetPreset
)
contentInset
=
InsetPresetToValue
(
preset
:
contentInsetPreset
)
}
}
/// Content insert value.
public
var
contentInset
:
Inset
s
=
Insets
PresetToValue
(
preset
:
.
square4
)
{
public
var
contentInset
:
Inset
=
Inset
PresetToValue
(
preset
:
.
square4
)
{
didSet
{
reloadView
()
}
...
...
@@ -348,7 +348,7 @@ public class CaptureView : View, UIGestureRecognizerDelegate {
timer
?
.
invalidate
()
timer
=
Timer
(
timeInterval
:
0.5
,
target
:
self
,
selector
:
#selector(
updateTimer
)
,
userInfo
:
nil
,
repeats
:
true
)
RunLoop
.
main
()
.
add
(
timer
!
,
forMode
:
.
commonModes
)
(
delegate
as?
Capture
ViewDelegate
)?
.
captureViewDidStartRecordTimer
?(
captureView
:
self
)
(
delegate
as?
Capture
Delegate
)?
.
captureDidStartRecordTimer
?(
capture
:
self
)
}
/// Updates the timer when recording.
...
...
@@ -358,7 +358,7 @@ public class CaptureView : View, UIGestureRecognizerDelegate {
let
hours
:
Int
=
Int
(
time
/
3600
)
let
minutes
:
Int
=
Int
((
time
/
60
)
.
truncatingRemainder
(
dividingBy
:
60
))
let
seconds
:
Int
=
Int
(
time
.
truncatingRemainder
(
dividingBy
:
60
))
(
delegate
as?
Capture
ViewDelegate
)?
.
captureViewDidUpdateRecordTimer
?(
captureView
:
self
,
hours
:
hours
,
minutes
:
minutes
,
seconds
:
seconds
)
(
delegate
as?
Capture
Delegate
)?
.
captureDidUpdateRecordTimer
?(
capture
:
self
,
hours
:
hours
,
minutes
:
minutes
,
seconds
:
seconds
)
}
/// Stops the timer when recording.
...
...
@@ -370,7 +370,7 @@ public class CaptureView : View, UIGestureRecognizerDelegate {
let
seconds
:
Int
=
Int
(
time
.
truncatingRemainder
(
dividingBy
:
60
))
timer
?
.
invalidate
()
timer
=
nil
(
delegate
as?
Capture
ViewDelegate
)?
.
captureViewDidStopRecordTimer
?(
captureView
:
self
,
hours
:
hours
,
minutes
:
minutes
,
seconds
:
seconds
)
(
delegate
as?
Capture
Delegate
)?
.
captureDidStopRecordTimer
?(
capture
:
self
,
hours
:
hours
,
minutes
:
minutes
,
seconds
:
seconds
)
}
/**
...
...
@@ -378,7 +378,7 @@ public class CaptureView : View, UIGestureRecognizerDelegate {
- Parameter button: A UIButton that is associated with the event.
*/
internal
func
handleFlashButton
(
button
:
UIButton
)
{
(
delegate
as?
Capture
ViewDelegate
)?
.
captureViewDidPressFlashButton
?(
captureView
:
self
,
button
:
button
)
(
delegate
as?
Capture
Delegate
)?
.
captureDidPressFlashButton
?(
capture
:
self
,
button
:
button
)
}
/**
...
...
@@ -387,7 +387,7 @@ public class CaptureView : View, UIGestureRecognizerDelegate {
*/
internal
func
handleSwitchCamerasButton
(
button
:
UIButton
)
{
captureSession
.
switchCameras
()
(
delegate
as?
Capture
ViewDelegate
)?
.
captureViewDidPressSwitchCamerasButton
?(
captureView
:
self
,
button
:
button
)
(
delegate
as?
Capture
Delegate
)?
.
captureDidPressSwitchCamerasButton
?(
capture
:
self
,
button
:
button
)
}
/**
...
...
@@ -406,7 +406,7 @@ public class CaptureView : View, UIGestureRecognizerDelegate {
startTimer
()
}
}
(
delegate
as?
Capture
ViewDelegate
)?
.
captureViewDidPressCaptureButton
?(
captureView
:
self
,
button
:
button
)
(
delegate
as?
Capture
Delegate
)?
.
captureDidPressCaptureButton
?(
capture
:
self
,
button
:
button
)
}
/**
...
...
@@ -415,7 +415,7 @@ public class CaptureView : View, UIGestureRecognizerDelegate {
*/
internal
func
handleCameraButton
(
button
:
UIButton
)
{
captureMode
=
.
photo
(
delegate
as?
Capture
ViewDelegate
)?
.
captureViewDidPressCameraButton
?(
captureView
:
self
,
button
:
button
)
(
delegate
as?
Capture
Delegate
)?
.
captureDidPressCameraButton
?(
capture
:
self
,
button
:
button
)
}
/**
...
...
@@ -424,7 +424,7 @@ public class CaptureView : View, UIGestureRecognizerDelegate {
*/
internal
func
handleVideoButton
(
button
:
UIButton
)
{
captureMode
=
.
video
(
delegate
as?
Capture
ViewDelegate
)?
.
captureViewDidPressVideoButton
?(
captureView
:
self
,
button
:
button
)
(
delegate
as?
Capture
Delegate
)?
.
captureDidPressVideoButton
?(
capture
:
self
,
button
:
button
)
}
/**
...
...
@@ -437,7 +437,7 @@ public class CaptureView : View, UIGestureRecognizerDelegate {
let
point
:
CGPoint
=
recognizer
.
location
(
in
:
self
)
captureSession
.
focus
(
at
:
previewView
.
captureDevicePointOfInterestForPoint
(
point
:
point
))
animateTapLayer
(
layer
:
focusLayer
!
,
point
:
point
)
(
delegate
as?
Capture
ViewDelegate
)?
.
captureViewDidTapToFocusAtPoint
?(
captureView
:
self
,
point
:
point
)
(
delegate
as?
Capture
Delegate
)?
.
captureDidTapToFocusAtPoint
?(
capture
:
self
,
point
:
point
)
}
}
...
...
@@ -451,7 +451,7 @@ public class CaptureView : View, UIGestureRecognizerDelegate {
let
point
:
CGPoint
=
recognizer
.
location
(
in
:
self
)
captureSession
.
expose
(
at
:
previewView
.
captureDevicePointOfInterestForPoint
(
point
:
point
))
animateTapLayer
(
layer
:
exposureLayer
!
,
point
:
point
)
(
delegate
as?
Capture
ViewDelegate
)?
.
captureViewDidTapToExposeAtPoint
?(
captureView
:
self
,
point
:
point
)
(
delegate
as?
Capture
Delegate
)?
.
captureDidTapToExposeAtPoint
?(
capture
:
self
,
point
:
point
)
}
}
...
...
@@ -465,7 +465,7 @@ public class CaptureView : View, UIGestureRecognizerDelegate {
captureSession
.
reset
()
let
point
:
CGPoint
=
previewView
.
pointForCaptureDevicePointOfInterest
(
point
:
CGPoint
(
x
:
0.5
,
y
:
0.5
))
animateTapLayer
(
layer
:
resetLayer
!
,
point
:
point
)
(
delegate
as?
Capture
ViewDelegate
)?
.
captureViewDidTapToResetAtPoint
?(
captureView
:
self
,
point
:
point
)
(
delegate
as?
Capture
Delegate
)?
.
captureDidTapToResetAtPoint
?(
capture
:
self
,
point
:
point
)
}
}
...
...
Sources/iOS/CaptureSession.swift
View file @
ac53a489
...
...
@@ -274,7 +274,7 @@ public class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
var
userInfo
:
Dictionary
<
String
,
AnyObject
>
=
Dictionary
<
String
,
AnyObject
>
()
userInfo
[
NSLocalizedDescriptionKey
]
=
"[Material Error: Unsupported focusMode.]"
userInfo
[
NSLocalizedFailureReasonErrorKey
]
=
"[Material Error: Unsupported focusMode.]"
error
=
NSError
(
domain
:
"io.cosmicmind.Material.Capture
View
"
,
code
:
0001
,
userInfo
:
userInfo
)
error
=
NSError
(
domain
:
"io.cosmicmind.Material.Capture"
,
code
:
0001
,
userInfo
:
userInfo
)
userInfo
[
NSUnderlyingErrorKey
]
=
error
}
if
let
e
:
NSError
=
error
{
...
...
@@ -303,7 +303,7 @@ public class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
var
userInfo
:
Dictionary
<
String
,
AnyObject
>
=
Dictionary
<
String
,
AnyObject
>
()
userInfo
[
NSLocalizedDescriptionKey
]
=
"[Material Error: Unsupported flashMode.]"
userInfo
[
NSLocalizedFailureReasonErrorKey
]
=
"[Material Error: Unsupported flashMode.]"
error
=
NSError
(
domain
:
"io.cosmicmind.Material.Capture
View
"
,
code
:
0002
,
userInfo
:
userInfo
)
error
=
NSError
(
domain
:
"io.cosmicmind.Material.Capture"
,
code
:
0002
,
userInfo
:
userInfo
)
userInfo
[
NSUnderlyingErrorKey
]
=
error
}
if
let
e
:
NSError
=
error
{
...
...
@@ -332,7 +332,7 @@ public class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
var
userInfo
:
Dictionary
<
String
,
AnyObject
>
=
Dictionary
<
String
,
AnyObject
>
()
userInfo
[
NSLocalizedDescriptionKey
]
=
"[Material Error: Unsupported torchMode.]"
userInfo
[
NSLocalizedFailureReasonErrorKey
]
=
"[Material Error: Unsupported torchMode.]"
error
=
NSError
(
domain
:
"io.cosmicmind.Material.Capture
View
"
,
code
:
0003
,
userInfo
:
userInfo
)
error
=
NSError
(
domain
:
"io.cosmicmind.Material.Capture"
,
code
:
0003
,
userInfo
:
userInfo
)
userInfo
[
NSUnderlyingErrorKey
]
=
error
}
if
let
e
:
NSError
=
error
{
...
...
@@ -477,7 +477,7 @@ public class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
var
userInfo
:
Dictionary
<
String
,
AnyObject
>
=
Dictionary
<
String
,
AnyObject
>
()
userInfo
[
NSLocalizedDescriptionKey
]
=
"[Material Error: Unsupported focus.]"
userInfo
[
NSLocalizedFailureReasonErrorKey
]
=
"[Material Error: Unsupported focus.]"
error
=
NSError
(
domain
:
"io.cosmicmind.Material.Capture
View
"
,
code
:
0004
,
userInfo
:
userInfo
)
error
=
NSError
(
domain
:
"io.cosmicmind.Material.Capture"
,
code
:
0004
,
userInfo
:
userInfo
)
userInfo
[
NSUnderlyingErrorKey
]
=
error
}
if
let
e
:
NSError
=
error
{
...
...
@@ -508,7 +508,7 @@ public class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
var
userInfo
:
Dictionary
<
String
,
AnyObject
>
=
Dictionary
<
String
,
AnyObject
>
()
userInfo
[
NSLocalizedDescriptionKey
]
=
"[Material Error: Unsupported expose.]"
userInfo
[
NSLocalizedFailureReasonErrorKey
]
=
"[Material Error: Unsupported expose.]"
error
=
NSError
(
domain
:
"io.cosmicmind.Material.Capture
View
"
,
code
:
0005
,
userInfo
:
userInfo
)
error
=
NSError
(
domain
:
"io.cosmicmind.Material.Capture"
,
code
:
0005
,
userInfo
:
userInfo
)
userInfo
[
NSUnderlyingErrorKey
]
=
error
}
if
let
e
:
NSError
=
error
{
...
...
@@ -580,14 +580,14 @@ public class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
var
userInfo
:
Dictionary
<
String
,
AnyObject
>
=
Dictionary
<
String
,
AnyObject
>
()
userInfo
[
NSLocalizedDescriptionKey
]
=
"[Material Error: Cannot fix image orientation.]"
userInfo
[
NSLocalizedFailureReasonErrorKey
]
=
"[Material Error: Cannot fix image orientation.]"
captureError
=
NSError
(
domain
:
"io.cosmicmind.Material.Capture
View
"
,
code
:
0006
,
userInfo
:
userInfo
)
captureError
=
NSError
(
domain
:
"io.cosmicmind.Material.Capture"
,
code
:
0006
,
userInfo
:
userInfo
)
userInfo
[
NSUnderlyingErrorKey
]
=
error
}
}
else
{
var
userInfo
:
Dictionary
<
String
,
AnyObject
>
=
Dictionary
<
String
,
AnyObject
>
()
userInfo
[
NSLocalizedDescriptionKey
]
=
"[Material Error: Cannot capture image from data.]"
userInfo
[
NSLocalizedFailureReasonErrorKey
]
=
"[Material Error: Cannot capture image from data.]"
captureError
=
NSError
(
domain
:
"io.cosmicmind.Material.Capture
View
"
,
code
:
0007
,
userInfo
:
userInfo
)
captureError
=
NSError
(
domain
:
"io.cosmicmind.Material.Capture"
,
code
:
0007
,
userInfo
:
userInfo
)
userInfo
[
NSUnderlyingErrorKey
]
=
error
}
}
...
...
@@ -771,7 +771,7 @@ public class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
default
:
break
}
// Draw the underlying
CG
Image with the calculated transform.
// Draw the underlying
cg
Image with the calculated transform.
guard
let
context
=
CGContext
(
data
:
nil
,
width
:
Int
(
image
.
size
.
width
),
height
:
Int
(
image
.
size
.
height
),
bitsPerComponent
:
image
.
cgImage
!.
bitsPerComponent
,
bytesPerRow
:
0
,
space
:
image
.
cgImage
!.
colorSpace
!
,
bitmapInfo
:
image
.
cgImage
!.
bitmapInfo
.
rawValue
)
else
{
return
nil
}
...
...
Sources/iOS/Card
View
.swift
→
Sources/iOS/Card.swift
View file @
ac53a489
...
...
@@ -30,7 +30,7 @@
import
UIKit
public
class
Card
View
:
PulseView
{
public
class
Card
:
PulseView
{
/**
:name: dividerLayer
*/
...
...
@@ -57,16 +57,16 @@ public class CardView : PulseView {
/**
:name: dividerInsets
*/
public
var
dividerInsetPreset
:
Inset
s
Preset
=
.
none
{
public
var
dividerInsetPreset
:
InsetPreset
=
.
none
{
didSet
{
dividerInset
=
Inset
s
PresetToValue
(
preset
:
dividerInsetPreset
)
dividerInset
=
InsetPresetToValue
(
preset
:
dividerInsetPreset
)
}
}
/**
:name: dividerInset
*/
@IBInspectable
public
var
dividerInset
=
Inset
s
(
top
:
8
,
left
:
0
,
bottom
:
8
,
right
:
0
)
{
@IBInspectable
public
var
dividerInset
=
Inset
(
top
:
8
,
left
:
0
,
bottom
:
8
,
right
:
0
)
{
didSet
{
reloadView
()
}
...
...
@@ -75,16 +75,16 @@ public class CardView : PulseView {
/**
:name: contentInsets
*/
public
var
contentInsetPreset
:
Inset
s
Preset
=
.
square2
{
public
var
contentInsetPreset
:
InsetPreset
=
.
square2
{
didSet
{
contentInset
=
Inset
s
PresetToValue
(
preset
:
contentInsetPreset
)
contentInset
=
InsetPresetToValue
(
preset
:
contentInsetPreset
)
}
}
/**
:name: contentInset
*/
@IBInspectable
public
var
contentInset
=
Inset
s
PresetToValue
(
preset
:
.
square2
)
{
@IBInspectable
public
var
contentInset
=
InsetPresetToValue
(
preset
:
.
square2
)
{
didSet
{
reloadView
()
}
...
...
@@ -93,16 +93,16 @@ public class CardView : PulseView {
/**
:name: titleLabelInsets
*/
public
var
titleLabelInsetPreset
:
Inset
s
Preset
=
.
square2
{
public
var
titleLabelInsetPreset
:
InsetPreset
=
.
square2
{
didSet
{
titleLabelInset
=
Inset
s
PresetToValue
(
preset
:
titleLabelInsetPreset
)
titleLabelInset
=
InsetPresetToValue
(
preset
:
titleLabelInsetPreset
)
}
}
/**
:name: titleLabelInset
*/
@IBInspectable
public
var
titleLabelInset
=
Inset
s
PresetToValue
(
preset
:
.
square2
)
{
@IBInspectable
public
var
titleLabelInset
=
InsetPresetToValue
(
preset
:
.
square2
)
{
didSet
{
reloadView
()
}
...
...
@@ -120,16 +120,16 @@ public class CardView : PulseView {
/**
:name: contentViewInsets
*/
public
var
contentViewInsetPreset
:
Inset
s
Preset
=
.
square2
{
public
var
contentViewInsetPreset
:
InsetPreset
=
.
square2
{
didSet
{
contentViewInset
=
Inset
s
PresetToValue
(
preset
:
contentViewInsetPreset
)
contentViewInset
=
InsetPresetToValue
(
preset
:
contentViewInsetPreset
)
}
}
/**
:name: contentViewInset
*/
@IBInspectable
public
var
contentViewInset
=
Inset
s
PresetToValue
(
preset
:
.
square2
)
{
@IBInspectable
public
var
contentViewInset
=
InsetPresetToValue
(
preset
:
.
square2
)
{
didSet
{
reloadView
()
}
...
...
@@ -147,16 +147,16 @@ public class CardView : PulseView {
/**
:name: leftButtonsInsets
*/
public
var
leftButtonsInsetPreset
:
Inset
s
Preset
=
.
none
{
public
var
leftButtonsInsetPreset
:
InsetPreset
=
.
none
{
didSet
{
leftButtonsInset
=
Inset
s
PresetToValue
(
preset
:
leftButtonsInsetPreset
)
leftButtonsInset
=
InsetPresetToValue
(
preset
:
leftButtonsInsetPreset
)
}
}
/**
:name: leftButtonsInset
*/
@IBInspectable
public
var
leftButtonsInset
=
Inset
s
.
zero
{
@IBInspectable
public
var
leftButtonsInset
=
Inset
.
zero
{
didSet
{
reloadView
()
}
...
...
@@ -174,16 +174,16 @@ public class CardView : PulseView {
/**
:name: rightButtonsInsets
*/
public
var
rightButtonsInsetPreset
:
Inset
s
Preset
=
.
none
{
public
var
rightButtonsInsetPreset
:
InsetPreset
=
.
none
{
didSet
{
rightButtonsInset
=
Inset
s
PresetToValue
(
preset
:
rightButtonsInsetPreset
)
rightButtonsInset
=
InsetPresetToValue
(
preset
:
rightButtonsInsetPreset
)
}
}
/**
:name: rightButtonsInset
*/
@IBInspectable
public
var
rightButtonsInset
=
Inset
s
.
zero
{
@IBInspectable
public
var
rightButtonsInset
=
Inset
.
zero
{
didSet
{
reloadView
()
}
...
...
@@ -391,7 +391,7 @@ public class CardView : PulseView {
*/
public
override
func
prepareView
()
{
super
.
prepareView
()
depth
=
.
depth1
depth
Preset
=
.
depth1
dividerColor
=
Color
.
grey
.
lighten3
cornerRadiusPreset
=
.
Radius1
}
...
...
Sources/iOS/ControlView.swift
View file @
ac53a489
...
...
@@ -37,7 +37,7 @@ public class ControlView : View {
}
/// A preset wrapper around contentInset.
public
var
contentInsetPreset
:
Inset
s
Preset
{
public
var
contentInsetPreset
:
InsetPreset
{
get
{
return
grid
.
contentInsetPreset
}
...
...
@@ -47,7 +47,7 @@ public class ControlView : View {
}
/// A wrapper around grid.contentInset.
@IBInspectable
public
var
contentInset
:
Inset
s
{
@IBInspectable
public
var
contentInset
:
Inset
{
get
{
return
grid
.
contentInset
}
...
...
Sources/iOS/Depth.swift
View file @
ac53a489
...
...
@@ -49,6 +49,11 @@ public struct Depth {
/// Radius.
public
var
radius
:
CGFloat
/// Offset as size.
public
var
offsetAsSize
:
CGSize
{
return
CGSize
(
width
:
offset
.
horizontal
,
height
:
offset
.
vertical
)
}
/**
Initializer.
- Parameter offset: UIOffset.
...
...
Sources/iOS/ErrorTextField.swift
View file @
ac53a489
...
...
@@ -34,7 +34,7 @@ public class ErrorTextField : TextField {
/// Controls the visibility of detailLabel
@IBInspectable
public
var
revealError
:
Bool
=
false
{
didSet
{
detailLabel
.
h
idden
=
!
revealError
detailLabel
.
isH
idden
=
!
revealError
}
}
...
...
Sources/iOS/FabButton.swift
View file @
ac53a489
...
...
@@ -32,15 +32,15 @@ import UIKit
public
class
FabButton
:
Button
{
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
public
override
func
prepareView
()
{
super
.
prepareView
()
depth
=
.
depth1
depth
Preset
=
.
depth1
shape
=
.
Circle
pulseAnimation
=
.
CenterWithBacking
pulseColor
=
Color
.
white
...
...
Sources/iOS/FlatButton.swift
View file @
ac53a489
...
...
@@ -32,15 +32,15 @@ import UIKit
public
class
FlatButton
:
Button
{
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
public
override
func
prepareView
()
{
super
.
prepareView
()
cornerRadiusPreset
=
.
Radius1
content
EdgeInsetsPreset
=
.
W
ideRectangle3
content
InsetPreset
=
.
w
ideRectangle3
}
}
\ No newline at end of file
}
Sources/iOS/Grid.swift
View file @
ac53a489
...
...
@@ -129,28 +129,28 @@ public class Grid {
public
private(set)
var
axis
:
GridAxis
!
/// Preset inset value for grid.
public
var
layoutInset
sPreset
:
Insets
Preset
=
.
none
{
public
var
layoutInset
Preset
:
Inset
Preset
=
.
none
{
didSet
{
layoutInset
s
=
InsetsPresetToValue
(
preset
:
contentInsets
Preset
)
layoutInset
=
InsetPresetToValue
(
preset
:
contentInset
Preset
)
}
}
/// Insets value for grid.
public
var
layoutInset
s
:
Insets
=
InsetsPresetToValue
(
preset
:
.
none
)
{
public
var
layoutInset
=
Inset
.
zero
{
didSet
{
reload
()
}
}
/// Preset inset value for grid.
public
var
contentInset
sPreset
:
Insets
Preset
=
.
none
{
public
var
contentInset
Preset
:
Inset
Preset
=
.
none
{
didSet
{
contentInset
s
=
InsetsPresetToValue
(
preset
:
contentInsets
Preset
)
contentInset
=
InsetPresetToValue
(
preset
:
contentInset
Preset
)
}
}
/// Insets value for grid.
public
var
contentInset
s
:
Insets
=
Insets
PresetToValue
(
preset
:
.
none
)
{
public
var
contentInset
:
Inset
=
Inset
PresetToValue
(
preset
:
.
none
)
{
didSet
{
reload
()
}
...
...
@@ -208,34 +208,34 @@ public class Grid {
parent
.
layoutIfNeeded
()
switch
axis
.
direction
{
case
.
horizontal
:
let
w
:
CGFloat
=
(
parent
.
bounds
.
width
-
contentInsets
.
left
-
contentInsets
.
right
-
layoutInsets
.
left
-
layoutInsets
.
right
+
interimSpace
)
/
CGFloat
(
gc
)
let
c
:
Int
=
child
.
grid
.
columns
let
co
:
Int
=
child
.
grid
.
offset
.
columns
let
vh
:
CGFloat
=
parent
.
bounds
.
height
-
contentInsets
.
top
-
contentInsets
.
bottom
-
layoutInsets
.
top
-
layoutInsets
.
bottom
let
vl
:
CGFloat
=
CGFloat
(
i
+
n
+
co
)
*
w
+
contentInsets
.
left
+
layoutInsets
.
left
let
vw
:
CGFloat
=
w
*
CGFloat
(
c
)
-
interimSpace
child
.
frame
=
CGRect
(
x
:
vl
,
y
:
contentInset
s
.
top
+
layoutInsets
.
top
,
width
:
vw
,
height
:
vh
)
let
w
=
(
parent
.
bounds
.
width
-
contentInset
.
left
-
contentInset
.
right
-
layoutInset
.
left
-
layoutInset
.
right
+
interimSpace
)
/
CGFloat
(
gc
)
let
c
=
child
.
grid
.
columns
let
co
=
child
.
grid
.
offset
.
columns
let
vh
=
parent
.
bounds
.
height
-
contentInset
.
top
-
contentInset
.
bottom
-
layoutInset
.
top
-
layoutInset
.
bottom
let
vl
=
CGFloat
(
i
+
n
+
co
)
*
w
+
contentInset
.
left
+
layoutInset
.
left
let
vw
=
w
*
CGFloat
(
c
)
-
interimSpace
child
.
frame
=
CGRect
(
x
:
vl
,
y
:
contentInset
.
top
+
layoutInset
.
top
,
width
:
vw
,
height
:
vh
)
n
+=
c
+
co
-
1
case
.
vertical
:
let
h
:
CGFloat
=
(
parent
.
bounds
.
height
-
contentInsets
.
top
-
contentInsets
.
bottom
-
layoutInsets
.
top
-
layoutInsets
.
bottom
+
interimSpace
)
/
CGFloat
(
gr
)
let
r
:
Int
=
child
.
grid
.
rows
let
ro
:
Int
=
child
.
grid
.
offset
.
rows
let
vw
:
CGFloat
=
parent
.
bounds
.
width
-
contentInsets
.
left
-
contentInsets
.
right
-
layoutInsets
.
left
-
layoutInsets
.
right
let
vt
:
CGFloat
=
CGFloat
(
i
+
n
+
ro
)
*
h
+
contentInsets
.
top
+
layoutInsets
.
top
let
vh
:
CGFloat
=
h
*
CGFloat
(
r
)
-
interimSpace
child
.
frame
=
CGRect
(
x
:
contentInset
s
.
left
+
layoutInsets
.
left
,
y
:
vt
,
width
:
vw
,
height
:
vh
)
let
h
=
(
parent
.
bounds
.
height
-
contentInset
.
top
-
contentInset
.
bottom
-
layoutInset
.
top
-
layoutInset
.
bottom
+
interimSpace
)
/
CGFloat
(
gr
)
let
r
=
child
.
grid
.
rows
let
ro
=
child
.
grid
.
offset
.
rows
let
vw
=
parent
.
bounds
.
width
-
contentInset
.
left
-
contentInset
.
right
-
layoutInset
.
left
-
layoutInset
.
right
let
vt
=
CGFloat
(
i
+
n
+
ro
)
*
h
+
contentInset
.
top
+
layoutInset
.
top
let
vh
=
h
*
CGFloat
(
r
)
-
interimSpace
child
.
frame
=
CGRect
(
x
:
contentInset
.
left
+
layoutInset
.
left
,
y
:
vt
,
width
:
vw
,
height
:
vh
)
n
+=
r
+
ro
-
1
case
.
none
:
let
w
:
CGFloat
=
(
parent
.
bounds
.
width
-
contentInsets
.
left
-
contentInsets
.
right
-
layoutInsets
.
left
-
layoutInsets
.
right
+
interimSpace
)
/
CGFloat
(
gc
)
let
c
:
Int
=
child
.
grid
.
columns
let
co
:
Int
=
child
.
grid
.
offset
.
columns
let
h
:
CGFloat
=
(
parent
.
bounds
.
height
-
contentInsets
.
top
-
contentInsets
.
bottom
-
layoutInsets
.
top
-
layoutInsets
.
bottom
+
interimSpace
)
/
CGFloat
(
gr
)
let
r
:
Int
=
child
.
grid
.
rows
let
ro
:
Int
=
child
.
grid
.
offset
.
rows
let
vt
:
CGFloat
=
CGFloat
(
ro
)
*
h
+
contentInsets
.
top
+
layoutInsets
.
top
let
vl
:
CGFloat
=
CGFloat
(
co
)
*
w
+
contentInsets
.
left
+
layoutInsets
.
left
let
vh
:
CGFloat
=
h
*
CGFloat
(
r
)
-
interimSpace
let
vw
:
CGFloat
=
w
*
CGFloat
(
c
)
-
interimSpace
let
w
=
(
parent
.
bounds
.
width
-
contentInset
.
left
-
contentInset
.
right
-
layoutInset
.
left
-
layoutInset
.
right
+
interimSpace
)
/
CGFloat
(
gc
)
let
c
=
child
.
grid
.
columns
let
co
=
child
.
grid
.
offset
.
columns
let
h
=
(
parent
.
bounds
.
height
-
contentInset
.
top
-
contentInset
.
bottom
-
layoutInset
.
top
-
layoutInset
.
bottom
+
interimSpace
)
/
CGFloat
(
gr
)
let
r
=
child
.
grid
.
rows
let
ro
=
child
.
grid
.
offset
.
rows
let
vt
=
CGFloat
(
ro
)
*
h
+
contentInset
.
top
+
layoutInset
.
top
let
vl
=
CGFloat
(
co
)
*
w
+
contentInset
.
left
+
layoutInset
.
left
let
vh
=
h
*
CGFloat
(
r
)
-
interimSpace
let
vw
=
w
*
CGFloat
(
c
)
-
interimSpace
child
.
frame
=
CGRect
(
x
:
vl
,
y
:
vt
,
width
:
vw
,
height
:
vh
)
}
}
...
...
Sources/iOS/IconButton.swift
View file @
ac53a489
...
...
@@ -32,16 +32,15 @@ import UIKit
public
class
IconButton
:
Button
{
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
public
override
func
prepareView
()
{
super
.
prepareView
()
cornerRadiusPreset
=
.
Radius1
contentEdgeInsetsPreset
=
.
WideRectangle3
pulseAnimation
=
.
Center
}
}
\ No newline at end of file
}
Sources/iOS/ImageCard
View
.swift
→
Sources/iOS/ImageCard.swift
View file @
ac53a489
...
...
@@ -30,7 +30,7 @@
import
UIKit
public
class
ImageCard
View
:
PulseView
{
public
class
ImageCard
:
PulseView
{
/**
:name: dividerLayer
*/
...
...
@@ -41,7 +41,7 @@ public class ImageCardView : PulseView {
*/
@IBInspectable
public
var
dividerColor
:
UIColor
?
{
didSet
{
dividerLayer
?
.
backgroundColor
=
dividerColor
?
.
CG
Color
dividerLayer
?
.
backgroundColor
=
dividerColor
?
.
cg
Color
}
}
...
...
@@ -57,16 +57,16 @@ public class ImageCardView : PulseView {
/**
:name: dividerInsets
*/
public
var
dividerInsetPreset
:
Inset
s
Preset
=
.
none
{
public
var
dividerInsetPreset
:
InsetPreset
=
.
none
{
didSet
{
dividerInset
=
Inset
s
PresetToValue
(
preset
:
dividerInsetPreset
)
dividerInset
=
InsetPresetToValue
(
preset
:
dividerInsetPreset
)
}
}
/**
:name: dividerInset
*/
@IBInspectable
public
var
dividerInset
=
Inset
s
(
top
:
8
,
left
:
0
,
bottom
:
8
,
right
:
0
)
{
@IBInspectable
public
var
dividerInset
=
Inset
(
top
:
8
,
left
:
0
,
bottom
:
8
,
right
:
0
)
{
didSet
{
reloadView
()
}
...
...
@@ -82,23 +82,23 @@ public class ImageCardView : PulseView {
*/
@IBInspectable
public
override
var
image
:
UIImage
?
{
get
{
return
nil
==
imageLayer
?
.
contents
?
nil
:
UIImage
(
CG
Image
:
imageLayer
?
.
contents
as!
CGImage
)
return
nil
==
imageLayer
?
.
contents
?
nil
:
UIImage
(
cg
Image
:
imageLayer
?
.
contents
as!
CGImage
)
}
set
(
value
)
{
if
let
v
=
value
{
prepareImageLayer
()
imageLayer
?
.
contents
=
v
.
CG
Image
imageLayer
?
.
contents
=
v
.
cg
Image
if
0
==
maxImageHeight
{
imageLayer
?
.
frame
.
size
.
height
=
image
!.
size
.
height
/
contentsScale
}
else
{
let
h
:
CGFloat
=
image
!.
size
.
height
/
contentsScale
imageLayer
?
.
frame
.
size
.
height
=
maxImageHeight
<
h
?
maxImageHeight
:
h
}
imageLayer
?
.
h
idden
=
false
imageLayer
?
.
isH
idden
=
false
}
else
{
imageLayer
?
.
contents
=
nil
imageLayer
?
.
frame
=
CGRect
.
zero
imageLayer
?
.
h
idden
=
true
imageLayer
?
.
isH
idden
=
true
imageLayer
?
.
removeFromSuperlayer
()
}
reloadView
()
...
...
@@ -168,16 +168,16 @@ public class ImageCardView : PulseView {
/**
:name: contentInsets
*/
public
var
contentInsetPreset
:
Inset
s
Preset
=
.
square2
{
public
var
contentInsetPreset
:
InsetPreset
=
.
square2
{
didSet
{
contentInset
=
Inset
s
PresetToValue
(
preset
:
contentInsetPreset
)
contentInset
=
InsetPresetToValue
(
preset
:
contentInsetPreset
)
}
}
/**
:name: contentInset
*/
@IBInspectable
public
var
contentInset
=
Inset
s
PresetToValue
(
preset
:
.
square2
)
{
@IBInspectable
public
var
contentInset
=
InsetPresetToValue
(
preset
:
.
square2
)
{
didSet
{
reloadView
()
}
...
...
@@ -186,16 +186,16 @@ public class ImageCardView : PulseView {
/**
:name: titleLabelInsets
*/
public
var
titleLabelInsetPreset
:
Inset
s
Preset
=
.
square2
{
public
var
titleLabelInsetPreset
:
InsetPreset
=
.
square2
{
didSet
{
titleLabelInset
=
Inset
s
PresetToValue
(
preset
:
titleLabelInsetPreset
)
titleLabelInset
=
InsetPresetToValue
(
preset
:
titleLabelInsetPreset
)
}
}
/**
:name: titleLabelInset
*/
@IBInspectable
public
var
titleLabelInset
=
Inset
s
PresetToValue
(
preset
:
.
square2
)
{
@IBInspectable
public
var
titleLabelInset
=
InsetPresetToValue
(
preset
:
.
square2
)
{
didSet
{
reloadView
()
}
...
...
@@ -213,16 +213,16 @@ public class ImageCardView : PulseView {
/**
:name: contentViewInsets
*/
public
var
contentViewInsetPreset
:
Inset
s
Preset
=
.
square2
{
public
var
contentViewInsetPreset
:
InsetPreset
=
.
square2
{
didSet
{
contentViewInset
=
Inset
s
PresetToValue
(
preset
:
contentViewInsetPreset
)
contentViewInset
=
InsetPresetToValue
(
preset
:
contentViewInsetPreset
)
}
}
/**
:name: contentViewInset
*/
@IBInspectable
public
var
contentViewInset
=
Inset
s
PresetToValue
(
preset
:
.
square2
)
{
@IBInspectable
public
var
contentViewInset
=
InsetPresetToValue
(
preset
:
.
square2
)
{
didSet
{
reloadView
()
}
...
...
@@ -240,16 +240,16 @@ public class ImageCardView : PulseView {
/**
:name: leftButtonsInsets
*/
public
var
leftButtonsInsetPreset
:
Inset
s
Preset
=
.
none
{
public
var
leftButtonsInsetPreset
:
InsetPreset
=
.
none
{
didSet
{
leftButtonsInset
=
Inset
s
PresetToValue
(
preset
:
leftButtonsInsetPreset
)
leftButtonsInset
=
InsetPresetToValue
(
preset
:
leftButtonsInsetPreset
)
}
}
/**
:name: leftButtonsInset
*/
@IBInspectable
public
var
leftButtonsInset
=
Inset
s
.
zero
{
@IBInspectable
public
var
leftButtonsInset
=
Inset
.
zero
{
didSet
{
reloadView
()
}
...
...
@@ -267,16 +267,16 @@ public class ImageCardView : PulseView {
/**
:name: rightButtonsInsets
*/
public
var
rightButtonsInsetPreset
:
Inset
s
Preset
=
.
none
{
public
var
rightButtonsInsetPreset
:
InsetPreset
=
.
none
{
didSet
{
rightButtonsInset
=
Inset
s
PresetToValue
(
preset
:
rightButtonsInsetPreset
)
rightButtonsInset
=
InsetPresetToValue
(
preset
:
rightButtonsInsetPreset
)
}
}
/**
:name: rightButtonsInset
*/
@IBInspectable
public
var
rightButtonsInset
=
Inset
s
.
zero
{
@IBInspectable
public
var
rightButtonsInset
=
Inset
.
zero
{
didSet
{
reloadView
()
}
...
...
@@ -532,7 +532,7 @@ public class ImageCardView : PulseView {
*/
public
override
func
prepareView
()
{
super
.
prepareView
()
depth
=
.
depth1
depth
Preset
=
.
depth1
dividerColor
=
Color
.
grey
.
lighten3
cornerRadiusPreset
=
.
Radius1
}
...
...
Sources/iOS/Insets.swift
View file @
ac53a489
...
...
@@ -32,7 +32,7 @@ import UIKit
import
UIKit
public
enum
Inset
s
Preset
{
public
enum
InsetPreset
{
case
none
// square
...
...
@@ -69,7 +69,7 @@ public enum InsetsPreset {
case
tallRectangle9
}
public
struct
Inset
s
{
public
struct
Inset
{
/// Top inset.
public
var
top
:
CGFloat
...
...
@@ -82,6 +82,10 @@ public struct Insets {
/// Right inset.
public
var
right
:
CGFloat
public
var
asEdgeInsets
:
UIEdgeInsets
{
return
UIEdgeInsets
(
top
:
top
,
left
:
left
,
bottom
:
bottom
,
right
:
right
)
}
/**
Initializer.
- Parameter top: Top inset.
...
...
@@ -97,78 +101,78 @@ public struct Insets {
}
/**
Static constructor for Inset
s
with values of 0.
- Returns: An Inset
s
struct with values of 0.
Static constructor for Inset with values of 0.
- Returns: An Inset struct with values of 0.
*/
static
var
zero
:
Inset
s
{
return
Inset
s
()
static
var
zero
:
Inset
{
return
Inset
()
}
}
/// Converts the Inset
sPreset to a Insets
value.
public
func
Inset
sPresetToValue
(
preset
:
InsetsPreset
)
->
Insets
{
/// Converts the Inset
Preset to a Inset
value.
public
func
Inset
PresetToValue
(
preset
:
InsetPreset
)
->
Inset
{
switch
preset
{
case
.
none
:
return
Inset
s
.
zero
return
Inset
.
zero
// square
case
.
square1
:
return
Inset
s
(
top
:
4
,
left
:
4
,
bottom
:
4
,
right
:
4
)
return
Inset
(
top
:
4
,
left
:
4
,
bottom
:
4
,
right
:
4
)
case
.
square2
:
return
Inset
s
(
top
:
8
,
left
:
8
,
bottom
:
8
,
right
:
8
)
return
Inset
(
top
:
8
,
left
:
8
,
bottom
:
8
,
right
:
8
)
case
.
square3
:
return
Inset
s
(
top
:
16
,
left
:
16
,
bottom
:
16
,
right
:
16
)
return
Inset
(
top
:
16
,
left
:
16
,
bottom
:
16
,
right
:
16
)
case
.
square4
:
return
Inset
s
(
top
:
24
,
left
:
24
,
bottom
:
24
,
right
:
24
)
return
Inset
(
top
:
24
,
left
:
24
,
bottom
:
24
,
right
:
24
)
case
.
square5
:
return
Inset
s
(
top
:
32
,
left
:
32
,
bottom
:
32
,
right
:
32
)
return
Inset
(
top
:
32
,
left
:
32
,
bottom
:
32
,
right
:
32
)
case
.
square6
:
return
Inset
s
(
top
:
40
,
left
:
40
,
bottom
:
40
,
right
:
40
)
return
Inset
(
top
:
40
,
left
:
40
,
bottom
:
40
,
right
:
40
)
case
.
square7
:
return
Inset
s
(
top
:
48
,
left
:
48
,
bottom
:
48
,
right
:
48
)
return
Inset
(
top
:
48
,
left
:
48
,
bottom
:
48
,
right
:
48
)
case
.
square8
:
return
Inset
s
(
top
:
56
,
left
:
56
,
bottom
:
56
,
right
:
56
)
return
Inset
(
top
:
56
,
left
:
56
,
bottom
:
56
,
right
:
56
)
case
.
square9
:
return
Inset
s
(
top
:
64
,
left
:
64
,
bottom
:
64
,
right
:
64
)
return
Inset
(
top
:
64
,
left
:
64
,
bottom
:
64
,
right
:
64
)
// rectangle
case
.
wideRectangle1
:
return
Inset
s
(
top
:
2
,
left
:
4
,
bottom
:
2
,
right
:
4
)
return
Inset
(
top
:
2
,
left
:
4
,
bottom
:
2
,
right
:
4
)
case
.
wideRectangle2
:
return
Inset
s
(
top
:
4
,
left
:
8
,
bottom
:
4
,
right
:
8
)
return
Inset
(
top
:
4
,
left
:
8
,
bottom
:
4
,
right
:
8
)
case
.
wideRectangle3
:
return
Inset
s
(
top
:
8
,
left
:
16
,
bottom
:
8
,
right
:
16
)
return
Inset
(
top
:
8
,
left
:
16
,
bottom
:
8
,
right
:
16
)
case
.
wideRectangle4
:
return
Inset
s
(
top
:
12
,
left
:
24
,
bottom
:
12
,
right
:
24
)
return
Inset
(
top
:
12
,
left
:
24
,
bottom
:
12
,
right
:
24
)
case
.
wideRectangle5
:
return
Inset
s
(
top
:
16
,
left
:
32
,
bottom
:
16
,
right
:
32
)
return
Inset
(
top
:
16
,
left
:
32
,
bottom
:
16
,
right
:
32
)
case
.
wideRectangle6
:
return
Inset
s
(
top
:
20
,
left
:
40
,
bottom
:
20
,
right
:
40
)
return
Inset
(
top
:
20
,
left
:
40
,
bottom
:
20
,
right
:
40
)
case
.
wideRectangle7
:
return
Inset
s
(
top
:
24
,
left
:
48
,
bottom
:
24
,
right
:
48
)
return
Inset
(
top
:
24
,
left
:
48
,
bottom
:
24
,
right
:
48
)
case
.
wideRectangle8
:
return
Inset
s
(
top
:
28
,
left
:
56
,
bottom
:
28
,
right
:
56
)
return
Inset
(
top
:
28
,
left
:
56
,
bottom
:
28
,
right
:
56
)
case
.
wideRectangle9
:
return
Inset
s
(
top
:
32
,
left
:
64
,
bottom
:
32
,
right
:
64
)
return
Inset
(
top
:
32
,
left
:
64
,
bottom
:
32
,
right
:
64
)
// flipped rectangle
case
.
tallRectangle1
:
return
Inset
s
(
top
:
4
,
left
:
2
,
bottom
:
4
,
right
:
2
)
return
Inset
(
top
:
4
,
left
:
2
,
bottom
:
4
,
right
:
2
)
case
.
tallRectangle2
:
return
Inset
s
(
top
:
8
,
left
:
4
,
bottom
:
8
,
right
:
4
)
return
Inset
(
top
:
8
,
left
:
4
,
bottom
:
8
,
right
:
4
)
case
.
tallRectangle3
:
return
Inset
s
(
top
:
16
,
left
:
8
,
bottom
:
16
,
right
:
8
)
return
Inset
(
top
:
16
,
left
:
8
,
bottom
:
16
,
right
:
8
)
case
.
tallRectangle4
:
return
Inset
s
(
top
:
24
,
left
:
12
,
bottom
:
24
,
right
:
12
)
return
Inset
(
top
:
24
,
left
:
12
,
bottom
:
24
,
right
:
12
)
case
.
tallRectangle5
:
return
Inset
s
(
top
:
32
,
left
:
16
,
bottom
:
32
,
right
:
16
)
return
Inset
(
top
:
32
,
left
:
16
,
bottom
:
32
,
right
:
16
)
case
.
tallRectangle6
:
return
Inset
s
(
top
:
40
,
left
:
20
,
bottom
:
40
,
right
:
20
)
return
Inset
(
top
:
40
,
left
:
20
,
bottom
:
40
,
right
:
20
)
case
.
tallRectangle7
:
return
Inset
s
(
top
:
48
,
left
:
24
,
bottom
:
48
,
right
:
24
)
return
Inset
(
top
:
48
,
left
:
24
,
bottom
:
48
,
right
:
24
)
case
.
tallRectangle8
:
return
Inset
s
(
top
:
56
,
left
:
28
,
bottom
:
56
,
right
:
28
)
return
Inset
(
top
:
56
,
left
:
28
,
bottom
:
56
,
right
:
28
)
case
.
tallRectangle9
:
return
Inset
s
(
top
:
64
,
left
:
32
,
bottom
:
64
,
right
:
32
)
return
Inset
(
top
:
64
,
left
:
32
,
bottom
:
64
,
right
:
32
)
}
}
Sources/iOS/Material+UIImage+FilterBlur.swift
View file @
ac53a489
...
...
@@ -61,7 +61,7 @@ public extension UIImage {
let
effectInContext
:
CGContext
=
UIGraphicsGetCurrentContext
()
!
CGContextScaleCTM
(
effectInContext
,
1.0
,
-
1.0
)
CGContextTranslateCTM
(
effectInContext
,
0
,
-
size
.
height
)
CGContextDrawImage
(
effectInContext
,
imageRect
,
self
.
CG
Image
)
CGContextDrawImage
(
effectInContext
,
imageRect
,
self
.
cg
Image
)
var
effectInBuffer
:
vImage_Buffer
=
createEffectBuffer
(
effectInContext
)
UIGraphicsBeginImageContextWithOptions
(
size
,
false
,
screenScale
)
...
...
@@ -129,12 +129,12 @@ public extension UIImage {
CGContextTranslateCTM
(
outputContext
,
0
,
-
size
.
height
)
// Draw base image.
CGContextDrawImage
(
outputContext
,
imageRect
,
self
.
CG
Image
)
CGContextDrawImage
(
outputContext
,
imageRect
,
self
.
cg
Image
)
// Draw effect image.
if
hasBlur
{
CGContextSaveGState
(
outputContext
)
CGContextDrawImage
(
outputContext
,
imageRect
,
effectImage
.
CG
Image
)
CGContextDrawImage
(
outputContext
,
imageRect
,
effectImage
.
cg
Image
)
CGContextRestoreGState
(
outputContext
)
}
...
...
Sources/iOS/Material+UIImage+TintColor.swift
View file @
ac53a489
...
...
@@ -46,7 +46,7 @@ public extension UIImage {
CGContextSetBlendMode
(
context
,
.
Multiply
)
let
rect
=
CGRectMake
(
0
,
0
,
size
.
width
,
size
.
height
)
CGContextClipToMask
(
context
,
rect
,
CG
Image
)
CGContextClipToMask
(
context
,
rect
,
cg
Image
)
color
.
setFill
()
CGContextFillRect
(
context
,
rect
)
...
...
Sources/iOS/MaterialCollectionReusableView.swift
View file @
ac53a489
...
...
@@ -69,7 +69,7 @@ public class MaterialCollectionReusableView : UICollectionReusableView {
*/
@IBInspectable
public
var
image
:
UIImage
?
{
didSet
{
visualLayer
.
contents
=
image
?
.
CG
Image
visualLayer
.
contents
=
image
?
.
cg
Image
}
}
...
...
Sources/iOS/MaterialCollectionViewCell.swift
View file @
ac53a489
...
...
@@ -69,7 +69,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
*/
@IBInspectable
public
var
image
:
UIImage
?
{
didSet
{
visualLayer
.
contents
=
image
?
.
CG
Image
visualLayer
.
contents
=
image
?
.
cg
Image
}
}
...
...
@@ -133,7 +133,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
}
/// A preset wrapper around contentInset.
public
var
contentInsetPreset
:
Inset
s
{
public
var
contentInsetPreset
:
Inset
Preset
{
get
{
return
contentView
.
grid
.
contentInsetPreset
}
...
...
Sources/iOS/MaterialCollectionViewLayout.swift
View file @
ac53a489
...
...
@@ -38,14 +38,14 @@ public class MaterialCollectionViewLayout : UICollectionViewLayout {
public
var
itemSize
:
CGSize
=
CGSize
.
zero
/// A preset wrapper around contentInset.
public
var
contentInsetPreset
:
Inset
s
Preset
=
.
none
{
public
var
contentInsetPreset
:
InsetPreset
=
.
none
{
didSet
{
contentInset
=
Inset
s
PresetToValue
(
preset
:
contentInsetPreset
)
contentInset
=
InsetPresetToValue
(
preset
:
contentInsetPreset
)
}
}
/// A wrapper around grid.contentInset.
public
var
contentInset
=
Inset
s
.
zero
public
var
contentInset
=
Inset
.
zero
/// Size of the content.
public
private(set)
var
contentSize
:
CGSize
=
CGSize
.
zero
...
...
Sources/iOS/Menu.swift
View file @
ac53a489
...
...
@@ -176,7 +176,7 @@ public class Menu {
base
=
v
[
0
]
}
let
view
:
UIView
=
v
[
i
]
view
.
h
idden
=
false
view
.
isH
idden
=
false
UIView
.
animateWithDuration
(
Double
(
i
)
*
duration
,
delay
:
delay
,
...
...
@@ -230,7 +230,7 @@ public class Menu {
}
})
{
[
weak
self
]
_
in
if
let
s
:
Menu
=
self
{
view
.
h
idden
=
true
view
.
isH
idden
=
true
s
.
enable
(
view
)
if
view
==
v
.
last
{
s
.
opened
=
false
...
...
@@ -261,7 +261,7 @@ public class Menu {
}
let
view
:
UIView
=
v
[
i
]
view
.
h
idden
=
false
view
.
isH
idden
=
false
let
h
:
CGFloat
=
nil
==
baseSize
?
itemSize
.
height
:
baseSize
!.
height
UIView
.
animateWithDuration
(
Double
(
i
)
*
duration
,
...
...
@@ -317,7 +317,7 @@ public class Menu {
}
})
{
[
weak
self
]
_
in
if
let
s
:
Menu
=
self
{
view
.
h
idden
=
true
view
.
isH
idden
=
true
s
.
enable
(
view
)
if
view
==
v
.
last
{
s
.
opened
=
false
...
...
@@ -348,7 +348,7 @@ public class Menu {
}
let
view
:
UIView
=
v
[
i
]
view
.
h
idden
=
false
view
.
isH
idden
=
false
UIView
.
animateWithDuration
(
Double
(
i
)
*
duration
,
delay
:
delay
,
...
...
@@ -401,7 +401,7 @@ public class Menu {
}
})
{
[
weak
self
]
_
in
if
let
s
:
Menu
=
self
{
view
.
h
idden
=
true
view
.
isH
idden
=
true
s
.
enable
(
view
)
if
view
==
v
.
last
{
s
.
opened
=
false
...
...
@@ -431,7 +431,7 @@ public class Menu {
base
=
v
[
0
]
}
let
view
:
UIView
=
v
[
i
]
view
.
h
idden
=
false
view
.
isH
idden
=
false
let
h
:
CGFloat
=
nil
==
baseSize
?
itemSize
.
height
:
baseSize
!.
height
UIView
.
animateWithDuration
(
Double
(
i
)
*
duration
,
...
...
@@ -487,7 +487,7 @@ public class Menu {
}
})
{
[
weak
self
]
_
in
if
let
s
:
Menu
=
self
{
view
.
h
idden
=
true
view
.
isH
idden
=
true
s
.
enable
(
view
)
if
view
==
v
.
last
{
s
.
opened
=
false
...
...
@@ -511,7 +511,7 @@ public class Menu {
view
.
layer
.
zPosition
=
10000
}
else
{
view
.
alpha
=
0
view
.
h
idden
=
true
view
.
isH
idden
=
true
view
.
frame
.
size
=
itemSize
view
.
frame
.
origin
.
x
=
origin
.
x
+
(
size
.
width
-
itemSize
.
width
)
/
2
view
.
frame
.
origin
.
y
=
origin
.
y
+
(
size
.
height
-
itemSize
.
height
)
/
2
...
...
Sources/iOS/NavigationBar.swift
View file @
ac53a489
...
...
@@ -62,14 +62,14 @@ public class NavigationBar : UINavigationBar {
}
/// A preset wrapper around contentInset.
public
var
contentInsetPreset
:
Inset
s
Preset
=
.
none
{
public
var
contentInsetPreset
:
InsetPreset
=
.
none
{
didSet
{
contentInset
=
Inset
s
PresetToValue
(
preset
:
contentInsetPreset
)
contentInset
=
InsetPresetToValue
(
preset
:
contentInsetPreset
)
}
}
/// A wrapper around grid.contentInset.
@IBInspectable
public
var
contentInset
:
Insets
=
Inset
s
.
zero
{
@IBInspectable
public
var
contentInset
:
Insets
=
Inset
.
zero
{
didSet
{
layoutSubviews
()
}
...
...
Sources/iOS/NavigationDrawerController.swift
View file @
ac53a489
...
...
@@ -894,7 +894,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
leftView
!.
backgroundColor
=
Color
.
clear
view
.
addSubview
(
leftView
!
)
leftView
!.
h
idden
=
true
leftView
!.
isH
idden
=
true
leftView
!.
position
.
x
=
-
leftViewWidth
/
2
leftView
!.
zPosition
=
2000
prepareLeftViewController
()
...
...
@@ -914,7 +914,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
rightView
!.
backgroundColor
=
Color
.
clear
view
.
addSubview
(
rightView
!
)
rightView
!.
h
idden
=
true
rightView
!.
isH
idden
=
true
rightView
!.
position
.
x
=
view
.
bounds
.
width
+
rightViewWidth
/
2
rightView
!.
zPosition
=
2000
prepareRightViewController
()
...
...
@@ -1090,7 +1090,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
*/
private
func
showView
(
container
:
View
)
{
container
.
depth
=
depth
container
.
h
idden
=
false
container
.
isH
idden
=
false
}
/**
...
...
@@ -1099,6 +1099,6 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
*/
private
func
hideView
(
container
:
View
)
{
container
.
depth
=
.
None
container
.
h
idden
=
true
container
.
isH
idden
=
true
}
}
Sources/iOS/RaisedButton.swift
View file @
ac53a489
...
...
@@ -32,17 +32,17 @@ import UIKit
public
class
RaisedButton
:
Button
{
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
public
override
func
prepareView
()
{
super
.
prepareView
()
depth
=
.
depth1
depth
Preset
=
.
depth1
cornerRadiusPreset
=
.
Radius1
content
EdgeInsetsPreset
=
.
W
ideRectangle3
content
InsetPreset
=
.
w
ideRectangle3
backgroundColor
=
Color
.
white
}
}
Sources/iOS/StatusBarController.swift
View file @
ac53a489
...
...
@@ -60,7 +60,7 @@ public class StatusBarController : RootController {
*/
public
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
statusBarView
.
h
idden
=
Device
.
isLandscape
&&
.
phone
==
Device
.
userInterfaceIdiom
statusBarView
.
isH
idden
=
Device
.
isLandscape
&&
.
phone
==
Device
.
userInterfaceIdiom
rootViewController
.
view
.
frame
=
view
.
bounds
}
...
...
Sources/iOS/TextView.swift
View file @
ac53a489
...
...
@@ -286,9 +286,9 @@ public class TextView: UITextView {
Text container UIEdgeInset preset property. This updates the
textContainerInset property with a preset value.
*/
public
var
textContainerInsetPreset
:
Inset
s
Preset
=
.
none
{
public
var
textContainerInsetPreset
:
InsetPreset
=
.
none
{
didSet
{
textContainerInset
=
Inset
s
PresetToValue
(
preset
:
textContainerInsetPreset
)
textContainerInset
=
InsetPresetToValue
(
preset
:
textContainerInsetPreset
)
}
}
...
...
@@ -417,7 +417,7 @@ public class TextView: UITextView {
/// Notification handler for when text changed.
internal
func
handleTextViewTextDidChange
()
{
if
let
p
=
placeholderLabel
{
p
.
h
idden
=
!
(
true
==
text
?
.
isEmpty
)
p
.
isH
idden
=
!
(
true
==
text
?
.
isEmpty
)
}
if
0
<
text
?
.
utf16
.
count
{
...
...
@@ -459,7 +459,7 @@ public class TextView: UITextView {
*/
public
func
prepareView
()
{
contentScaleFactor
=
Device
.
scale
textContainerInset
=
Inset
s
.
zero
textContainerInset
=
Inset
.
zero
backgroundColor
=
Color
.
white
masksToBounds
=
false
removeNotificationHandlers
()
...
...
@@ -483,7 +483,7 @@ public class TextView: UITextView {
/// Prepares the titleLabel property.
private
func
prepareTitleLabel
()
{
if
let
v
:
UILabel
=
titleLabel
{
v
.
h
idden
=
true
v
.
isH
idden
=
true
addSubview
(
v
)
if
0
<
text
?
.
utf16
.
count
{
showTitleLabel
()
...
...
@@ -496,13 +496,13 @@ public class TextView: UITextView {
/// Shows and animates the titleLabel property.
private
func
showTitleLabel
()
{
if
let
v
:
UILabel
=
titleLabel
{
if
v
.
h
idden
{
if
v
.
isH
idden
{
if
let
s
:
String
=
placeholderLabel
?
.
text
{
v
.
text
=
s
}
let
h
:
CGFloat
=
ceil
(
v
.
font
.
lineHeight
)
v
.
frame
=
CGRectMake
(
0
,
-
h
,
bounds
.
width
,
h
)
v
.
h
idden
=
false
v
.
isH
idden
=
false
UIView
.
animateWithDuration
(
0.25
,
animations
:
{
[
weak
self
]
in
if
let
s
:
TextView
=
self
{
v
.
alpha
=
1
...
...
@@ -516,12 +516,12 @@ public class TextView: UITextView {
/// Hides and animates the titleLabel property.
private
func
hideTitleLabel
()
{
if
let
v
:
UILabel
=
titleLabel
{
if
!
v
.
h
idden
{
if
!
v
.
isH
idden
{
UIView
.
animateWithDuration
(
0.25
,
animations
:
{
v
.
alpha
=
0
v
.
frame
.
origin
.
y
=
-
v
.
frame
.
height
})
{
_
in
v
.
h
idden
=
true
v
.
isH
idden
=
true
}
}
}
...
...
Sources/iOS/ToolbarController.swift
View file @
ac53a489
...
...
@@ -114,13 +114,13 @@ public class ToolbarController : RootController {
addChildViewController
(
v
)
v
.
view
.
frame
=
view
.
bounds
v
.
view
.
center
.
y
=
2
*
view
.
bounds
.
height
v
.
view
.
h
idden
=
true
v
.
view
.
isH
idden
=
true
view
.
insertSubview
(
v
.
view
,
aboveSubview
:
toolbar
)
v
.
view
.
layer
.
zPosition
=
1500
v
.
didMoveToParentViewController
(
self
)
// Animate the noteButton out and the noteViewController! in.
v
.
view
.
h
idden
=
false
v
.
view
.
isH
idden
=
false
v
.
view
.
layer
.
rasterizationScale
=
Device
.
scale
v
.
view
.
layer
.
shouldRasterize
=
true
view
.
layer
.
rasterizationScale
=
Device
.
scale
...
...
Sources/iOS/View.swift
View file @
ac53a489
...
...
@@ -248,20 +248,25 @@ public class View: UIView {
}
}
/**
/// A preset value for Depth.
public
var
depthPreset
:
DepthPreset
=
.
none
{
didSet
{
depth
=
DepthPresetToValue
(
preset
:
depthPreset
)
}
}
/**
A property that sets the shadowOffset, shadowOpacity, and shadowRadius
for the backing layer. This is the preferred method of setting depth
in order to maintain consitency across UI objects.
for the backing layer.
*/
public
var
depthPreset
=
.
none
{
didSet
{
let
value
:
Depth
=
DepthPresetToValue
(
preset
:
depth
)
shadowOffset
=
value
.
offset
shadowOpacity
=
value
.
opacity
shadowRadius
=
value
.
radius
layoutShadowPath
()
}
}
public
var
depth
=
Depth
.
zero
{
didSet
{
shadowOffset
=
depth
.
offsetAsSize
shadowOpacity
=
depth
.
opacity
shadowRadius
=
depth
.
radius
layoutShadowPath
()
}
}
/**
A property that sets the cornerRadius of the backing layer. If the shape
...
...
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