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
3c21dd3e
Commit
3c21dd3e
authored
Oct 06, 2018
by
Orkhan Alikhanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added isThemingEnabled
parent
e9fc6bb6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
Sources/iOS/Theme.swift
+33
-0
No files found.
Sources/iOS/Theme.swift
View file @
3c21dd3e
...
@@ -32,7 +32,14 @@ import UIKit
...
@@ -32,7 +32,14 @@ import UIKit
import
Motion
import
Motion
public
protocol
Themeable
{
public
protocol
Themeable
{
/**
Applies given theme.
- Parameter theme: A Theme.
*/
func
apply
(
theme
:
Theme
)
func
apply
(
theme
:
Theme
)
/// A boolean indicating if theming is enabled.
var
isThemingEnabled
:
Bool
{
get
set
}
}
}
public
struct
Theme
{
public
struct
Theme
{
...
@@ -109,6 +116,10 @@ public extension Theme {
...
@@ -109,6 +116,10 @@ public extension Theme {
- Parameter to view: A UIView.
- Parameter to view: A UIView.
*/
*/
static
func
apply
(
theme
:
Theme
,
to
view
:
UIView
)
{
static
func
apply
(
theme
:
Theme
,
to
view
:
UIView
)
{
guard
!
((
view
as?
Themeable
)?
.
isThemingEnabled
==
false
)
else
{
return
}
(
view
as?
Themeable
)?
.
apply
(
theme
:
theme
)
(
view
as?
Themeable
)?
.
apply
(
theme
:
theme
)
view
.
subviews
.
forEach
{
view
.
subviews
.
forEach
{
...
@@ -122,6 +133,10 @@ public extension Theme {
...
@@ -122,6 +133,10 @@ public extension Theme {
- Parameter to viewController: A UIViewController.
- Parameter to viewController: A UIViewController.
*/
*/
static
func
apply
(
theme
:
Theme
,
to
viewController
:
UIViewController
)
{
static
func
apply
(
theme
:
Theme
,
to
viewController
:
UIViewController
)
{
guard
!
((
viewController
as?
Themeable
)?
.
isThemingEnabled
==
false
)
else
{
return
}
apply
(
theme
:
theme
,
to
:
viewController
.
view
)
apply
(
theme
:
theme
,
to
:
viewController
.
view
)
(
viewController
as?
Themeable
)?
.
apply
(
theme
:
theme
)
(
viewController
as?
Themeable
)?
.
apply
(
theme
:
theme
)
...
@@ -143,3 +158,21 @@ public extension Theme {
...
@@ -143,3 +158,21 @@ public extension Theme {
current
=
v
current
=
v
}
}
}
}
/// A memory reference to the isThemingEnabled for Themeable NSObject subclasses.
fileprivate
var
IsThemingEnabledKey
:
UInt8
=
0
public
extension
Themeable
where
Self
:
NSObject
{
/// A boolean indicating if theming is enabled.
var
isThemingEnabled
:
Bool
{
get
{
return
AssociatedObject
.
get
(
base
:
self
,
key
:
&
IsThemingEnabledKey
)
{
true
}
}
set
(
value
)
{
AssociatedObject
.
set
(
base
:
self
,
key
:
&
IsThemingEnabledKey
,
value
:
value
)
}
}
}
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