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
3386efad
Unverified
Commit
3386efad
authored
Oct 10, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: Color is now a subclass of UIColor
parent
6840f013
Show whitespace changes
Inline
Side-by-side
Showing
86 changed files
with
408 additions
and
389 deletions
+408
-389
Examples/Programmatic/Bar/Bar/ViewController.swift
+6
-6
Examples/Programmatic/BottomNavigationController/BottomNavigationController/AppBottomNavigationController.swift
+1
-1
Examples/Programmatic/BottomNavigationController/BottomNavigationController/AudioViewController.swift
+3
-3
Examples/Programmatic/BottomNavigationController/BottomNavigationController/PhotoViewController.swift
+3
-3
Examples/Programmatic/BottomNavigationController/BottomNavigationController/RemindersViewController.swift
+3
-3
Examples/Programmatic/BottomNavigationController/BottomNavigationController/SearchViewController.swift
+3
-3
Examples/Programmatic/BottomNavigationController/BottomNavigationController/VideoViewController.swift
+3
-3
Examples/Programmatic/Button/Button/ViewController.swift
+4
-4
Examples/Programmatic/CaptureController/CaptureController/AppCaptureController.swift
+4
-4
Examples/Programmatic/CaptureController/CaptureController/ViewController.swift
+17
-17
Examples/Programmatic/Card/Card/ViewController.swift
+5
-5
Examples/Programmatic/ImageCard/ImageCard/ViewController.swift
+7
-7
Examples/Programmatic/Layer/Layer/ViewController.swift
+2
-2
Examples/Programmatic/MenuController/MenuController/AppMenuController.swift
+1
-1
Examples/Programmatic/MenuController/MenuController/RootViewController.swift
+4
-4
Examples/Programmatic/NavigationController/NavigationController/AppNavigationController.swift
+1
-1
Examples/Programmatic/NavigationController/NavigationController/NextViewController.swift
+4
-4
Examples/Programmatic/NavigationController/NavigationController/RootViewController.swift
+6
-6
Examples/Programmatic/NavigationDrawerController/NavigationDrawerController/LeftViewController.swift
+2
-2
Examples/Programmatic/NavigationDrawerController/NavigationDrawerController/RightViewController.swift
+2
-2
Examples/Programmatic/NavigationDrawerController/NavigationDrawerController/RootViewController.swift
+1
-1
Examples/Programmatic/NavigationDrawerController/NavigationDrawerController/TransitionedViewController.swift
+1
-1
Examples/Programmatic/PageTabBarController/PageTabBarController/AppPageTabBarController.swift
+2
-2
Examples/Programmatic/PageTabBarController/PageTabBarController/BlueViewController.swift
+2
-2
Examples/Programmatic/PageTabBarController/PageTabBarController/GreenViewController.swift
+2
-2
Examples/Programmatic/PageTabBarController/PageTabBarController/RedViewController.swift
+2
-2
Examples/Programmatic/PhotoLibraryController/PhotoLibraryController/AppToolbarController.swift
+1
-1
Examples/Programmatic/PhotoLibraryController/PhotoLibraryController/PhotoLibraryCollectionViewCell.swift
+1
-1
Examples/Programmatic/PhotoLibraryController/PhotoLibraryController/PhotoLibraryViewController.swift
+2
-2
Examples/Programmatic/PresenterCard/PresenterCard/ViewController.swift
+6
-6
Examples/Programmatic/SearchBarController/SearchBarController/RootViewController.swift
+1
-1
Examples/Programmatic/SnackbarController/SnackbarController/RootViewController.swift
+2
-2
Examples/Programmatic/StatusBarController/StatusBarController/RootViewController.swift
+1
-1
Examples/Programmatic/Switch/Switch/ViewController.swift
+1
-1
Examples/Programmatic/TabBar/TabBar/ViewController.swift
+7
-7
Examples/Programmatic/TextField/TextField/ViewController.swift
+6
-6
Examples/Programmatic/ToolbarController/ToolbarController/RootViewController.swift
+1
-1
Examples/Programmatic/View/View/ViewController.swift
+2
-2
Examples/Storyboards/BottomNavigationController/BottomNavigationController/AppBottomNavigationController.swift
+1
-1
Examples/Storyboards/BottomNavigationController/BottomNavigationController/AudioViewController.swift
+3
-3
Examples/Storyboards/BottomNavigationController/BottomNavigationController/PhotoViewController.swift
+3
-3
Examples/Storyboards/BottomNavigationController/BottomNavigationController/RemindersViewController.swift
+3
-3
Examples/Storyboards/BottomNavigationController/BottomNavigationController/SearchViewController.swift
+3
-3
Examples/Storyboards/BottomNavigationController/BottomNavigationController/VideoViewController.swift
+3
-3
Examples/Storyboards/Button/Button/ViewController.swift
+1
-1
Examples/Storyboards/NavigationController/NavigationController/NextViewController.swift
+2
-2
Examples/Storyboards/NavigationController/NavigationController/RootViewController.swift
+1
-1
Examples/Storyboards/NavigationDrawerController/NavigationDrawerController/LeftViewController.swift
+1
-1
Examples/Storyboards/NavigationDrawerController/NavigationDrawerController/RightViewController.swift
+1
-1
Examples/Storyboards/PageTabBarController/PageTabBarController/AppPageTabBarController.swift
+1
-1
Examples/Storyboards/PageTabBarController/PageTabBarController/BlueViewController.swift
+2
-2
Examples/Storyboards/PageTabBarController/PageTabBarController/GreenViewController.swift
+2
-2
Examples/Storyboards/PageTabBarController/PageTabBarController/RedViewController.swift
+2
-2
Examples/Storyboards/SearchBarController/SearchBarController/RootViewController.swift
+1
-1
Examples/Storyboards/SnackbarController/SnackbarController/RootViewController.swift
+2
-2
Examples/Storyboards/StatusBarController/StatusBarController/RootViewController.swift
+1
-1
Sources/iOS/BottomNavigationController.swift
+1
-1
Sources/iOS/BottomTabBar.swift
+3
-3
Sources/iOS/Button.swift
+9
-9
Sources/iOS/Capture.swift
+100
-62
Sources/iOS/CaptureController.swift
+35
-46
Sources/iOS/CaptureSession.swift
+36
-36
Sources/iOS/CollectionReusableView.swift
+2
-2
Sources/iOS/CollectionView.swift
+5
-4
Sources/iOS/CollectionViewCell.swift
+2
-2
Sources/iOS/Color.swift
+9
-18
Sources/iOS/Divider.swift
+1
-1
Sources/iOS/FabButton.swift
+2
-2
Sources/iOS/Material+CALayer.swift
+1
-1
Sources/iOS/Material+UIImage.swift
+2
-2
Sources/iOS/Material+UIView.swift
+1
-1
Sources/iOS/MenuItem.swift
+1
-1
Sources/iOS/NavigationBar.swift
+4
-4
Sources/iOS/NavigationController.swift
+1
-1
Sources/iOS/NavigationDrawerController.swift
+1
-1
Sources/iOS/PhotoLibraryController.swift
+1
-1
Sources/iOS/Pulse.swift
+1
-1
Sources/iOS/RaisedButton.swift
+1
-1
Sources/iOS/RootController.swift
+1
-1
Sources/iOS/SearchBar.swift
+3
-3
Sources/iOS/Switch.swift
+11
-11
Sources/iOS/TableViewCell.swift
+1
-1
Sources/iOS/TextField.swift
+3
-3
Sources/iOS/TextView.swift
+3
-3
Sources/iOS/View.swift
+1
-1
Sources/macOS/Color.swift
+11
-11
No files found.
Examples/Programmatic/Bar/Bar/ViewController.swift
View file @
3386efad
...
@@ -47,7 +47,7 @@ class ViewController: UIViewController {
...
@@ -47,7 +47,7 @@ class ViewController: UIViewController {
override
func
viewDidLoad
()
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
white
view
.
backgroundColor
=
.
white
prepareMenuButton
()
prepareMenuButton
()
prepareFavoriteButton
()
prepareFavoriteButton
()
...
@@ -56,23 +56,23 @@ class ViewController: UIViewController {
...
@@ -56,23 +56,23 @@ class ViewController: UIViewController {
}
}
private
func
prepareMenuButton
()
{
private
func
prepareMenuButton
()
{
menuButton
=
IconButton
(
image
:
Icon
.
cm
.
menu
,
tintColor
:
Color
.
white
)
menuButton
=
IconButton
(
image
:
Icon
.
cm
.
menu
,
tintColor
:
.
white
)
}
}
private
func
prepareFavoriteButton
()
{
private
func
prepareFavoriteButton
()
{
favoriteButton
=
IconButton
(
image
:
Icon
.
favorite
,
tintColor
:
Color
.
white
)
favoriteButton
=
IconButton
(
image
:
Icon
.
favorite
,
tintColor
:
.
white
)
}
}
private
func
prepareShareButton
()
{
private
func
prepareShareButton
()
{
shareButton
=
IconButton
(
image
:
Icon
.
cm
.
share
,
tintColor
:
Color
.
white
)
shareButton
=
IconButton
(
image
:
Icon
.
cm
.
share
,
tintColor
:
.
white
)
}
}
private
func
prepareBar
()
{
private
func
prepareBar
()
{
bar
=
Bar
(
leftViews
:
[
menuButton
],
rightViews
:
[
favoriteButton
,
shareButton
])
bar
=
Bar
(
leftViews
:
[
menuButton
],
rightViews
:
[
favoriteButton
,
shareButton
])
bar
.
backgroundColor
=
Color
.
blue
.
base
bar
.
backgroundColor
=
.
blue
.
base
bar
.
contentView
.
cornerRadiusPreset
=
.
cornerRadius1
bar
.
contentView
.
cornerRadiusPreset
=
.
cornerRadius1
bar
.
contentView
.
backgroundColor
=
Color
.
blue
.
lighten3
bar
.
contentView
.
backgroundColor
=
.
blue
.
lighten3
view
.
layout
(
bar
)
.
horizontally
()
.
center
()
view
.
layout
(
bar
)
.
horizontally
()
.
center
()
}
}
...
...
Examples/Programmatic/BottomNavigationController/BottomNavigationController/AppBottomNavigationController.swift
View file @
3386efad
...
@@ -39,6 +39,6 @@ class AppBottomNavigationController: BottomNavigationController {
...
@@ -39,6 +39,6 @@ class AppBottomNavigationController: BottomNavigationController {
private
func
prepareTabBar
()
{
private
func
prepareTabBar
()
{
tabBar
.
depthPreset
=
.
none
tabBar
.
depthPreset
=
.
none
tabBar
.
dividerColor
=
Color
.
grey
.
lighten3
tabBar
.
dividerColor
=
.
grey
.
lighten3
}
}
}
}
Examples/Programmatic/BottomNavigationController/BottomNavigationController/AudioViewController.swift
View file @
3386efad
...
@@ -39,12 +39,12 @@ class AudioViewController: UIViewController {
...
@@ -39,12 +39,12 @@ class AudioViewController: UIViewController {
/// Prepare tabBarItem.
/// Prepare tabBarItem.
private
func
prepareTabBarItem
()
{
private
func
prepareTabBarItem
()
{
tabBarItem
.
image
=
Icon
.
cm
.
audioLibrary
?
.
tint
WithColor
(
color
:
Color
.
blueGrey
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
tabBarItem
.
image
=
Icon
.
cm
.
audioLibrary
?
.
tint
(
with
:
.
blueGrey
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
tabBarItem
.
selectedImage
=
Icon
.
cm
.
audioLibrary
?
.
tint
WithColor
(
color
:
Color
.
blue
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
tabBarItem
.
selectedImage
=
Icon
.
cm
.
audioLibrary
?
.
tint
(
with
:
.
blue
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
}
}
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
blue
.
base
view
.
backgroundColor
=
.
blue
.
base
}
}
}
}
Examples/Programmatic/BottomNavigationController/BottomNavigationController/PhotoViewController.swift
View file @
3386efad
...
@@ -39,12 +39,12 @@ class PhotoViewController: UIViewController {
...
@@ -39,12 +39,12 @@ class PhotoViewController: UIViewController {
/// Prepare tabBarItem.
/// Prepare tabBarItem.
private
func
prepareTabBarItem
()
{
private
func
prepareTabBarItem
()
{
tabBarItem
.
image
=
Icon
.
cm
.
photoCamera
?
.
tint
WithColor
(
color
:
Color
.
blueGrey
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
tabBarItem
.
image
=
Icon
.
cm
.
photoCamera
?
.
tint
(
with
:
.
blueGrey
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
tabBarItem
.
selectedImage
=
Icon
.
cm
.
photoCamera
?
.
tint
WithColor
(
color
:
Color
.
blue
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
tabBarItem
.
selectedImage
=
Icon
.
cm
.
photoCamera
?
.
tint
(
with
:
.
blue
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
}
}
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
red
.
base
view
.
backgroundColor
=
.
red
.
base
}
}
}
}
Examples/Programmatic/BottomNavigationController/BottomNavigationController/RemindersViewController.swift
View file @
3386efad
...
@@ -39,12 +39,12 @@ class RemindersViewController: UIViewController {
...
@@ -39,12 +39,12 @@ class RemindersViewController: UIViewController {
/// Prepare tabBarItem.
/// Prepare tabBarItem.
private
func
prepareTabBarItem
()
{
private
func
prepareTabBarItem
()
{
tabBarItem
.
image
=
Icon
.
cm
.
bell
?
.
tint
WithColor
(
color
:
Color
.
blueGrey
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
tabBarItem
.
image
=
Icon
.
cm
.
bell
?
.
tint
(
with
:
.
blueGrey
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
tabBarItem
.
selectedImage
=
Icon
.
cm
.
bell
?
.
tint
WithColor
(
color
:
Color
.
blue
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
tabBarItem
.
selectedImage
=
Icon
.
cm
.
bell
?
.
tint
(
with
:
.
blue
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
}
}
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
yellow
.
base
view
.
backgroundColor
=
.
yellow
.
base
}
}
}
}
Examples/Programmatic/BottomNavigationController/BottomNavigationController/SearchViewController.swift
View file @
3386efad
...
@@ -39,12 +39,12 @@ class SearchViewController: UIViewController {
...
@@ -39,12 +39,12 @@ class SearchViewController: UIViewController {
/// Prepare tabBarItem.
/// Prepare tabBarItem.
private
func
prepareTabBarItem
()
{
private
func
prepareTabBarItem
()
{
tabBarItem
.
image
=
Icon
.
cm
.
search
?
.
tint
WithColor
(
color
:
Color
.
blueGrey
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
tabBarItem
.
image
=
Icon
.
cm
.
search
?
.
tint
(
with
:
.
blueGrey
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
tabBarItem
.
selectedImage
=
Icon
.
cm
.
search
?
.
tint
WithColor
(
color
:
Color
.
blue
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
tabBarItem
.
selectedImage
=
Icon
.
cm
.
search
?
.
tint
(
with
:
.
blue
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
}
}
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
blueGrey
.
base
view
.
backgroundColor
=
.
blueGrey
.
base
}
}
}
}
Examples/Programmatic/BottomNavigationController/BottomNavigationController/VideoViewController.swift
View file @
3386efad
...
@@ -39,12 +39,12 @@ class VideoViewController: UIViewController {
...
@@ -39,12 +39,12 @@ class VideoViewController: UIViewController {
/// Prepare tabBarItem.
/// Prepare tabBarItem.
private
func
prepareTabBarItem
()
{
private
func
prepareTabBarItem
()
{
tabBarItem
.
image
=
Icon
.
cm
.
videocam
?
.
tint
WithColor
(
color
:
Color
.
blueGrey
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
tabBarItem
.
image
=
Icon
.
cm
.
videocam
?
.
tint
(
with
:
blueGrey
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
tabBarItem
.
selectedImage
=
Icon
.
cm
.
videocam
?
.
tint
WithColor
(
color
:
Color
.
blue
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
tabBarItem
.
selectedImage
=
Icon
.
cm
.
videocam
?
.
tint
(
with
:
blue
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
}
}
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
green
.
base
view
.
backgroundColor
=
green
.
base
}
}
}
}
Examples/Programmatic/Button/Button/ViewController.swift
View file @
3386efad
...
@@ -58,7 +58,7 @@ struct ButtonLayout {
...
@@ -58,7 +58,7 @@ struct ButtonLayout {
class
ViewController
:
UIViewController
{
class
ViewController
:
UIViewController
{
override
func
viewDidLoad
()
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
white
view
.
backgroundColor
=
white
prepareFlatButton
()
prepareFlatButton
()
prepareRaisedButton
()
prepareRaisedButton
()
...
@@ -76,8 +76,8 @@ class ViewController: UIViewController {
...
@@ -76,8 +76,8 @@ class ViewController: UIViewController {
}
}
private
func
prepareRaisedButton
()
{
private
func
prepareRaisedButton
()
{
let
button
=
RaisedButton
(
title
:
"Raised Button"
,
titleColor
:
Color
.
white
)
let
button
=
RaisedButton
(
title
:
"Raised Button"
,
titleColor
:
white
)
button
.
backgroundColor
=
Color
.
blue
.
base
button
.
backgroundColor
=
blue
.
base
view
.
layout
(
button
)
view
.
layout
(
button
)
.
width
(
ButtonLayout
.
Raised
.
width
)
.
width
(
ButtonLayout
.
Raised
.
width
)
...
@@ -86,7 +86,7 @@ class ViewController: UIViewController {
...
@@ -86,7 +86,7 @@ class ViewController: UIViewController {
}
}
private
func
prepareFabButton
()
{
private
func
prepareFabButton
()
{
let
button
=
FabButton
(
image
:
Icon
.
cm
.
add
,
tintColor
:
Color
.
white
)
let
button
=
FabButton
(
image
:
Icon
.
cm
.
add
,
tintColor
:
white
)
view
.
layout
(
button
)
view
.
layout
(
button
)
.
width
(
ButtonLayout
.
Fab
.
diameter
)
.
width
(
ButtonLayout
.
Fab
.
diameter
)
...
...
Examples/Programmatic/CaptureController/CaptureController/AppCaptureController.swift
View file @
3386efad
...
@@ -42,11 +42,11 @@ class AppCaptureController: CaptureController {
...
@@ -42,11 +42,11 @@ class AppCaptureController: CaptureController {
private
func
prepareToolbar
()
{
private
func
prepareToolbar
()
{
toolbar
.
titleLabel
.
isHidden
=
true
toolbar
.
titleLabel
.
isHidden
=
true
toolbar
.
titleLabel
.
textColor
=
Color
.
white
toolbar
.
titleLabel
.
textColor
=
white
toolbar
.
detailLabel
.
isHidden
=
true
toolbar
.
detailLabel
.
isHidden
=
true
toolbar
.
detail
=
"Recording"
toolbar
.
detail
=
"Recording"
toolbar
.
detailLabel
.
textColor
=
Color
.
red
.
accent1
toolbar
.
detailLabel
.
textColor
=
red
.
accent1
toolbar
.
leftViews
=
[
switchCamerasButton
]
toolbar
.
leftViews
=
[
switchCamerasButton
]
toolbar
.
rightViews
=
[
flashButton
]
toolbar
.
rightViews
=
[
flashButton
]
...
@@ -55,8 +55,8 @@ class AppCaptureController: CaptureController {
...
@@ -55,8 +55,8 @@ class AppCaptureController: CaptureController {
private
func
prepareCaptureButton
()
{
private
func
prepareCaptureButton
()
{
captureButton
.
width
=
72
captureButton
.
width
=
72
captureButton
.
height
=
72
captureButton
.
height
=
72
captureButton
.
backgroundColor
=
Color
.
red
.
darken1
.
withAlphaComponent
(
0.3
)
captureButton
.
backgroundColor
=
red
.
darken1
.
withAlphaComponent
(
0.3
)
captureButton
.
borderColor
=
Color
.
white
captureButton
.
borderColor
=
white
captureButton
.
borderWidthPreset
=
.
border3
captureButton
.
borderWidthPreset
=
.
border3
captureButton
.
depthPreset
=
.
none
captureButton
.
depthPreset
=
.
none
}
}
...
...
Examples/Programmatic/CaptureController/CaptureController/ViewController.swift
View file @
3386efad
...
@@ -44,26 +44,26 @@ class ViewController: UIViewController {
...
@@ -44,26 +44,26 @@ class ViewController: UIViewController {
}
}
cc
.
capture
.
delegate
=
self
cc
.
capture
.
delegate
=
self
cc
.
capture
.
captureS
ession
.
delegate
=
self
cc
.
capture
.
s
ession
.
delegate
=
self
view
.
layout
(
cc
.
capture
)
.
edges
()
view
.
layout
(
cc
.
capture
)
.
edges
()
}
}
}
}
/// CaptureSessionDelegate.
/// CaptureSessionDelegate.
extension
ViewController
:
CaptureSessionDelegate
{
extension
ViewController
:
CaptureSessionDelegate
{
public
func
captureSessionFailedWithError
(
captureS
ession
:
CaptureSession
,
error
:
Error
)
{
public
func
sessionFailedWithError
(
s
ession
:
CaptureSession
,
error
:
Error
)
{
print
(
error
)
print
(
error
)
}
}
public
func
captureSessionStillImageAsynchronously
(
captureS
ession
:
CaptureSession
,
image
:
UIImage
)
{
public
func
sessionStillImageAsynchronously
(
s
ession
:
CaptureSession
,
image
:
UIImage
)
{
print
(
"captureStillImageAsynchronously"
)
print
(
"captureStillImageAsynchronously"
)
}
}
public
func
captureSessionCreateMovieFileFailedWithError
(
captureS
ession
:
CaptureSession
,
error
:
Error
)
{
public
func
sessionCreateMovieFileFailedWithError
(
s
ession
:
CaptureSession
,
error
:
Error
)
{
print
(
"Capture Failed
\(
error
)
"
)
print
(
"Capture Failed
\(
error
)
"
)
}
}
public
func
captureSessionDidStartRecordingToOutputFileAtURL
(
captureS
ession
:
CaptureSession
,
captureOutput
:
AVCaptureFileOutput
,
fileURL
:
NSURL
,
fromConnections
connections
:
[
Any
])
{
public
func
sessionDidStartRecordingToOutputFileAtURL
(
s
ession
:
CaptureSession
,
captureOutput
:
AVCaptureFileOutput
,
fileURL
:
NSURL
,
fromConnections
connections
:
[
Any
])
{
print
(
"Capture Started Recording
\(
fileURL
)
"
)
print
(
"Capture Started Recording
\(
fileURL
)
"
)
// cameraButton.isHidden = true
// cameraButton.isHidden = true
// videoButton.isHidden = true
// videoButton.isHidden = true
...
@@ -71,7 +71,7 @@ extension ViewController: CaptureSessionDelegate {
...
@@ -71,7 +71,7 @@ extension ViewController: CaptureSessionDelegate {
// flashButton.isHidden = true
// flashButton.isHidden = true
}
}
public
func
captureSessionDidFinishRecordingToOutputFileAtURL
(
captureS
ession
:
CaptureSession
,
captureOutput
:
AVCaptureFileOutput
,
outputFileURL
:
NSURL
,
fromConnections
connections
:
[
Any
],
error
:
Error
!
)
{
public
func
sessionDidFinishRecordingToOutputFileAtURL
(
s
ession
:
CaptureSession
,
captureOutput
:
AVCaptureFileOutput
,
outputFileURL
:
NSURL
,
fromConnections
connections
:
[
Any
],
error
:
Error
!
)
{
print
(
"Capture Stopped Recording
\(
outputFileURL
)
"
)
print
(
"Capture Stopped Recording
\(
outputFileURL
)
"
)
// cameraButton.isHidden = false
// cameraButton.isHidden = false
// videoButton.isHidden = false
// videoButton.isHidden = false
...
@@ -94,17 +94,17 @@ extension ViewController: CaptureSessionDelegate {
...
@@ -94,17 +94,17 @@ extension ViewController: CaptureSessionDelegate {
// toolbar.detailLabel.isHidden = true
// toolbar.detailLabel.isHidden = true
}
}
public
func
captureSessionWillSwitchCameras
(
captureS
ession
:
CaptureSession
,
position
:
AVCaptureDevicePosition
)
{
public
func
sessionWillSwitchCameras
(
s
ession
:
CaptureSession
,
position
:
AVCaptureDevicePosition
)
{
// ... do something
// ... do something
}
}
public
func
captureSessionDidSwitchCameras
(
captureS
ession
:
CaptureSession
,
position
:
AVCaptureDevicePosition
)
{
public
func
sessionDidSwitchCameras
(
s
ession
:
CaptureSession
,
position
:
AVCaptureDevicePosition
)
{
// if .back == position {
// if .back == position {
// capture.
captureS
ession.flashMode = .auto
// capture.
s
ession.flashMode = .auto
// flashButton.image = UIImage(named: "ic_flash_auto_white")
// flashButton.image = UIImage(named: "ic_flash_auto_white")
// switchCamerasButton.image = UIImage(named: "ic_camera_front_white")
// switchCamerasButton.image = UIImage(named: "ic_camera_front_white")
// } else {
// } else {
// capture.
captureS
ession.flashMode = .off
// capture.
s
ession.flashMode = .off
// flashButton.image = UIImage(named: "ic_flash_off_white")
// flashButton.image = UIImage(named: "ic_flash_off_white")
// switchCamerasButton.image = UIImage(named: "ic_camera_rear_white")
// switchCamerasButton.image = UIImage(named: "ic_camera_rear_white")
// }
// }
...
@@ -114,7 +114,7 @@ extension ViewController: CaptureSessionDelegate {
...
@@ -114,7 +114,7 @@ extension ViewController: CaptureSessionDelegate {
/// CaptureDelegate.
/// CaptureDelegate.
extension
ViewController
:
CaptureDelegate
{
extension
ViewController
:
CaptureDelegate
{
public
func
captureDidPressFlashButton
(
capture
:
Capture
,
button
:
UIButton
)
{
public
func
captureDidPressFlashButton
(
capture
:
Capture
,
button
:
UIButton
)
{
// guard .back == capture.
captureS
ession.position else {
// guard .back == capture.
s
ession.position else {
// return
// return
// }
// }
//
//
...
@@ -122,25 +122,25 @@ extension ViewController: CaptureDelegate {
...
@@ -122,25 +122,25 @@ extension ViewController: CaptureDelegate {
// return
// return
// }
// }
//
//
// switch capture.
captureS
ession.flashMode {
// switch capture.
s
ession.flashMode {
// case .off:
// case .off:
// b.image = UIImage(named: "ic_flash_on_white")
// b.image = UIImage(named: "ic_flash_on_white")
// capture.
captureS
ession.flashMode = .on
// capture.
s
ession.flashMode = .on
// case .on:
// case .on:
// b.image = UIImage(named: "ic_flash_auto_white")
// b.image = UIImage(named: "ic_flash_auto_white")
// capture.
captureS
ession.flashMode = .auto
// capture.
s
ession.flashMode = .auto
// case .auto:
// case .auto:
// b.image = UIImage(named: "ic_flash_off_white")
// b.image = UIImage(named: "ic_flash_off_white")
// capture.
captureS
ession.flashMode = .off
// capture.
s
ession.flashMode = .off
// }
// }
}
}
public
func
captureDidPressCameraButton
(
capture
:
Capture
,
button
:
UIButton
)
{
public
func
captureDidPressCameraButton
(
capture
:
Capture
,
button
:
UIButton
)
{
// captureButton.backgroundColor =
Color.
blue.darken1.withAlphaComponent(0.3)
// captureButton.backgroundColor = blue.darken1.withAlphaComponent(0.3)
}
}
public
func
captureDidPressVideoButton
(
capture
:
Capture
,
button
:
UIButton
)
{
public
func
captureDidPressVideoButton
(
capture
:
Capture
,
button
:
UIButton
)
{
// captureButton.backgroundColor =
Color.
red.darken1.withAlphaComponent(0.3)
// captureButton.backgroundColor = red.darken1.withAlphaComponent(0.3)
}
}
public
func
captureDidPressCaptureButton
(
capture
:
Capture
,
button
:
UIButton
)
{
public
func
captureDidPressCaptureButton
(
capture
:
Capture
,
button
:
UIButton
)
{
...
...
Examples/Programmatic/Card/Card/ViewController.swift
View file @
3386efad
...
@@ -50,7 +50,7 @@ class ViewController: UIViewController {
...
@@ -50,7 +50,7 @@ class ViewController: UIViewController {
override
func
viewDidLoad
()
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
grey
.
lighten5
view
.
backgroundColor
=
grey
.
lighten5
prepareDateFormatter
()
prepareDateFormatter
()
prepareDateLabel
()
prepareDateLabel
()
...
@@ -71,16 +71,16 @@ class ViewController: UIViewController {
...
@@ -71,16 +71,16 @@ class ViewController: UIViewController {
private
func
prepareDateLabel
()
{
private
func
prepareDateLabel
()
{
dateLabel
=
UILabel
()
dateLabel
=
UILabel
()
dateLabel
.
font
=
RobotoFont
.
regular
(
with
:
12
)
dateLabel
.
font
=
RobotoFont
.
regular
(
with
:
12
)
dateLabel
.
textColor
=
Color
.
blueGrey
.
base
dateLabel
.
textColor
=
blueGrey
.
base
dateLabel
.
text
=
dateFormatter
.
string
(
from
:
Date
.
distantFuture
)
dateLabel
.
text
=
dateFormatter
.
string
(
from
:
Date
.
distantFuture
)
}
}
private
func
prepareFavoriteButton
()
{
private
func
prepareFavoriteButton
()
{
favoriteButton
=
IconButton
(
image
:
Icon
.
favorite
,
tintColor
:
Color
.
red
.
base
)
favoriteButton
=
IconButton
(
image
:
Icon
.
favorite
,
tintColor
:
red
.
base
)
}
}
private
func
prepareMoreButton
()
{
private
func
prepareMoreButton
()
{
moreButton
=
IconButton
(
image
:
Icon
.
cm
.
moreVertical
,
tintColor
:
Color
.
blueGrey
.
base
)
moreButton
=
IconButton
(
image
:
Icon
.
cm
.
moreVertical
,
tintColor
:
blueGrey
.
base
)
}
}
private
func
prepareAuthorView
()
{
private
func
prepareAuthorView
()
{
...
@@ -97,7 +97,7 @@ class ViewController: UIViewController {
...
@@ -97,7 +97,7 @@ class ViewController: UIViewController {
toolbar
.
detail
=
"Build Beautiful Software"
toolbar
.
detail
=
"Build Beautiful Software"
toolbar
.
detailLabel
.
textAlignment
=
.
left
toolbar
.
detailLabel
.
textAlignment
=
.
left
toolbar
.
detailLabel
.
textColor
=
Color
.
blueGrey
.
base
toolbar
.
detailLabel
.
textColor
=
blueGrey
.
base
}
}
private
func
prepareContentView
()
{
private
func
prepareContentView
()
{
...
...
Examples/Programmatic/ImageCard/ImageCard/ViewController.swift
View file @
3386efad
...
@@ -50,7 +50,7 @@ class ViewController: UIViewController {
...
@@ -50,7 +50,7 @@ class ViewController: UIViewController {
override
func
viewDidLoad
()
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
grey
.
lighten5
view
.
backgroundColor
=
grey
.
lighten5
prepareImageView
()
prepareImageView
()
prepareFavoriteButton
()
prepareFavoriteButton
()
...
@@ -70,19 +70,19 @@ class ViewController: UIViewController {
...
@@ -70,19 +70,19 @@ class ViewController: UIViewController {
}
}
private
func
prepareFavoriteButton
()
{
private
func
prepareFavoriteButton
()
{
favoriteButton
=
FlatButton
(
image
:
Icon
.
favorite
,
tintColor
:
Color
.
blueGrey
.
base
)
favoriteButton
=
FlatButton
(
image
:
Icon
.
favorite
,
tintColor
:
blueGrey
.
base
)
}
}
private
func
prepareShareButton
()
{
private
func
prepareShareButton
()
{
shareButton
=
FlatButton
(
image
:
Icon
.
cm
.
share
,
tintColor
:
Color
.
blueGrey
.
base
)
shareButton
=
FlatButton
(
image
:
Icon
.
cm
.
share
,
tintColor
:
blueGrey
.
base
)
}
}
private
func
prepareStarButton
()
{
private
func
prepareStarButton
()
{
starButton
=
FlatButton
(
image
:
Icon
.
cm
.
star
,
tintColor
:
Color
.
blueGrey
.
base
)
starButton
=
FlatButton
(
image
:
Icon
.
cm
.
star
,
tintColor
:
blueGrey
.
base
)
}
}
private
func
prepareMoreButton
()
{
private
func
prepareMoreButton
()
{
moreButton
=
IconButton
(
image
:
Icon
.
cm
.
moreHorizontal
,
tintColor
:
Color
.
white
)
moreButton
=
IconButton
(
image
:
Icon
.
cm
.
moreHorizontal
,
tintColor
:
white
)
}
}
private
func
prepareToolbar
()
{
private
func
prepareToolbar
()
{
...
@@ -90,10 +90,10 @@ class ViewController: UIViewController {
...
@@ -90,10 +90,10 @@ class ViewController: UIViewController {
toolbar
.
backgroundColor
=
nil
toolbar
.
backgroundColor
=
nil
toolbar
.
title
=
"CosmicMind"
toolbar
.
title
=
"CosmicMind"
toolbar
.
titleLabel
.
textColor
=
Color
.
white
toolbar
.
titleLabel
.
textColor
=
white
toolbar
.
detail
=
"Build Beautiful Software"
toolbar
.
detail
=
"Build Beautiful Software"
toolbar
.
detailLabel
.
textColor
=
Color
.
white
toolbar
.
detailLabel
.
textColor
=
white
}
}
private
func
prepareContentView
()
{
private
func
prepareContentView
()
{
...
...
Examples/Programmatic/Layer/Layer/ViewController.swift
View file @
3386efad
...
@@ -37,7 +37,7 @@ class ViewController: UIViewController {
...
@@ -37,7 +37,7 @@ class ViewController: UIViewController {
override
func
viewDidLoad
()
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
white
view
.
backgroundColor
=
white
prepareLayer
()
prepareLayer
()
}
}
...
@@ -50,7 +50,7 @@ class ViewController: UIViewController {
...
@@ -50,7 +50,7 @@ class ViewController: UIViewController {
layer
=
Layer
(
frame
:
CGRect
(
x
:
(
w
-
d
)
/
2
,
y
:
(
h
-
d
)
/
2
,
width
:
d
,
height
:
d
))
layer
=
Layer
(
frame
:
CGRect
(
x
:
(
w
-
d
)
/
2
,
y
:
(
h
-
d
)
/
2
,
width
:
d
,
height
:
d
))
layer
.
depthPreset
=
.
depth3
layer
.
depthPreset
=
.
depth3
layer
.
shapePreset
=
.
circle
layer
.
shapePreset
=
.
circle
layer
.
backgroundColor
=
Color
.
white
.
cgColor
layer
.
backgroundColor
=
white
.
cgColor
layer
.
image
=
UIImage
(
named
:
"CosmicMind"
)
layer
.
image
=
UIImage
(
named
:
"CosmicMind"
)
view
.
layer
.
addSublayer
(
layer
)
view
.
layer
.
addSublayer
(
layer
)
...
...
Examples/Programmatic/MenuController/MenuController/AppMenuController.swift
View file @
3386efad
...
@@ -38,7 +38,7 @@ class AppMenuController: MenuController {
...
@@ -38,7 +38,7 @@ class AppMenuController: MenuController {
open
override
func
prepare
()
{
open
override
func
prepare
()
{
super
.
prepare
()
super
.
prepare
()
view
.
backgroundColor
=
Color
.
grey
.
lighten5
view
.
backgroundColor
=
grey
.
lighten5
prepareMenu
()
prepareMenu
()
}
}
...
...
Examples/Programmatic/MenuController/MenuController/RootViewController.swift
View file @
3386efad
...
@@ -38,7 +38,7 @@ class RootViewController: UIViewController {
...
@@ -38,7 +38,7 @@ class RootViewController: UIViewController {
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
grey
.
lighten5
view
.
backgroundColor
=
grey
.
lighten5
prepareAddButton
()
prepareAddButton
()
prepareAudioLibraryButton
()
prepareAudioLibraryButton
()
...
@@ -69,14 +69,14 @@ class RootViewController: UIViewController {
...
@@ -69,14 +69,14 @@ class RootViewController: UIViewController {
}
}
private
func
prepareAddButton
()
{
private
func
prepareAddButton
()
{
addButton
=
FabButton
(
image
:
Icon
.
cm
.
add
,
tintColor
:
Color
.
white
)
addButton
=
FabButton
(
image
:
Icon
.
cm
.
add
,
tintColor
:
white
)
addButton
.
addTarget
(
self
,
action
:
#selector(
handleToggleMenu
)
,
for
:
.
touchUpInside
)
addButton
.
addTarget
(
self
,
action
:
#selector(
handleToggleMenu
)
,
for
:
.
touchUpInside
)
}
}
private
func
prepareAudioLibraryButton
()
{
private
func
prepareAudioLibraryButton
()
{
audioLibraryMenuItem
=
MenuItem
()
audioLibraryMenuItem
=
MenuItem
()
audioLibraryMenuItem
.
button
.
image
=
Icon
.
cm
.
audioLibrary
audioLibraryMenuItem
.
button
.
image
=
Icon
.
cm
.
audioLibrary
audioLibraryMenuItem
.
button
.
backgroundColor
=
Color
.
green
.
base
audioLibraryMenuItem
.
button
.
backgroundColor
=
green
.
base
audioLibraryMenuItem
.
button
.
depthPreset
=
.
depth1
audioLibraryMenuItem
.
button
.
depthPreset
=
.
depth1
audioLibraryMenuItem
.
title
=
"Audio Library"
audioLibraryMenuItem
.
title
=
"Audio Library"
}
}
...
@@ -84,7 +84,7 @@ class RootViewController: UIViewController {
...
@@ -84,7 +84,7 @@ class RootViewController: UIViewController {
private
func
prepareBellButton
()
{
private
func
prepareBellButton
()
{
reminderMenuItem
=
MenuItem
()
reminderMenuItem
=
MenuItem
()
reminderMenuItem
.
button
.
image
=
Icon
.
cm
.
bell
reminderMenuItem
.
button
.
image
=
Icon
.
cm
.
bell
reminderMenuItem
.
button
.
backgroundColor
=
Color
.
blue
.
base
reminderMenuItem
.
button
.
backgroundColor
=
blue
.
base
reminderMenuItem
.
title
=
"Reminders"
reminderMenuItem
.
title
=
"Reminders"
}
}
...
...
Examples/Programmatic/NavigationController/NavigationController/AppNavigationController.swift
View file @
3386efad
...
@@ -35,7 +35,7 @@ class AppNavigationController: NavigationController {
...
@@ -35,7 +35,7 @@ class AppNavigationController: NavigationController {
open
override
func
prepare
()
{
open
override
func
prepare
()
{
super
.
prepare
()
super
.
prepare
()
statusBarStyle
=
.
lightContent
statusBarStyle
=
.
lightContent
(
navigationBar
as?
NavigationBar
)?
.
backgroundColor
=
Color
.
blue
.
base
(
navigationBar
as?
NavigationBar
)?
.
backgroundColor
=
blue
.
base
}
}
}
}
Examples/Programmatic/NavigationController/NavigationController/NextViewController.swift
View file @
3386efad
...
@@ -34,19 +34,19 @@ import Material
...
@@ -34,19 +34,19 @@ import Material
class
NextViewController
:
UIViewController
{
class
NextViewController
:
UIViewController
{
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
white
view
.
backgroundColor
=
white
prepareNavigationItem
()
prepareNavigationItem
()
}
}
private
func
prepareNavigationItem
()
{
private
func
prepareNavigationItem
()
{
navigationItem
.
title
=
"Title"
navigationItem
.
title
=
"Title"
navigationItem
.
titleLabel
.
textColor
=
Color
.
white
navigationItem
.
titleLabel
.
textColor
=
white
navigationItem
.
detail
=
"Detail Description"
navigationItem
.
detail
=
"Detail Description"
navigationItem
.
detailLabel
.
textColor
=
Color
.
lightBlue
.
lighten5
navigationItem
.
detailLabel
.
textColor
=
lightBlue
.
lighten5
navigationItem
.
backButton
.
tintColor
=
Color
.
white
navigationItem
.
backButton
.
tintColor
=
white
}
}
}
}
Examples/Programmatic/NavigationController/NavigationController/RootViewController.swift
View file @
3386efad
...
@@ -42,7 +42,7 @@ class RootViewController: UIViewController {
...
@@ -42,7 +42,7 @@ class RootViewController: UIViewController {
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
grey
.
lighten5
view
.
backgroundColor
=
grey
.
lighten5
prepareMenuButton
()
prepareMenuButton
()
prepareStarButton
()
prepareStarButton
()
...
@@ -56,23 +56,23 @@ class RootViewController: UIViewController {
...
@@ -56,23 +56,23 @@ class RootViewController: UIViewController {
}
}
private
func
prepareMenuButton
()
{
private
func
prepareMenuButton
()
{
menuButton
=
IconButton
(
image
:
Icon
.
cm
.
menu
,
tintColor
:
Color
.
white
)
menuButton
=
IconButton
(
image
:
Icon
.
cm
.
menu
,
tintColor
:
white
)
}
}
private
func
prepareStarButton
()
{
private
func
prepareStarButton
()
{
starButton
=
IconButton
(
image
:
Icon
.
cm
.
star
,
tintColor
:
Color
.
white
)
starButton
=
IconButton
(
image
:
Icon
.
cm
.
star
,
tintColor
:
white
)
}
}
private
func
prepareSearchButton
()
{
private
func
prepareSearchButton
()
{
searchButton
=
IconButton
(
image
:
Icon
.
cm
.
search
,
tintColor
:
Color
.
white
)
searchButton
=
IconButton
(
image
:
Icon
.
cm
.
search
,
tintColor
:
white
)
}
}
private
func
prepareNavigationItem
()
{
private
func
prepareNavigationItem
()
{
navigationItem
.
title
=
"Material"
navigationItem
.
title
=
"Material"
navigationItem
.
titleLabel
.
textColor
=
Color
.
white
navigationItem
.
titleLabel
.
textColor
=
white
navigationItem
.
detail
=
"Build Beautiful Software"
navigationItem
.
detail
=
"Build Beautiful Software"
navigationItem
.
detailLabel
.
textColor
=
Color
.
lightBlue
.
lighten5
navigationItem
.
detailLabel
.
textColor
=
lightBlue
.
lighten5
navigationItem
.
leftViews
=
[
menuButton
]
navigationItem
.
leftViews
=
[
menuButton
]
navigationItem
.
rightViews
=
[
starButton
,
searchButton
]
navigationItem
.
rightViews
=
[
starButton
,
searchButton
]
...
...
Examples/Programmatic/NavigationDrawerController/NavigationDrawerController/LeftViewController.swift
View file @
3386efad
...
@@ -36,7 +36,7 @@ class LeftViewController: UIViewController {
...
@@ -36,7 +36,7 @@ class LeftViewController: UIViewController {
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
blue
.
base
view
.
backgroundColor
=
blue
.
base
prepareTransitionButton
()
prepareTransitionButton
()
}
}
...
@@ -55,7 +55,7 @@ class LeftViewController: UIViewController {
...
@@ -55,7 +55,7 @@ class LeftViewController: UIViewController {
}
}
private
func
prepareTransitionButton
()
{
private
func
prepareTransitionButton
()
{
transitionButton
=
FlatButton
(
title
:
"Transition VC"
,
titleColor
:
Color
.
white
)
transitionButton
=
FlatButton
(
title
:
"Transition VC"
,
titleColor
:
white
)
transitionButton
.
addTarget
(
self
,
action
:
#selector(
handleTransitionButton
)
,
for
:
.
touchUpInside
)
transitionButton
.
addTarget
(
self
,
action
:
#selector(
handleTransitionButton
)
,
for
:
.
touchUpInside
)
view
.
layout
(
transitionButton
)
.
horizontally
()
.
center
()
view
.
layout
(
transitionButton
)
.
horizontally
()
.
center
()
...
...
Examples/Programmatic/NavigationDrawerController/NavigationDrawerController/RightViewController.swift
View file @
3386efad
...
@@ -36,7 +36,7 @@ class RightViewController: UIViewController {
...
@@ -36,7 +36,7 @@ class RightViewController: UIViewController {
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
blue
.
base
view
.
backgroundColor
=
blue
.
base
prepareRootButton
()
prepareRootButton
()
}
}
...
@@ -55,7 +55,7 @@ class RightViewController: UIViewController {
...
@@ -55,7 +55,7 @@ class RightViewController: UIViewController {
}
}
private
func
prepareRootButton
()
{
private
func
prepareRootButton
()
{
rootButton
=
FlatButton
(
title
:
"Root VC"
,
titleColor
:
Color
.
white
)
rootButton
=
FlatButton
(
title
:
"Root VC"
,
titleColor
:
white
)
rootButton
.
addTarget
(
self
,
action
:
#selector(
handleTransitionButton
)
,
for
:
.
touchUpInside
)
rootButton
.
addTarget
(
self
,
action
:
#selector(
handleTransitionButton
)
,
for
:
.
touchUpInside
)
view
.
layout
(
rootButton
)
.
horizontally
()
.
center
()
view
.
layout
(
rootButton
)
.
horizontally
()
.
center
()
...
...
Examples/Programmatic/NavigationDrawerController/NavigationDrawerController/RootViewController.swift
View file @
3386efad
...
@@ -34,7 +34,7 @@ import Material
...
@@ -34,7 +34,7 @@ import Material
class
RootViewController
:
UIViewController
{
class
RootViewController
:
UIViewController
{
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
white
view
.
backgroundColor
=
white
prepareToolbar
()
prepareToolbar
()
}
}
...
...
Examples/Programmatic/NavigationDrawerController/NavigationDrawerController/TransitionedViewController.swift
View file @
3386efad
...
@@ -34,7 +34,7 @@ import Material
...
@@ -34,7 +34,7 @@ import Material
class
TransitionedViewController
:
UIViewController
{
class
TransitionedViewController
:
UIViewController
{
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
purple
.
base
view
.
backgroundColor
=
purple
.
base
prepareToolbar
()
prepareToolbar
()
}
}
...
...
Examples/Programmatic/PageTabBarController/PageTabBarController/AppPageTabBarController.swift
View file @
3386efad
...
@@ -40,8 +40,8 @@ class AppPageTabBarController: PageTabBarController {
...
@@ -40,8 +40,8 @@ class AppPageTabBarController: PageTabBarController {
}
}
private
func
preparePageTabBar
()
{
private
func
preparePageTabBar
()
{
pageTabBar
.
lineColor
=
Color
.
blueGrey
.
base
pageTabBar
.
lineColor
=
blueGrey
.
base
pageTabBar
.
dividerColor
=
Color
.
blueGrey
.
lighten5
pageTabBar
.
dividerColor
=
blueGrey
.
lighten5
}
}
}
}
...
...
Examples/Programmatic/PageTabBarController/PageTabBarController/BlueViewController.swift
View file @
3386efad
...
@@ -44,12 +44,12 @@ class BlueViewController: UIViewController {
...
@@ -44,12 +44,12 @@ class BlueViewController: UIViewController {
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
blue
.
base
view
.
backgroundColor
=
blue
.
base
}
}
private
func
preparePageTabBarItem
()
{
private
func
preparePageTabBarItem
()
{
pageTabBarItem
.
title
=
"Blue"
pageTabBarItem
.
title
=
"Blue"
pageTabBarItem
.
titleColor
=
Color
.
blueGrey
.
base
pageTabBarItem
.
titleColor
=
blueGrey
.
base
}
}
}
}
Examples/Programmatic/PageTabBarController/PageTabBarController/GreenViewController.swift
View file @
3386efad
...
@@ -44,12 +44,12 @@ class GreenViewController: UIViewController {
...
@@ -44,12 +44,12 @@ class GreenViewController: UIViewController {
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
green
.
base
view
.
backgroundColor
=
green
.
base
}
}
private
func
preparePageTabBarItem
()
{
private
func
preparePageTabBarItem
()
{
pageTabBarItem
.
title
=
"Green"
pageTabBarItem
.
title
=
"Green"
pageTabBarItem
.
titleColor
=
Color
.
blueGrey
.
base
pageTabBarItem
.
titleColor
=
blueGrey
.
base
}
}
}
}
Examples/Programmatic/PageTabBarController/PageTabBarController/RedViewController.swift
View file @
3386efad
...
@@ -44,12 +44,12 @@ class RedViewController: UIViewController {
...
@@ -44,12 +44,12 @@ class RedViewController: UIViewController {
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
red
.
base
view
.
backgroundColor
=
red
.
base
}
}
private
func
preparePageTabBarItem
()
{
private
func
preparePageTabBarItem
()
{
pageTabBarItem
.
title
=
"Red"
pageTabBarItem
.
title
=
"Red"
pageTabBarItem
.
titleColor
=
Color
.
blueGrey
.
base
pageTabBarItem
.
titleColor
=
blueGrey
.
base
}
}
}
}
Examples/Programmatic/PhotoLibraryController/PhotoLibraryController/AppToolbarController.swift
View file @
3386efad
...
@@ -42,6 +42,6 @@ class AppToolbarController: ToolbarController {
...
@@ -42,6 +42,6 @@ class AppToolbarController: ToolbarController {
private
func
prepareToolbar
()
{
private
func
prepareToolbar
()
{
toolbar
.
title
=
"Photo Library"
toolbar
.
title
=
"Photo Library"
toolbar
.
depthPreset
=
.
none
toolbar
.
depthPreset
=
.
none
toolbar
.
dividerColor
=
Color
.
grey
.
lighten3
toolbar
.
dividerColor
=
grey
.
lighten3
}
}
}
}
Examples/Programmatic/PhotoLibraryController/PhotoLibraryController/PhotoLibraryCollectionViewCell.swift
View file @
3386efad
...
@@ -50,7 +50,7 @@ class PhotoLibraryCollectionReusableView: CollectionReusableView {
...
@@ -50,7 +50,7 @@ class PhotoLibraryCollectionReusableView: CollectionReusableView {
toolbar
.
contentEdgeInsets
.
left
=
16
toolbar
.
contentEdgeInsets
.
left
=
16
toolbar
.
contentEdgeInsets
.
right
=
16
toolbar
.
contentEdgeInsets
.
right
=
16
toolbar
.
depthPreset
=
.
none
toolbar
.
depthPreset
=
.
none
toolbar
.
dividerColor
=
Color
.
grey
.
lighten3
toolbar
.
dividerColor
=
grey
.
lighten3
layout
(
toolbar
)
.
edges
()
layout
(
toolbar
)
.
edges
()
}
}
}
}
Examples/Programmatic/PhotoLibraryController/PhotoLibraryController/PhotoLibraryViewController.swift
View file @
3386efad
...
@@ -73,7 +73,7 @@ class PhotoLibraryViewController: PhotoLibraryController {
...
@@ -73,7 +73,7 @@ class PhotoLibraryViewController: PhotoLibraryController {
open
override
func
prepare
()
{
open
override
func
prepare
()
{
super
.
prepare
()
super
.
prepare
()
view
.
backgroundColor
=
Color
.
grey
.
lighten5
view
.
backgroundColor
=
grey
.
lighten5
prepareCollectionView
()
prepareCollectionView
()
...
@@ -141,7 +141,7 @@ class PhotoLibraryViewController: PhotoLibraryController {
...
@@ -141,7 +141,7 @@ class PhotoLibraryViewController: PhotoLibraryController {
layout
.
sectionHeadersPinToVisibleBounds
=
true
layout
.
sectionHeadersPinToVisibleBounds
=
true
collectionView
=
PhotoLibraryCollectionView
(
frame
:
.
zero
,
collectionViewLayout
:
layout
)
collectionView
=
PhotoLibraryCollectionView
(
frame
:
.
zero
,
collectionViewLayout
:
layout
)
collectionView
.
backgroundColor
=
Color
.
clear
collectionView
.
backgroundColor
=
clear
collectionView
.
delegate
=
self
collectionView
.
delegate
=
self
collectionView
.
dataSource
=
self
collectionView
.
dataSource
=
self
view
.
layout
(
collectionView
)
.
edges
()
view
.
layout
(
collectionView
)
.
edges
()
...
...
Examples/Programmatic/PresenterCard/PresenterCard/ViewController.swift
View file @
3386efad
...
@@ -51,7 +51,7 @@ class ViewController: UIViewController {
...
@@ -51,7 +51,7 @@ class ViewController: UIViewController {
override
func
viewDidLoad
()
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
grey
.
lighten5
view
.
backgroundColor
=
grey
.
lighten5
preparePresenterView
()
preparePresenterView
()
prepareDateFormatter
()
prepareDateFormatter
()
...
@@ -79,21 +79,21 @@ class ViewController: UIViewController {
...
@@ -79,21 +79,21 @@ class ViewController: UIViewController {
private
func
prepareDateLabel
()
{
private
func
prepareDateLabel
()
{
dateLabel
=
UILabel
()
dateLabel
=
UILabel
()
dateLabel
.
font
=
RobotoFont
.
regular
(
with
:
12
)
dateLabel
.
font
=
RobotoFont
.
regular
(
with
:
12
)
dateLabel
.
textColor
=
Color
.
blueGrey
.
base
dateLabel
.
textColor
=
blueGrey
.
base
dateLabel
.
textAlignment
=
.
center
dateLabel
.
textAlignment
=
.
center
dateLabel
.
text
=
dateFormatter
.
string
(
from
:
Date
.
distantFuture
)
dateLabel
.
text
=
dateFormatter
.
string
(
from
:
Date
.
distantFuture
)
}
}
private
func
prepareFavoriteButton
()
{
private
func
prepareFavoriteButton
()
{
favoriteButton
=
IconButton
(
image
:
Icon
.
favorite
,
tintColor
:
Color
.
red
.
base
)
favoriteButton
=
IconButton
(
image
:
Icon
.
favorite
,
tintColor
:
red
.
base
)
}
}
private
func
prepareShareButton
()
{
private
func
prepareShareButton
()
{
shareButton
=
IconButton
(
image
:
Icon
.
cm
.
share
,
tintColor
:
Color
.
blueGrey
.
base
)
shareButton
=
IconButton
(
image
:
Icon
.
cm
.
share
,
tintColor
:
blueGrey
.
base
)
}
}
private
func
prepareMoreButton
()
{
private
func
prepareMoreButton
()
{
moreButton
=
IconButton
(
image
:
Icon
.
cm
.
moreHorizontal
,
tintColor
:
Color
.
blueGrey
.
base
)
moreButton
=
IconButton
(
image
:
Icon
.
cm
.
moreHorizontal
,
tintColor
:
blueGrey
.
base
)
}
}
private
func
prepareToolbar
()
{
private
func
prepareToolbar
()
{
...
@@ -104,7 +104,7 @@ class ViewController: UIViewController {
...
@@ -104,7 +104,7 @@ class ViewController: UIViewController {
toolbar
.
detail
=
"Build Beautiful Software"
toolbar
.
detail
=
"Build Beautiful Software"
toolbar
.
detailLabel
.
textAlignment
=
.
left
toolbar
.
detailLabel
.
textAlignment
=
.
left
toolbar
.
detailLabel
.
textColor
=
Color
.
blueGrey
.
base
toolbar
.
detailLabel
.
textColor
=
blueGrey
.
base
}
}
private
func
prepareContentView
()
{
private
func
prepareContentView
()
{
...
...
Examples/Programmatic/SearchBarController/SearchBarController/RootViewController.swift
View file @
3386efad
...
@@ -37,7 +37,7 @@ class RootViewController: UIViewController {
...
@@ -37,7 +37,7 @@ class RootViewController: UIViewController {
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
grey
.
lighten1
view
.
backgroundColor
=
grey
.
lighten1
}
}
open
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
open
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
...
...
Examples/Programmatic/SnackbarController/SnackbarController/RootViewController.swift
View file @
3386efad
...
@@ -36,7 +36,7 @@ class RootViewController: UIViewController {
...
@@ -36,7 +36,7 @@ class RootViewController: UIViewController {
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
grey
.
lighten5
view
.
backgroundColor
=
grey
.
lighten5
}
}
open
override
func
viewDidAppear
(
_
animated
:
Bool
)
{
open
override
func
viewDidAppear
(
_
animated
:
Bool
)
{
...
@@ -49,7 +49,7 @@ class RootViewController: UIViewController {
...
@@ -49,7 +49,7 @@ class RootViewController: UIViewController {
}
}
private
func
prepareUndoButton
()
{
private
func
prepareUndoButton
()
{
undoButton
=
FlatButton
(
title
:
"Undo"
,
titleColor
:
Color
.
yellow
.
base
)
undoButton
=
FlatButton
(
title
:
"Undo"
,
titleColor
:
yellow
.
base
)
undoButton
.
pulseAnimation
=
.
backing
undoButton
.
pulseAnimation
=
.
backing
undoButton
.
titleLabel
?
.
font
=
snackbarController
?
.
snackbar
.
textLabel
.
font
undoButton
.
titleLabel
?
.
font
=
snackbarController
?
.
snackbar
.
textLabel
.
font
}
}
...
...
Examples/Programmatic/StatusBarController/StatusBarController/RootViewController.swift
View file @
3386efad
...
@@ -34,7 +34,7 @@ import Material
...
@@ -34,7 +34,7 @@ import Material
class
RootViewController
:
UIViewController
{
class
RootViewController
:
UIViewController
{
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
grey
.
lighten1
view
.
backgroundColor
=
grey
.
lighten1
}
}
}
}
Examples/Programmatic/Switch/Switch/ViewController.swift
View file @
3386efad
...
@@ -35,7 +35,7 @@ class ViewController: UIViewController {
...
@@ -35,7 +35,7 @@ class ViewController: UIViewController {
override
func
viewDidLoad
()
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
white
view
.
backgroundColor
=
white
prepareSwitch
()
prepareSwitch
()
}
}
...
...
Examples/Programmatic/TabBar/TabBar/ViewController.swift
View file @
3386efad
...
@@ -40,22 +40,22 @@ class ViewController: UIViewController {
...
@@ -40,22 +40,22 @@ class ViewController: UIViewController {
override
func
viewDidLoad
()
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
white
view
.
backgroundColor
=
white
prepareButtons
()
prepareButtons
()
prepareTabBar
()
prepareTabBar
()
}
}
private
func
prepareButtons
()
{
private
func
prepareButtons
()
{
let
btn1
=
FlatButton
(
title
:
"Library"
,
titleColor
:
Color
.
blueGrey
.
base
)
let
btn1
=
FlatButton
(
title
:
"Library"
,
titleColor
:
blueGrey
.
base
)
btn1
.
pulseAnimation
=
.
none
btn1
.
pulseAnimation
=
.
none
buttons
.
append
(
btn1
)
buttons
.
append
(
btn1
)
let
btn2
=
FlatButton
(
title
:
"Photo"
,
titleColor
:
Color
.
blueGrey
.
base
)
let
btn2
=
FlatButton
(
title
:
"Photo"
,
titleColor
:
blueGrey
.
base
)
btn2
.
pulseAnimation
=
.
none
btn2
.
pulseAnimation
=
.
none
buttons
.
append
(
btn2
)
buttons
.
append
(
btn2
)
let
btn3
=
FlatButton
(
title
:
"Video"
,
titleColor
:
Color
.
blueGrey
.
base
)
let
btn3
=
FlatButton
(
title
:
"Video"
,
titleColor
:
blueGrey
.
base
)
btn3
.
pulseAnimation
=
.
none
btn3
.
pulseAnimation
=
.
none
buttons
.
append
(
btn3
)
buttons
.
append
(
btn3
)
}
}
...
@@ -63,13 +63,13 @@ class ViewController: UIViewController {
...
@@ -63,13 +63,13 @@ class ViewController: UIViewController {
private
func
prepareTabBar
()
{
private
func
prepareTabBar
()
{
tabBar
=
TabBar
()
tabBar
=
TabBar
()
tabBar
.
dividerColor
=
Color
.
grey
.
lighten3
tabBar
.
dividerColor
=
grey
.
lighten3
tabBar
.
dividerAlignment
=
.
top
tabBar
.
dividerAlignment
=
.
top
tabBar
.
lineColor
=
Color
.
blue
.
base
tabBar
.
lineColor
=
blue
.
base
tabBar
.
lineAlignment
=
.
top
tabBar
.
lineAlignment
=
.
top
tabBar
.
backgroundColor
=
Color
.
grey
.
lighten5
tabBar
.
backgroundColor
=
grey
.
lighten5
tabBar
.
buttons
=
buttons
tabBar
.
buttons
=
buttons
view
.
layout
(
tabBar
)
.
horizontally
()
.
bottom
()
view
.
layout
(
tabBar
)
.
horizontally
()
.
bottom
()
...
...
Examples/Programmatic/TextField/TextField/ViewController.swift
View file @
3386efad
...
@@ -38,7 +38,7 @@ class ViewController: UIViewController {
...
@@ -38,7 +38,7 @@ class ViewController: UIViewController {
override
func
viewDidLoad
()
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
white
view
.
backgroundColor
=
white
prepareNameField
()
prepareNameField
()
prepareEmailField
()
prepareEmailField
()
...
@@ -53,7 +53,7 @@ class ViewController: UIViewController {
...
@@ -53,7 +53,7 @@ class ViewController: UIViewController {
/// Prepares the resign responder button.
/// Prepares the resign responder button.
private
func
prepareResignResponderButton
()
{
private
func
prepareResignResponderButton
()
{
let
btn
=
RaisedButton
(
title
:
"Resign"
,
titleColor
:
Color
.
blue
.
base
)
let
btn
=
RaisedButton
(
title
:
"Resign"
,
titleColor
:
blue
.
base
)
btn
.
addTarget
(
self
,
action
:
#selector(
handleResignResponderButton(button:)
)
,
for
:
.
touchUpInside
)
btn
.
addTarget
(
self
,
action
:
#selector(
handleResignResponderButton(button:)
)
,
for
:
.
touchUpInside
)
view
.
layout
(
btn
)
.
width
(
100
)
.
height
(
50
)
.
bottom
(
24
)
.
right
(
24
)
view
.
layout
(
btn
)
.
width
(
100
)
.
height
(
50
)
.
bottom
(
24
)
.
right
(
24
)
...
@@ -87,9 +87,9 @@ class ViewController: UIViewController {
...
@@ -87,9 +87,9 @@ class ViewController: UIViewController {
emailField
.
isClearIconButtonEnabled
=
true
emailField
.
isClearIconButtonEnabled
=
true
emailField
.
delegate
=
self
emailField
.
delegate
=
self
emailField
.
placeholderNormalColor
=
Color
.
amber
.
darken4
emailField
.
placeholderNormalColor
=
amber
.
darken4
emailField
.
placeholderActiveColor
=
Color
.
pink
.
base
emailField
.
placeholderActiveColor
=
pink
.
base
emailField
.
dividerNormalColor
=
Color
.
cyan
.
base
emailField
.
dividerNormalColor
=
cyan
.
base
view
.
addSubview
(
emailField
)
view
.
addSubview
(
emailField
)
}
}
...
@@ -102,7 +102,7 @@ class ViewController: UIViewController {
...
@@ -102,7 +102,7 @@ class ViewController: UIViewController {
passwordField
.
isVisibilityIconButtonEnabled
=
true
passwordField
.
isVisibilityIconButtonEnabled
=
true
// Setting the visibilityIconButton color.
// Setting the visibilityIconButton color.
passwordField
.
visibilityIconButton
?
.
tintColor
=
Color
.
green
.
base
.
withAlphaComponent
(
passwordField
.
isSecureTextEntry
?
0.38
:
0.54
)
passwordField
.
visibilityIconButton
?
.
tintColor
=
green
.
base
.
withAlphaComponent
(
passwordField
.
isSecureTextEntry
?
0.38
:
0.54
)
// Size the TextField to the maximum width, less 40 pixels on either side
// Size the TextField to the maximum width, less 40 pixels on either side
// with a top margin of 200 pixels.
// with a top margin of 200 pixels.
...
...
Examples/Programmatic/ToolbarController/ToolbarController/RootViewController.swift
View file @
3386efad
...
@@ -38,7 +38,7 @@ class RootViewController: UIViewController {
...
@@ -38,7 +38,7 @@ class RootViewController: UIViewController {
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
white
view
.
backgroundColor
=
white
}
}
open
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
open
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
...
...
Examples/Programmatic/View/View/ViewController.swift
View file @
3386efad
...
@@ -37,7 +37,7 @@ class ViewController: UIViewController {
...
@@ -37,7 +37,7 @@ class ViewController: UIViewController {
override
func
viewDidLoad
()
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
white
view
.
backgroundColor
=
white
prepareLogo
()
prepareLogo
()
}
}
...
@@ -48,7 +48,7 @@ class ViewController: UIViewController {
...
@@ -48,7 +48,7 @@ class ViewController: UIViewController {
logo
=
View
()
logo
=
View
()
logo
.
depthPreset
=
.
depth3
logo
.
depthPreset
=
.
depth3
logo
.
shapePreset
=
.
circle
logo
.
shapePreset
=
.
circle
logo
.
backgroundColor
=
Color
.
white
logo
.
backgroundColor
=
white
logo
.
image
=
UIImage
(
named
:
"CosmicMind"
)
logo
.
image
=
UIImage
(
named
:
"CosmicMind"
)
view
.
layout
(
logo
)
.
width
(
d
)
.
height
(
d
)
.
center
()
view
.
layout
(
logo
)
.
width
(
d
)
.
height
(
d
)
.
center
()
...
...
Examples/Storyboards/BottomNavigationController/BottomNavigationController/AppBottomNavigationController.swift
View file @
3386efad
...
@@ -39,6 +39,6 @@ class AppBottomNavigationController: BottomNavigationController {
...
@@ -39,6 +39,6 @@ class AppBottomNavigationController: BottomNavigationController {
private
func
prepareTabBar
()
{
private
func
prepareTabBar
()
{
tabBar
.
depthPreset
=
.
none
tabBar
.
depthPreset
=
.
none
tabBar
.
divider
.
color
=
Color
.
grey
.
lighten3
tabBar
.
divider
Color
=
.
grey
.
lighten3
}
}
}
}
Examples/Storyboards/BottomNavigationController/BottomNavigationController/AudioViewController.swift
View file @
3386efad
...
@@ -39,12 +39,12 @@ class AudioViewController: UIViewController {
...
@@ -39,12 +39,12 @@ class AudioViewController: UIViewController {
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
blue
.
base
view
.
backgroundColor
=
.
blue
.
base
}
}
private
func
prepareTabBarItem
()
{
private
func
prepareTabBarItem
()
{
tabBarItem
.
title
=
nil
tabBarItem
.
title
=
nil
tabBarItem
.
image
=
Icon
.
cm
.
audioLibrary
?
.
tint
WithColor
(
color
:
Color
.
blueGrey
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
tabBarItem
.
image
=
Icon
.
cm
.
audioLibrary
?
.
tint
(
with
:
.
blueGrey
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
tabBarItem
.
selectedImage
=
Icon
.
cm
.
audioLibrary
?
.
tint
WithColor
(
color
:
Color
.
blue
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
tabBarItem
.
selectedImage
=
Icon
.
cm
.
audioLibrary
?
.
tint
(
with
:
.
blue
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
}
}
}
}
Examples/Storyboards/BottomNavigationController/BottomNavigationController/PhotoViewController.swift
View file @
3386efad
...
@@ -39,12 +39,12 @@ class PhotoViewController: UIViewController {
...
@@ -39,12 +39,12 @@ class PhotoViewController: UIViewController {
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
red
.
base
view
.
backgroundColor
=
.
red
.
base
}
}
private
func
prepareTabBarItem
()
{
private
func
prepareTabBarItem
()
{
tabBarItem
.
title
=
nil
tabBarItem
.
title
=
nil
tabBarItem
.
image
=
Icon
.
cm
.
photoCamera
?
.
tint
WithColor
(
color
:
Color
.
blueGrey
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
tabBarItem
.
image
=
Icon
.
cm
.
photoCamera
?
.
tint
(
with
:
.
blueGrey
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
tabBarItem
.
selectedImage
=
Icon
.
cm
.
photoCamera
?
.
tint
WithColor
(
color
:
Color
.
blue
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
tabBarItem
.
selectedImage
=
Icon
.
cm
.
photoCamera
?
.
tint
(
with
:
.
blue
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
}
}
}
}
Examples/Storyboards/BottomNavigationController/BottomNavigationController/RemindersViewController.swift
View file @
3386efad
...
@@ -39,12 +39,12 @@ class RemindersViewController: UIViewController {
...
@@ -39,12 +39,12 @@ class RemindersViewController: UIViewController {
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
yellow
.
base
view
.
backgroundColor
=
.
yellow
.
base
}
}
private
func
prepareTabBarItem
()
{
private
func
prepareTabBarItem
()
{
tabBarItem
.
title
=
nil
tabBarItem
.
title
=
nil
tabBarItem
.
image
=
Icon
.
cm
.
bell
?
.
tint
WithColor
(
color
:
Color
.
blueGrey
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
tabBarItem
.
image
=
Icon
.
cm
.
bell
?
.
tint
(
with
:
.
blueGrey
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
tabBarItem
.
selectedImage
=
Icon
.
cm
.
bell
?
.
tint
WithColor
(
color
:
Color
.
blue
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
tabBarItem
.
selectedImage
=
Icon
.
cm
.
bell
?
.
tint
(
with
:
.
blue
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
}
}
}
}
Examples/Storyboards/BottomNavigationController/BottomNavigationController/SearchViewController.swift
View file @
3386efad
...
@@ -39,12 +39,12 @@ class SearchViewController: UIViewController {
...
@@ -39,12 +39,12 @@ class SearchViewController: UIViewController {
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
blueGrey
.
base
view
.
backgroundColor
=
.
blueGrey
.
base
}
}
private
func
prepareTabBarItem
()
{
private
func
prepareTabBarItem
()
{
tabBarItem
.
title
=
nil
tabBarItem
.
title
=
nil
tabBarItem
.
image
=
Icon
.
cm
.
search
?
.
tint
WithColor
(
color
:
Color
.
blueGrey
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
tabBarItem
.
image
=
Icon
.
cm
.
search
?
.
tint
(
with
:
.
blueGrey
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
tabBarItem
.
selectedImage
=
Icon
.
cm
.
search
?
.
tint
WithColor
(
color
:
Color
.
blue
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
tabBarItem
.
selectedImage
=
Icon
.
cm
.
search
?
.
tint
(
with
:
.
blue
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
}
}
}
}
Examples/Storyboards/BottomNavigationController/BottomNavigationController/VideoViewController.swift
View file @
3386efad
...
@@ -39,12 +39,12 @@ class VideoViewController: UIViewController {
...
@@ -39,12 +39,12 @@ class VideoViewController: UIViewController {
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
green
.
base
view
.
backgroundColor
=
green
.
base
}
}
private
func
prepareTabBarItem
()
{
private
func
prepareTabBarItem
()
{
tabBarItem
.
title
=
nil
tabBarItem
.
title
=
nil
tabBarItem
.
image
=
Icon
.
cm
.
videocam
?
.
tint
WithColor
(
color
:
Color
.
blueGrey
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
tabBarItem
.
image
=
Icon
.
cm
.
videocam
?
.
tint
(
with
:
blueGrey
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
tabBarItem
.
selectedImage
=
Icon
.
cm
.
videocam
?
.
tint
WithColor
(
color
:
Color
.
blue
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
tabBarItem
.
selectedImage
=
Icon
.
cm
.
videocam
?
.
tint
(
with
:
blue
.
base
)?
.
withRenderingMode
(
.
alwaysOriginal
)
}
}
}
}
Examples/Storyboards/Button/Button/ViewController.swift
View file @
3386efad
...
@@ -47,7 +47,7 @@ class ViewController: UIViewController {
...
@@ -47,7 +47,7 @@ class ViewController: UIViewController {
private
func
prepareIconButton
()
{
private
func
prepareIconButton
()
{
iconButton
.
image
=
Icon
.
search
iconButton
.
image
=
Icon
.
search
iconButton
.
pulseColor
=
Color
.
blue
.
base
iconButton
.
pulseColor
=
blue
.
base
}
}
}
}
...
...
Examples/Storyboards/NavigationController/NavigationController/NextViewController.swift
View file @
3386efad
...
@@ -34,7 +34,7 @@ import Material
...
@@ -34,7 +34,7 @@ import Material
class
NextViewController
:
UIViewController
{
class
NextViewController
:
UIViewController
{
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
grey
.
base
view
.
backgroundColor
=
grey
.
base
prepareNavigationItem
()
prepareNavigationItem
()
}
}
...
@@ -43,7 +43,7 @@ class NextViewController: UIViewController {
...
@@ -43,7 +43,7 @@ class NextViewController: UIViewController {
navigationItem
.
title
=
"Title"
navigationItem
.
title
=
"Title"
navigationItem
.
detail
=
"Detail Description"
navigationItem
.
detail
=
"Detail Description"
navigationItem
.
backButton
.
tintColor
=
Color
.
blue
.
base
navigationItem
.
backButton
.
tintColor
=
blue
.
base
}
}
}
}
Examples/Storyboards/NavigationController/NavigationController/RootViewController.swift
View file @
3386efad
...
@@ -42,7 +42,7 @@ class RootViewController: UIViewController {
...
@@ -42,7 +42,7 @@ class RootViewController: UIViewController {
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
grey
.
lighten1
view
.
backgroundColor
=
grey
.
lighten1
prepareMenuButton
()
prepareMenuButton
()
prepareStarButton
()
prepareStarButton
()
...
...
Examples/Storyboards/NavigationDrawerController/NavigationDrawerController/LeftViewController.swift
View file @
3386efad
...
@@ -34,6 +34,6 @@ import Material
...
@@ -34,6 +34,6 @@ import Material
class
LeftViewController
:
UIViewController
{
class
LeftViewController
:
UIViewController
{
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
blue
.
base
view
.
backgroundColor
=
blue
.
base
}
}
}
}
Examples/Storyboards/NavigationDrawerController/NavigationDrawerController/RightViewController.swift
View file @
3386efad
...
@@ -34,6 +34,6 @@ import Material
...
@@ -34,6 +34,6 @@ import Material
class
RightViewController
:
UIViewController
{
class
RightViewController
:
UIViewController
{
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
blue
.
base
view
.
backgroundColor
=
blue
.
base
}
}
}
}
Examples/Storyboards/PageTabBarController/PageTabBarController/AppPageTabBarController.swift
View file @
3386efad
...
@@ -40,7 +40,7 @@ class AppPageTabBarController: PageTabBarController {
...
@@ -40,7 +40,7 @@ class AppPageTabBarController: PageTabBarController {
}
}
private
func
preparePageTabBar
()
{
private
func
preparePageTabBar
()
{
pageTabBar
.
lineColor
=
Color
.
grey
.
darken1
pageTabBar
.
lineColor
=
grey
.
darken1
}
}
}
}
...
...
Examples/Storyboards/PageTabBarController/PageTabBarController/BlueViewController.swift
View file @
3386efad
...
@@ -44,12 +44,12 @@ class BlueViewController: UIViewController {
...
@@ -44,12 +44,12 @@ class BlueViewController: UIViewController {
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
blue
.
base
view
.
backgroundColor
=
blue
.
base
}
}
private
func
preparePageTabBarItem
()
{
private
func
preparePageTabBarItem
()
{
pageTabBarItem
.
title
=
"Blue"
pageTabBarItem
.
title
=
"Blue"
pageTabBarItem
.
titleColor
=
Color
.
blueGrey
.
base
pageTabBarItem
.
titleColor
=
blueGrey
.
base
}
}
}
}
Examples/Storyboards/PageTabBarController/PageTabBarController/GreenViewController.swift
View file @
3386efad
...
@@ -44,12 +44,12 @@ class GreenViewController: UIViewController {
...
@@ -44,12 +44,12 @@ class GreenViewController: UIViewController {
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
green
.
base
view
.
backgroundColor
=
green
.
base
}
}
private
func
preparePageTabBarItem
()
{
private
func
preparePageTabBarItem
()
{
pageTabBarItem
.
title
=
"Green"
pageTabBarItem
.
title
=
"Green"
pageTabBarItem
.
titleColor
=
Color
.
blueGrey
.
base
pageTabBarItem
.
titleColor
=
blueGrey
.
base
}
}
}
}
Examples/Storyboards/PageTabBarController/PageTabBarController/RedViewController.swift
View file @
3386efad
...
@@ -44,12 +44,12 @@ class RedViewController: UIViewController {
...
@@ -44,12 +44,12 @@ class RedViewController: UIViewController {
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
red
.
base
view
.
backgroundColor
=
red
.
base
}
}
private
func
preparePageTabBarItem
()
{
private
func
preparePageTabBarItem
()
{
pageTabBarItem
.
title
=
"Red"
pageTabBarItem
.
title
=
"Red"
pageTabBarItem
.
titleColor
=
Color
.
blueGrey
.
base
pageTabBarItem
.
titleColor
=
blueGrey
.
base
}
}
}
}
Examples/Storyboards/SearchBarController/SearchBarController/RootViewController.swift
View file @
3386efad
...
@@ -37,7 +37,7 @@ class RootViewController: UIViewController {
...
@@ -37,7 +37,7 @@ class RootViewController: UIViewController {
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
grey
.
lighten1
view
.
backgroundColor
=
grey
.
lighten1
}
}
open
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
open
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
...
...
Examples/Storyboards/SnackbarController/SnackbarController/RootViewController.swift
View file @
3386efad
...
@@ -36,7 +36,7 @@ class RootViewController: UIViewController {
...
@@ -36,7 +36,7 @@ class RootViewController: UIViewController {
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
grey
.
lighten5
view
.
backgroundColor
=
grey
.
lighten5
}
}
open
override
func
viewDidAppear
(
_
animated
:
Bool
)
{
open
override
func
viewDidAppear
(
_
animated
:
Bool
)
{
...
@@ -49,7 +49,7 @@ class RootViewController: UIViewController {
...
@@ -49,7 +49,7 @@ class RootViewController: UIViewController {
}
}
private
func
prepareUndoButton
()
{
private
func
prepareUndoButton
()
{
undoButton
=
FlatButton
(
title
:
"Undo"
,
titleColor
:
Color
.
yellow
.
base
)
undoButton
=
FlatButton
(
title
:
"Undo"
,
titleColor
:
yellow
.
base
)
undoButton
.
pulseAnimation
=
.
backing
undoButton
.
pulseAnimation
=
.
backing
undoButton
.
titleLabel
?
.
font
=
snackbarController
?
.
snackbar
.
textLabel
.
font
undoButton
.
titleLabel
?
.
font
=
snackbarController
?
.
snackbar
.
textLabel
.
font
}
}
...
...
Examples/Storyboards/StatusBarController/StatusBarController/RootViewController.swift
View file @
3386efad
...
@@ -34,7 +34,7 @@ import Material
...
@@ -34,7 +34,7 @@ import Material
class
RootViewController
:
UIViewController
{
class
RootViewController
:
UIViewController
{
open
override
func
viewDidLoad
()
{
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
view
.
backgroundColor
=
Color
.
grey
.
lighten5
view
.
backgroundColor
=
grey
.
lighten5
}
}
}
}
Sources/iOS/BottomNavigationController.swift
View file @
3386efad
...
@@ -160,7 +160,7 @@ open class BottomNavigationController: UITabBarController, UITabBarControllerDel
...
@@ -160,7 +160,7 @@ open class BottomNavigationController: UITabBarController, UITabBarControllerDel
private
func
prepareTabBar
()
{
private
func
prepareTabBar
()
{
tabBar
.
depthPreset
=
.
depth1
tabBar
.
depthPreset
=
.
depth1
tabBar
.
dividerAlignment
=
.
top
tabBar
.
dividerAlignment
=
.
top
let
image
=
UIImage
.
image
WithColor
(
color
:
Color
.
clear
,
size
:
CGSize
(
width
:
1
,
height
:
1
))
let
image
=
UIImage
.
image
(
with
:
Color
.
clear
,
size
:
CGSize
(
width
:
1
,
height
:
1
))
tabBar
.
shadowImage
=
image
tabBar
.
shadowImage
=
image
tabBar
.
backgroundImage
=
image
tabBar
.
backgroundImage
=
image
tabBar
.
backgroundColor
=
Color
.
white
tabBar
.
backgroundColor
=
Color
.
white
...
...
Sources/iOS/BottomTabBar.swift
View file @
3386efad
...
@@ -41,7 +41,7 @@ open class BottomTabBar: UITabBar {
...
@@ -41,7 +41,7 @@ open class BottomTabBar: UITabBar {
/// Automatically aligns the BottomNavigationBar to the superview.
/// Automatically aligns the BottomNavigationBar to the superview.
open
var
isAlignedToParentAutomatically
=
true
open
var
isAlignedToParentAutomatically
=
true
/// A property that accesses the backing layer's background
Color.
/// A property that accesses the backing layer's background
@IBInspectable
@IBInspectable
open
override
var
backgroundColor
:
UIColor
?
{
open
override
var
backgroundColor
:
UIColor
?
{
didSet
{
didSet
{
...
@@ -127,8 +127,8 @@ open class BottomTabBar: UITabBar {
...
@@ -127,8 +127,8 @@ open class BottomTabBar: UITabBar {
depthPreset
=
.
depth1
depthPreset
=
.
depth1
dividerAlignment
=
.
top
dividerAlignment
=
.
top
contentScaleFactor
=
Device
.
scale
contentScaleFactor
=
Device
.
scale
backgroundColor
=
Color
.
white
backgroundColor
=
.
white
let
image
=
UIImage
.
image
WithColor
(
color
:
Color
.
clear
,
size
:
CGSize
(
width
:
1
,
height
:
1
))
let
image
=
UIImage
.
image
(
with
:
.
clear
,
size
:
CGSize
(
width
:
1
,
height
:
1
))
shadowImage
=
image
shadowImage
=
image
backgroundImage
=
image
backgroundImage
=
image
}
}
...
...
Sources/iOS/Button.swift
View file @
3386efad
...
@@ -75,7 +75,7 @@ open class Button: UIButton {
...
@@ -75,7 +75,7 @@ open class Button: UIButton {
}
}
}
}
/// A property that accesses the backing layer's background
Color.
/// A property that accesses the backing layer's background
@IBInspectable
@IBInspectable
open
override
var
backgroundColor
:
UIColor
?
{
open
override
var
backgroundColor
:
UIColor
?
{
didSet
{
didSet
{
...
@@ -143,9 +143,9 @@ open class Button: UIButton {
...
@@ -143,9 +143,9 @@ open class Button: UIButton {
}
}
/**
/**
A convenience initializer that acceps an image and tint
Color.
A convenience initializer that acceps an image and tint
- Parameter image: A UIImage.
- Parameter image: A UIImage.
- Parameter tintColor: A UI
Color.
- Parameter tintColor: A UI
*/
*/
public
convenience
init
(
image
:
UIImage
?,
tintColor
:
UIColor
=
Color
.
blue
.
base
)
{
public
convenience
init
(
image
:
UIImage
?,
tintColor
:
UIColor
=
Color
.
blue
.
base
)
{
self
.
init
()
self
.
init
()
...
@@ -153,9 +153,9 @@ open class Button: UIButton {
...
@@ -153,9 +153,9 @@ open class Button: UIButton {
}
}
/**
/**
A convenience initializer that acceps a title and title
Color.
A convenience initializer that acceps a title and title
- Parameter title: A String.
- Parameter title: A String.
- Parameter titleColor: A UI
Color.
- Parameter titleColor: A UI
*/
*/
public
convenience
init
(
title
:
String
?,
titleColor
:
UIColor
=
Color
.
blue
.
base
)
{
public
convenience
init
(
title
:
String
?,
titleColor
:
UIColor
=
Color
.
blue
.
base
)
{
self
.
init
()
self
.
init
()
...
@@ -252,9 +252,9 @@ open class Button: UIButton {
...
@@ -252,9 +252,9 @@ open class Button: UIButton {
}
}
/**
/**
Prepares the Button with an image and tint
Color.
Prepares the Button with an image and tint
- Parameter image: A UIImage.
- Parameter image: A UIImage.
- Parameter tintColor: A UI
Color.
- Parameter tintColor: A UI
*/
*/
private
func
prepare
(
with
image
:
UIImage
?,
tintColor
:
UIColor
)
{
private
func
prepare
(
with
image
:
UIImage
?,
tintColor
:
UIColor
)
{
self
.
image
=
image
self
.
image
=
image
...
@@ -263,9 +263,9 @@ open class Button: UIButton {
...
@@ -263,9 +263,9 @@ open class Button: UIButton {
}
}
/**
/**
Prepares the Button with a title and title
Color.
Prepares the Button with a title and title
- Parameter title: A String.
- Parameter title: A String.
- Parameter titleColor: A UI
Color.
- Parameter titleColor: A UI
*/
*/
private
func
prepare
(
with
title
:
String
?,
titleColor
:
UIColor
)
{
private
func
prepare
(
with
title
:
String
?,
titleColor
:
UIColor
)
{
self
.
title
=
title
self
.
title
=
title
...
...
Sources/iOS/Capture.swift
View file @
3386efad
...
@@ -151,10 +151,11 @@ open class Capture: View, UIGestureRecognizerDelegate {
...
@@ -151,10 +151,11 @@ open class Capture: View, UIGestureRecognizerDelegate {
open
lazy
var
captureMode
:
CaptureMode
=
.
video
open
lazy
var
captureMode
:
CaptureMode
=
.
video
/// A boolean indicating whether to enable tap to focus.
/// A boolean indicating whether to enable tap to focus.
@IBInspectable
open
var
enableTapToFocus
=
false
{
@IBInspectable
open
var
isTapToFocusEnabled
=
false
{
didSet
{
didSet
{
if
enableTapToFocus
{
if
isTapToFocusEnabled
{
enableTapToReset
=
true
isTapToResetEnabled
=
true
prepareFocusLayer
()
prepareFocusLayer
()
prepareTapGesture
(
gesture
:
&
tapToFocusGesture
,
numberOfTapsRequired
:
1
,
numberOfTouchesRequired
:
1
,
selector
:
#selector(
handleTapToFocusGesture
)
)
prepareTapGesture
(
gesture
:
&
tapToFocusGesture
,
numberOfTapsRequired
:
1
,
numberOfTouchesRequired
:
1
,
selector
:
#selector(
handleTapToFocusGesture
)
)
if
let
v
:
UITapGestureRecognizer
=
tapToExposeGesture
{
if
let
v
:
UITapGestureRecognizer
=
tapToExposeGesture
{
...
@@ -169,10 +170,11 @@ open class Capture: View, UIGestureRecognizerDelegate {
...
@@ -169,10 +170,11 @@ open class Capture: View, UIGestureRecognizerDelegate {
}
}
/// A boolean indicating whether to enable tap to expose.
/// A boolean indicating whether to enable tap to expose.
@IBInspectable
open
var
enableTapToExpose
=
false
{
@IBInspectable
open
var
isTapToExposeEnabled
=
false
{
didSet
{
didSet
{
if
enableTapToExpose
{
if
isTapToExposeEnabled
{
enableTapToReset
=
true
isTapToResetEnabled
=
true
prepareExposureLayer
()
prepareExposureLayer
()
prepareTapGesture
(
gesture
:
&
tapToExposeGesture
,
numberOfTapsRequired
:
2
,
numberOfTouchesRequired
:
1
,
selector
:
#selector(
handleTapToExposeGesture
)
)
prepareTapGesture
(
gesture
:
&
tapToExposeGesture
,
numberOfTapsRequired
:
2
,
numberOfTouchesRequired
:
1
,
selector
:
#selector(
handleTapToExposeGesture
)
)
if
let
v
:
UITapGestureRecognizer
=
tapToFocusGesture
{
if
let
v
:
UITapGestureRecognizer
=
tapToFocusGesture
{
...
@@ -187,9 +189,10 @@ open class Capture: View, UIGestureRecognizerDelegate {
...
@@ -187,9 +189,10 @@ open class Capture: View, UIGestureRecognizerDelegate {
}
}
/// A boolean indicating whether to enable tap to reset.
/// A boolean indicating whether to enable tap to reset.
@IBInspectable
open
var
enableTapToReset
=
false
{
@IBInspectable
open
var
isTapToResetEnabled
=
false
{
didSet
{
didSet
{
if
enableTapToReset
{
if
isTapToResetEnabled
{
prepareResetLayer
()
prepareResetLayer
()
prepareTapGesture
(
gesture
:
&
tapToResetGesture
,
numberOfTapsRequired
:
2
,
numberOfTouchesRequired
:
2
,
selector
:
#selector(
handleTapToResetGesture
)
)
prepareTapGesture
(
gesture
:
&
tapToResetGesture
,
numberOfTapsRequired
:
2
,
numberOfTouchesRequired
:
2
,
selector
:
#selector(
handleTapToResetGesture
)
)
if
let
v
:
UITapGestureRecognizer
=
tapToFocusGesture
{
if
let
v
:
UITapGestureRecognizer
=
tapToFocusGesture
{
...
@@ -207,24 +210,25 @@ open class Capture: View, UIGestureRecognizerDelegate {
...
@@ -207,24 +210,25 @@ open class Capture: View, UIGestureRecognizerDelegate {
}
}
/// Insets preset value for content.
/// Insets preset value for content.
open
var
contentEdgeInsetsPreset
:
EdgeInsetsPreset
=
.
none
{
open
var
contentEdgeInsetsPreset
=
EdgeInsetsPreset
.
none
{
didSet
{
didSet
{
content
Inset
=
EdgeInsetsPresetToValue
(
preset
:
contentEdgeInsetsPreset
)
content
EdgeInsets
=
EdgeInsetsPresetToValue
(
preset
:
contentEdgeInsetsPreset
)
}
}
}
}
/// Content insert value.
/// Content insert value.
open
var
contentInset
=
EdgeInsetsPresetToValue
(
preset
:
.
square4
)
{
@IBInspectable
open
var
contentEdgeInsets
=
EdgeInsets
.
zero
{
didSet
{
didSet
{
reloadView
()
reloadView
()
}
}
}
}
/// A reference to the CapturePreview view.
/// A reference to the CapturePreview view.
open
internal(set)
var
preview
View
:
CapturePreview
!
open
internal(set)
var
preview
:
CapturePreview
!
/// A reference to the CaptureSession.
/// A reference to the CaptureSession.
open
internal(set)
var
captureS
ession
:
CaptureSession
!
open
internal(set)
var
s
ession
:
CaptureSession
!
/// A reference to the focus layer used in focus animations.
/// A reference to the focus layer used in focus animations.
open
internal(set)
var
focusLayer
:
Layer
?
open
internal(set)
var
focusLayer
:
Layer
?
...
@@ -236,9 +240,9 @@ open class Capture: View, UIGestureRecognizerDelegate {
...
@@ -236,9 +240,9 @@ open class Capture: View, UIGestureRecognizerDelegate {
open
internal(set)
var
resetLayer
:
Layer
?
open
internal(set)
var
resetLayer
:
Layer
?
/// A reference to the cameraButton.
/// A reference to the cameraButton.
open
var
cameraButton
:
UIButton
?
{
open
var
cameraButton
:
IconButton
!
{
didSet
{
didSet
{
if
let
v
:
UIButton
=
cameraButton
{
if
let
v
=
cameraButton
{
v
.
addTarget
(
self
,
action
:
#selector(
handleCameraButton
)
,
for
:
.
touchUpInside
)
v
.
addTarget
(
self
,
action
:
#selector(
handleCameraButton
)
,
for
:
.
touchUpInside
)
}
}
reloadView
()
reloadView
()
...
@@ -246,9 +250,9 @@ open class Capture: View, UIGestureRecognizerDelegate {
...
@@ -246,9 +250,9 @@ open class Capture: View, UIGestureRecognizerDelegate {
}
}
/// A reference to the captureButton.
/// A reference to the captureButton.
open
var
captureButton
:
UIButton
?
{
open
var
captureButton
:
FabButton
!
{
didSet
{
didSet
{
if
let
v
:
UIButton
=
captureButton
{
if
let
v
=
captureButton
{
v
.
addTarget
(
self
,
action
:
#selector(
handleCaptureButton
)
,
for
:
.
touchUpInside
)
v
.
addTarget
(
self
,
action
:
#selector(
handleCaptureButton
)
,
for
:
.
touchUpInside
)
}
}
reloadView
()
reloadView
()
...
@@ -257,9 +261,9 @@ open class Capture: View, UIGestureRecognizerDelegate {
...
@@ -257,9 +261,9 @@ open class Capture: View, UIGestureRecognizerDelegate {
/// A reference to the videoButton.
/// A reference to the videoButton.
open
var
videoButton
:
UIButton
?
{
open
var
videoButton
:
IconButton
!
{
didSet
{
didSet
{
if
let
v
:
UIButton
=
videoButton
{
if
let
v
=
videoButton
{
v
.
addTarget
(
self
,
action
:
#selector(
handleVideoButton
)
,
for
:
.
touchUpInside
)
v
.
addTarget
(
self
,
action
:
#selector(
handleVideoButton
)
,
for
:
.
touchUpInside
)
}
}
reloadView
()
reloadView
()
...
@@ -267,18 +271,18 @@ open class Capture: View, UIGestureRecognizerDelegate {
...
@@ -267,18 +271,18 @@ open class Capture: View, UIGestureRecognizerDelegate {
}
}
/// A reference to the switchCameraButton.
/// A reference to the switchCameraButton.
open
var
switchCamerasButton
:
UIButton
?
{
open
var
switchCamerasButton
:
IconButton
!
{
didSet
{
didSet
{
if
let
v
:
UIButton
=
switchCamerasButton
{
if
let
v
=
switchCamerasButton
{
v
.
addTarget
(
self
,
action
:
#selector(
handleSwitchCamerasButton
)
,
for
:
.
touchUpInside
)
v
.
addTarget
(
self
,
action
:
#selector(
handleSwitchCamerasButton
)
,
for
:
.
touchUpInside
)
}
}
}
}
}
}
/// A reference to the flashButton.
/// A reference to the flashButton.
open
var
flashButton
:
UIButton
?
{
open
var
flashButton
:
IconButton
!
{
didSet
{
didSet
{
if
let
v
:
UIButton
=
flashButton
{
if
let
v
=
flashButton
{
v
.
addTarget
(
self
,
action
:
#selector(
handleFlashButton
)
,
for
:
.
touchUpInside
)
v
.
addTarget
(
self
,
action
:
#selector(
handleFlashButton
)
,
for
:
.
touchUpInside
)
}
}
}
}
...
@@ -291,22 +295,22 @@ open class Capture: View, UIGestureRecognizerDelegate {
...
@@ -291,22 +295,22 @@ open class Capture: View, UIGestureRecognizerDelegate {
open
override
func
layoutSubviews
()
{
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
super
.
layoutSubviews
()
preview
View
.
frame
=
bounds
preview
.
frame
=
bounds
if
let
v
:
UIButton
=
cameraButton
{
if
let
v
=
cameraButton
{
v
.
frame
.
origin
.
y
=
bounds
.
height
-
content
Inset
.
bottom
-
v
.
bounds
.
height
v
.
frame
.
origin
.
y
=
bounds
.
height
-
content
EdgeInsets
.
bottom
-
v
.
bounds
.
height
v
.
frame
.
origin
.
x
=
content
Inset
.
left
v
.
frame
.
origin
.
x
=
content
EdgeInsets
.
left
}
}
if
let
v
:
UIButton
=
captureButton
{
if
let
v
=
captureButton
{
v
.
frame
.
origin
.
y
=
bounds
.
height
-
content
Inset
.
bottom
-
v
.
bounds
.
height
v
.
frame
.
origin
.
y
=
bounds
.
height
-
content
EdgeInsets
.
bottom
-
v
.
bounds
.
height
v
.
frame
.
origin
.
x
=
(
bounds
.
width
-
v
.
bounds
.
width
)
/
2
v
.
frame
.
origin
.
x
=
(
bounds
.
width
-
v
.
bounds
.
width
)
/
2
}
}
if
let
v
:
UIButton
=
videoButton
{
if
let
v
=
videoButton
{
v
.
frame
.
origin
.
y
=
bounds
.
height
-
content
Inset
.
bottom
-
v
.
bounds
.
height
v
.
frame
.
origin
.
y
=
bounds
.
height
-
content
EdgeInsets
.
bottom
-
v
.
bounds
.
height
v
.
frame
.
origin
.
x
=
bounds
.
width
-
v
.
bounds
.
width
-
content
Inset
.
right
v
.
frame
.
origin
.
x
=
bounds
.
width
-
v
.
bounds
.
width
-
content
EdgeInsets
.
right
}
}
if
let
v
:
AVCaptureConnection
=
(
preview
View
.
layer
as!
AVCaptureVideoPreviewLayer
)
.
connection
{
if
let
v
:
AVCaptureConnection
=
(
preview
.
layer
as!
AVCaptureVideoPreviewLayer
)
.
connection
{
v
.
videoOrientation
=
captureS
ession
.
videoOrientation
v
.
videoOrientation
=
s
ession
.
videoOrientation
}
}
}
}
...
@@ -319,9 +323,17 @@ open class Capture: View, UIGestureRecognizerDelegate {
...
@@ -319,9 +323,17 @@ open class Capture: View, UIGestureRecognizerDelegate {
*/
*/
open
override
func
prepare
()
{
open
override
func
prepare
()
{
super
.
prepare
()
super
.
prepare
()
backgroundColor
=
Color
.
black
backgroundColor
=
.
black
isTapToFocusEnabled
=
true
isTapToExposeEnabled
=
true
prepareCaptureSession
()
prepareCaptureSession
()
preparePreviewView
()
preparePreviewView
()
prepareCaptureButton
()
prepareCameraButton
()
prepareVideoButton
()
prepareSwitchCamerasButton
()
prepareFlashButton
()
}
}
/// Reloads the view.
/// Reloads the view.
...
@@ -332,17 +344,17 @@ open class Capture: View, UIGestureRecognizerDelegate {
...
@@ -332,17 +344,17 @@ open class Capture: View, UIGestureRecognizerDelegate {
v
.
removeFromSuperview
()
v
.
removeFromSuperview
()
}
}
insertSubview
(
preview
View
,
at
:
0
)
insertSubview
(
preview
,
at
:
0
)
if
let
v
:
UIButton
=
captureButton
{
if
let
v
=
captureButton
{
insertSubview
(
v
,
at
:
1
)
insertSubview
(
v
,
at
:
1
)
}
}
if
let
v
:
UIButton
=
cameraButton
{
if
let
v
=
cameraButton
{
insertSubview
(
v
,
at
:
2
)
insertSubview
(
v
,
at
:
2
)
}
}
if
let
v
:
UIButton
=
videoButton
{
if
let
v
=
videoButton
{
insertSubview
(
v
,
at
:
3
)
insertSubview
(
v
,
at
:
3
)
}
}
}
}
...
@@ -357,7 +369,7 @@ open class Capture: View, UIGestureRecognizerDelegate {
...
@@ -357,7 +369,7 @@ open class Capture: View, UIGestureRecognizerDelegate {
/// Updates the timer when recording.
/// Updates the timer when recording.
internal
func
updateTimer
()
{
internal
func
updateTimer
()
{
let
duration
:
CMTime
=
captureS
ession
.
recordedDuration
let
duration
:
CMTime
=
s
ession
.
recordedDuration
let
time
:
Double
=
CMTimeGetSeconds
(
duration
)
let
time
:
Double
=
CMTimeGetSeconds
(
duration
)
let
hours
:
Int
=
Int
(
time
/
3600
)
let
hours
:
Int
=
Int
(
time
/
3600
)
let
minutes
:
Int
=
Int
((
time
/
60
)
.
truncatingRemainder
(
dividingBy
:
60
))
let
minutes
:
Int
=
Int
((
time
/
60
)
.
truncatingRemainder
(
dividingBy
:
60
))
...
@@ -367,7 +379,7 @@ open class Capture: View, UIGestureRecognizerDelegate {
...
@@ -367,7 +379,7 @@ open class Capture: View, UIGestureRecognizerDelegate {
/// Stops the timer when recording.
/// Stops the timer when recording.
internal
func
stopTimer
()
{
internal
func
stopTimer
()
{
let
duration
:
CMTime
=
captureS
ession
.
recordedDuration
let
duration
:
CMTime
=
s
ession
.
recordedDuration
let
time
:
Double
=
CMTimeGetSeconds
(
duration
)
let
time
:
Double
=
CMTimeGetSeconds
(
duration
)
let
hours
:
Int
=
Int
(
time
/
3600
)
let
hours
:
Int
=
Int
(
time
/
3600
)
let
minutes
:
Int
=
Int
((
time
/
60
)
.
truncatingRemainder
(
dividingBy
:
60
))
let
minutes
:
Int
=
Int
((
time
/
60
)
.
truncatingRemainder
(
dividingBy
:
60
))
...
@@ -392,7 +404,7 @@ open class Capture: View, UIGestureRecognizerDelegate {
...
@@ -392,7 +404,7 @@ open class Capture: View, UIGestureRecognizerDelegate {
*/
*/
@objc
@objc
internal
func
handleSwitchCamerasButton
(
button
:
UIButton
)
{
internal
func
handleSwitchCamerasButton
(
button
:
UIButton
)
{
captureS
ession
.
switchCameras
()
s
ession
.
switchCameras
()
delegate
?
.
captureDidPressSwitchCamerasButton
?(
capture
:
self
,
button
:
button
)
delegate
?
.
captureDidPressSwitchCamerasButton
?(
capture
:
self
,
button
:
button
)
}
}
...
@@ -403,13 +415,13 @@ open class Capture: View, UIGestureRecognizerDelegate {
...
@@ -403,13 +415,13 @@ open class Capture: View, UIGestureRecognizerDelegate {
@objc
@objc
internal
func
handleCaptureButton
(
button
:
UIButton
)
{
internal
func
handleCaptureButton
(
button
:
UIButton
)
{
if
.
photo
==
captureMode
{
if
.
photo
==
captureMode
{
captureS
ession
.
captureStillImage
()
s
ession
.
captureStillImage
()
}
else
if
.
video
==
captureMode
{
}
else
if
.
video
==
captureMode
{
if
captureS
ession
.
isRecording
{
if
s
ession
.
isRecording
{
captureS
ession
.
stopRecording
()
s
ession
.
stopRecording
()
stopTimer
()
stopTimer
()
}
else
{
}
else
{
captureS
ession
.
startRecording
()
s
ession
.
startRecording
()
startTimer
()
startTimer
()
}
}
}
}
...
@@ -442,9 +454,9 @@ open class Capture: View, UIGestureRecognizerDelegate {
...
@@ -442,9 +454,9 @@ open class Capture: View, UIGestureRecognizerDelegate {
*/
*/
@objc
@objc
internal
func
handleTapToFocusGesture
(
recognizer
:
UITapGestureRecognizer
)
{
internal
func
handleTapToFocusGesture
(
recognizer
:
UITapGestureRecognizer
)
{
if
enableTapToFocus
&&
captureS
ession
.
isFocusPointOfInterestSupported
{
if
isTapToFocusEnabled
&&
s
ession
.
isFocusPointOfInterestSupported
{
let
point
:
CGPoint
=
recognizer
.
location
(
in
:
self
)
let
point
:
CGPoint
=
recognizer
.
location
(
in
:
self
)
captureSession
.
focus
(
at
:
previewV
iew
.
captureDevicePointOfInterestForPoint
(
point
:
point
))
session
.
focus
(
at
:
prev
iew
.
captureDevicePointOfInterestForPoint
(
point
:
point
))
animateTapLayer
(
layer
:
focusLayer
!
,
point
:
point
)
animateTapLayer
(
layer
:
focusLayer
!
,
point
:
point
)
delegate
?
.
captureDidTapToFocusAtPoint
?(
capture
:
self
,
point
:
point
)
delegate
?
.
captureDidTapToFocusAtPoint
?(
capture
:
self
,
point
:
point
)
}
}
...
@@ -456,9 +468,9 @@ open class Capture: View, UIGestureRecognizerDelegate {
...
@@ -456,9 +468,9 @@ open class Capture: View, UIGestureRecognizerDelegate {
*/
*/
@objc
@objc
internal
func
handleTapToExposeGesture
(
recognizer
:
UITapGestureRecognizer
)
{
internal
func
handleTapToExposeGesture
(
recognizer
:
UITapGestureRecognizer
)
{
if
enableTapToExpose
&&
captureS
ession
.
isExposurePointOfInterestSupported
{
if
isTapToExposeEnabled
&&
s
ession
.
isExposurePointOfInterestSupported
{
let
point
:
CGPoint
=
recognizer
.
location
(
in
:
self
)
let
point
:
CGPoint
=
recognizer
.
location
(
in
:
self
)
captureSession
.
expose
(
at
:
previewV
iew
.
captureDevicePointOfInterestForPoint
(
point
:
point
))
session
.
expose
(
at
:
prev
iew
.
captureDevicePointOfInterestForPoint
(
point
:
point
))
animateTapLayer
(
layer
:
exposureLayer
!
,
point
:
point
)
animateTapLayer
(
layer
:
exposureLayer
!
,
point
:
point
)
delegate
?
.
captureDidTapToExposeAtPoint
?(
capture
:
self
,
point
:
point
)
delegate
?
.
captureDidTapToExposeAtPoint
?(
capture
:
self
,
point
:
point
)
}
}
...
@@ -470,9 +482,9 @@ open class Capture: View, UIGestureRecognizerDelegate {
...
@@ -470,9 +482,9 @@ open class Capture: View, UIGestureRecognizerDelegate {
*/
*/
@objc
@objc
internal
func
handleTapToResetGesture
(
recognizer
:
UITapGestureRecognizer
)
{
internal
func
handleTapToResetGesture
(
recognizer
:
UITapGestureRecognizer
)
{
if
enableTapToReset
{
if
isTapToResetEnabled
{
captureS
ession
.
reset
()
s
ession
.
reset
()
let
point
:
CGPoint
=
preview
View
.
pointForCaptureDevicePointOfInterest
(
point
:
CGPoint
(
x
:
0.5
,
y
:
0.5
))
let
point
:
CGPoint
=
preview
.
pointForCaptureDevicePointOfInterest
(
point
:
CGPoint
(
x
:
0.5
,
y
:
0.5
))
animateTapLayer
(
layer
:
resetLayer
!
,
point
:
point
)
animateTapLayer
(
layer
:
resetLayer
!
,
point
:
point
)
delegate
?
.
captureDidTapToResetAtPoint
?(
capture
:
self
,
point
:
point
)
delegate
?
.
captureDidTapToResetAtPoint
?(
capture
:
self
,
point
:
point
)
}
}
...
@@ -507,16 +519,42 @@ open class Capture: View, UIGestureRecognizerDelegate {
...
@@ -507,16 +519,42 @@ open class Capture: View, UIGestureRecognizerDelegate {
}
}
}
}
/// Prepare the
captureS
ession.
/// Prepare the
s
ession.
private
func
prepareCaptureSession
()
{
private
func
prepareCaptureSession
()
{
captureS
ession
=
CaptureSession
()
s
ession
=
CaptureSession
()
}
}
/// Prepares the preview
View
.
/// Prepares the preview.
private
func
preparePreviewView
()
{
private
func
preparePreviewView
()
{
previewView
=
CapturePreview
()
preview
=
CapturePreview
()
(
previewView
.
layer
as!
AVCaptureVideoPreviewLayer
)
.
session
=
captureSession
.
session
(
preview
.
layer
as!
AVCaptureVideoPreviewLayer
)
.
session
=
session
.
session
captureSession
.
startSession
()
session
.
startSession
()
}
/// Prepares the captureButton.
private
func
prepareCaptureButton
()
{
captureButton
=
FabButton
()
}
/// Prepares the cameraButton.
private
func
prepareCameraButton
()
{
cameraButton
=
IconButton
(
image
:
Icon
.
cm
.
photoCamera
,
tintColor
:
.
white
)
}
/// Preapres the videoButton.
private
func
prepareVideoButton
()
{
videoButton
=
IconButton
(
image
:
Icon
.
cm
.
videocam
,
tintColor
:
.
white
)
}
/// Prepares the switchCameraButton.
private
func
prepareSwitchCamerasButton
()
{
switchCamerasButton
=
IconButton
(
image
:
UIImage
(
named
:
"ic_camera_front_white"
),
tintColor
:
.
white
)
}
/// Prepares the flashButton.
private
func
prepareFlashButton
()
{
flashButton
=
IconButton
(
image
:
UIImage
(
named
:
"ic_flash_auto_white"
),
tintColor
:
.
white
)
session
.
flashMode
=
.
auto
}
}
/// Prepares the focusLayer.
/// Prepares the focusLayer.
...
@@ -526,7 +564,7 @@ open class Capture: View, UIGestureRecognizerDelegate {
...
@@ -526,7 +564,7 @@ open class Capture: View, UIGestureRecognizerDelegate {
focusLayer
!.
isHidden
=
true
focusLayer
!.
isHidden
=
true
focusLayer
!.
borderWidth
=
2
focusLayer
!.
borderWidth
=
2
focusLayer
!.
borderColor
=
Color
.
white
.
cgColor
focusLayer
!.
borderColor
=
Color
.
white
.
cgColor
preview
View
.
layer
.
addSublayer
(
focusLayer
!
)
preview
.
layer
.
addSublayer
(
focusLayer
!
)
}
}
}
}
...
@@ -537,7 +575,7 @@ open class Capture: View, UIGestureRecognizerDelegate {
...
@@ -537,7 +575,7 @@ open class Capture: View, UIGestureRecognizerDelegate {
exposureLayer
!.
isHidden
=
true
exposureLayer
!.
isHidden
=
true
exposureLayer
!.
borderWidth
=
2
exposureLayer
!.
borderWidth
=
2
exposureLayer
!.
borderColor
=
Color
.
yellow
.
darken1
.
cgColor
exposureLayer
!.
borderColor
=
Color
.
yellow
.
darken1
.
cgColor
preview
View
.
layer
.
addSublayer
(
exposureLayer
!
)
preview
.
layer
.
addSublayer
(
exposureLayer
!
)
}
}
}
}
...
@@ -548,7 +586,7 @@ open class Capture: View, UIGestureRecognizerDelegate {
...
@@ -548,7 +586,7 @@ open class Capture: View, UIGestureRecognizerDelegate {
resetLayer
!.
isHidden
=
true
resetLayer
!.
isHidden
=
true
resetLayer
!.
borderWidth
=
2
resetLayer
!.
borderWidth
=
2
resetLayer
!.
borderColor
=
Color
.
red
.
accent1
.
cgColor
resetLayer
!.
borderColor
=
Color
.
red
.
accent1
.
cgColor
preview
View
.
layer
.
addSublayer
(
resetLayer
!
)
preview
.
layer
.
addSublayer
(
resetLayer
!
)
}
}
}
}
...
...
Sources/iOS/CaptureController.swift
View file @
3386efad
...
@@ -29,7 +29,6 @@
...
@@ -29,7 +29,6 @@
*/
*/
import
UIKit
import
UIKit
import
Material
extension
UIViewController
{
extension
UIViewController
{
/**
/**
...
@@ -50,69 +49,59 @@ extension UIViewController {
...
@@ -50,69 +49,59 @@ extension UIViewController {
}
}
open
class
CaptureController
:
ToolbarController
,
CaptureDelegate
,
CaptureSessionDelegate
{
open
class
CaptureController
:
ToolbarController
,
CaptureDelegate
,
CaptureSessionDelegate
{
/// A reference to the Capture instance.
open
private(set)
lazy
var
capture
:
Capture
=
Capture
()
open
private(set)
lazy
var
capture
:
Capture
=
Capture
()
open
private(set)
var
cameraButton
:
IconButton
!
open
private(set)
var
videoButton
:
IconButton
!
open
private(set)
var
switchCamerasButton
:
IconButton
!
open
private(set)
var
flashButton
:
IconButton
!
open
private(set)
var
captureButton
:
FabButton
!
open
override
func
prepare
()
{
/// A reference to capture's cameraButton.
super
.
prepare
()
open
var
cameraButton
:
IconButton
{
view
.
backgroundColor
=
Color
.
black
return
capture
.
cameraButton
display
=
.
full
prepareToolbar
()
prepareCaptureButton
()
prepareCameraButton
()
prepareVideoButton
()
prepareSwitchCamerasButton
()
prepareFlashButton
()
prepareCapture
()
}
}
/// Prepares the Toolbar.
/// A reference to capture's videoButton.
private
func
prepareToolbar
()
{
open
var
videoButton
:
IconButton
{
toolbar
.
backgroundColor
=
Color
.
clear
return
capture
.
videoButton
toolbar
.
depthPreset
=
.
none
}
}
/// Prepares the captureButton.
/// A reference to capture's switchCamerasButton.
private
func
prepareCaptureButton
()
{
open
var
switchCamerasButton
:
IconButton
{
captureButton
=
FabButton
()
return
capture
.
switchCamerasButton
capture
.
captureButton
=
captureButton
}
}
/// Prepares the cameraButton.
/// A reference to capture's flashButton.
private
func
prepareCameraButton
()
{
open
var
flashButton
:
IconButton
{
cameraButton
=
IconButton
(
image
:
Icon
.
cm
.
photoCamera
,
tintColor
:
Color
.
white
)
return
capture
.
flashButton
capture
.
cameraButton
=
cameraButton
}
}
/// Preapres the videoButton.
/// A reference to capture's captureButton.
private
func
prepareVideoButton
()
{
open
var
captureButton
:
FabButton
{
videoButton
=
IconButton
(
image
:
Icon
.
cm
.
videocam
,
tintColor
:
Color
.
white
)
return
capture
.
captureButton
capture
.
videoButton
=
videoButton
}
}
/// Prepares the switchCameraButton.
/**
private
func
prepareSwitchCamerasButton
()
{
Prepares the view instance when intialized. When subclassing,
switchCamerasButton
=
IconButton
(
image
:
UIImage
(
named
:
"ic_camera_front_white"
),
tintColor
:
Color
.
white
)
it is recommended to override the prepare method
capture
.
switchCamerasButton
=
switchCamerasButton
to initialize property values and other setup operations.
The super.prepare method should always be called immediately
when subclassing.
*/
open
override
func
prepare
()
{
super
.
prepare
()
view
.
backgroundColor
=
.
black
display
=
.
full
prepareToolbar
()
prepareCapture
()
}
}
/// Prepares the flashButton.
/// Prepares the Toolbar.
private
func
prepareFlashButton
()
{
private
func
prepareToolbar
()
{
flashButton
=
IconButton
(
image
:
UIImage
(
named
:
"ic_flash_auto_white"
),
tintColor
:
Color
.
white
)
toolbar
.
backgroundColor
=
.
clear
capture
.
flashButton
=
flashButton
toolbar
.
depthPreset
=
.
none
capture
.
captureSession
.
flashMode
=
.
auto
}
}
/// Prepares capture.
/// Prepares capture.
private
func
prepareCapture
()
{
private
func
prepareCapture
()
{
capture
.
enableTapToFocus
=
true
capture
.
enableTapToExpose
=
true
capture
.
delegate
=
self
capture
.
delegate
=
self
capture
.
captureS
ession
.
delegate
=
self
capture
.
s
ession
.
delegate
=
self
}
}
}
}
Sources/iOS/CaptureSession.swift
View file @
3386efad
...
@@ -90,82 +90,82 @@ public func CaptureSessionPresetToString(preset: CaptureSessionPreset) -> String
...
@@ -90,82 +90,82 @@ public func CaptureSessionPresetToString(preset: CaptureSessionPreset) -> String
public
protocol
CaptureSessionDelegate
{
public
protocol
CaptureSessionDelegate
{
/**
/**
A delegation method that is fired when the captureSesstion failes with an error.
A delegation method that is fired when the captureSesstion failes with an error.
- Parameter
captureS
ession: A reference to the calling CaptureSession.
- Parameter
s
ession: A reference to the calling CaptureSession.
- Parameter error: A Error corresponding to the error.
- Parameter error: A Error corresponding to the error.
*/
*/
@objc
@objc
optional
func
captureSessionFailedWithError
(
captureS
ession
:
CaptureSession
,
error
:
Error
)
optional
func
sessionFailedWithError
(
s
ession
:
CaptureSession
,
error
:
Error
)
/**
/**
A delegation method that is fired when the camera has been switched to another.
A delegation method that is fired when the camera has been switched to another.
- Parameter
captureS
ession: A reference to the calling CaptureSession.
- Parameter
s
ession: A reference to the calling CaptureSession.
- Parameter position: An AVCaptureDevicePosition that the camera has switched to.
- Parameter position: An AVCaptureDevicePosition that the camera has switched to.
*/
*/
@objc
@objc
optional
func
captureSessionDidSwitchCameras
(
captureS
ession
:
CaptureSession
,
position
:
AVCaptureDevicePosition
)
optional
func
sessionDidSwitchCameras
(
s
ession
:
CaptureSession
,
position
:
AVCaptureDevicePosition
)
/**
/**
A delegation method that is fired before the camera has been switched to another.
A delegation method that is fired before the camera has been switched to another.
- Parameter
captureS
ession: A reference to the calling CaptureSession.
- Parameter
s
ession: A reference to the calling CaptureSession.
- Parameter position: An AVCaptureDevicePosition that the camera will switch to.
- Parameter position: An AVCaptureDevicePosition that the camera will switch to.
*/
*/
@objc
@objc
optional
func
captureSessionWillSwitchCameras
(
captureS
ession
:
CaptureSession
,
position
:
AVCaptureDevicePosition
)
optional
func
sessionWillSwitchCameras
(
s
ession
:
CaptureSession
,
position
:
AVCaptureDevicePosition
)
/**
/**
A delegation method that is fired when an image has been captured asynchronously.
A delegation method that is fired when an image has been captured asynchronously.
- Parameter
captureS
ession: A reference to the calling CaptureSession.
- Parameter
s
ession: A reference to the calling CaptureSession.
- Parameter image: An image that has been captured.
- Parameter image: An image that has been captured.
*/
*/
@objc
@objc
optional
func
captureSessionStillImageAsynchronously
(
captureS
ession
:
CaptureSession
,
image
:
UIImage
)
optional
func
sessionStillImageAsynchronously
(
s
ession
:
CaptureSession
,
image
:
UIImage
)
/**
/**
A delegation method that is fired when capturing an image asynchronously has failed.
A delegation method that is fired when capturing an image asynchronously has failed.
- Parameter
captureS
ession: A reference to the calling CaptureSession.
- Parameter
s
ession: A reference to the calling CaptureSession.
- Parameter error: A Error corresponding to the error.
- Parameter error: A Error corresponding to the error.
*/
*/
@objc
@objc
optional
func
captureSessionStillImageAsynchronouslyFailedWithError
(
captureS
ession
:
CaptureSession
,
error
:
Error
)
optional
func
sessionStillImageAsynchronouslyFailedWithError
(
s
ession
:
CaptureSession
,
error
:
Error
)
/**
/**
A delegation method that is fired when creating a movie file has failed.
A delegation method that is fired when creating a movie file has failed.
- Parameter
captureS
ession: A reference to the calling CaptureSession.
- Parameter
s
ession: A reference to the calling CaptureSession.
- Parameter error: A Error corresponding to the error.
- Parameter error: A Error corresponding to the error.
*/
*/
@objc
@objc
optional
func
captureSessionCreateMovieFileFailedWithError
(
captureS
ession
:
CaptureSession
,
error
:
Error
)
optional
func
sessionCreateMovieFileFailedWithError
(
s
ession
:
CaptureSession
,
error
:
Error
)
/**
/**
A delegation method that is fired when capturing a movie has failed.
A delegation method that is fired when capturing a movie has failed.
- Parameter
captureS
ession: A reference to the calling CaptureSession.
- Parameter
s
ession: A reference to the calling CaptureSession.
- Parameter error: A Error corresponding to the error.
- Parameter error: A Error corresponding to the error.
*/
*/
@objc
@objc
optional
func
captureSessionMovieFailedWithError
(
captureS
ession
:
CaptureSession
,
error
:
Error
)
optional
func
sessionMovieFailedWithError
(
s
ession
:
CaptureSession
,
error
:
Error
)
/**
/**
A delegation method that is fired when a session started recording and writing
A delegation method that is fired when a session started recording and writing
to a file.
to a file.
- Parameter
captureS
ession: A reference to the calling CaptureSession.
- Parameter
s
ession: A reference to the calling CaptureSession.
- Parameter captureOut: An AVCaptureFileOutput.
- Parameter captureOut: An AVCaptureFileOutput.
- Parameter fileURL: A file URL.
- Parameter fileURL: A file URL.
- Parameter fromConnections: An array of Anys.
- Parameter fromConnections: An array of Anys.
*/
*/
@objc
@objc
optional
func
captureSessionDidStartRecordingToOutputFileAtURL
(
captureS
ession
:
CaptureSession
,
captureOutput
:
AVCaptureFileOutput
,
fileURL
:
NSURL
,
fromConnections
connections
:
[
Any
])
optional
func
sessionDidStartRecordingToOutputFileAtURL
(
s
ession
:
CaptureSession
,
captureOutput
:
AVCaptureFileOutput
,
fileURL
:
NSURL
,
fromConnections
connections
:
[
Any
])
/**
/**
A delegation method that is fired when a session finished recording and writing
A delegation method that is fired when a session finished recording and writing
to a file.
to a file.
- Parameter
captureS
ession: A reference to the calling CaptureSession.
- Parameter
s
ession: A reference to the calling CaptureSession.
- Parameter captureOut: An AVCaptureFileOutput.
- Parameter captureOut: An AVCaptureFileOutput.
- Parameter fileURL: A file URL.
- Parameter fileURL: A file URL.
- Parameter fromConnections: An array of Anys.
- Parameter fromConnections: An array of Anys.
- Parameter error: A Error corresponding to an error.
- Parameter error: A Error corresponding to an error.
*/
*/
@objc
@objc
optional
func
captureSessionDidFinishRecordingToOutputFileAtURL
(
captureS
ession
:
CaptureSession
,
captureOutput
:
AVCaptureFileOutput
,
outputFileURL
:
NSURL
,
fromConnections
connections
:
[
Any
],
error
:
Error
!
)
optional
func
sessionDidFinishRecordingToOutputFileAtURL
(
s
ession
:
CaptureSession
,
captureOutput
:
AVCaptureFileOutput
,
outputFileURL
:
NSURL
,
fromConnections
connections
:
[
Any
],
error
:
Error
!
)
}
}
@objc(CaptureSession)
@objc(CaptureSession)
...
@@ -279,7 +279,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
...
@@ -279,7 +279,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
userInfo
[
NSUnderlyingErrorKey
]
=
error
userInfo
[
NSUnderlyingErrorKey
]
=
error
}
}
if
let
e
=
error
{
if
let
e
=
error
{
delegate
?
.
captureSessionFailedWithError
?(
captureS
ession
:
self
,
error
:
e
)
delegate
?
.
sessionFailedWithError
?(
s
ession
:
self
,
error
:
e
)
}
}
}
}
}
}
...
@@ -308,7 +308,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
...
@@ -308,7 +308,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
userInfo
[
NSUnderlyingErrorKey
]
=
error
userInfo
[
NSUnderlyingErrorKey
]
=
error
}
}
if
let
e
=
error
{
if
let
e
=
error
{
delegate
?
.
captureSessionFailedWithError
?(
captureS
ession
:
self
,
error
:
e
)
delegate
?
.
sessionFailedWithError
?(
s
ession
:
self
,
error
:
e
)
}
}
}
}
}
}
...
@@ -337,7 +337,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
...
@@ -337,7 +337,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
userInfo
[
NSUnderlyingErrorKey
]
=
error
userInfo
[
NSUnderlyingErrorKey
]
=
error
}
}
if
let
e
:
NSError
=
error
{
if
let
e
:
NSError
=
error
{
delegate
?
.
captureSessionFailedWithError
?(
captureS
ession
:
self
,
error
:
e
)
delegate
?
.
sessionFailedWithError
?(
s
ession
:
self
,
error
:
e
)
}
}
}
}
}
}
...
@@ -403,7 +403,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
...
@@ -403,7 +403,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
if
canSwitchCameras
{
if
canSwitchCameras
{
do
{
do
{
if
let
v
:
AVCaptureDevicePosition
=
position
{
if
let
v
:
AVCaptureDevicePosition
=
position
{
delegate
?
.
captureSessionWillSwitchCameras
?(
captureS
ession
:
self
,
position
:
v
)
delegate
?
.
sessionWillSwitchCameras
?(
s
ession
:
self
,
position
:
v
)
let
videoInput
:
AVCaptureDeviceInput
?
=
try
AVCaptureDeviceInput
(
device
:
inactiveCamera
!
)
let
videoInput
:
AVCaptureDeviceInput
?
=
try
AVCaptureDeviceInput
(
device
:
inactiveCamera
!
)
session
.
beginConfiguration
()
session
.
beginConfiguration
()
session
.
removeInput
(
activeVideoInput
)
session
.
removeInput
(
activeVideoInput
)
...
@@ -415,10 +415,10 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
...
@@ -415,10 +415,10 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
session
.
addInput
(
activeVideoInput
)
session
.
addInput
(
activeVideoInput
)
}
}
session
.
commitConfiguration
()
session
.
commitConfiguration
()
delegate
?
.
captureSessionDidSwitchCameras
?(
captureS
ession
:
self
,
position
:
position
!
)
delegate
?
.
sessionDidSwitchCameras
?(
s
ession
:
self
,
position
:
position
!
)
}
}
}
catch
let
e
as
NSError
{
}
catch
let
e
as
NSError
{
delegate
?
.
captureSessionFailedWithError
?(
captureS
ession
:
self
,
error
:
e
)
delegate
?
.
sessionFailedWithError
?(
s
ession
:
self
,
error
:
e
)
}
}
}
}
}
}
...
@@ -483,7 +483,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
...
@@ -483,7 +483,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
userInfo
[
NSUnderlyingErrorKey
]
=
error
userInfo
[
NSUnderlyingErrorKey
]
=
error
}
}
if
let
e
=
error
{
if
let
e
=
error
{
delegate
?
.
captureSessionFailedWithError
?(
captureS
ession
:
self
,
error
:
e
)
delegate
?
.
sessionFailedWithError
?(
s
ession
:
self
,
error
:
e
)
}
}
}
}
...
@@ -514,7 +514,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
...
@@ -514,7 +514,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
userInfo
[
NSUnderlyingErrorKey
]
=
error
userInfo
[
NSUnderlyingErrorKey
]
=
error
}
}
if
let
e
=
error
{
if
let
e
=
error
{
delegate
?
.
captureSessionFailedWithError
?(
captureS
ession
:
self
,
error
:
e
)
delegate
?
.
sessionFailedWithError
?(
s
ession
:
self
,
error
:
e
)
}
}
}
}
...
@@ -529,7 +529,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
...
@@ -529,7 +529,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
device
.
exposureMode
=
.
locked
device
.
exposureMode
=
.
locked
device
.
unlockForConfiguration
()
device
.
unlockForConfiguration
()
}
catch
let
e
as
NSError
{
}
catch
let
e
as
NSError
{
self
.
delegate
?
.
captureSessionFailedWithError
?(
captureS
ession
:
self
,
error
:
e
)
self
.
delegate
?
.
sessionFailedWithError
?(
s
ession
:
self
,
error
:
e
)
}
}
}
}
}
}
...
@@ -560,7 +560,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
...
@@ -560,7 +560,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
}
}
device
.
unlockForConfiguration
()
device
.
unlockForConfiguration
()
}
catch
let
e
as
NSError
{
}
catch
let
e
as
NSError
{
delegate
?
.
captureSessionFailedWithError
?(
captureS
ession
:
self
,
error
:
e
)
delegate
?
.
sessionFailedWithError
?(
s
ession
:
self
,
error
:
e
)
}
}
}
}
...
@@ -577,7 +577,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
...
@@ -577,7 +577,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
let
data
=
AVCaptureStillImageOutput
.
jpegStillImageNSDataRepresentation
(
sampleBuffer
)
!
let
data
=
AVCaptureStillImageOutput
.
jpegStillImageNSDataRepresentation
(
sampleBuffer
)
!
if
let
image1
=
UIImage
(
data
:
data
)
{
if
let
image1
=
UIImage
(
data
:
data
)
{
if
let
image2
=
image1
.
adjustOrientation
()
{
if
let
image2
=
image1
.
adjustOrientation
()
{
s
.
delegate
?
.
captureSessionStillImageAsynchronously
?(
captureS
ession
:
s
,
image
:
image2
)
s
.
delegate
?
.
sessionStillImageAsynchronously
?(
s
ession
:
s
,
image
:
image2
)
}
else
{
}
else
{
var
userInfo
=
[
String
:
Any
]()
var
userInfo
=
[
String
:
Any
]()
userInfo
[
NSLocalizedDescriptionKey
]
=
"[Material Error: Cannot fix image orientation.]"
userInfo
[
NSLocalizedDescriptionKey
]
=
"[Material Error: Cannot fix image orientation.]"
...
@@ -595,7 +595,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
...
@@ -595,7 +595,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
}
}
if
let
e
:
Error
=
captureError
{
if
let
e
:
Error
=
captureError
{
s
.
delegate
?
.
captureSessionStillImageAsynchronouslyFailedWithError
?(
captureS
ession
:
s
,
error
:
e
)
s
.
delegate
?
.
sessionStillImageAsynchronouslyFailedWithError
?(
s
ession
:
s
,
error
:
e
)
}
}
}
}
}
}
...
@@ -620,7 +620,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
...
@@ -620,7 +620,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
v
.
isSmoothAutoFocusEnabled
=
true
v
.
isSmoothAutoFocusEnabled
=
true
v
.
unlockForConfiguration
()
v
.
unlockForConfiguration
()
}
catch
let
e
as
NSError
{
}
catch
let
e
as
NSError
{
s
.
delegate
?
.
captureSessionFailedWithError
?(
captureS
ession
:
s
,
error
:
e
)
s
.
delegate
?
.
sessionFailedWithError
?(
s
ession
:
s
,
error
:
e
)
}
}
}
}
...
@@ -643,12 +643,12 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
...
@@ -643,12 +643,12 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
public
func
capture
(
_
captureOutput
:
AVCaptureFileOutput
!
,
didStartRecordingToOutputFileAt
fileURL
:
URL
!
,
fromConnections
connections
:
[
Any
]
!
)
{
public
func
capture
(
_
captureOutput
:
AVCaptureFileOutput
!
,
didStartRecordingToOutputFileAt
fileURL
:
URL
!
,
fromConnections
connections
:
[
Any
]
!
)
{
isRecording
=
true
isRecording
=
true
delegate
?
.
captureSessionDidStartRecordingToOutputFileAtURL
?(
captureS
ession
:
self
,
captureOutput
:
captureOutput
,
fileURL
:
fileURL
as
NSURL
,
fromConnections
:
connections
)
delegate
?
.
sessionDidStartRecordingToOutputFileAtURL
?(
s
ession
:
self
,
captureOutput
:
captureOutput
,
fileURL
:
fileURL
as
NSURL
,
fromConnections
:
connections
)
}
}
public
func
capture
(
_
captureOutput
:
AVCaptureFileOutput
!
,
didFinishRecordingToOutputFileAt
outputFileURL
:
URL
!
,
fromConnections
connections
:
[
Any
]
!
,
error
:
Error
!
)
{
public
func
capture
(
_
captureOutput
:
AVCaptureFileOutput
!
,
didFinishRecordingToOutputFileAt
outputFileURL
:
URL
!
,
fromConnections
connections
:
[
Any
]
!
,
error
:
Error
!
)
{
isRecording
=
false
isRecording
=
false
delegate
?
.
captureSessionDidFinishRecordingToOutputFileAtURL
?(
captureS
ession
:
self
,
captureOutput
:
captureOutput
,
outputFileURL
:
outputFileURL
as
NSURL
,
fromConnections
:
connections
,
error
:
error
)
delegate
?
.
sessionDidFinishRecordingToOutputFileAtURL
?(
s
ession
:
self
,
captureOutput
:
captureOutput
,
outputFileURL
:
outputFileURL
as
NSURL
,
fromConnections
:
connections
,
error
:
error
)
}
}
/// Prepares the sessionQueue.
/// Prepares the sessionQueue.
...
@@ -669,7 +669,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
...
@@ -669,7 +669,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
session
.
addInput
(
activeVideoInput
)
session
.
addInput
(
activeVideoInput
)
}
}
}
catch
let
e
as
NSError
{
}
catch
let
e
as
NSError
{
delegate
?
.
captureSessionFailedWithError
?(
captureS
ession
:
self
,
error
:
e
)
delegate
?
.
sessionFailedWithError
?(
s
ession
:
self
,
error
:
e
)
}
}
}
}
...
@@ -681,7 +681,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
...
@@ -681,7 +681,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
session
.
addInput
(
activeAudioInput
)
session
.
addInput
(
activeAudioInput
)
}
}
}
catch
let
e
as
NSError
{
}
catch
let
e
as
NSError
{
delegate
?
.
captureSessionFailedWithError
?(
captureS
ession
:
self
,
error
:
e
)
delegate
?
.
sessionFailedWithError
?(
s
ession
:
self
,
error
:
e
)
}
}
}
}
...
@@ -729,7 +729,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
...
@@ -729,7 +729,7 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
dateFormatter
.
timeStyle
=
.
full
dateFormatter
.
timeStyle
=
.
full
return
directory
.
appendingPathComponent
(
dateFormatter
.
string
(
from
:
NSDate
()
as
Date
)
+
".mov"
)
return
directory
.
appendingPathComponent
(
dateFormatter
.
string
(
from
:
NSDate
()
as
Date
)
+
".mov"
)
}
catch
let
e
as
NSError
{
}
catch
let
e
as
NSError
{
delegate
?
.
captureSessionCreateMovieFileFailedWithError
?(
captureS
ession
:
self
,
error
:
e
)
delegate
?
.
sessionCreateMovieFileFailedWithError
?(
s
ession
:
self
,
error
:
e
)
}
}
return
nil
return
nil
}
}
...
...
Sources/iOS/CollectionReusableView.swift
View file @
3386efad
...
@@ -157,7 +157,7 @@ open class CollectionReusableView: UICollectionReusableView {
...
@@ -157,7 +157,7 @@ open class CollectionReusableView: UICollectionReusableView {
}
}
/// A reference to EdgeInsets.
/// A reference to EdgeInsets.
@IBInspectable
open
var
content
Inset
:
UIEdgeInsets
{
@IBInspectable
open
var
content
EdgeInsets
:
UIEdgeInsets
{
get
{
get
{
return
grid
.
contentEdgeInsets
return
grid
.
contentEdgeInsets
}
}
...
@@ -183,7 +183,7 @@ open class CollectionReusableView: UICollectionReusableView {
...
@@ -183,7 +183,7 @@ open class CollectionReusableView: UICollectionReusableView {
}
}
}
}
/// A property that accesses the backing layer's background
Color.
/// A property that accesses the backing layer's background
@IBInspectable
open
override
var
backgroundColor
:
UIColor
?
{
@IBInspectable
open
override
var
backgroundColor
:
UIColor
?
{
didSet
{
didSet
{
layer
.
backgroundColor
=
backgroundColor
?
.
cgColor
layer
.
backgroundColor
=
backgroundColor
?
.
cgColor
...
...
Sources/iOS/CollectionView.swift
View file @
3386efad
...
@@ -41,7 +41,7 @@ open class CollectionView: UICollectionView {
...
@@ -41,7 +41,7 @@ open class CollectionView: UICollectionView {
}
}
}
}
open
override
var
contentInset
:
UI
EdgeInsets
{
open
var
contentEdgeInsets
:
EdgeInsets
{
get
{
get
{
return
(
collectionViewLayout
as?
CollectionViewLayout
)
!.
contentEdgeInsets
return
(
collectionViewLayout
as?
CollectionViewLayout
)
!.
contentEdgeInsets
}
}
...
@@ -68,7 +68,8 @@ open class CollectionView: UICollectionView {
...
@@ -68,7 +68,8 @@ open class CollectionView: UICollectionView {
}
}
/// Spacing between items.
/// Spacing between items.
@IBInspectable
open
var
interimSpace
:
InterimSpace
{
@IBInspectable
open
var
interimSpace
:
InterimSpace
{
get
{
get
{
return
(
collectionViewLayout
as?
CollectionViewLayout
)
!.
interimSpace
return
(
collectionViewLayout
as?
CollectionViewLayout
)
!.
interimSpace
}
}
...
@@ -119,7 +120,7 @@ open class CollectionView: UICollectionView {
...
@@ -119,7 +120,7 @@ open class CollectionView: UICollectionView {
*/
*/
open
func
prepare
()
{
open
func
prepare
()
{
contentScaleFactor
=
Device
.
scale
contentScaleFactor
=
Device
.
scale
backgroundColor
=
Color
.
clear
backgroundColor
=
.
clear
content
Inset
=
.
zero
content
EdgeInsets
=
.
zero
}
}
}
}
Sources/iOS/CollectionViewCell.swift
View file @
3386efad
...
@@ -162,7 +162,7 @@ open class CollectionViewCell: UICollectionViewCell {
...
@@ -162,7 +162,7 @@ open class CollectionViewCell: UICollectionViewCell {
/// A reference to EdgeInsets.
/// A reference to EdgeInsets.
@IBInspectable
@IBInspectable
open
var
content
Inset
:
EdgeInsets
{
open
var
content
EdgeInsets
:
EdgeInsets
{
get
{
get
{
return
contentView
.
grid
.
contentEdgeInsets
return
contentView
.
grid
.
contentEdgeInsets
}
}
...
@@ -189,7 +189,7 @@ open class CollectionViewCell: UICollectionViewCell {
...
@@ -189,7 +189,7 @@ open class CollectionViewCell: UICollectionViewCell {
}
}
}
}
/// A property that accesses the backing layer's background
Color.
/// A property that accesses the backing layer's background
@IBInspectable
@IBInspectable
open
override
var
backgroundColor
:
UIColor
?
{
open
override
var
backgroundColor
:
UIColor
?
{
didSet
{
didSet
{
...
...
Sources/iOS/Color.swift
View file @
3386efad
...
@@ -56,30 +56,21 @@ public protocol ColorPalette {
...
@@ -56,30 +56,21 @@ public protocol ColorPalette {
optional
static
var
accent4
:
UIColor
{
get
}
optional
static
var
accent4
:
UIColor
{
get
}
}
}
open
class
Color
{
open
class
Color
:
UIColor
{
// clear
open
static
let
clear
=
UIColor
.
clear
// white
open
static
let
white
=
UIColor
.
white
// black
open
static
let
black
=
UIColor
.
black
// dark text
// dark text
open
class
darkText
{
open
class
darkText
{
open
static
let
primary
=
Color
.
black
.
withAlphaComponent
(
0.87
)
open
static
let
primary
=
black
.
withAlphaComponent
(
0.87
)
open
static
let
secondary
=
Color
.
black
.
withAlphaComponent
(
0.54
)
open
static
let
secondary
=
black
.
withAlphaComponent
(
0.54
)
open
static
let
others
=
Color
.
black
.
withAlphaComponent
(
0.38
)
open
static
let
others
=
black
.
withAlphaComponent
(
0.38
)
open
static
let
dividers
=
Color
.
black
.
withAlphaComponent
(
0.12
)
open
static
let
dividers
=
black
.
withAlphaComponent
(
0.12
)
}
}
// light text
// light text
open
class
lightText
{
open
class
lightText
{
open
static
let
primary
=
Color
.
white
open
static
let
primary
=
white
open
static
let
secondary
=
Color
.
white
.
withAlphaComponent
(
0.7
)
open
static
let
secondary
=
white
.
withAlphaComponent
(
0.7
)
open
static
let
others
=
Color
.
white
.
withAlphaComponent
(
0.5
)
open
static
let
others
=
white
.
withAlphaComponent
(
0.5
)
open
static
let
dividers
=
Color
.
white
.
withAlphaComponent
(
0.12
)
open
static
let
dividers
=
white
.
withAlphaComponent
(
0.12
)
}
}
// red
// red
...
...
Sources/iOS/Divider.swift
View file @
3386efad
...
@@ -48,7 +48,7 @@ open class Divider {
...
@@ -48,7 +48,7 @@ open class Divider {
/// A reference to the height.
/// A reference to the height.
public
var
height
:
CGFloat
public
var
height
:
CGFloat
/// A UI
Color.
/// A UI
open
var
color
:
UIColor
?
{
open
var
color
:
UIColor
?
{
get
{
get
{
return
line
?
.
backgroundColor
return
line
?
.
backgroundColor
...
...
Sources/iOS/FabButton.swift
View file @
3386efad
...
@@ -43,8 +43,8 @@ open class FabButton: Button {
...
@@ -43,8 +43,8 @@ open class FabButton: Button {
depthPreset
=
.
depth1
depthPreset
=
.
depth1
shapePreset
=
.
circle
shapePreset
=
.
circle
pulseAnimation
=
.
centerWithBacking
pulseAnimation
=
.
centerWithBacking
tintColor
=
Color
.
white
tintColor
=
.
white
pulseColor
=
Color
.
white
pulseColor
=
.
white
backgroundColor
=
Color
.
red
.
base
backgroundColor
=
Color
.
red
.
base
}
}
}
}
Sources/iOS/Material+CALayer.swift
View file @
3386efad
...
@@ -239,7 +239,7 @@ extension CALayer {
...
@@ -239,7 +239,7 @@ extension CALayer {
}
}
}
}
/// A UIColor reference to the `background
Color.
cgColor`.
/// A UIColor reference to the `backgroundcgColor`.
open
var
color
:
UIColor
?
{
open
var
color
:
UIColor
?
{
get
{
get
{
return
nil
==
backgroundColor
?
nil
:
UIColor
(
cgColor
:
backgroundColor
!
)
return
nil
==
backgroundColor
?
nil
:
UIColor
(
cgColor
:
backgroundColor
!
)
...
...
Sources/iOS/Material+UIImage.swift
View file @
3386efad
...
@@ -100,7 +100,7 @@ extension UIImage {
...
@@ -100,7 +100,7 @@ extension UIImage {
- Parameter color: The UIColor to create the image from.
- Parameter color: The UIColor to create the image from.
- Returns: A UIImage that is the color passed in.
- Returns: A UIImage that is the color passed in.
*/
*/
open
func
tint
WithColor
(
color
:
UIColor
)
->
UIImage
?
{
open
func
tint
(
with
color
:
UIColor
)
->
UIImage
?
{
UIGraphicsBeginImageContextWithOptions
(
size
,
false
,
Device
.
scale
)
UIGraphicsBeginImageContextWithOptions
(
size
,
false
,
Device
.
scale
)
guard
let
context
=
UIGraphicsGetCurrentContext
()
else
{
guard
let
context
=
UIGraphicsGetCurrentContext
()
else
{
return
nil
return
nil
...
@@ -129,7 +129,7 @@ extension UIImage {
...
@@ -129,7 +129,7 @@ extension UIImage {
- Parameter size: The size of the image to create.
- Parameter size: The size of the image to create.
- Returns: A UIImage that is the color passed in.
- Returns: A UIImage that is the color passed in.
*/
*/
open
class
func
image
WithColor
(
color
:
UIColor
,
size
:
CGSize
)
->
UIImage
?
{
open
class
func
image
(
with
color
:
UIColor
,
size
:
CGSize
)
->
UIImage
?
{
let
rect
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
size
.
width
,
height
:
size
.
height
)
let
rect
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
size
.
width
,
height
:
size
.
height
)
UIGraphicsBeginImageContextWithOptions
(
size
,
false
,
0
)
UIGraphicsBeginImageContextWithOptions
(
size
,
false
,
0
)
color
.
setFill
()
color
.
setFill
()
...
...
Sources/iOS/Material+UIView.swift
View file @
3386efad
...
@@ -110,7 +110,7 @@ extension UIView {
...
@@ -110,7 +110,7 @@ extension UIView {
}
}
}
}
/// A property that accesses the backing layer's shadow
Color.
/// A property that accesses the backing layer's shadow
@IBInspectable
@IBInspectable
open
var
shadowColor
:
UIColor
?
{
open
var
shadowColor
:
UIColor
?
{
get
{
get
{
...
...
Sources/iOS/MenuItem.swift
View file @
3386efad
...
@@ -98,7 +98,7 @@ open class MenuItem: View {
...
@@ -98,7 +98,7 @@ open class MenuItem: View {
private
func
prepareTitleLabel
()
{
private
func
prepareTitleLabel
()
{
titleLabel
.
font
=
RobotoFont
.
regular
(
with
:
14
)
titleLabel
.
font
=
RobotoFont
.
regular
(
with
:
14
)
titleLabel
.
textAlignment
=
.
center
titleLabel
.
textAlignment
=
.
center
titleLabel
.
backgroundColor
=
Color
.
white
titleLabel
.
backgroundColor
=
.
white
titleLabel
.
depthPreset
=
button
.
depthPreset
titleLabel
.
depthPreset
=
button
.
depthPreset
titleLabel
.
cornerRadiusPreset
=
.
cornerRadius1
titleLabel
.
cornerRadiusPreset
=
.
cornerRadius1
addSubview
(
titleLabel
)
addSubview
(
titleLabel
)
...
...
Sources/iOS/NavigationBar.swift
View file @
3386efad
...
@@ -115,7 +115,7 @@ open class NavigationBar: UINavigationBar {
...
@@ -115,7 +115,7 @@ open class NavigationBar: UINavigationBar {
}
}
}
}
/// A property that accesses the backing layer's background
Color.
/// A property that accesses the backing layer's background
@IBInspectable
@IBInspectable
open
override
var
backgroundColor
:
UIColor
?
{
open
override
var
backgroundColor
:
UIColor
?
{
didSet
{
didSet
{
...
@@ -300,7 +300,7 @@ open class NavigationBar: UINavigationBar {
...
@@ -300,7 +300,7 @@ open class NavigationBar: UINavigationBar {
The super.prepare method should always be called immediately
The super.prepare method should always be called immediately
when subclassing.
when subclassing.
*/
*/
public
func
prepare
()
{
open
func
prepare
()
{
barStyle
=
.
black
barStyle
=
.
black
isTranslucent
=
false
isTranslucent
=
false
depthPreset
=
.
depth1
depthPreset
=
.
depth1
...
@@ -308,10 +308,10 @@ open class NavigationBar: UINavigationBar {
...
@@ -308,10 +308,10 @@ open class NavigationBar: UINavigationBar {
contentEdgeInsetsPreset
=
.
square1
contentEdgeInsetsPreset
=
.
square1
contentScaleFactor
=
Device
.
scale
contentScaleFactor
=
Device
.
scale
backButtonImage
=
Icon
.
cm
.
arrowBack
backButtonImage
=
Icon
.
cm
.
arrowBack
let
image
=
UIImage
.
image
WithColor
(
color
:
Color
.
clear
,
size
:
CGSize
(
width
:
1
,
height
:
1
))
let
image
=
UIImage
.
image
(
with
:
.
clear
,
size
:
CGSize
(
width
:
1
,
height
:
1
))
shadowImage
=
image
shadowImage
=
image
setBackgroundImage
(
image
,
for
:
.
default
)
setBackgroundImage
(
image
,
for
:
.
default
)
backgroundColor
=
Color
.
white
backgroundColor
=
.
white
}
}
/**
/**
...
...
Sources/iOS/NavigationController.swift
View file @
3386efad
...
@@ -112,7 +112,7 @@ open class NavigationController: UINavigationController {
...
@@ -112,7 +112,7 @@ open class NavigationController: UINavigationController {
*/
*/
open
func
prepare
()
{
open
func
prepare
()
{
view
.
clipsToBounds
=
true
view
.
clipsToBounds
=
true
view
.
backgroundColor
=
Color
.
white
view
.
backgroundColor
=
.
white
view
.
contentScaleFactor
=
Device
.
scale
view
.
contentScaleFactor
=
Device
.
scale
// This ensures the panning gesture is available when going back between views.
// This ensures the panning gesture is available when going back between views.
...
...
Sources/iOS/NavigationDrawerController.swift
View file @
3386efad
...
@@ -975,7 +975,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
...
@@ -975,7 +975,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
/// Prepares the contentViewController.
/// Prepares the contentViewController.
private
func
prepareContentViewController
()
{
private
func
prepareContentViewController
()
{
contentViewController
.
view
.
backgroundColor
=
Color
.
black
contentViewController
.
view
.
backgroundColor
=
.
black
prepare
(
viewController
:
contentViewController
,
withContainer
:
view
)
prepare
(
viewController
:
contentViewController
,
withContainer
:
view
)
view
.
sendSubview
(
toBack
:
contentViewController
.
view
)
view
.
sendSubview
(
toBack
:
contentViewController
.
view
)
}
}
...
...
Sources/iOS/PhotoLibraryController.swift
View file @
3386efad
...
@@ -48,7 +48,7 @@ open class PhotoLibraryController: UIViewController {
...
@@ -48,7 +48,7 @@ open class PhotoLibraryController: UIViewController {
*/
*/
open
func
prepare
()
{
open
func
prepare
()
{
view
.
clipsToBounds
=
true
view
.
clipsToBounds
=
true
view
.
backgroundColor
=
Color
.
white
view
.
backgroundColor
=
.
white
view
.
contentScaleFactor
=
Device
.
scale
view
.
contentScaleFactor
=
Device
.
scale
preparePhotoLibrary
()
preparePhotoLibrary
()
}
}
...
...
Sources/iOS/Pulse.swift
View file @
3386efad
...
@@ -34,7 +34,7 @@ internal struct Pulse {
...
@@ -34,7 +34,7 @@ internal struct Pulse {
/// An Array of layers.
/// An Array of layers.
internal
lazy
var
layers
=
[
CAShapeLayer
]()
internal
lazy
var
layers
=
[
CAShapeLayer
]()
/// A UI
Color.
/// A UI
internal
var
color
=
Color
.
blueGrey
.
base
internal
var
color
=
Color
.
blueGrey
.
base
/// A reference to the PulseAnimation.
/// A reference to the PulseAnimation.
...
...
Sources/iOS/RaisedButton.swift
View file @
3386efad
...
@@ -42,6 +42,6 @@ open class RaisedButton: Button {
...
@@ -42,6 +42,6 @@ open class RaisedButton: Button {
super
.
prepare
()
super
.
prepare
()
depthPreset
=
.
depth1
depthPreset
=
.
depth1
cornerRadiusPreset
=
.
cornerRadius1
cornerRadiusPreset
=
.
cornerRadius1
backgroundColor
=
Color
.
white
backgroundColor
=
.
white
}
}
}
}
Sources/iOS/RootController.swift
View file @
3386efad
...
@@ -152,7 +152,7 @@ open class RootController: UIViewController {
...
@@ -152,7 +152,7 @@ open class RootController: UIViewController {
*/
*/
open
func
prepare
()
{
open
func
prepare
()
{
view
.
clipsToBounds
=
true
view
.
clipsToBounds
=
true
view
.
backgroundColor
=
Color
.
white
view
.
backgroundColor
=
.
white
view
.
contentScaleFactor
=
Device
.
scale
view
.
contentScaleFactor
=
Device
.
scale
prepareRootViewController
()
prepareRootViewController
()
}
}
...
...
Sources/iOS/SearchBar.swift
View file @
3386efad
...
@@ -74,17 +74,17 @@ open class SearchBar: Bar {
...
@@ -74,17 +74,17 @@ open class SearchBar: Bar {
@IBInspectable
@IBInspectable
open
var
placeholder
:
String
?
{
open
var
placeholder
:
String
?
{
didSet
{
didSet
{
if
let
v
:
String
=
placeholder
{
if
let
v
=
placeholder
{
textField
.
attributedPlaceholder
=
NSAttributedString
(
string
:
v
,
attributes
:
[
NSForegroundColorAttributeName
:
placeholderColor
])
textField
.
attributedPlaceholder
=
NSAttributedString
(
string
:
v
,
attributes
:
[
NSForegroundColorAttributeName
:
placeholderColor
])
}
}
}
}
}
}
/// Placeholder text
Color.
/// Placeholder text
@IBInspectable
@IBInspectable
open
var
placeholderColor
=
Color
.
darkText
.
others
{
open
var
placeholderColor
=
Color
.
darkText
.
others
{
didSet
{
didSet
{
if
let
v
:
String
=
placeholder
{
if
let
v
=
placeholder
{
textField
.
attributedPlaceholder
=
NSAttributedString
(
string
:
v
,
attributes
:
[
NSForegroundColorAttributeName
:
placeholderColor
])
textField
.
attributedPlaceholder
=
NSAttributedString
(
string
:
v
,
attributes
:
[
NSForegroundColorAttributeName
:
placeholderColor
])
}
}
}
}
...
...
Sources/iOS/Switch.swift
View file @
3386efad
...
@@ -89,7 +89,7 @@ open class Switch: UIControl {
...
@@ -89,7 +89,7 @@ open class Switch: UIControl {
/// Indicates if the animation should bounce.
/// Indicates if the animation should bounce.
@IBInspectable
@IBInspectable
public
var
bounceable
=
true
{
open
var
bounceable
=
true
{
didSet
{
didSet
{
bounceOffset
=
bounceable
?
3
:
0
bounceOffset
=
bounceable
?
3
:
0
}
}
...
@@ -97,7 +97,7 @@ open class Switch: UIControl {
...
@@ -97,7 +97,7 @@ open class Switch: UIControl {
/// Button on color.
/// Button on color.
@IBInspectable
@IBInspectable
public
var
buttonOnColor
=
Color
.
clear
{
open
var
buttonOnColor
=
Color
.
clear
{
didSet
{
didSet
{
styleForState
(
state
:
switchState
)
styleForState
(
state
:
switchState
)
}
}
...
@@ -105,7 +105,7 @@ open class Switch: UIControl {
...
@@ -105,7 +105,7 @@ open class Switch: UIControl {
/// Button off color.
/// Button off color.
@IBInspectable
@IBInspectable
public
var
buttonOffColor
=
Color
.
clear
{
open
var
buttonOffColor
=
Color
.
clear
{
didSet
{
didSet
{
styleForState
(
state
:
switchState
)
styleForState
(
state
:
switchState
)
}
}
...
@@ -113,7 +113,7 @@ open class Switch: UIControl {
...
@@ -113,7 +113,7 @@ open class Switch: UIControl {
/// Track on color.
/// Track on color.
@IBInspectable
@IBInspectable
public
var
trackOnColor
=
Color
.
clear
{
open
var
trackOnColor
=
Color
.
clear
{
didSet
{
didSet
{
styleForState
(
state
:
switchState
)
styleForState
(
state
:
switchState
)
}
}
...
@@ -121,7 +121,7 @@ open class Switch: UIControl {
...
@@ -121,7 +121,7 @@ open class Switch: UIControl {
/// Track off color.
/// Track off color.
@IBInspectable
@IBInspectable
public
var
trackOffColor
=
Color
.
clear
{
open
var
trackOffColor
=
Color
.
clear
{
didSet
{
didSet
{
styleForState
(
state
:
switchState
)
styleForState
(
state
:
switchState
)
}
}
...
@@ -129,7 +129,7 @@ open class Switch: UIControl {
...
@@ -129,7 +129,7 @@ open class Switch: UIControl {
/// Button on disabled color.
/// Button on disabled color.
@IBInspectable
@IBInspectable
public
var
buttonOnDisabledColor
=
Color
.
clear
{
open
var
buttonOnDisabledColor
=
Color
.
clear
{
didSet
{
didSet
{
styleForState
(
state
:
switchState
)
styleForState
(
state
:
switchState
)
}
}
...
@@ -137,7 +137,7 @@ open class Switch: UIControl {
...
@@ -137,7 +137,7 @@ open class Switch: UIControl {
/// Track on disabled color.
/// Track on disabled color.
@IBInspectable
@IBInspectable
public
var
trackOnDisabledColor
=
Color
.
clear
{
open
var
trackOnDisabledColor
=
Color
.
clear
{
didSet
{
didSet
{
styleForState
(
state
:
switchState
)
styleForState
(
state
:
switchState
)
}
}
...
@@ -145,7 +145,7 @@ open class Switch: UIControl {
...
@@ -145,7 +145,7 @@ open class Switch: UIControl {
/// Button off disabled color.
/// Button off disabled color.
@IBInspectable
@IBInspectable
public
var
buttonOffDisabledColor
=
Color
.
clear
{
open
var
buttonOffDisabledColor
=
Color
.
clear
{
didSet
{
didSet
{
styleForState
(
state
:
switchState
)
styleForState
(
state
:
switchState
)
}
}
...
@@ -153,21 +153,21 @@ open class Switch: UIControl {
...
@@ -153,21 +153,21 @@ open class Switch: UIControl {
/// Track off disabled color.
/// Track off disabled color.
@IBInspectable
@IBInspectable
public
var
trackOffDisabledColor
=
Color
.
clear
{
open
var
trackOffDisabledColor
=
Color
.
clear
{
didSet
{
didSet
{
styleForState
(
state
:
switchState
)
styleForState
(
state
:
switchState
)
}
}
}
}
/// Track view reference.
/// Track view reference.
public
private(set)
var
track
:
UIView
{
open
private(set)
var
track
:
UIView
{
didSet
{
didSet
{
prepareTrack
()
prepareTrack
()
}
}
}
}
/// Button view reference.
/// Button view reference.
public
private(set)
var
button
:
FabButton
{
open
private(set)
var
button
:
FabButton
{
didSet
{
didSet
{
prepareButton
()
prepareButton
()
}
}
...
...
Sources/iOS/TableViewCell.swift
View file @
3386efad
...
@@ -74,7 +74,7 @@ open class TableViewCell: UITableViewCell {
...
@@ -74,7 +74,7 @@ open class TableViewCell: UITableViewCell {
}
}
}
}
/// A property that accesses the backing layer's background
Color.
/// A property that accesses the backing layer's background
@IBInspectable
@IBInspectable
open
override
var
backgroundColor
:
UIColor
?
{
open
override
var
backgroundColor
:
UIColor
?
{
didSet
{
didSet
{
...
...
Sources/iOS/TextField.swift
View file @
3386efad
...
@@ -125,7 +125,7 @@ open class TextField: UITextField {
...
@@ -125,7 +125,7 @@ open class TextField: UITextField {
@IBInspectable
@IBInspectable
open
private(set)
var
placeholderLabel
:
UILabel
!
open
private(set)
var
placeholderLabel
:
UILabel
!
/// Placeholder normal text
Color.
/// Placeholder normal text
@IBInspectable
@IBInspectable
open
var
placeholderNormalColor
=
Color
.
darkText
.
others
{
open
var
placeholderNormalColor
=
Color
.
darkText
.
others
{
didSet
{
didSet
{
...
@@ -141,7 +141,7 @@ open class TextField: UITextField {
...
@@ -141,7 +141,7 @@ open class TextField: UITextField {
}
}
}
}
/// Placeholder active text
Color.
/// Placeholder active text
@IBInspectable
@IBInspectable
open
var
placeholderActiveColor
=
Color
.
blue
.
base
{
open
var
placeholderActiveColor
=
Color
.
blue
.
base
{
didSet
{
didSet
{
...
@@ -178,7 +178,7 @@ open class TextField: UITextField {
...
@@ -178,7 +178,7 @@ open class TextField: UITextField {
}
}
}
}
/// Detail text
Color.
/// Detail text
@IBInspectable
@IBInspectable
open
var
detailColor
=
Color
.
darkText
.
others
{
open
var
detailColor
=
Color
.
darkText
.
others
{
didSet
{
didSet
{
...
...
Sources/iOS/TextView.swift
View file @
3386efad
...
@@ -35,7 +35,7 @@ public protocol TextViewDelegate : UITextViewDelegate {}
...
@@ -35,7 +35,7 @@ public protocol TextViewDelegate : UITextViewDelegate {}
@objc(TextView)
@objc(TextView)
public
class
TextView
:
UITextView
{
public
class
TextView
:
UITextView
{
/// A property that accesses the backing layer's background
Color.
/// A property that accesses the backing layer's background
@IBInspectable
public
override
var
backgroundColor
:
UIColor
?
{
@IBInspectable
public
override
var
backgroundColor
:
UIColor
?
{
didSet
{
didSet
{
layer
.
backgroundColor
=
backgroundColor
?
.
cgColor
layer
.
backgroundColor
=
backgroundColor
?
.
cgColor
...
@@ -223,7 +223,7 @@ public class TextView: UITextView {
...
@@ -223,7 +223,7 @@ public class TextView: UITextView {
public
func
prepare
()
{
public
func
prepare
()
{
contentScaleFactor
=
Device
.
scale
contentScaleFactor
=
Device
.
scale
textContainerInset
=
.
zero
textContainerInset
=
.
zero
backgroundColor
=
Color
.
white
backgroundColor
=
.
white
clipsToBounds
=
false
clipsToBounds
=
false
removeNotificationHandlers
()
removeNotificationHandlers
()
prepareNotificationHandlers
()
prepareNotificationHandlers
()
...
@@ -236,7 +236,7 @@ public class TextView: UITextView {
...
@@ -236,7 +236,7 @@ public class TextView: UITextView {
v
.
font
=
font
v
.
font
=
font
v
.
textAlignment
=
textAlignment
v
.
textAlignment
=
textAlignment
v
.
numberOfLines
=
0
v
.
numberOfLines
=
0
v
.
backgroundColor
=
Color
.
clear
v
.
backgroundColor
=
.
clear
addSubview
(
v
)
addSubview
(
v
)
reloadView
()
reloadView
()
handleTextViewTextDidChange
()
handleTextViewTextDidChange
()
...
...
Sources/iOS/View.swift
View file @
3386efad
...
@@ -116,7 +116,7 @@ open class View: UIView {
...
@@ -116,7 +116,7 @@ open class View: UIView {
}
}
}
}
/// A property that accesses the backing layer's background
Color.
/// A property that accesses the backing layer's background
@IBInspectable
@IBInspectable
open
override
var
backgroundColor
:
UIColor
?
{
open
override
var
backgroundColor
:
UIColor
?
{
didSet
{
didSet
{
...
...
Sources/macOS/Color.swift
View file @
3386efad
...
@@ -58,28 +58,28 @@ public protocol ColorPalette {
...
@@ -58,28 +58,28 @@ public protocol ColorPalette {
open
class
Color
{
open
class
Color
{
// clear
// clear
open
static
let
clear
=
NS
Color
.
clear
open
static
let
clear
=
NSclear
// white
// white
open
static
let
white
=
NS
Color
.
white
open
static
let
white
=
NSwhite
// black
// black
open
static
let
black
=
NS
Color
.
black
open
static
let
black
=
NSblack
// dark text
// dark text
open
class
darkText
{
open
class
darkText
{
open
static
let
primary
=
Color
.
black
.
withAlphaComponent
(
0.87
)
open
static
let
primary
=
black
.
withAlphaComponent
(
0.87
)
open
static
let
secondary
=
Color
.
black
.
withAlphaComponent
(
0.54
)
open
static
let
secondary
=
black
.
withAlphaComponent
(
0.54
)
open
static
let
others
=
Color
.
black
.
withAlphaComponent
(
0.38
)
open
static
let
others
=
black
.
withAlphaComponent
(
0.38
)
open
static
let
dividers
=
Color
.
black
.
withAlphaComponent
(
0.12
)
open
static
let
dividers
=
black
.
withAlphaComponent
(
0.12
)
}
}
// light text
// light text
open
class
lightText
{
open
class
lightText
{
open
static
let
primary
=
Color
.
white
open
static
let
primary
=
white
open
static
let
secondary
=
Color
.
white
.
withAlphaComponent
(
0.7
)
open
static
let
secondary
=
white
.
withAlphaComponent
(
0.7
)
open
static
let
others
=
Color
.
white
.
withAlphaComponent
(
0.5
)
open
static
let
others
=
white
.
withAlphaComponent
(
0.5
)
open
static
let
dividers
=
Color
.
white
.
withAlphaComponent
(
0.12
)
open
static
let
dividers
=
white
.
withAlphaComponent
(
0.12
)
}
}
// red
// red
...
...
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