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
928ba8cb
Unverified
Commit
928ba8cb
authored
Sep 09, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: updated access rights and renamed ControlView to ContentView
parent
05b19fa0
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
224 additions
and
203 deletions
+224
-203
Material.xcodeproj/project.pbxproj
+18
-10
Sources/iOS/BarView.swift
+1
-1
Sources/iOS/Button.swift
+1
-1
Sources/iOS/Capture.swift
+5
-5
Sources/iOS/CaptureSession.swift
+2
-2
Sources/iOS/CollectionView.swift
+4
-4
Sources/iOS/CollectionViewLayout.swift
+15
-15
Sources/iOS/ContentView.swift
+5
-3
Sources/iOS/Menu.swift
+8
-7
Sources/iOS/NavigationDrawerController.swift
+49
-49
Sources/iOS/SearchBar.swift
+6
-7
Sources/iOS/Switch.swift
+102
-91
Sources/iOS/TextField.swift
+8
-8
No files found.
Material.xcodeproj/project.pbxproj
View file @
928ba8cb
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
96BCB7A41CB40DC500C806FE
/* CaptureSession.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB75B1CB40DC500C806FE
/* CaptureSession.swift */
;
};
96BCB7A41CB40DC500C806FE
/* CaptureSession.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB75B1CB40DC500C806FE
/* CaptureSession.swift */
;
};
96BCB7A51CB40DC500C806FE
/* Capture.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB75C1CB40DC500C806FE
/* Capture.swift */
;
};
96BCB7A51CB40DC500C806FE
/* Capture.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB75C1CB40DC500C806FE
/* Capture.swift */
;
};
96BCB7A61CB40DC500C806FE
/* Card.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB75D1CB40DC500C806FE
/* Card.swift */
;
};
96BCB7A61CB40DC500C806FE
/* Card.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB75D1CB40DC500C806FE
/* Card.swift */
;
};
96BCB7A71CB40DC500C806FE
/* Cont
rolView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB75E1CB40DC500C806FE
/* Control
View.swift */
;
};
96BCB7A71CB40DC500C806FE
/* Cont
entView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB75E1CB40DC500C806FE
/* Content
View.swift */
;
};
96BCB7A81CB40DC500C806FE
/* FabButton.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB75F1CB40DC500C806FE
/* FabButton.swift */
;
};
96BCB7A81CB40DC500C806FE
/* FabButton.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB75F1CB40DC500C806FE
/* FabButton.swift */
;
};
96BCB7A91CB40DC500C806FE
/* FlatButton.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7601CB40DC500C806FE
/* FlatButton.swift */
;
};
96BCB7A91CB40DC500C806FE
/* FlatButton.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7601CB40DC500C806FE
/* FlatButton.swift */
;
};
96BCB7AA1CB40DC500C806FE
/* Grid.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7611CB40DC500C806FE
/* Grid.swift */
;
};
96BCB7AA1CB40DC500C806FE
/* Grid.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7611CB40DC500C806FE
/* Grid.swift */
;
};
...
@@ -133,7 +133,7 @@
...
@@ -133,7 +133,7 @@
96BCB8351CB4115200C806FE
/* MaterialTextLayer.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB78A1CB40DC500C806FE
/* MaterialTextLayer.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8351CB4115200C806FE
/* MaterialTextLayer.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB78A1CB40DC500C806FE
/* MaterialTextLayer.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8361CB4115200C806FE
/* Grid.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7611CB40DC500C806FE
/* Grid.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8361CB4115200C806FE
/* Grid.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7611CB40DC500C806FE
/* Grid.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8371CB4115200C806FE
/* Layout.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7811CB40DC500C806FE
/* Layout.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8371CB4115200C806FE
/* Layout.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7811CB40DC500C806FE
/* Layout.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8381CB4115200C806FE
/* Cont
rolView.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB75E1CB40DC500C806FE
/* Control
View.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8381CB4115200C806FE
/* Cont
entView.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB75E1CB40DC500C806FE
/* Content
View.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8391CB4115200C806FE
/* SearchBar.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7951CB40DC500C806FE
/* SearchBar.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8391CB4115200C806FE
/* SearchBar.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7951CB40DC500C806FE
/* SearchBar.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB83A1CB4115200C806FE
/* SearchBarController.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7961CB40DC500C806FE
/* SearchBarController.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB83A1CB4115200C806FE
/* SearchBarController.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7961CB40DC500C806FE
/* SearchBarController.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB83B1CB4115200C806FE
/* NavigationDrawerController.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7971CB40DC500C806FE
/* NavigationDrawerController.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB83B1CB4115200C806FE
/* NavigationDrawerController.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7971CB40DC500C806FE
/* NavigationDrawerController.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
...
@@ -225,7 +225,7 @@
...
@@ -225,7 +225,7 @@
96BCB75B1CB40DC500C806FE
/* CaptureSession.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
CaptureSession.swift
;
sourceTree
=
"<group>"
;
};
96BCB75B1CB40DC500C806FE
/* CaptureSession.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
CaptureSession.swift
;
sourceTree
=
"<group>"
;
};
96BCB75C1CB40DC500C806FE
/* Capture.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Capture.swift
;
sourceTree
=
"<group>"
;
};
96BCB75C1CB40DC500C806FE
/* Capture.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Capture.swift
;
sourceTree
=
"<group>"
;
};
96BCB75D1CB40DC500C806FE
/* Card.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Card.swift
;
sourceTree
=
"<group>"
;
};
96BCB75D1CB40DC500C806FE
/* Card.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Card.swift
;
sourceTree
=
"<group>"
;
};
96BCB75E1CB40DC500C806FE
/* Cont
rolView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Control
View.swift
;
sourceTree
=
"<group>"
;
};
96BCB75E1CB40DC500C806FE
/* Cont
entView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Content
View.swift
;
sourceTree
=
"<group>"
;
};
96BCB75F1CB40DC500C806FE
/* FabButton.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
FabButton.swift
;
sourceTree
=
"<group>"
;
};
96BCB75F1CB40DC500C806FE
/* FabButton.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
FabButton.swift
;
sourceTree
=
"<group>"
;
};
96BCB7601CB40DC500C806FE
/* FlatButton.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
FlatButton.swift
;
sourceTree
=
"<group>"
;
};
96BCB7601CB40DC500C806FE
/* FlatButton.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
FlatButton.swift
;
sourceTree
=
"<group>"
;
};
96BCB7611CB40DC500C806FE
/* Grid.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Grid.swift
;
sourceTree
=
"<group>"
;
};
96BCB7611CB40DC500C806FE
/* Grid.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Grid.swift
;
sourceTree
=
"<group>"
;
};
...
@@ -342,6 +342,14 @@
...
@@ -342,6 +342,14 @@
name
=
Divider
;
name
=
Divider
;
sourceTree
=
"<group>"
;
sourceTree
=
"<group>"
;
};
};
96264BE41D833C8400576F37
/* BarView */
=
{
isa
=
PBXGroup
;
children
=
(
96BCB7981CB40DC500C806FE
/* BarView.swift */
,
);
name
=
BarView
;
sourceTree
=
"<group>"
;
};
962864601D5410FD00690B69
/* JSON */
=
{
962864601D5410FD00690B69
/* JSON */
=
{
isa
=
PBXGroup
;
isa
=
PBXGroup
;
children
=
(
children
=
(
...
@@ -448,13 +456,12 @@
...
@@ -448,13 +456,12 @@
name
=
SearchBar
;
name
=
SearchBar
;
sourceTree
=
"<group>"
;
sourceTree
=
"<group>"
;
};
};
963FBF061D669795008F8512
/* Cont
rol
View */
=
{
963FBF061D669795008F8512
/* Cont
ent
View */
=
{
isa
=
PBXGroup
;
isa
=
PBXGroup
;
children
=
(
children
=
(
96BCB75E1CB40DC500C806FE
/* ControlView.swift */
,
96BCB75E1CB40DC500C806FE
/* ContentView.swift */
,
96BCB7981CB40DC500C806FE
/* BarView.swift */
,
);
);
name
=
Cont
rol
View
;
name
=
Cont
ent
View
;
sourceTree
=
"<group>"
;
sourceTree
=
"<group>"
;
};
};
9661222C1D3EC414008BB4CB
/* macOS */
=
{
9661222C1D3EC414008BB4CB
/* macOS */
=
{
...
@@ -509,12 +516,13 @@
...
@@ -509,12 +516,13 @@
isa
=
PBXGroup
;
isa
=
PBXGroup
;
children
=
(
children
=
(
96BCB8091CB4107700C806FE
/* Animate */
,
96BCB8091CB4107700C806FE
/* Animate */
,
96264BE41D833C8400576F37
/* BarView */
,
962DDD081D6FBBD0001C307C
/* BottomTabBar */
,
962DDD081D6FBBD0001C307C
/* BottomTabBar */
,
96BCB8031CB40F4B00C806FE
/* Button */
,
96BCB8031CB40F4B00C806FE
/* Button */
,
96BCB8021CB40F3B00C806FE
/* Card */
,
96BCB8021CB40F3B00C806FE
/* Card */
,
96BCB7FF1CB40EF000C806FE
/* Capture */
,
96BCB7FF1CB40EF000C806FE
/* Capture */
,
96BCB8051CB40F9C00C806FE
/* Collection */
,
96BCB8051CB40F9C00C806FE
/* Collection */
,
963FBF061D669795008F8512
/* Cont
rol
View */
,
963FBF061D669795008F8512
/* Cont
ent
View */
,
96BCB8001CB40F0300C806FE
/* Color */
,
96BCB8001CB40F0300C806FE
/* Color */
,
962A92581D42839100DBAF8E
/* Data */
,
962A92581D42839100DBAF8E
/* Data */
,
96BCB80B1CB410CC00C806FE
/* Device */
,
96BCB80B1CB410CC00C806FE
/* Device */
,
...
@@ -808,7 +816,7 @@
...
@@ -808,7 +816,7 @@
96BCB8351CB4115200C806FE
/* MaterialTextLayer.swift in Headers */
,
96BCB8351CB4115200C806FE
/* MaterialTextLayer.swift in Headers */
,
96BCB8361CB4115200C806FE
/* Grid.swift in Headers */
,
96BCB8361CB4115200C806FE
/* Grid.swift in Headers */
,
96BCB8371CB4115200C806FE
/* Layout.swift in Headers */
,
96BCB8371CB4115200C806FE
/* Layout.swift in Headers */
,
96BCB8381CB4115200C806FE
/* Cont
rol
View.swift in Headers */
,
96BCB8381CB4115200C806FE
/* Cont
ent
View.swift in Headers */
,
96BCB8391CB4115200C806FE
/* SearchBar.swift in Headers */
,
96BCB8391CB4115200C806FE
/* SearchBar.swift in Headers */
,
96BCB83A1CB4115200C806FE
/* SearchBarController.swift in Headers */
,
96BCB83A1CB4115200C806FE
/* SearchBarController.swift in Headers */
,
96BCB83B1CB4115200C806FE
/* NavigationDrawerController.swift in Headers */
,
96BCB83B1CB4115200C806FE
/* NavigationDrawerController.swift in Headers */
,
...
@@ -1101,7 +1109,7 @@
...
@@ -1101,7 +1109,7 @@
96BCB7D21CB40DC500C806FE
/* TableViewCell.swift in Sources */
,
96BCB7D21CB40DC500C806FE
/* TableViewCell.swift in Sources */
,
96F1DC881D654FDF0025F925
/* Material+CALayer.swift in Sources */
,
96F1DC881D654FDF0025F925
/* Material+CALayer.swift in Sources */
,
96BCB7B61CB40DC500C806FE
/* Animation.swift in Sources */
,
96BCB7B61CB40DC500C806FE
/* Animation.swift in Sources */
,
96BCB7A71CB40DC500C806FE
/* Cont
rol
View.swift in Sources */
,
96BCB7A71CB40DC500C806FE
/* Cont
ent
View.swift in Sources */
,
96BCB7DB1CB40DC500C806FE
/* NavigationItem.swift in Sources */
,
96BCB7DB1CB40DC500C806FE
/* NavigationItem.swift in Sources */
,
96BCB7E01CB40DC500C806FE
/* NavigationDrawerController.swift in Sources */
,
96BCB7E01CB40DC500C806FE
/* NavigationDrawerController.swift in Sources */
,
9628645F1D540AF300690B69
/* DynamicFontType.swift in Sources */
,
9628645F1D540AF300690B69
/* DynamicFontType.swift in Sources */
,
...
...
Sources/iOS/BarView.swift
View file @
928ba8cb
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
import
UIKit
import
UIKit
open
class
BarView
:
Cont
rol
View
{
open
class
BarView
:
Cont
ent
View
{
/// Divider layer.
/// Divider layer.
open
internal(set)
var
divider
:
Divider
!
open
internal(set)
var
divider
:
Divider
!
...
...
Sources/iOS/Button.swift
View file @
928ba8cb
...
@@ -42,7 +42,7 @@ open class Button: UIButton {
...
@@ -42,7 +42,7 @@ open class Button: UIButton {
open
private(set)
lazy
var
visualLayer
=
CAShapeLayer
()
open
private(set)
lazy
var
visualLayer
=
CAShapeLayer
()
/// An Array of pulse layers.
/// An Array of pulse layers.
public
private(set)
lazy
var
pulseLayers
=
[
CAShapeLayer
]()
open
private(set)
lazy
var
pulseLayers
=
[
CAShapeLayer
]()
/// The opacity value for the pulse animation.
/// The opacity value for the pulse animation.
@IBInspectable
@IBInspectable
...
...
Sources/iOS/Capture.swift
View file @
928ba8cb
...
@@ -221,19 +221,19 @@ open class Capture: View, UIGestureRecognizerDelegate {
...
@@ -221,19 +221,19 @@ open class Capture: View, UIGestureRecognizerDelegate {
}
}
/// A reference to the CapturePreview view.
/// A reference to the CapturePreview view.
open
private
(set)
var
previewView
:
CapturePreview
!
open
internal
(set)
var
previewView
:
CapturePreview
!
/// A reference to the CaptureSession.
/// A reference to the CaptureSession.
open
private
(set)
var
captureSession
:
CaptureSession
!
open
internal
(set)
var
captureSession
:
CaptureSession
!
/// A reference to the focus layer used in focus animations.
/// A reference to the focus layer used in focus animations.
open
private
(set)
var
focusLayer
:
Layer
?
open
internal
(set)
var
focusLayer
:
Layer
?
/// A reference to the exposure layer used in exposure animations.
/// A reference to the exposure layer used in exposure animations.
open
private
(set)
var
exposureLayer
:
Layer
?
open
internal
(set)
var
exposureLayer
:
Layer
?
/// A reference to the reset layer used in reset animations.
/// A reference to the reset layer used in reset animations.
open
private
(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
:
UIButton
?
{
...
...
Sources/iOS/CaptureSession.swift
View file @
928ba8cb
...
@@ -192,10 +192,10 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
...
@@ -192,10 +192,10 @@ open class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
internal
var
session
:
AVCaptureSession
!
internal
var
session
:
AVCaptureSession
!
/// A boolean indicating if the session is running.
/// A boolean indicating if the session is running.
open
private(set)
var
isRunning
:
Bool
=
false
open
internal(set)
var
isRunning
=
false
/// A boolean indicating if the session is recording.
/// A boolean indicating if the session is recording.
open
private(set)
var
isRecording
:
Bool
=
false
open
internal(set)
var
isRecording
=
false
/// A reference to the recorded time duration.
/// A reference to the recorded time duration.
open
var
recordedDuration
:
CMTime
{
open
var
recordedDuration
:
CMTime
{
...
...
Sources/iOS/CollectionView.swift
View file @
928ba8cb
...
@@ -35,19 +35,19 @@ open class CollectionView: UICollectionView {
...
@@ -35,19 +35,19 @@ open class CollectionView: UICollectionView {
/// A preset wrapper around contentInset.
/// A preset wrapper around contentInset.
open
var
contentEdgeInsetsPreset
:
EdgeInsets
{
open
var
contentEdgeInsetsPreset
:
EdgeInsets
{
get
{
get
{
return
(
collectionViewLayout
as?
CollectionViewLayout
)
!.
content
Inset
return
(
collectionViewLayout
as?
CollectionViewLayout
)
!.
content
EdgeInsets
}
}
set
(
value
)
{
set
(
value
)
{
(
collectionViewLayout
as?
CollectionViewLayout
)
!.
content
Inset
=
value
(
collectionViewLayout
as?
CollectionViewLayout
)
!.
content
EdgeInsets
=
value
}
}
}
}
open
override
var
contentInset
:
UIEdgeInsets
{
open
override
var
contentInset
:
UIEdgeInsets
{
get
{
get
{
return
(
collectionViewLayout
as?
CollectionViewLayout
)
!.
content
Inset
return
(
collectionViewLayout
as?
CollectionViewLayout
)
!.
content
EdgeInsets
}
}
set
(
value
)
{
set
(
value
)
{
(
collectionViewLayout
as?
CollectionViewLayout
)
!.
content
Inset
=
value
(
collectionViewLayout
as?
CollectionViewLayout
)
!.
content
EdgeInsets
=
value
}
}
}
}
...
...
Sources/iOS/CollectionViewLayout.swift
View file @
928ba8cb
...
@@ -37,27 +37,27 @@ open class CollectionViewLayout: UICollectionViewLayout {
...
@@ -37,27 +37,27 @@ open class CollectionViewLayout: UICollectionViewLayout {
/// The size of items.
/// The size of items.
open
var
itemSize
=
CGSize
.
zero
open
var
itemSize
=
CGSize
.
zero
/// A preset wrapper around content
Inset
.
/// A preset wrapper around content
EdgeInsets
.
open
var
contentEdgeInsetsPreset
:
EdgeInsetsPreset
=
.
none
{
open
var
contentEdgeInsetsPreset
:
EdgeInsetsPreset
=
.
none
{
didSet
{
didSet
{
content
Inset
=
EdgeInsetsPresetToValue
(
preset
:
contentEdgeInsetsPreset
)
content
EdgeInsets
=
EdgeInsetsPresetToValue
(
preset
:
contentEdgeInsetsPreset
)
}
}
}
}
/// A wrapper around grid.content
Inset
.
/// A wrapper around grid.content
EdgeInsets
.
open
var
content
Inset
=
EdgeInsets
.
zero
open
var
content
EdgeInsets
=
EdgeInsets
.
zero
/// Size of the content.
/// Size of the content.
open
private
(set)
var
contentSize
=
CGSize
.
zero
open
internal
(set)
var
contentSize
=
CGSize
.
zero
/// Layout attribute items.
/// Layout attribute items.
open
private(set)
var
layoutItems
=
[(
UICollectionViewLayoutAttributes
,
NSIndexPath
)]()
open
internal(set)
lazy
var
layoutItems
=
[(
UICollectionViewLayoutAttributes
,
NSIndexPath
)]()
/// Cell data source items.
/// Cell data source items.
open
private
(set)
var
dataSourceItems
:
[
DataSourceItem
]?
open
internal
(set)
var
dataSourceItems
:
[
DataSourceItem
]?
/// Scroll direction.
/// Scroll direction.
open
var
scrollDirection
:
UICollectionViewScrollDirection
=
.
vertical
open
var
scrollDirection
=
UICollectionViewScrollDirection
.
vertical
/// A preset wrapper around interimSpace.
/// A preset wrapper around interimSpace.
open
var
interimSpacePreset
=
InterimSpacePreset
.
none
{
open
var
interimSpacePreset
=
InterimSpacePreset
.
none
{
...
@@ -93,11 +93,11 @@ open class CollectionViewLayout: UICollectionViewLayout {
...
@@ -93,11 +93,11 @@ open class CollectionViewLayout: UICollectionViewLayout {
let
item
:
DataSourceItem
=
dataSourceItems
!
[
indexPath
.
item
]
let
item
:
DataSourceItem
=
dataSourceItems
!
[
indexPath
.
item
]
if
0
<
itemSize
.
width
&&
0
<
itemSize
.
height
{
if
0
<
itemSize
.
width
&&
0
<
itemSize
.
height
{
attributes
.
frame
=
CGRect
(
x
:
offset
.
x
,
y
:
offset
.
y
,
width
:
itemSize
.
width
-
content
Inset
.
left
-
contentInset
.
right
,
height
:
itemSize
.
height
-
contentInset
.
top
-
contentInset
.
bottom
)
attributes
.
frame
=
CGRect
(
x
:
offset
.
x
,
y
:
offset
.
y
,
width
:
itemSize
.
width
-
content
EdgeInsets
.
left
-
contentEdgeInsets
.
right
,
height
:
itemSize
.
height
-
contentEdgeInsets
.
top
-
contentEdgeInsets
.
bottom
)
}
else
if
.
vertical
==
scrollDirection
{
}
else
if
.
vertical
==
scrollDirection
{
attributes
.
frame
=
CGRect
(
x
:
content
Inset
.
left
,
y
:
offset
.
y
,
width
:
collectionView
!.
bounds
.
width
-
contentInset
.
left
-
contentInset
.
right
,
height
:
item
.
height
??
collectionView
!.
bounds
.
height
)
attributes
.
frame
=
CGRect
(
x
:
content
EdgeInsets
.
left
,
y
:
offset
.
y
,
width
:
collectionView
!.
bounds
.
width
-
contentEdgeInsets
.
left
-
contentEdgeInsets
.
right
,
height
:
item
.
height
??
collectionView
!.
bounds
.
height
)
}
else
{
}
else
{
attributes
.
frame
=
CGRect
(
x
:
offset
.
x
,
y
:
content
Inset
.
top
,
width
:
item
.
width
??
collectionView
!.
bounds
.
width
,
height
:
collectionView
!.
bounds
.
height
-
contentInset
.
top
-
contentInset
.
bottom
)
attributes
.
frame
=
CGRect
(
x
:
offset
.
x
,
y
:
content
EdgeInsets
.
top
,
width
:
item
.
width
??
collectionView
!.
bounds
.
width
,
height
:
collectionView
!.
bounds
.
height
-
contentEdgeInsets
.
top
-
contentEdgeInsets
.
bottom
)
}
}
return
attributes
return
attributes
...
@@ -131,8 +131,8 @@ open class CollectionViewLayout: UICollectionViewLayout {
...
@@ -131,8 +131,8 @@ open class CollectionViewLayout: UICollectionViewLayout {
self
.
dataSourceItems
=
dataSourceItems
self
.
dataSourceItems
=
dataSourceItems
layoutItems
.
removeAll
()
layoutItems
.
removeAll
()
offset
.
x
=
content
Inset
.
left
offset
.
x
=
content
EdgeInsets
.
left
offset
.
y
=
content
Inset
.
top
offset
.
y
=
content
EdgeInsets
.
top
for
i
in
0
..<
dataSourceItems
.
count
{
for
i
in
0
..<
dataSourceItems
.
count
{
let
item
:
DataSourceItem
=
dataSourceItems
[
i
]
let
item
:
DataSourceItem
=
dataSourceItems
[
i
]
...
@@ -146,8 +146,8 @@ open class CollectionViewLayout: UICollectionViewLayout {
...
@@ -146,8 +146,8 @@ open class CollectionViewLayout: UICollectionViewLayout {
offset
.
y
+=
nil
==
item
.
height
?
itemSize
.
height
:
item
.
height
!
offset
.
y
+=
nil
==
item
.
height
?
itemSize
.
height
:
item
.
height
!
}
}
offset
.
x
+=
content
Inset
.
right
-
interimSpace
offset
.
x
+=
content
EdgeInsets
.
right
-
interimSpace
offset
.
y
+=
content
Inset
.
bottom
-
interimSpace
offset
.
y
+=
content
EdgeInsets
.
bottom
-
interimSpace
if
0
<
itemSize
.
width
&&
0
<
itemSize
.
height
{
if
0
<
itemSize
.
width
&&
0
<
itemSize
.
height
{
contentSize
=
CGSize
(
width
:
offset
.
x
,
height
:
offset
.
y
)
contentSize
=
CGSize
(
width
:
offset
.
x
,
height
:
offset
.
y
)
...
...
Sources/iOS/Cont
rol
View.swift
→
Sources/iOS/Cont
ent
View.swift
View file @
928ba8cb
...
@@ -36,7 +36,7 @@ public enum ContentViewAlignment: Int {
...
@@ -36,7 +36,7 @@ public enum ContentViewAlignment: Int {
case
center
case
center
}
}
open
class
Cont
rol
View
:
View
{
open
class
Cont
ent
View
:
View
{
/// Should center the contentView.
/// Should center the contentView.
open
var
contentViewAlignment
=
ContentViewAlignment
.
any
{
open
var
contentViewAlignment
=
ContentViewAlignment
.
any
{
didSet
{
didSet
{
...
@@ -93,7 +93,8 @@ open class ControlView: View {
...
@@ -93,7 +93,8 @@ open class ControlView: View {
}
}
/// Grid cell factor.
/// Grid cell factor.
@IBInspectable
open
var
gridFactor
:
CGFloat
=
24
{
@IBInspectable
open
var
gridFactor
:
CGFloat
=
24
{
didSet
{
didSet
{
assert
(
0
<
gridFactor
,
"[Material Error: gridFactor must be greater than 0.]"
)
assert
(
0
<
gridFactor
,
"[Material Error: gridFactor must be greater than 0.]"
)
layoutSubviews
()
layoutSubviews
()
...
@@ -101,7 +102,7 @@ open class ControlView: View {
...
@@ -101,7 +102,7 @@ open class ControlView: View {
}
}
/// ContentView that holds the any desired subviews.
/// ContentView that holds the any desired subviews.
open
private(set)
lazy
var
contentView
:
UIView
=
UIView
()
open
private(set)
lazy
var
contentView
=
UIView
()
/// Left side UIControls.
/// Left side UIControls.
open
var
leftControls
=
[
UIView
]()
{
open
var
leftControls
=
[
UIView
]()
{
...
@@ -196,6 +197,7 @@ open class ControlView: View {
...
@@ -196,6 +197,7 @@ open class ControlView: View {
}
}
contentView
.
grid
.
begin
()
contentView
.
grid
.
begin
()
if
.
center
==
contentViewAlignment
{
if
.
center
==
contentViewAlignment
{
if
lc
<
rc
{
if
lc
<
rc
{
contentView
.
grid
.
columns
=
columns
-
2
*
rc
contentView
.
grid
.
columns
=
columns
-
2
*
rc
...
...
Sources/iOS/Menu.swift
View file @
928ba8cb
...
@@ -46,11 +46,11 @@ public protocol MenuDelegate {
...
@@ -46,11 +46,11 @@ public protocol MenuDelegate {
}
}
open
class
Menu
:
View
{
open
class
Menu
:
View
{
/// A delegation reference.
open
weak
var
delegate
:
MenuDelegate
?
/// A Boolean that indicates if the menu is open or not.
/// A Boolean that indicates if the menu is open or not.
open
private(set)
var
isOpened
=
false
open
internal(set)
var
isOpened
=
false
/// Enables the animations for the Menu.
open
internal(set)
var
isEnabled
=
true
/// A preset wrapper around interimSpace.
/// A preset wrapper around interimSpace.
open
var
interimSpacePreset
=
InterimSpacePreset
.
none
{
open
var
interimSpacePreset
=
InterimSpacePreset
.
none
{
...
@@ -66,9 +66,6 @@ open class Menu: View {
...
@@ -66,9 +66,6 @@ open class Menu: View {
}
}
}
}
/// Enables the animations for the Menu.
open
private(set)
var
isEnabled
=
true
/// The direction in which the animation opens the menu.
/// The direction in which the animation opens the menu.
open
var
direction
=
MenuDirection
.
up
{
open
var
direction
=
MenuDirection
.
up
{
didSet
{
didSet
{
...
@@ -76,6 +73,9 @@ open class Menu: View {
...
@@ -76,6 +73,9 @@ open class Menu: View {
}
}
}
}
/// A delegation reference.
open
weak
var
delegate
:
MenuDelegate
?
/// An Array of UIViews.
/// An Array of UIViews.
open
var
views
=
[
UIView
]()
{
open
var
views
=
[
UIView
]()
{
didSet
{
didSet
{
...
@@ -86,6 +86,7 @@ open class Menu: View {
...
@@ -86,6 +86,7 @@ open class Menu: View {
for
v
in
views
{
for
v
in
views
{
addSubview
(
v
)
addSubview
(
v
)
}
}
reload
()
reload
()
}
}
}
}
...
...
Sources/iOS/NavigationDrawerController.swift
View file @
928ba8cb
...
@@ -193,16 +193,16 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
...
@@ -193,16 +193,16 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
opening and closing. Defaults to true.
opening and closing. Defaults to true.
*/
*/
@IBInspectable
@IBInspectable
open
var
e
nabled
:
Bool
{
open
var
isE
nabled
:
Bool
{
get
{
get
{
return
enabledLeftView
||
enabledRightView
return
isLeftViewEnabled
||
isRightViewEnabled
}
}
set
(
value
)
{
set
(
value
)
{
if
nil
!=
leftView
{
if
nil
!=
leftView
{
enabledLeftView
=
value
isLeftViewEnabled
=
value
}
}
if
nil
!=
rightView
{
if
nil
!=
rightView
{
enabledRightView
=
value
isRightViewEnabled
=
value
}
}
}
}
}
}
...
@@ -212,18 +212,18 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
...
@@ -212,18 +212,18 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
opening and closing. Defaults to true.
opening and closing. Defaults to true.
*/
*/
@IBInspectable
@IBInspectable
open
var
enabledLeftView
=
false
{
open
var
isLeftViewEnabled
=
false
{
didSet
{
didSet
{
enabledLeftPanGesture
=
enabledLeftView
isLeftPanGestureEnabled
=
isLeftViewEnabled
enabledLeftTapGesture
=
enabledLeftView
isLeftTapGestureEnabled
=
isLeftViewEnabled
}
}
}
}
/// Enables the left pan gesture.
/// Enables the left pan gesture.
@IBInspectable
@IBInspectable
open
var
enabledLeftPanGesture
=
false
{
open
var
isLeftPanGestureEnabled
=
false
{
didSet
{
didSet
{
if
enabledLeftPanGesture
{
if
isLeftPanGestureEnabled
{
prepareLeftPanGesture
()
prepareLeftPanGesture
()
}
else
{
}
else
{
removeLeftPanGesture
()
removeLeftPanGesture
()
...
@@ -233,9 +233,9 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
...
@@ -233,9 +233,9 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
/// Enables the left tap gesture.
/// Enables the left tap gesture.
@IBInspectable
@IBInspectable
open
var
enabledLeftTapGesture
=
false
{
open
var
isLeftTapGestureEnabled
=
false
{
didSet
{
didSet
{
if
enabledLeftTapGesture
{
if
isLeftTapGestureEnabled
{
prepareLeftTapGesture
()
prepareLeftTapGesture
()
}
else
{
}
else
{
removeLeftTapGesture
()
removeLeftTapGesture
()
...
@@ -248,18 +248,18 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
...
@@ -248,18 +248,18 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
opening and closing. Defaults to true.
opening and closing. Defaults to true.
*/
*/
@IBInspectable
@IBInspectable
open
var
enabledRightView
=
false
{
open
var
isRightViewEnabled
=
false
{
didSet
{
didSet
{
enabledRightPanGesture
=
enabledRightView
isRightPanGestureEnabled
=
isRightViewEnabled
enabledRightTapGesture
=
enabledRightView
isRightTapGestureEnabled
=
isRightViewEnabled
}
}
}
}
/// Enables the right pan gesture.
/// Enables the right pan gesture.
@IBInspectable
@IBInspectable
open
var
enabledRightPanGesture
=
false
{
open
var
isRightPanGestureEnabled
=
false
{
didSet
{
didSet
{
if
enabledRightPanGesture
{
if
isRightPanGestureEnabled
{
prepareRightPanGesture
()
prepareRightPanGesture
()
}
else
{
}
else
{
removeRightPanGesture
()
removeRightPanGesture
()
...
@@ -269,9 +269,9 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
...
@@ -269,9 +269,9 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
/// Enables the right tap gesture.
/// Enables the right tap gesture.
@IBInspectable
@IBInspectable
open
var
enabledRightTapGesture
=
false
{
open
var
isRightTapGestureEnabled
=
false
{
didSet
{
didSet
{
if
enabledRightTapGesture
{
if
isRightTapGestureEnabled
{
prepareRightTapGesture
()
prepareRightTapGesture
()
}
else
{
}
else
{
removeRightTapGesture
()
removeRightTapGesture
()
...
@@ -284,10 +284,10 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
...
@@ -284,10 +284,10 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
when the leftView is opened. Defaults to true.
when the leftView is opened. Defaults to true.
*/
*/
@IBInspectable
@IBInspectable
open
var
enableHideStatusBar
=
true
open
var
isHiddenStatusBarEnabled
=
true
/// Sets the statusBar to hidden or not.
/// Sets the statusBar to hidden or not.
open
private
(set)
var
isStatusBarHidden
=
false
open
internal
(set)
var
isStatusBarHidden
=
false
/**
/**
A DepthPreset property that is used to set the depth of the
A DepthPreset property that is used to set the depth of the
...
@@ -310,12 +310,12 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
...
@@ -310,12 +310,12 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
open
private(set)
var
rightView
:
View
?
open
private(set)
var
rightView
:
View
?
/// Indicates whether the leftView or rightView is opened.
/// Indicates whether the leftView or rightView is opened.
open
var
o
pened
:
Bool
{
open
var
isO
pened
:
Bool
{
return
openedLeftView
||
openedRightView
return
isLeftViewOpened
||
isRightViewOpened
}
}
/// indicates if the leftView is opened.
/// indicates if the leftView is opened.
open
var
openedLeftView
:
Bool
{
open
var
isLeftViewOpened
:
Bool
{
guard
nil
!=
leftView
else
{
guard
nil
!=
leftView
else
{
return
false
return
false
}
}
...
@@ -323,7 +323,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
...
@@ -323,7 +323,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
}
}
/// Indicates if the rightView is opened.
/// Indicates if the rightView is opened.
open
var
openedRightView
:
Bool
{
open
var
isRightViewOpened
:
Bool
{
guard
nil
!=
rightView
else
{
guard
nil
!=
rightView
else
{
return
false
return
false
}
}
...
@@ -337,7 +337,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
...
@@ -337,7 +337,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
this, and to add a hidden transition viewController for complex
this, and to add a hidden transition viewController for complex
situations, the contentViewController was added.
situations, the contentViewController was added.
*/
*/
open
private(set)
lazy
var
contentViewController
:
UIViewController
=
UIViewController
()
open
private(set)
lazy
var
contentViewController
=
UIViewController
()
/**
/**
A UIViewController property that references the
A UIViewController property that references the
...
@@ -413,7 +413,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
...
@@ -413,7 +413,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
/// Layout subviews.
/// Layout subviews.
open
override
func
layoutSubviews
()
{
open
override
func
layoutSubviews
()
{
if
o
pened
{
if
isO
pened
{
hideStatusBar
()
hideStatusBar
()
}
else
{
}
else
{
showStatusBar
()
showStatusBar
()
...
@@ -446,7 +446,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
...
@@ -446,7 +446,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
super
.
viewWillTransition
(
to
:
size
,
with
:
coordinator
)
super
.
viewWillTransition
(
to
:
size
,
with
:
coordinator
)
// Ensures the view is hidden.
// Ensures the view is hidden.
if
let
v
:
View
=
rightView
{
if
let
v
:
View
=
rightView
{
v
.
position
.
x
=
size
.
width
+
(
openedRightView
?
-
v
.
width
:
v
.
width
)
/
2
v
.
position
.
x
=
size
.
width
+
(
isRightViewOpened
?
-
v
.
width
:
v
.
width
)
/
2
}
}
}
}
...
@@ -466,7 +466,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
...
@@ -466,7 +466,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
var
hide
:
Bool
=
hidden
var
hide
:
Bool
=
hidden
if
openedRightView
{
if
isRightViewOpened
{
hide
=
true
hide
=
true
}
}
...
@@ -540,7 +540,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
...
@@ -540,7 +540,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
var
hide
:
Bool
=
hidden
var
hide
:
Bool
=
hidden
if
openedLeftView
{
if
isLeftViewOpened
{
hide
=
true
hide
=
true
}
}
...
@@ -605,7 +605,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
...
@@ -605,7 +605,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
leftView. Defaults to 0.
leftView. Defaults to 0.
*/
*/
open
func
toggleLeftView
(
velocity
:
CGFloat
=
0
)
{
open
func
toggleLeftView
(
velocity
:
CGFloat
=
0
)
{
openedLeftView
?
closeLeftView
(
velocity
:
velocity
)
:
openLeftView
(
velocity
:
velocity
)
isLeftViewOpened
?
closeLeftView
(
velocity
:
velocity
)
:
openLeftView
(
velocity
:
velocity
)
}
}
/**
/**
...
@@ -616,7 +616,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
...
@@ -616,7 +616,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
leftView. Defaults to 0.
leftView. Defaults to 0.
*/
*/
open
func
toggleRightView
(
velocity
:
CGFloat
=
0
)
{
open
func
toggleRightView
(
velocity
:
CGFloat
=
0
)
{
openedRightView
?
closeRightView
(
velocity
:
velocity
)
:
openRightView
(
velocity
:
velocity
)
isRightViewOpened
?
closeRightView
(
velocity
:
velocity
)
:
openRightView
(
velocity
:
velocity
)
}
}
/**
/**
...
@@ -626,7 +626,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
...
@@ -626,7 +626,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
leftView. Defaults to 0.
leftView. Defaults to 0.
*/
*/
open
func
openLeftView
(
velocity
:
CGFloat
=
0
)
{
open
func
openLeftView
(
velocity
:
CGFloat
=
0
)
{
if
enabledLeftView
{
if
isLeftViewEnabled
{
if
let
v
:
View
=
leftView
{
if
let
v
:
View
=
leftView
{
hideStatusBar
()
hideStatusBar
()
showView
(
container
:
v
)
showView
(
container
:
v
)
...
@@ -652,7 +652,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
...
@@ -652,7 +652,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
leftView. Defaults to 0.
leftView. Defaults to 0.
*/
*/
open
func
openRightView
(
velocity
:
CGFloat
=
0
)
{
open
func
openRightView
(
velocity
:
CGFloat
=
0
)
{
if
enabledRightView
{
if
isRightViewEnabled
{
if
let
v
:
View
=
rightView
{
if
let
v
:
View
=
rightView
{
hideStatusBar
()
hideStatusBar
()
showView
(
container
:
v
)
showView
(
container
:
v
)
...
@@ -680,7 +680,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
...
@@ -680,7 +680,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
leftView. Defaults to 0.
leftView. Defaults to 0.
*/
*/
open
func
closeLeftView
(
velocity
:
CGFloat
=
0
)
{
open
func
closeLeftView
(
velocity
:
CGFloat
=
0
)
{
if
enabledLeftView
{
if
isLeftViewEnabled
{
if
let
v
:
View
=
leftView
{
if
let
v
:
View
=
leftView
{
isUserInteractionEnabled
=
true
isUserInteractionEnabled
=
true
delegate
?
.
navigationDrawerWillClose
?(
navigationDrawerController
:
self
,
position
:
.
left
)
delegate
?
.
navigationDrawerWillClose
?(
navigationDrawerController
:
self
,
position
:
.
left
)
...
@@ -708,7 +708,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
...
@@ -708,7 +708,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
leftView. Defaults to 0.
leftView. Defaults to 0.
*/
*/
open
func
closeRightView
(
velocity
:
CGFloat
=
0
)
{
open
func
closeRightView
(
velocity
:
CGFloat
=
0
)
{
if
enabledRightView
{
if
isRightViewEnabled
{
if
let
v
:
View
=
rightView
{
if
let
v
:
View
=
rightView
{
isUserInteractionEnabled
=
true
isUserInteractionEnabled
=
true
delegate
?
.
navigationDrawerWillClose
?(
navigationDrawerController
:
self
,
position
:
.
right
)
delegate
?
.
navigationDrawerWillClose
?(
navigationDrawerController
:
self
,
position
:
.
right
)
...
@@ -736,16 +736,16 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
...
@@ -736,16 +736,16 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
- Returns: A Boolean of whether to continue the gesture or not.
- Returns: A Boolean of whether to continue the gesture or not.
*/
*/
open
func
gestureRecognizer
(
_
gestureRecognizer
:
UIGestureRecognizer
,
shouldReceive
touch
:
UITouch
)
->
Bool
{
open
func
gestureRecognizer
(
_
gestureRecognizer
:
UIGestureRecognizer
,
shouldReceive
touch
:
UITouch
)
->
Bool
{
if
!
openedRightView
&&
gestureRecognizer
==
leftPanGesture
&&
(
openedLeftView
||
isPointContainedWithinLeftThreshold
(
point
:
touch
.
location
(
in
:
view
)))
{
if
!
isRightViewOpened
&&
gestureRecognizer
==
leftPanGesture
&&
(
isLeftViewOpened
||
isPointContainedWithinLeftThreshold
(
point
:
touch
.
location
(
in
:
view
)))
{
return
true
return
true
}
}
if
!
openedLeftView
&&
gestureRecognizer
==
rightPanGesture
&&
(
openedRightView
||
isPointContainedWithinRighThreshold
(
point
:
touch
.
location
(
in
:
view
)))
{
if
!
isLeftViewOpened
&&
gestureRecognizer
==
rightPanGesture
&&
(
isRightViewOpened
||
isPointContainedWithinRighThreshold
(
point
:
touch
.
location
(
in
:
view
)))
{
return
true
return
true
}
}
if
openedLeftView
&&
gestureRecognizer
==
leftTapGesture
{
if
isLeftViewOpened
&&
gestureRecognizer
==
leftTapGesture
{
return
true
return
true
}
}
if
openedRightView
&&
gestureRecognizer
==
rightTapGesture
{
if
isRightViewOpened
&&
gestureRecognizer
==
rightTapGesture
{
return
true
return
true
}
}
return
false
return
false
...
@@ -759,7 +759,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
...
@@ -759,7 +759,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
*/
*/
@objc
@objc
internal
func
handleLeftViewPanGesture
(
recognizer
:
UIPanGestureRecognizer
)
{
internal
func
handleLeftViewPanGesture
(
recognizer
:
UIPanGestureRecognizer
)
{
if
enabledLeftView
&&
(
openedLeftView
||
!
openedRightView
&&
isPointContainedWithinLeftThreshold
(
point
:
recognizer
.
location
(
in
:
view
)))
{
if
isLeftViewEnabled
&&
(
isLeftViewOpened
||
!
isRightViewOpened
&&
isPointContainedWithinLeftThreshold
(
point
:
recognizer
.
location
(
in
:
view
)))
{
if
let
v
:
View
=
leftView
{
if
let
v
:
View
=
leftView
{
let
point
:
CGPoint
=
recognizer
.
location
(
in
:
view
)
let
point
:
CGPoint
=
recognizer
.
location
(
in
:
view
)
...
@@ -808,7 +808,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
...
@@ -808,7 +808,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
*/
*/
@objc
@objc
internal
func
handleRightViewPanGesture
(
recognizer
:
UIPanGestureRecognizer
)
{
internal
func
handleRightViewPanGesture
(
recognizer
:
UIPanGestureRecognizer
)
{
if
enabledRightView
&&
(
openedRightView
||
!
openedLeftView
&&
isPointContainedWithinRighThreshold
(
point
:
recognizer
.
location
(
in
:
view
)))
{
if
isRightViewEnabled
&&
(
isRightViewOpened
||
!
isLeftViewOpened
&&
isPointContainedWithinRighThreshold
(
point
:
recognizer
.
location
(
in
:
view
)))
{
if
let
v
:
View
=
rightView
{
if
let
v
:
View
=
rightView
{
let
point
:
CGPoint
=
recognizer
.
location
(
in
:
view
)
let
point
:
CGPoint
=
recognizer
.
location
(
in
:
view
)
...
@@ -857,10 +857,10 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
...
@@ -857,10 +857,10 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
*/
*/
@objc
@objc
internal
func
handleLeftViewTapGesture
(
recognizer
:
UITapGestureRecognizer
)
{
internal
func
handleLeftViewTapGesture
(
recognizer
:
UITapGestureRecognizer
)
{
if
openedLeftView
{
if
isLeftViewOpened
{
if
let
v
:
View
=
leftView
{
if
let
v
:
View
=
leftView
{
delegate
?
.
navigationDrawerDidTap
?(
navigationDrawerController
:
self
,
point
:
recognizer
.
location
(
in
:
view
),
position
:
.
left
)
delegate
?
.
navigationDrawerDidTap
?(
navigationDrawerController
:
self
,
point
:
recognizer
.
location
(
in
:
view
),
position
:
.
left
)
if
enabledLeftView
&&
openedLeftView
&&
!
isPointContainedWithinView
(
container
:
v
,
point
:
recognizer
.
location
(
in
:
v
))
{
if
isLeftViewEnabled
&&
isLeftViewOpened
&&
!
isPointContainedWithinView
(
container
:
v
,
point
:
recognizer
.
location
(
in
:
v
))
{
closeLeftView
()
closeLeftView
()
}
}
}
}
...
@@ -875,10 +875,10 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
...
@@ -875,10 +875,10 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
*/
*/
@objc
@objc
internal
func
handleRightViewTapGesture
(
recognizer
:
UITapGestureRecognizer
)
{
internal
func
handleRightViewTapGesture
(
recognizer
:
UITapGestureRecognizer
)
{
if
openedRightView
{
if
isRightViewOpened
{
if
let
v
:
View
=
rightView
{
if
let
v
:
View
=
rightView
{
delegate
?
.
navigationDrawerDidTap
?(
navigationDrawerController
:
self
,
point
:
recognizer
.
location
(
in
:
view
),
position
:
.
right
)
delegate
?
.
navigationDrawerDidTap
?(
navigationDrawerController
:
self
,
point
:
recognizer
.
location
(
in
:
view
),
position
:
.
right
)
if
enabledRightView
&&
openedRightView
&&
!
isPointContainedWithinView
(
container
:
v
,
point
:
recognizer
.
location
(
in
:
v
))
{
if
isRightViewEnabled
&&
isRightViewOpened
&&
!
isPointContainedWithinView
(
container
:
v
,
point
:
recognizer
.
location
(
in
:
v
))
{
closeRightView
()
closeRightView
()
}
}
}
}
...
@@ -912,7 +912,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
...
@@ -912,7 +912,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
return
return
}
}
enabledLeftView
=
true
isLeftViewEnabled
=
true
leftViewWidth
=
.
phone
==
Device
.
userInterfaceIdiom
?
280
:
320
leftViewWidth
=
.
phone
==
Device
.
userInterfaceIdiom
?
280
:
320
leftView
=
View
()
leftView
=
View
()
...
@@ -932,7 +932,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
...
@@ -932,7 +932,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
return
return
}
}
enabledRightView
=
true
isRightViewEnabled
=
true
rightViewWidth
=
.
phone
==
Device
.
userInterfaceIdiom
?
280
:
320
rightViewWidth
=
.
phone
==
Device
.
userInterfaceIdiom
?
280
:
320
rightView
=
View
()
rightView
=
View
()
...
@@ -1046,7 +1046,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
...
@@ -1046,7 +1046,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
/// Hides the statusBar.
/// Hides the statusBar.
private
func
hideStatusBar
()
{
private
func
hideStatusBar
()
{
if
enableHideStatusBar
{
if
isHiddenStatusBarEnabled
{
if
!
isStatusBarHidden
{
if
!
isStatusBarHidden
{
isStatusBarHidden
=
true
isStatusBarHidden
=
true
DispatchQueue
.
main
.
async
{
[
weak
self
]
in
DispatchQueue
.
main
.
async
{
[
weak
self
]
in
...
@@ -1063,7 +1063,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
...
@@ -1063,7 +1063,7 @@ open class NavigationDrawerController: RootController, UIGestureRecognizerDelega
/// Toggles the statusBar
/// Toggles the statusBar
private
func
toggleStatusBar
()
{
private
func
toggleStatusBar
()
{
if
o
pened
||
Device
.
isLandscape
&&
.
phone
==
Device
.
userInterfaceIdiom
{
if
isO
pened
||
Device
.
isLandscape
&&
.
phone
==
Device
.
userInterfaceIdiom
{
hideStatusBar
()
hideStatusBar
()
}
else
{
}
else
{
showStatusBar
()
showStatusBar
()
...
...
Sources/iOS/SearchBar.swift
View file @
928ba8cb
...
@@ -32,17 +32,17 @@ import UIKit
...
@@ -32,17 +32,17 @@ import UIKit
open
class
SearchBar
:
BarView
{
open
class
SearchBar
:
BarView
{
/// The UITextField for the searchBar.
/// The UITextField for the searchBar.
open
private(set)
var
textField
:
UITextField
!
open
private(set)
lazy
var
textField
=
UITextField
()
/// Reference to the clearButton.
/// Reference to the clearButton.
open
private(set)
var
clearButton
:
IconButton
!
open
private(set)
var
clearButton
:
IconButton
!
/// Handle the clearButton manually.
/// Handle the clearButton manually.
@IBInspectable
@IBInspectable
open
var
clearButtonAutoHandleEnabled
:
Bool
=
true
{
open
var
isClearButtonAutoHandleEnabled
=
true
{
didSet
{
didSet
{
clearButton
.
removeTarget
(
self
,
action
:
#selector(
handleClearButton
)
,
for
:
.
touchUpInside
)
clearButton
.
removeTarget
(
self
,
action
:
#selector(
handleClearButton
)
,
for
:
.
touchUpInside
)
if
c
learButtonAutoHandleEnabled
{
if
isC
learButtonAutoHandleEnabled
{
clearButton
.
addTarget
(
self
,
action
:
#selector(
handleClearButton
)
,
for
:
.
touchUpInside
)
clearButton
.
addTarget
(
self
,
action
:
#selector(
handleClearButton
)
,
for
:
.
touchUpInside
)
}
}
}
}
...
@@ -82,7 +82,7 @@ open class SearchBar: BarView {
...
@@ -82,7 +82,7 @@ open class SearchBar: BarView {
/// Placeholder textColor.
/// Placeholder textColor.
@IBInspectable
@IBInspectable
open
var
placeholderColor
:
UIColor
=
Color
.
darkText
.
others
{
open
var
placeholderColor
=
Color
.
darkText
.
others
{
didSet
{
didSet
{
if
let
v
:
String
=
placeholder
{
if
let
v
:
String
=
placeholder
{
textField
.
attributedPlaceholder
=
NSAttributedString
(
string
:
v
,
attributes
:
[
NSForegroundColorAttributeName
:
placeholderColor
])
textField
.
attributedPlaceholder
=
NSAttributedString
(
string
:
v
,
attributes
:
[
NSForegroundColorAttributeName
:
placeholderColor
])
...
@@ -142,7 +142,7 @@ open class SearchBar: BarView {
...
@@ -142,7 +142,7 @@ open class SearchBar: BarView {
/// Layout the clearButton.
/// Layout the clearButton.
open
func
layoutClearButton
()
{
open
func
layoutClearButton
()
{
let
h
:
CGFloat
=
textField
.
frame
.
height
let
h
=
textField
.
frame
.
height
clearButton
.
frame
=
CGRect
(
x
:
textField
.
frame
.
width
-
h
,
y
:
0
,
width
:
h
,
height
:
h
)
clearButton
.
frame
=
CGRect
(
x
:
textField
.
frame
.
width
-
h
,
y
:
0
,
width
:
h
,
height
:
h
)
}
}
...
@@ -154,7 +154,6 @@ open class SearchBar: BarView {
...
@@ -154,7 +154,6 @@ open class SearchBar: BarView {
/// Prepares the textField.
/// Prepares the textField.
private
func
prepareTextField
()
{
private
func
prepareTextField
()
{
textField
=
UITextField
()
textField
.
contentScaleFactor
=
Device
.
scale
textField
.
contentScaleFactor
=
Device
.
scale
textField
.
font
=
RobotoFont
.
regular
(
with
:
17
)
textField
.
font
=
RobotoFont
.
regular
(
with
:
17
)
textField
.
backgroundColor
=
Color
.
clear
textField
.
backgroundColor
=
Color
.
clear
...
@@ -169,7 +168,7 @@ open class SearchBar: BarView {
...
@@ -169,7 +168,7 @@ open class SearchBar: BarView {
private
func
prepareClearButton
()
{
private
func
prepareClearButton
()
{
clearButton
=
IconButton
(
image
:
Icon
.
cm
.
close
,
tintColor
:
placeholderColor
)
clearButton
=
IconButton
(
image
:
Icon
.
cm
.
close
,
tintColor
:
placeholderColor
)
clearButton
.
contentEdgeInsets
=
.
zero
clearButton
.
contentEdgeInsets
=
.
zero
c
learButtonAutoHandleEnabled
=
true
isC
learButtonAutoHandleEnabled
=
true
textField
.
clearButtonMode
=
.
never
textField
.
clearButtonMode
=
.
never
textField
.
rightViewMode
=
.
whileEditing
textField
.
rightViewMode
=
.
whileEditing
textField
.
rightView
=
clearButton
textField
.
rightView
=
clearButton
...
...
Sources/iOS/Switch.swift
View file @
928ba8cb
...
@@ -30,39 +30,39 @@
...
@@ -30,39 +30,39 @@
import
UIKit
import
UIKit
@objc(SwitchStyle)
@objc(Switch
Control
Style)
public
enum
SwitchStyle
:
Int
{
public
enum
Switch
Control
Style
:
Int
{
case
light
case
light
case
dark
case
dark
}
}
@objc(SwitchState)
@objc(Switch
Control
State)
public
enum
SwitchState
:
Int
{
public
enum
Switch
Control
State
:
Int
{
case
on
case
on
case
off
case
off
}
}
@objc(SwitchSize)
@objc(Switch
Control
Size)
public
enum
SwitchSize
:
Int
{
public
enum
Switch
Control
Size
:
Int
{
case
small
case
small
case
medium
case
medium
case
large
case
large
}
}
@objc(SwitchDelegate)
@objc(Switch
Control
Delegate)
public
protocol
SwitchDelegate
{
public
protocol
Switch
Control
Delegate
{
/**
/**
A Switch delegate method for state changes.
A Switch
Control
delegate method for state changes.
- Parameter control: Switch control.
- Parameter control: Switch
Control
control.
*/
*/
func
switchStateChanged
(
control
:
Switch
)
func
switchStateChanged
(
control
:
Switch
Control
)
}
}
@objc(Switch)
@objc(Switch
Control
)
@IBDesignable
@IBDesignable
public
class
Switch
:
UIControl
{
open
class
SwitchControl
:
UIControl
{
/// An internal reference to the switchState public property.
/// An internal reference to the switchState public property.
private
var
internalSwitch
State
:
Switch
State
=
.
off
private
var
internalSwitch
ControlState
:
SwitchControl
State
=
.
off
/// Track thickness.
/// Track thickness.
private
var
trackThickness
:
CGFloat
=
0
private
var
trackThickness
:
CGFloat
=
0
...
@@ -80,66 +80,75 @@ public class Switch: UIControl {
...
@@ -80,66 +80,75 @@ public class Switch: UIControl {
private
var
bounceOffset
:
CGFloat
=
3
private
var
bounceOffset
:
CGFloat
=
3
/// An Optional delegation method.
/// An Optional delegation method.
open
weak
var
delegate
:
SwitchDelegate
?
open
weak
var
delegate
:
Switch
Control
Delegate
?
/// Indicates if the animation should bounce.
/// Indicates if the animation should bounce.
@IBInspectable
public
var
bounceable
:
Bool
=
true
{
@IBInspectable
public
var
bounceable
=
true
{
didSet
{
didSet
{
bounceOffset
=
bounceable
?
3
:
0
bounceOffset
=
bounceable
?
3
:
0
}
}
}
}
/// Button on color.
/// Button on color.
@IBInspectable
public
var
buttonOnColor
:
UIColor
=
Color
.
clear
{
@IBInspectable
public
var
buttonOnColor
=
Color
.
clear
{
didSet
{
didSet
{
styleForState
(
state
:
switchState
)
styleForState
(
state
:
switchState
)
}
}
}
}
/// Button off color.
/// Button off color.
@IBInspectable
public
var
buttonOffColor
:
UIColor
=
Color
.
clear
{
@IBInspectable
public
var
buttonOffColor
=
Color
.
clear
{
didSet
{
didSet
{
styleForState
(
state
:
switchState
)
styleForState
(
state
:
switchState
)
}
}
}
}
/// Track on color.
/// Track on color.
@IBInspectable
public
var
trackOnColor
:
UIColor
=
Color
.
clear
{
@IBInspectable
public
var
trackOnColor
=
Color
.
clear
{
didSet
{
didSet
{
styleForState
(
state
:
switchState
)
styleForState
(
state
:
switchState
)
}
}
}
}
/// Track off color.
/// Track off color.
@IBInspectable
public
var
trackOffColor
:
UIColor
=
Color
.
clear
{
@IBInspectable
public
var
trackOffColor
=
Color
.
clear
{
didSet
{
didSet
{
styleForState
(
state
:
switchState
)
styleForState
(
state
:
switchState
)
}
}
}
}
/// Button on disabled color.
/// Button on disabled color.
@IBInspectable
public
var
buttonOnDisabledColor
:
UIColor
=
Color
.
clear
{
@IBInspectable
public
var
buttonOnDisabledColor
=
Color
.
clear
{
didSet
{
didSet
{
styleForState
(
state
:
switchState
)
styleForState
(
state
:
switchState
)
}
}
}
}
/// Track on disabled color.
/// Track on disabled color.
@IBInspectable
public
var
trackOnDisabledColor
:
UIColor
=
Color
.
clear
{
@IBInspectable
public
var
trackOnDisabledColor
=
Color
.
clear
{
didSet
{
didSet
{
styleForState
(
state
:
switchState
)
styleForState
(
state
:
switchState
)
}
}
}
}
/// Button off disabled color.
/// Button off disabled color.
@IBInspectable
public
var
buttonOffDisabledColor
:
UIColor
=
Color
.
clear
{
@IBInspectable
public
var
buttonOffDisabledColor
=
Color
.
clear
{
didSet
{
didSet
{
styleForState
(
state
:
switchState
)
styleForState
(
state
:
switchState
)
}
}
}
}
/// Track off disabled color.
/// Track off disabled color.
@IBInspectable
public
var
trackOffDisabledColor
:
UIColor
=
Color
.
clear
{
@IBInspectable
public
var
trackOffDisabledColor
=
Color
.
clear
{
didSet
{
didSet
{
styleForState
(
state
:
switchState
)
styleForState
(
state
:
switchState
)
}
}
...
@@ -159,36 +168,38 @@ public class Switch: UIControl {
...
@@ -159,36 +168,38 @@ public class Switch: UIControl {
}
}
}
}
@IBInspectable
public
override
var
isEnabled
:
Bool
{
@IBInspectable
open
override
var
isEnabled
:
Bool
{
didSet
{
didSet
{
styleForState
(
state
:
internalSwitchState
)
styleForState
(
state
:
internalSwitch
Control
State
)
}
}
}
}
/// A boolean indicating if the switch is on or not.
/// A boolean indicating if the switch is on or not.
@IBInspectable
public
var
on
:
Bool
{
@IBInspectable
public
var
on
:
Bool
{
get
{
get
{
return
.
on
==
internalSwitchState
return
.
on
==
internalSwitch
Control
State
}
}
set
(
value
)
{
set
(
value
)
{
setOn
(
on
:
value
,
animated
:
true
)
setOn
(
on
:
value
,
animated
:
true
)
}
}
}
}
/// Switch state.
/// Switch
Control
state.
public
var
switchState
:
SwitchState
{
public
var
switchState
:
Switch
Control
State
{
get
{
get
{
return
internalSwitchState
return
internalSwitch
Control
State
}
}
set
(
value
)
{
set
(
value
)
{
if
value
!=
internalSwitchState
{
if
value
!=
internalSwitch
Control
State
{
internalSwitchState
=
value
internalSwitch
Control
State
=
value
}
}
}
}
}
}
/// Switch style.
/// Switch
Control
style.
public
var
switchStyle
:
SwitchStyle
=
.
dark
{
public
var
switchStyle
:
Switch
Control
Style
=
.
dark
{
didSet
{
didSet
{
switch
switchStyle
{
switch
switchStyle
{
case
.
light
:
case
.
light
:
...
@@ -213,8 +224,8 @@ public class Switch: UIControl {
...
@@ -213,8 +224,8 @@ public class Switch: UIControl {
}
}
}
}
/// Switch size.
/// Switch
Control
size.
public
var
switchSize
:
SwitchSize
=
.
medium
{
public
var
switchSize
:
Switch
Control
Size
=
.
medium
{
didSet
{
didSet
{
switch
switchSize
{
switch
switchSize
{
case
.
small
:
case
.
small
:
...
@@ -233,19 +244,19 @@ public class Switch: UIControl {
...
@@ -233,19 +244,19 @@ public class Switch: UIControl {
}
}
}
}
public
override
var
frame
:
CGRect
{
open
override
var
frame
:
CGRect
{
didSet
{
didSet
{
layoutSwitch
()
layoutSwitch
Control
()
}
}
}
}
public
override
var
bounds
:
CGRect
{
open
override
var
bounds
:
CGRect
{
didSet
{
didSet
{
layoutSwitch
()
layoutSwitch
Control
()
}
}
}
}
public
override
var
intrinsicContentSize
:
CGSize
{
open
override
var
intrinsicContentSize
:
CGSize
{
switch
switchSize
{
switch
switchSize
{
case
.
small
:
case
.
small
:
return
CGSize
(
width
:
30
,
height
:
25
)
return
CGSize
(
width
:
30
,
height
:
25
)
...
@@ -266,9 +277,9 @@ public class Switch: UIControl {
...
@@ -266,9 +277,9 @@ public class Switch: UIControl {
super
.
init
(
coder
:
aDecoder
)
super
.
init
(
coder
:
aDecoder
)
prepareTrack
()
prepareTrack
()
prepareButton
()
prepareButton
()
prepareSwitchSize
(
size
:
.
medium
)
prepareSwitch
Control
Size
(
size
:
.
medium
)
prepareSwitchStyle
(
style
:
.
light
)
prepareSwitch
Control
Style
(
style
:
.
light
)
prepareSwitchState
(
state
:
.
off
)
prepareSwitch
Control
State
(
state
:
.
off
)
}
}
/**
/**
...
@@ -284,39 +295,39 @@ public class Switch: UIControl {
...
@@ -284,39 +295,39 @@ public class Switch: UIControl {
super
.
init
(
frame
:
frame
)
super
.
init
(
frame
:
frame
)
prepareTrack
()
prepareTrack
()
prepareButton
()
prepareButton
()
prepareSwitchSize
(
size
:
.
medium
)
prepareSwitch
Control
Size
(
size
:
.
medium
)
prepareSwitchStyle
(
style
:
.
light
)
prepareSwitch
Control
Style
(
style
:
.
light
)
prepareSwitchState
(
state
:
.
off
)
prepareSwitch
Control
State
(
state
:
.
off
)
}
}
/**
/**
An initializer that sets the state, style, and size of the Switch instance.
An initializer that sets the state, style, and size of the Switch
Control
instance.
- Parameter state: A SwitchState value.
- Parameter state: A Switch
Control
State value.
- Parameter style: A SwitchStyle value.
- Parameter style: A Switch
Control
Style value.
- Parameter size: A SwitchSize value.
- Parameter size: A Switch
Control
Size value.
*/
*/
public
init
(
state
:
Switch
State
=
.
off
,
style
:
SwitchStyle
=
.
dark
,
size
:
Switch
Size
=
.
medium
)
{
public
init
(
state
:
Switch
ControlState
=
.
off
,
style
:
SwitchControlStyle
=
.
dark
,
size
:
SwitchControl
Size
=
.
medium
)
{
trackLayer
=
CAShapeLayer
()
trackLayer
=
CAShapeLayer
()
button
=
FabButton
()
button
=
FabButton
()
super
.
init
(
frame
:
CGRect
.
null
)
super
.
init
(
frame
:
CGRect
.
null
)
prepareTrack
()
prepareTrack
()
prepareButton
()
prepareButton
()
prepareSwitchSize
(
size
:
size
)
prepareSwitch
Control
Size
(
size
:
size
)
prepareSwitchStyle
(
style
:
style
)
prepareSwitch
Control
Style
(
style
:
style
)
prepareSwitchState
(
state
:
state
)
prepareSwitch
Control
State
(
state
:
state
)
}
}
public
override
func
willMove
(
toSuperview
newSuperview
:
UIView
?)
{
open
override
func
willMove
(
toSuperview
newSuperview
:
UIView
?)
{
super
.
willMove
(
toSuperview
:
newSuperview
)
super
.
willMove
(
toSuperview
:
newSuperview
)
styleForState
(
state
:
internalSwitchState
)
styleForState
(
state
:
internalSwitch
Control
State
)
}
}
/**
/**
Toggle the Switch state, if On will be Off, and if Off will be On.
Toggle the Switch
Control
state, if On will be Off, and if Off will be On.
- Parameter completion: An Optional completion block.
- Parameter completion: An Optional completion block.
*/
*/
public
func
toggle
(
completion
:
((
Switch
)
->
Void
)?
=
nil
)
{
public
func
toggle
(
completion
:
((
Switch
Control
)
->
Void
)?
=
nil
)
{
setSwitch
State
(
state
:
.
on
==
internalSwitch
State
?
.
off
:
.
on
,
animated
:
true
,
completion
:
completion
)
setSwitch
ControlState
(
state
:
.
on
==
internalSwitchControl
State
?
.
off
:
.
on
,
animated
:
true
,
completion
:
completion
)
}
}
/**
/**
...
@@ -324,22 +335,22 @@ public class Switch: UIControl {
...
@@ -324,22 +335,22 @@ public class Switch: UIControl {
- Parameter on: A bool of whether the switch should be in the on state or not.
- Parameter on: A bool of whether the switch should be in the on state or not.
- Parameter animated: A Boolean indicating to set the animation or not.
- Parameter animated: A Boolean indicating to set the animation or not.
*/
*/
public
func
setOn
(
on
:
Bool
,
animated
:
Bool
,
completion
:
((
Switch
)
->
Void
)?
=
nil
)
{
public
func
setOn
(
on
:
Bool
,
animated
:
Bool
,
completion
:
((
Switch
Control
)
->
Void
)?
=
nil
)
{
setSwitchState
(
state
:
on
?
.
on
:
.
off
,
animated
:
animated
,
completion
:
completion
)
setSwitch
Control
State
(
state
:
on
?
.
on
:
.
off
,
animated
:
animated
,
completion
:
completion
)
}
}
/**
/**
Set the switchState property with an option to animate.
Set the switchState property with an option to animate.
- Parameter state: The SwitchState to set.
- Parameter state: The Switch
Control
State to set.
- Parameter animated: A Boolean indicating to set the animation or not.
- Parameter animated: A Boolean indicating to set the animation or not.
- Parameter completion: An Optional completion block.
- Parameter completion: An Optional completion block.
*/
*/
public
func
setSwitch
State
(
state
:
SwitchState
,
animated
:
Bool
=
true
,
completion
:
((
Switch
)
->
Void
)?
=
nil
)
{
public
func
setSwitch
ControlState
(
state
:
SwitchControlState
,
animated
:
Bool
=
true
,
completion
:
((
SwitchControl
)
->
Void
)?
=
nil
)
{
if
isEnabled
&&
internalSwitchState
!=
state
{
if
isEnabled
&&
internalSwitch
Control
State
!=
state
{
internalSwitchState
=
state
internalSwitch
Control
State
=
state
if
animated
{
if
animated
{
animateToState
(
state
:
state
)
{
[
weak
self
]
_
in
animateToState
(
state
:
state
)
{
[
weak
self
]
_
in
if
let
s
:
Switch
=
self
{
if
let
s
:
Switch
Control
=
self
{
s
.
sendActions
(
for
:
.
valueChanged
)
s
.
sendActions
(
for
:
.
valueChanged
)
completion
?(
s
)
completion
?(
s
)
s
.
delegate
?
.
switchStateChanged
(
control
:
s
)
s
.
delegate
?
.
switchStateChanged
(
control
:
s
)
...
@@ -364,7 +375,7 @@ public class Switch: UIControl {
...
@@ -364,7 +375,7 @@ public class Switch: UIControl {
internal
func
handleTouchUpOutsideOrCanceled
(
sender
:
FabButton
,
event
:
UIEvent
)
{
internal
func
handleTouchUpOutsideOrCanceled
(
sender
:
FabButton
,
event
:
UIEvent
)
{
if
let
v
:
UITouch
=
event
.
touches
(
for
:
sender
)?
.
first
{
if
let
v
:
UITouch
=
event
.
touches
(
for
:
sender
)?
.
first
{
let
q
:
CGFloat
=
sender
.
x
+
v
.
location
(
in
:
sender
)
.
x
-
v
.
previousLocation
(
in
:
sender
)
.
x
let
q
:
CGFloat
=
sender
.
x
+
v
.
location
(
in
:
sender
)
.
x
-
v
.
previousLocation
(
in
:
sender
)
.
x
setSwitchState
(
state
:
q
>
(
width
-
button
.
width
)
/
2
?
.
on
:
.
off
,
animated
:
true
)
setSwitch
Control
State
(
state
:
q
>
(
width
-
button
.
width
)
/
2
?
.
on
:
.
off
,
animated
:
true
)
}
}
}
}
...
@@ -389,9 +400,9 @@ public class Switch: UIControl {
...
@@ -389,9 +400,9 @@ public class Switch: UIControl {
}
}
}
}
public
override
func
touchesBegan
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
open
override
func
touchesBegan
(
_
touches
:
Set
<
UITouch
>
,
with
event
:
UIEvent
?)
{
if
true
==
trackLayer
.
frame
.
contains
(
layer
.
convert
(
touches
.
first
!.
location
(
in
:
self
),
from
:
layer
))
{
if
true
==
trackLayer
.
frame
.
contains
(
layer
.
convert
(
touches
.
first
!.
location
(
in
:
self
),
from
:
layer
))
{
setOn
(
on
:
.
on
!=
internalSwitchState
,
animated
:
true
)
setOn
(
on
:
.
on
!=
internalSwitch
Control
State
,
animated
:
true
)
}
}
}
}
...
@@ -413,35 +424,35 @@ public class Switch: UIControl {
...
@@ -413,35 +424,35 @@ public class Switch: UIControl {
/**
/**
Prepares the switchState property. This is used mainly to allow
Prepares the switchState property. This is used mainly to allow
init to set the state value and have an effect.
init to set the state value and have an effect.
- Parameter state: The SwitchState to set.
- Parameter state: The Switch
Control
State to set.
*/
*/
private
func
prepareSwitch
State
(
state
:
Switch
State
)
{
private
func
prepareSwitch
ControlState
(
state
:
SwitchControl
State
)
{
setSwitchState
(
state
:
state
,
animated
:
false
)
setSwitch
Control
State
(
state
:
state
,
animated
:
false
)
}
}
/**
/**
Prepares the switchStyle property. This is used mainly to allow
Prepares the switchStyle property. This is used mainly to allow
init to set the state value and have an effect.
init to set the state value and have an effect.
- Parameter style: The SwitchStyle to set.
- Parameter style: The Switch
Control
Style to set.
*/
*/
private
func
prepareSwitch
Style
(
style
:
Switch
Style
)
{
private
func
prepareSwitch
ControlStyle
(
style
:
SwitchControl
Style
)
{
switchStyle
=
style
switchStyle
=
style
}
}
/**
/**
Prepares the switchSize property. This is used mainly to allow
Prepares the switchSize property. This is used mainly to allow
init to set the size value and have an effect.
init to set the size value and have an effect.
- Parameter size: The SwitchSize to set.
- Parameter size: The Switch
Control
Size to set.
*/
*/
private
func
prepareSwitch
Size
(
size
:
Switch
Size
)
{
private
func
prepareSwitch
ControlSize
(
size
:
SwitchControl
Size
)
{
switchSize
=
size
switchSize
=
size
}
}
/**
/**
Updates the style based on the state.
Updates the style based on the state.
- Parameter state: The SwitchState to set the style to.
- Parameter state: The Switch
Control
State to set the style to.
*/
*/
private
func
styleForState
(
state
:
SwitchState
)
{
private
func
styleForState
(
state
:
Switch
Control
State
)
{
if
isEnabled
{
if
isEnabled
{
updateColorForState
(
state
:
state
)
updateColorForState
(
state
:
state
)
}
else
{
}
else
{
...
@@ -451,9 +462,9 @@ public class Switch: UIControl {
...
@@ -451,9 +462,9 @@ public class Switch: UIControl {
/**
/**
Updates the coloring for the enabled state.
Updates the coloring for the enabled state.
- Parameter state: SwitchState.
- Parameter state: Switch
Control
State.
*/
*/
private
func
updateColorForState
(
state
:
SwitchState
)
{
private
func
updateColorForState
(
state
:
Switch
Control
State
)
{
if
.
on
==
state
{
if
.
on
==
state
{
button
.
backgroundColor
=
buttonOnColor
button
.
backgroundColor
=
buttonOnColor
trackLayer
.
backgroundColor
=
trackOnColor
.
cgColor
trackLayer
.
backgroundColor
=
trackOnColor
.
cgColor
...
@@ -465,9 +476,9 @@ public class Switch: UIControl {
...
@@ -465,9 +476,9 @@ public class Switch: UIControl {
/**
/**
Updates the coloring for the disabled state.
Updates the coloring for the disabled state.
- Parameter state: SwitchState.
- Parameter state: Switch
Control
State.
*/
*/
private
func
updateColorForDisabledState
(
state
:
SwitchState
)
{
private
func
updateColorForDisabledState
(
state
:
Switch
Control
State
)
{
if
.
on
==
state
{
if
.
on
==
state
{
button
.
backgroundColor
=
buttonOnDisabledColor
button
.
backgroundColor
=
buttonOnDisabledColor
trackLayer
.
backgroundColor
=
trackOnDisabledColor
.
cgColor
trackLayer
.
backgroundColor
=
trackOnDisabledColor
.
cgColor
...
@@ -478,7 +489,7 @@ public class Switch: UIControl {
...
@@ -478,7 +489,7 @@ public class Switch: UIControl {
}
}
/// Laout the button and track views.
/// Laout the button and track views.
private
func
layoutSwitch
()
{
private
func
layoutSwitch
Control
()
{
var
w
:
CGFloat
=
0
var
w
:
CGFloat
=
0
switch
switchSize
{
switch
switchSize
{
case
.
small
:
case
.
small
:
...
@@ -498,34 +509,34 @@ public class Switch: UIControl {
...
@@ -498,34 +509,34 @@ public class Switch: UIControl {
onPosition
=
width
-
px
-
buttonDiameter
onPosition
=
width
-
px
-
buttonDiameter
offPosition
=
px
offPosition
=
px
if
.
on
==
internalSwitchState
{
if
.
on
==
internalSwitch
Control
State
{
button
.
x
=
onPosition
button
.
x
=
onPosition
}
}
}
}
/**
/**
Set the switchState property with an animate.
Set the switchState property with an animate.
- Parameter state: The SwitchState to set.
- Parameter state: The Switch
Control
State to set.
- Parameter completion: An Optional completion block.
- Parameter completion: An Optional completion block.
*/
*/
private
func
animateToState
(
state
:
Switch
State
,
completion
:
((
Switch
)
->
Void
)?
=
nil
)
{
private
func
animateToState
(
state
:
Switch
ControlState
,
completion
:
((
SwitchControl
)
->
Void
)?
=
nil
)
{
isUserInteractionEnabled
=
false
isUserInteractionEnabled
=
false
UIView
.
animate
(
withDuration
:
0.15
,
UIView
.
animate
(
withDuration
:
0.15
,
delay
:
0.05
,
delay
:
0.05
,
options
:
[
.
curveEaseIn
,
.
curveEaseOut
],
options
:
[
.
curveEaseIn
,
.
curveEaseOut
],
animations
:
{
[
weak
self
]
in
animations
:
{
[
weak
self
]
in
if
let
s
:
Switch
=
self
{
if
let
s
:
Switch
Control
=
self
{
s
.
button
.
x
=
.
on
==
state
?
s
.
onPosition
+
s
.
bounceOffset
:
s
.
offPosition
-
s
.
bounceOffset
s
.
button
.
x
=
.
on
==
state
?
s
.
onPosition
+
s
.
bounceOffset
:
s
.
offPosition
-
s
.
bounceOffset
s
.
styleForState
(
state
:
state
)
s
.
styleForState
(
state
:
state
)
}
}
})
{
[
weak
self
]
_
in
})
{
[
weak
self
]
_
in
UIView
.
animate
(
withDuration
:
0.15
,
UIView
.
animate
(
withDuration
:
0.15
,
animations
:
{
[
weak
self
]
in
animations
:
{
[
weak
self
]
in
if
let
s
:
Switch
=
self
{
if
let
s
:
Switch
Control
=
self
{
s
.
button
.
x
=
.
on
==
state
?
s
.
onPosition
:
s
.
offPosition
s
.
button
.
x
=
.
on
==
state
?
s
.
onPosition
:
s
.
offPosition
}
}
})
{
[
weak
self
]
_
in
})
{
[
weak
self
]
_
in
if
let
s
:
Switch
=
self
{
if
let
s
:
Switch
Control
=
self
{
s
.
isUserInteractionEnabled
=
true
s
.
isUserInteractionEnabled
=
true
completion
?(
s
)
completion
?(
s
)
}
}
...
...
Sources/iOS/TextField.swift
View file @
928ba8cb
...
@@ -40,7 +40,7 @@ open class TextField: UITextField {
...
@@ -40,7 +40,7 @@ open class TextField: UITextField {
}
}
/// A Boolean that indicates if the TextField is in an animating state.
/// A Boolean that indicates if the TextField is in an animating state.
open
private(set)
var
a
nimating
=
false
open
internal(set)
var
isA
nimating
=
false
/// A property that accesses the backing layer's backgroundColor.
/// A property that accesses the backing layer's backgroundColor.
@IBInspectable
@IBInspectable
...
@@ -199,7 +199,7 @@ open class TextField: UITextField {
...
@@ -199,7 +199,7 @@ open class TextField: UITextField {
/// Enables the clearIconButton.
/// Enables the clearIconButton.
@IBInspectable
@IBInspectable
open
var
enableClearIconButton
:
Bool
{
open
var
isClearIconButtonEnable
:
Bool
{
get
{
get
{
return
nil
!=
clearIconButton
return
nil
!=
clearIconButton
}
}
...
@@ -234,7 +234,7 @@ open class TextField: UITextField {
...
@@ -234,7 +234,7 @@ open class TextField: UITextField {
/// Enables the visibilityIconButton.
/// Enables the visibilityIconButton.
@IBInspectable
@IBInspectable
open
var
enableVisibilityIconButton
:
Bool
{
open
var
isVisibilityIconButtonEnable
:
Bool
{
get
{
get
{
return
nil
!=
visibilityIconButton
return
nil
!=
visibilityIconButton
}
}
...
@@ -379,7 +379,7 @@ open class TextField: UITextField {
...
@@ -379,7 +379,7 @@ open class TextField: UITextField {
/// Ensures that the components are sized correctly.
/// Ensures that the components are sized correctly.
open
func
layoutToSize
()
{
open
func
layoutToSize
()
{
if
!
a
nimating
{
if
!
isA
nimating
{
layoutPlaceholderLabel
()
layoutPlaceholderLabel
()
layoutDetailLabel
()
layoutDetailLabel
()
layoutClearIconButton
()
layoutClearIconButton
()
...
@@ -461,7 +461,7 @@ open class TextField: UITextField {
...
@@ -461,7 +461,7 @@ open class TextField: UITextField {
/// The animation for the placeholder when editing begins.
/// The animation for the placeholder when editing begins.
open
func
placeholderEditingDidBeginAnimation
()
{
open
func
placeholderEditingDidBeginAnimation
()
{
if
placeholderLabel
.
transform
.
isIdentity
{
if
placeholderLabel
.
transform
.
isIdentity
{
a
nimating
=
true
isA
nimating
=
true
UIView
.
animate
(
withDuration
:
0.15
,
animations
:
{
[
weak
self
]
in
UIView
.
animate
(
withDuration
:
0.15
,
animations
:
{
[
weak
self
]
in
if
let
s
=
self
{
if
let
s
=
self
{
s
.
placeholderLabel
.
transform
=
CGAffineTransform
(
scaleX
:
0.75
,
y
:
0.75
)
s
.
placeholderLabel
.
transform
=
CGAffineTransform
(
scaleX
:
0.75
,
y
:
0.75
)
...
@@ -476,7 +476,7 @@ open class TextField: UITextField {
...
@@ -476,7 +476,7 @@ open class TextField: UITextField {
s
.
placeholderLabel
.
textColor
=
s
.
placeholderActiveColor
s
.
placeholderLabel
.
textColor
=
s
.
placeholderActiveColor
}
}
})
{
[
weak
self
]
_
in
})
{
[
weak
self
]
_
in
self
?
.
a
nimating
=
false
self
?
.
isA
nimating
=
false
}
}
}
else
if
isEditing
{
}
else
if
isEditing
{
placeholderLabel
.
textColor
=
placeholderActiveColor
placeholderLabel
.
textColor
=
placeholderActiveColor
...
@@ -486,7 +486,7 @@ open class TextField: UITextField {
...
@@ -486,7 +486,7 @@ open class TextField: UITextField {
/// The animation for the placeholder when editing ends.
/// The animation for the placeholder when editing ends.
open
func
placeholderEditingDidEndAnimation
()
{
open
func
placeholderEditingDidEndAnimation
()
{
if
!
placeholderLabel
.
transform
.
isIdentity
&&
true
==
text
?
.
isEmpty
{
if
!
placeholderLabel
.
transform
.
isIdentity
&&
true
==
text
?
.
isEmpty
{
a
nimating
=
true
isA
nimating
=
true
UIView
.
animate
(
withDuration
:
0.15
,
animations
:
{
[
weak
self
]
in
UIView
.
animate
(
withDuration
:
0.15
,
animations
:
{
[
weak
self
]
in
if
let
s
=
self
{
if
let
s
=
self
{
s
.
placeholderLabel
.
transform
=
CGAffineTransform
.
identity
s
.
placeholderLabel
.
transform
=
CGAffineTransform
.
identity
...
@@ -495,7 +495,7 @@ open class TextField: UITextField {
...
@@ -495,7 +495,7 @@ open class TextField: UITextField {
s
.
placeholderLabel
.
textColor
=
s
.
placeholderColor
s
.
placeholderLabel
.
textColor
=
s
.
placeholderColor
}
}
})
{
[
weak
self
]
_
in
})
{
[
weak
self
]
_
in
self
?
.
a
nimating
=
false
self
?
.
isA
nimating
=
false
}
}
}
else
if
!
isEditing
{
}
else
if
!
isEditing
{
placeholderLabel
.
textColor
=
placeholderColor
placeholderLabel
.
textColor
=
placeholderColor
...
...
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