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
94cce7e2
Commit
94cce7e2
authored
Oct 10, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
samples issue-70: added internal delegation for TabBar to be used by TabsController
parent
5c8aa125
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
14 deletions
+31
-14
Material.xcodeproj/project.pbxproj
+1
-1
Sources/iOS/TabBar.swift
+25
-11
Sources/iOS/TabsController.swift
+5
-2
No files found.
Material.xcodeproj/project.pbxproj
View file @
94cce7e2
...
@@ -358,7 +358,7 @@
...
@@ -358,7 +358,7 @@
96BCB7971CB40DC500C806FE
/* NavigationDrawerController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
NavigationDrawerController.swift
;
sourceTree
=
"<group>"
;
};
96BCB7971CB40DC500C806FE
/* NavigationDrawerController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
NavigationDrawerController.swift
;
sourceTree
=
"<group>"
;
};
96BCB7981CB40DC500C806FE
/* Bar.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Bar.swift
;
sourceTree
=
"<group>"
;
};
96BCB7981CB40DC500C806FE
/* Bar.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Bar.swift
;
sourceTree
=
"<group>"
;
};
96BCB7991CB40DC500C806FE
/* TransitionController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
TransitionController.swift
;
sourceTree
=
"<group>"
;
};
96BCB7991CB40DC500C806FE
/* TransitionController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
TransitionController.swift
;
sourceTree
=
"<group>"
;
};
96BCB79A1CB40DC500C806FE
/* TabBar.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
TabBar.swift
;
sourceTree
=
"<group>"
;
};
96BCB79A1CB40DC500C806FE
/* TabBar.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
indentWidth
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
TabBar.swift
;
sourceTree
=
"<group>"
;
tabWidth
=
4
;
};
96BCB79C1CB40DC500C806FE
/* TextField.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
TextField.swift
;
sourceTree
=
"<group>"
;
};
96BCB79C1CB40DC500C806FE
/* TextField.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
TextField.swift
;
sourceTree
=
"<group>"
;
};
96BCB79D1CB40DC500C806FE
/* TextStorage.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
TextStorage.swift
;
sourceTree
=
"<group>"
;
};
96BCB79D1CB40DC500C806FE
/* TextStorage.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
TextStorage.swift
;
sourceTree
=
"<group>"
;
};
96BCB79E1CB40DC500C806FE
/* TextView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
TextView.swift
;
sourceTree
=
"<group>"
;
};
96BCB79E1CB40DC500C806FE
/* TextView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
TextView.swift
;
sourceTree
=
"<group>"
;
};
...
...
Sources/iOS/TabBar.swift
View file @
94cce7e2
...
@@ -39,8 +39,8 @@ open class TabItem: FlatButton {
...
@@ -39,8 +39,8 @@ open class TabItem: FlatButton {
@objc(TabBarLineAlignment)
@objc(TabBarLineAlignment)
public
enum
TabBarLineAlignment
:
Int
{
public
enum
TabBarLineAlignment
:
Int
{
case
top
case
top
case
bottom
case
bottom
}
}
@objc(TabBarDelegate)
@objc(TabBarDelegate)
...
@@ -74,6 +74,18 @@ public protocol TabBarDelegate {
...
@@ -74,6 +74,18 @@ public protocol TabBarDelegate {
optional
func
tabBar
(
tabBar
:
TabBar
,
didSelect
tabItem
:
TabItem
)
optional
func
tabBar
(
tabBar
:
TabBar
,
didSelect
tabItem
:
TabItem
)
}
}
@objc(_TabBarDelegate)
internal
protocol
_TabBarDelegate
{
/**
A delegation method that is executed when the tabItem will trigger the
animation to the next tab.
- Parameter tabBar: A TabBar.
- Parameter tabItem: A TabItem.
*/
@objc
optional
func
_tabBar
(
tabBar
:
TabBar
,
willSelect
tabItem
:
TabItem
)
}
@objc(TabBarStyle)
@objc(TabBarStyle)
public
enum
TabBarStyle
:
Int
{
public
enum
TabBarStyle
:
Int
{
case
auto
case
auto
...
@@ -124,6 +136,7 @@ open class TabBar: Bar {
...
@@ -124,6 +136,7 @@ open class TabBar: Bar {
/// A delegation reference.
/// A delegation reference.
open
weak
var
delegate
:
TabBarDelegate
?
open
weak
var
delegate
:
TabBarDelegate
?
internal
weak
var
_delegate
:
_TabBarDelegate
?
/// The currently selected tabItem.
/// The currently selected tabItem.
open
internal(set)
var
selectedTabItem
:
TabItem
?
open
internal(set)
var
selectedTabItem
:
TabItem
?
...
@@ -170,17 +183,17 @@ open class TabBar: Bar {
...
@@ -170,17 +183,17 @@ open class TabBar: Bar {
}
}
}
}
/// TabItems.
/// TabItems.
open
var
tabItems
=
[
TabItem
]()
{
open
var
tabItems
=
[
TabItem
]()
{
didSet
{
didSet
{
for
b
in
oldValue
{
for
b
in
oldValue
{
b
.
removeFromSuperview
()
b
.
removeFromSuperview
()
}
}
prepareTabItems
()
prepareTabItems
()
layoutSubviews
()
layoutSubviews
()
}
}
}
}
/// A reference to the line UIView.
/// A reference to the line UIView.
open
let
line
=
UIView
()
open
let
line
=
UIView
()
...
@@ -222,7 +235,7 @@ open class TabBar: Bar {
...
@@ -222,7 +235,7 @@ open class TabBar: Bar {
layoutLine
()
layoutLine
()
updateScrollView
()
updateScrollView
()
}
}
open
override
func
prepare
()
{
open
override
func
prepare
()
{
super
.
prepare
()
super
.
prepare
()
...
@@ -402,6 +415,7 @@ fileprivate extension TabBar {
...
@@ -402,6 +415,7 @@ fileprivate extension TabBar {
*/
*/
func
animate
(
to
tabItem
:
TabItem
,
isTriggeredByUserInteraction
:
Bool
,
completion
:
((
TabItem
)
->
Void
)?
=
nil
)
{
func
animate
(
to
tabItem
:
TabItem
,
isTriggeredByUserInteraction
:
Bool
,
completion
:
((
TabItem
)
->
Void
)?
=
nil
)
{
if
isTriggeredByUserInteraction
{
if
isTriggeredByUserInteraction
{
_delegate
?
.
_tabBar
?(
tabBar
:
self
,
willSelect
:
tabItem
)
delegate
?
.
tabBar
?(
tabBar
:
self
,
willSelect
:
tabItem
)
delegate
?
.
tabBar
?(
tabBar
:
self
,
willSelect
:
tabItem
)
}
}
...
...
Sources/iOS/TabsController.swift
View file @
94cce7e2
...
@@ -284,6 +284,7 @@ fileprivate extension TabsController {
...
@@ -284,6 +284,7 @@ fileprivate extension TabsController {
/// Prepares the TabBar.
/// Prepares the TabBar.
func
prepareTabBar
()
{
func
prepareTabBar
()
{
tabBar
.
lineAlignment
=
.
bottom
==
tabBarAlignment
?
.
top
:
.
bottom
tabBar
.
lineAlignment
=
.
bottom
==
tabBarAlignment
?
.
top
:
.
bottom
tabBar
.
_delegate
=
self
tabBar
.
delegate
=
self
tabBar
.
delegate
=
self
view
.
addSubview
(
tabBar
)
view
.
addSubview
(
tabBar
)
}
}
...
@@ -378,9 +379,9 @@ extension TabsController {
...
@@ -378,9 +379,9 @@ extension TabsController {
}
}
}
}
extension
TabsController
:
TabBarDelegate
{
extension
TabsController
:
_
TabBarDelegate
{
@objc
@objc
open
func
tabBar
(
tabBar
:
TabBar
,
willSelect
tabItem
:
TabItem
)
{
func
_
tabBar
(
tabBar
:
TabBar
,
willSelect
tabItem
:
TabItem
)
{
guard
!
(
false
==
tabBar
.
delegate
?
.
tabBar
?(
tabBar
:
tabBar
,
shouldSelect
:
tabItem
))
else
{
guard
!
(
false
==
tabBar
.
delegate
?
.
tabBar
?(
tabBar
:
tabBar
,
shouldSelect
:
tabItem
))
else
{
return
return
}
}
...
@@ -406,3 +407,5 @@ extension TabsController: TabBarDelegate {
...
@@ -406,3 +407,5 @@ extension TabsController: TabBarDelegate {
}
}
}
}
}
}
extension
TabsController
:
TabBarDelegate
{}
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