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
b5908d83
Commit
b5908d83
authored
Oct 06, 2018
by
Orkhan Alikhanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made buttons themeable
parent
c217102c
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
57 additions
and
3 deletions
+57
-3
Sources/iOS/BaseIconLayerButton.swift
+8
-0
Sources/iOS/Button.swift
+8
-1
Sources/iOS/CheckButton.swift
+7
-0
Sources/iOS/FABButton.swift
+9
-1
Sources/iOS/FlatButton.swift
+9
-0
Sources/iOS/IconButton.swift
+7
-0
Sources/iOS/RaisedButton.swift
+9
-1
No files found.
Sources/iOS/BaseIconLayerButton.swift
View file @
b5908d83
...
...
@@ -142,6 +142,14 @@ open class BaseIconLayerButton: Button {
reloadImage
()
}
}
open
override
func
apply
(
theme
:
Theme
)
{
super
.
apply
(
theme
:
theme
)
setIconColor
(
theme
.
secondary
,
for
:
.
selected
)
setIconColor
(
theme
.
onSurface
.
withAlphaComponent
(
0.38
),
for
:
.
normal
)
titleColor
=
theme
.
onSurface
.
withAlphaComponent
(
0.60
)
}
/// This might be considered as a hackish way, but it's just manipulation
...
...
Sources/iOS/Button.swift
View file @
b5908d83
...
...
@@ -31,7 +31,7 @@
import
UIKit
import
Motion
open
class
Button
:
UIButton
,
Pulseable
,
PulseableLayer
{
open
class
Button
:
UIButton
,
Pulseable
,
PulseableLayer
,
Themeable
{
/**
A CAShapeLayer used to manage elements that would be affected by
the clipToBounds property of the backing layer. For example, this
...
...
@@ -281,7 +281,14 @@ open class Button: UIButton, Pulseable, PulseableLayer {
contentScaleFactor
=
Screen
.
scale
prepareVisualLayer
()
preparePulse
()
applyCurrentTheme
()
}
/**
Applies given theme to the view.
- Parameter theme: A Theme.
*/
open
func
apply
(
theme
:
Theme
)
{
}
}
extension
Button
{
...
...
Sources/iOS/CheckButton.swift
View file @
b5908d83
...
...
@@ -31,6 +31,12 @@ open class CheckButton: BaseIconLayerButton {
guard
!
isAnimating
else
{
return
}
setSelected
(
!
isSelected
,
animated
:
true
)
}
open
override
func
apply
(
theme
:
Theme
)
{
super
.
apply
(
theme
:
theme
)
checkmarkColor
=
theme
.
onSecondary
}
}
internal
class
CheckBoxLayer
:
BaseIconLayer
{
...
...
@@ -86,6 +92,7 @@ internal class CheckBoxLayer: BaseIconLayer {
if
isSelected
{
borderLayer
.
borderWidth
=
borderLayerNormalBorderWidth
}
else
{
borderLayer
.
borderWidth
=
0
borderLayer
.
backgroundColor
=
(
isEnabled
?
normalColor
:
disabledColor
)
.
cgColor
checkMarkLeftLayer
.
strokeEnd
=
1
checkMarkRightLayer
.
strokeEnd
=
1
...
...
Sources/iOS/FABButton.swift
View file @
b5908d83
...
...
@@ -36,6 +36,14 @@ open class FABButton: Button {
depthPreset
=
.
depth1
shapePreset
=
.
circle
pulseAnimation
=
.
centerWithBacking
backgroundColor
=
.
white
}
open
override
func
apply
(
theme
:
Theme
)
{
super
.
apply
(
theme
:
theme
)
backgroundColor
=
theme
.
secondary
titleColor
=
theme
.
onSecondary
tintColor
=
theme
.
onSecondary
pulseColor
=
theme
.
onSecondary
}
}
Sources/iOS/FlatButton.swift
View file @
b5908d83
...
...
@@ -35,4 +35,13 @@ open class FlatButton: Button {
super
.
prepare
()
cornerRadiusPreset
=
.
cornerRadius1
}
open
override
func
apply
(
theme
:
Theme
)
{
super
.
apply
(
theme
:
theme
)
backgroundColor
=
.
clear
titleColor
=
theme
.
secondary
tintColor
=
theme
.
secondary
pulseColor
=
theme
.
secondary
}
}
Sources/iOS/IconButton.swift
View file @
b5908d83
...
...
@@ -35,4 +35,11 @@ open class IconButton: Button {
super
.
prepare
()
pulseAnimation
=
.
center
}
open
override
func
apply
(
theme
:
Theme
)
{
super
.
apply
(
theme
:
theme
)
tintColor
=
theme
.
secondary
pulseColor
=
theme
.
secondary
}
}
Sources/iOS/RaisedButton.swift
View file @
b5908d83
...
...
@@ -35,6 +35,14 @@ open class RaisedButton: Button {
super
.
prepare
()
depthPreset
=
.
depth1
cornerRadiusPreset
=
.
cornerRadius1
backgroundColor
=
.
white
}
open
override
func
apply
(
theme
:
Theme
)
{
super
.
apply
(
theme
:
theme
)
backgroundColor
=
theme
.
secondary
titleColor
=
theme
.
onSecondary
pulseColor
=
theme
.
onSecondary
tintColor
=
theme
.
onSecondary
}
}
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