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
85d97b17
Commit
85d97b17
authored
Oct 06, 2018
by
Orkhan Alikhanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made NavigationBar themeable
parent
c08a143e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
3 deletions
+31
-3
Sources/iOS/NavigationBar.swift
+31
-3
No files found.
Sources/iOS/NavigationBar.swift
View file @
85d97b17
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
import
UIKit
import
UIKit
open
class
NavigationBar
:
UINavigationBar
{
open
class
NavigationBar
:
UINavigationBar
,
Themeable
{
/// Will layout the view.
/// Will layout the view.
open
var
willLayout
:
Bool
{
open
var
willLayout
:
Bool
{
return
0
<
bounds
.
width
&&
0
<
bounds
.
height
&&
nil
!=
superview
return
0
<
bounds
.
width
&&
0
<
bounds
.
height
&&
nil
!=
superview
...
@@ -168,7 +168,32 @@ open class NavigationBar: UINavigationBar {
...
@@ -168,7 +168,32 @@ open class NavigationBar: UINavigationBar {
let
image
=
UIImage
()
let
image
=
UIImage
()
shadowImage
=
image
shadowImage
=
image
setBackgroundImage
(
image
,
for
:
.
default
)
setBackgroundImage
(
image
,
for
:
.
default
)
backgroundColor
=
.
white
applyCurrentTheme
()
}
open
func
apply
(
theme
:
Theme
)
{
backgroundColor
=
theme
.
primary
items
?
.
forEach
{
apply
(
theme
:
theme
,
to
:
$0
)
}
}
private
func
apply
(
theme
:
Theme
,
to
item
:
UINavigationItem
)
{
item
.
toolbar
.
backgroundColor
=
.
clear
(
item
.
toolbar
.
leftViews
+
item
.
toolbar
.
rightViews
+
item
.
toolbar
.
centerViews
)
.
compactMap
{
$0
as?
IconButton
}
.
filter
{
$0
.
isThemingEnabled
}
.
forEach
{
$0
.
tintColor
=
theme
.
onPrimary
$0
.
pulseColor
=
theme
.
onPrimary
}
if
!
((
item
.
titleLabel
as?
Themeable
)?
.
isThemingEnabled
==
false
)
{
item
.
titleLabel
.
textColor
=
theme
.
onPrimary
}
if
!
((
item
.
detailLabel
as?
Themeable
)?
.
isThemingEnabled
==
false
)
{
item
.
detailLabel
.
textColor
=
theme
.
onPrimary
}
}
}
}
}
...
@@ -182,8 +207,11 @@ internal extension NavigationBar {
...
@@ -182,8 +207,11 @@ internal extension NavigationBar {
return
return
}
}
if
isThemingEnabled
{
apply
(
theme
:
.
current
,
to
:
item
)
}
let
toolbar
=
item
.
toolbar
let
toolbar
=
item
.
toolbar
toolbar
.
backgroundColor
=
.
clear
toolbar
.
interimSpace
=
interimSpace
toolbar
.
interimSpace
=
interimSpace
toolbar
.
contentEdgeInsets
=
contentEdgeInsets
toolbar
.
contentEdgeInsets
=
contentEdgeInsets
...
...
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