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