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
aa4f01ee
Commit
aa4f01ee
authored
Mar 28, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
issue-260: fixed issue where MaterialSwitch color was not propagating until engaged
parent
83c4c4a6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
15 deletions
+65
-15
Sources/BottomNavigationController.swift
+5
-5
Sources/MaterialSwitch.swift
+60
-10
No files found.
Sources/BottomNavigationController.swift
View file @
aa4f01ee
...
...
@@ -130,11 +130,11 @@ public class BottomNavigationController : UITabBarController, UITabBarController
/// Handles transitions when tabBarItems are pressed.
public
func
tabBarController
(
tabBarController
:
UITabBarController
,
animationControllerForTransitionFromViewController
fromVC
:
UIViewController
,
toViewController
toVC
:
UIViewController
)
->
UIViewControllerAnimatedTransitioning
?
{
let
f
rom
VC
:
UIViewController
?
=
fromVC
let
to
VC
:
UIViewController
?
=
toVC
if
nil
==
fromVC
||
nil
==
to
VC
{
return
nil
}
let
fVC
:
UIViewController
?
=
fromVC
let
t
VC
:
UIViewController
?
=
toVC
if
nil
==
fVC
||
nil
==
t
VC
{
return
nil
}
return
.
Fade
==
transitionAnimation
?
BottomNavigationFadeAnimatedTransitioning
()
:
nil
}
...
...
Sources/MaterialSwitch.swift
View file @
aa4f01ee
...
...
@@ -125,28 +125,60 @@ public class MaterialSwitch : UIControl {
}
/// Button on color.
@IBInspectable
public
var
buttonOnColor
:
UIColor
=
MaterialColor
.
clear
@IBInspectable
public
var
buttonOnColor
:
UIColor
=
MaterialColor
.
clear
{
didSet
{
styleForState
(
switchState
)
}
}
/// Button off color.
@IBInspectable
public
var
buttonOffColor
:
UIColor
=
MaterialColor
.
clear
@IBInspectable
public
var
buttonOffColor
:
UIColor
=
MaterialColor
.
clear
{
didSet
{
styleForState
(
switchState
)
}
}
/// Track on color.
@IBInspectable
public
var
trackOnColor
:
UIColor
=
MaterialColor
.
clear
@IBInspectable
public
var
trackOnColor
:
UIColor
=
MaterialColor
.
clear
{
didSet
{
styleForState
(
switchState
)
}
}
/// Track off color.
@IBInspectable
public
var
trackOffColor
:
UIColor
=
MaterialColor
.
clear
@IBInspectable
public
var
trackOffColor
:
UIColor
=
MaterialColor
.
clear
{
didSet
{
styleForState
(
switchState
)
}
}
/// Button on disabled color.
@IBInspectable
public
var
buttonOnDisabledColor
:
UIColor
=
MaterialColor
.
clear
@IBInspectable
public
var
buttonOnDisabledColor
:
UIColor
=
MaterialColor
.
clear
{
didSet
{
styleForState
(
switchState
)
}
}
/// Track on disabled color.
@IBInspectable
public
var
trackOnDisabledColor
:
UIColor
=
MaterialColor
.
clear
@IBInspectable
public
var
trackOnDisabledColor
:
UIColor
=
MaterialColor
.
clear
{
didSet
{
styleForState
(
switchState
)
}
}
/// Button off disabled color.
@IBInspectable
public
var
buttonOffDisabledColor
:
UIColor
=
MaterialColor
.
clear
@IBInspectable
public
var
buttonOffDisabledColor
:
UIColor
=
MaterialColor
.
clear
{
didSet
{
styleForState
(
switchState
)
}
}
/// Track off disabled color.
@IBInspectable
public
var
trackOffDisabledColor
:
UIColor
=
MaterialColor
.
clear
@IBInspectable
public
var
trackOffDisabledColor
:
UIColor
=
MaterialColor
.
clear
{
didSet
{
styleForState
(
switchState
)
}
}
/// Track view reference.
public
private(set)
var
trackLayer
:
MaterialLayer
{
...
...
@@ -264,6 +296,24 @@ public class MaterialSwitch : UIControl {
}
/**
An initializer that initializes the object with a CGRect object.
If AutoLayout is used, it is better to initilize the instance
using the init(state:style:size:) initializer, or set the CGRect
to CGRectNull.
- Parameter frame: A CGRect instance.
*/
public
override
init
(
frame
:
CGRect
)
{
trackLayer
=
MaterialLayer
()
button
=
FabButton
()
super
.
init
(
frame
:
frame
)
prepareTrack
()
prepareButton
()
prepareSwitchSize
(
.
Default
)
prepareSwitchStyle
(
.
LightContent
)
prepareSwitchState
(
.
Off
)
}
/**
An initializer that sets the state, style, and size of the MaterialSwitch instance.
- Parameter state: A MaterialSwitchState value.
- Parameter style: A MaterialSwitchStyle value.
...
...
@@ -425,7 +475,7 @@ public class MaterialSwitch : UIControl {
*/
private
func
styleForState
(
state
:
MaterialSwitchState
)
{
if
enabled
{
updateColorFor
Enabled
State
(
state
)
updateColorForState
(
state
)
}
else
{
updateColorForDisabledState
(
state
)
}
...
...
@@ -435,7 +485,7 @@ public class MaterialSwitch : UIControl {
Updates the coloring for the enabled state.
- Parameter state: MaterialSwitchState.
*/
private
func
updateColorFor
Enabled
State
(
state
:
MaterialSwitchState
)
{
private
func
updateColorForState
(
state
:
MaterialSwitchState
)
{
if
.
On
==
state
{
button
.
backgroundColor
=
buttonOnColor
trackLayer
.
backgroundColor
=
trackOnColor
.
CGColor
...
...
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