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
5cbdd8f2
Commit
5cbdd8f2
authored
Oct 09, 2018
by
Orkhan Alikhanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made TabsController themeable
parent
656c5e23
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
0 deletions
+53
-0
Sources/iOS/TabsController.swift
+53
-0
No files found.
Sources/iOS/TabsController.swift
View file @
5cbdd8f2
...
@@ -39,6 +39,12 @@ public enum TabBarAlignment: Int {
...
@@ -39,6 +39,12 @@ public enum TabBarAlignment: Int {
case
bottom
case
bottom
}
}
public
enum
TabBarThemingStyle
{
case
auto
case
primary
case
secondary
}
extension
UIViewController
{
extension
UIViewController
{
/// TabItem reference.
/// TabItem reference.
@objc
@objc
...
@@ -165,6 +171,9 @@ open class TabsController: TransitionController {
...
@@ -165,6 +171,9 @@ open class TabsController: TransitionController {
}
}
}
}
/// The tabBar theming style.
open
var
tabBarThemingStyle
=
TabBarThemingStyle
.
auto
/**
/**
A UIPanGestureRecognizer property internally used for the interactive
A UIPanGestureRecognizer property internally used for the interactive
swipe.
swipe.
...
@@ -218,11 +227,55 @@ open class TabsController: TransitionController {
...
@@ -218,11 +227,55 @@ open class TabsController: TransitionController {
prepareTabBar
()
prepareTabBar
()
prepareTabItems
()
prepareTabItems
()
prepareSelectedIndexViewController
()
prepareSelectedIndexViewController
()
applyCurrentTheme
()
}
}
open
override
func
transition
(
to
viewController
:
UIViewController
,
completion
:
((
Bool
)
->
Void
)?)
{
open
override
func
transition
(
to
viewController
:
UIViewController
,
completion
:
((
Bool
)
->
Void
)?)
{
transition
(
to
:
viewController
,
isTriggeredByUserInteraction
:
false
,
completion
:
completion
)
transition
(
to
:
viewController
,
isTriggeredByUserInteraction
:
false
,
completion
:
completion
)
}
}
open
override
func
apply
(
theme
:
Theme
)
{
super
.
apply
(
theme
:
theme
)
switch
tabBarThemingStyle
{
case
.
auto
where
parent
is
NavigationController
&&
tabBarAlignment
==
.
top
:
fallthrough
case
.
primary
:
applyPrimary
(
theme
:
theme
)
default
:
applySecondary
(
theme
:
theme
)
}
}
}
private
extension
TabsController
{
/**
Applies theming taking primary color as base.
- Parameter theme: A Theme
*/
func
applyPrimary
(
theme
:
Theme
)
{
tabBar
.
lineColor
=
theme
.
onPrimary
.
withAlphaComponent
(
0.68
)
tabBar
.
backgroundColor
=
theme
.
primary
tabBar
.
setTabItemsColor
(
theme
.
onPrimary
,
for
:
.
normal
)
tabBar
.
setTabItemsColor
(
theme
.
onPrimary
,
for
:
.
selected
)
tabBar
.
setTabItemsColor
(
theme
.
onPrimary
,
for
:
.
highlighted
)
tabBar
.
isDividerHidden
=
true
}
/**
Applies theming taking secondary color as base.
- Parameter theme: A Theme
*/
func
applySecondary
(
theme
:
Theme
)
{
tabBar
.
lineColor
=
theme
.
secondary
tabBar
.
backgroundColor
=
theme
.
background
tabBar
.
setTabItemsColor
(
theme
.
onSurface
.
withAlphaComponent
(
0.60
),
for
:
.
normal
)
tabBar
.
setTabItemsColor
(
theme
.
secondary
,
for
:
.
selected
)
tabBar
.
setTabItemsColor
(
theme
.
secondary
,
for
:
.
highlighted
)
tabBar
.
dividerColor
=
theme
.
onSurface
.
withAlphaComponent
(
0.12
)
}
}
}
fileprivate
extension
TabsController
{
fileprivate
extension
TabsController
{
...
...
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