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
af81c22e
Commit
af81c22e
authored
Jul 04, 2018
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor cleanup for extension reference in Switch
parent
ec3e3e8c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
19 deletions
+20
-19
Sources/iOS/Switch.swift
+20
-19
No files found.
Sources/iOS/Switch.swift
View file @
af81c22e
...
...
@@ -371,7 +371,9 @@ extension Switch {
open
func
setSwitchState
(
state
:
SwitchState
,
animated
:
Bool
=
true
,
completion
:
((
Switch
)
->
Void
)?
=
nil
)
{
updateSwitchState
(
state
:
state
,
animated
:
animated
,
isTriggeredByUserInteraction
:
false
,
completion
:
completion
)
}
}
fileprivate
extension
Switch
{
/**
Set the switchState property with an option to animate.
- Parameter state: The SwitchState to set.
...
...
@@ -414,14 +416,12 @@ extension Switch {
delegate
?
.
switchDidChangeState
(
control
:
self
,
state
:
internalSwitchState
)
}
}
}
extension
Switch
{
/**
Updates the coloring for the enabled state.
- Parameter state: SwitchState.
*/
f
ileprivate
f
unc
updateColorForState
(
state
:
SwitchState
)
{
func
updateColorForState
(
state
:
SwitchState
)
{
if
.
on
==
state
{
button
.
backgroundColor
=
buttonOnColor
track
.
backgroundColor
=
trackOnColor
...
...
@@ -435,7 +435,7 @@ extension Switch {
Updates the coloring for the disabled state.
- Parameter state: SwitchState.
*/
f
ileprivate
f
unc
updateColorForDisabledState
(
state
:
SwitchState
)
{
func
updateColorForDisabledState
(
state
:
SwitchState
)
{
if
.
on
==
state
{
button
.
backgroundColor
=
buttonOnDisabledColor
track
.
backgroundColor
=
trackOnDisabledColor
...
...
@@ -449,22 +449,23 @@ extension Switch {
Updates the style based on the state.
- Parameter state: The SwitchState to set the style to.
*/
f
ileprivate
f
unc
styleForState
(
state
:
SwitchState
)
{
func
styleForState
(
state
:
SwitchState
)
{
if
isEnabled
{
updateColorForState
(
state
:
state
)
}
else
{
updateColorForDisabledState
(
state
:
state
)
}
}
}
extension
Switch
{
fileprivate
extension
Switch
{
/**
Set the switchState property with an animate.
- Parameter state: The SwitchState to set.
- Parameter completion: An Optional completion block.
*/
f
ileprivate
f
unc
animateToState
(
state
:
SwitchState
,
completion
:
((
Switch
)
->
Void
)?
=
nil
)
{
func
animateToState
(
state
:
SwitchState
,
completion
:
((
Switch
)
->
Void
)?
=
nil
)
{
isUserInteractionEnabled
=
false
UIView
.
animate
(
withDuration
:
0.15
,
delay
:
0.05
,
...
...
@@ -496,14 +497,14 @@ extension Switch {
}
}
extension
Switch
{
fileprivate
extension
Switch
{
/**
Handle the TouchUpOutside and TouchCancel moments.
- Parameter sender: A UIButton.
- Parameter event: A UIEvent.
*/
@objc
f
ileprivate
f
unc
handleTouchUpOutsideOrCanceled
(
sender
:
FABButton
,
event
:
UIEvent
)
{
func
handleTouchUpOutsideOrCanceled
(
sender
:
FABButton
,
event
:
UIEvent
)
{
guard
let
v
=
event
.
touches
(
for
:
sender
)?
.
first
else
{
return
}
...
...
@@ -514,7 +515,7 @@ extension Switch {
/// Handles the TouchUpInside event.
@objc
f
ileprivate
f
unc
handleTouchUpInside
()
{
func
handleTouchUpInside
()
{
updateSwitchState
(
state
:
isOn
?
.
off
:
.
on
,
animated
:
true
,
isTriggeredByUserInteraction
:
true
)
}
...
...
@@ -524,7 +525,7 @@ extension Switch {
- Parameter event: A UIEvent.
*/
@objc
f
ileprivate
f
unc
handleTouchDragInside
(
sender
:
FABButton
,
event
:
UIEvent
)
{
func
handleTouchDragInside
(
sender
:
FABButton
,
event
:
UIEvent
)
{
guard
let
v
=
event
.
touches
(
for
:
sender
)?
.
first
else
{
return
}
...
...
@@ -539,14 +540,14 @@ extension Switch {
}
}
extension
Switch
{
fileprivate
extension
Switch
{
/// Prepares the track.
f
ileprivate
f
unc
prepareTrack
()
{
func
prepareTrack
()
{
addSubview
(
track
)
}
/// Prepares the button.
f
ileprivate
f
unc
prepareButton
()
{
func
prepareButton
()
{
button
.
addTarget
(
self
,
action
:
#selector(
handleTouchUpInside
)
,
for
:
.
touchUpInside
)
button
.
addTarget
(
self
,
action
:
#selector(
handleTouchDragInside
)
,
for
:
.
touchDragInside
)
button
.
addTarget
(
self
,
action
:
#selector(
handleTouchUpOutsideOrCanceled
)
,
for
:
.
touchCancel
)
...
...
@@ -559,7 +560,7 @@ extension Switch {
init to set the state value and have an effect.
- Parameter state: The SwitchState to set.
*/
f
ileprivate
f
unc
prepareSwitchState
(
state
:
SwitchState
=
.
off
)
{
func
prepareSwitchState
(
state
:
SwitchState
=
.
off
)
{
updateSwitchState
(
state
:
state
,
animated
:
false
,
isTriggeredByUserInteraction
:
false
)
}
...
...
@@ -568,7 +569,7 @@ extension Switch {
init to set the state value and have an effect.
- Parameter style: The SwitchStyle to set.
*/
f
ileprivate
f
unc
prepareSwitchStyle
(
style
:
SwitchStyle
=
.
light
)
{
func
prepareSwitchStyle
(
style
:
SwitchStyle
=
.
light
)
{
switchStyle
=
style
}
...
...
@@ -577,7 +578,7 @@ extension Switch {
init to set the size value and have an effect.
- Parameter size: The SwitchSize to set.
*/
f
ileprivate
f
unc
prepareSwitchSize
(
size
:
SwitchSize
=
.
medium
)
{
func
prepareSwitchSize
(
size
:
SwitchSize
=
.
medium
)
{
switchSize
=
size
}
}
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