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
d75ed300
Unverified
Commit
d75ed300
authored
Apr 15, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial scrollable TabBar work added
parent
0c526c8f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
9 deletions
+59
-9
Sources/iOS/Bar.swift
+13
-1
Sources/iOS/PageMenuController.swift
+3
-4
Sources/iOS/TabBar.swift
+43
-4
No files found.
Sources/iOS/Bar.swift
View file @
d75ed300
...
@@ -105,7 +105,7 @@ open class Bar: View {
...
@@ -105,7 +105,7 @@ open class Bar: View {
}
}
/// ContentView that holds the any desired subviews.
/// ContentView that holds the any desired subviews.
open
let
contentView
=
UIView
()
open
let
contentView
=
UI
Scroll
View
()
/// Left side UIViews.
/// Left side UIViews.
open
var
leftViews
:
[
UIView
]
{
open
var
leftViews
:
[
UIView
]
{
...
@@ -272,5 +272,17 @@ open class Bar: View {
...
@@ -272,5 +272,17 @@ open class Bar: View {
autoresizingMask
=
.
flexibleWidth
autoresizingMask
=
.
flexibleWidth
interimSpacePreset
=
.
interimSpace3
interimSpacePreset
=
.
interimSpace3
contentEdgeInsetsPreset
=
.
square1
contentEdgeInsetsPreset
=
.
square1
prepareContentView
()
}
}
extension
Bar
{
/// Prepares the contentView.
fileprivate
func
prepareContentView
()
{
contentView
.
bounces
=
false
contentView
.
isPagingEnabled
=
true
contentView
.
showsVerticalScrollIndicator
=
false
contentView
.
showsHorizontalScrollIndicator
=
false
contentView
.
contentScaleFactor
=
Screen
.
scale
}
}
}
}
Sources/iOS/PageMenuController.swift
View file @
d75ed300
...
@@ -196,6 +196,7 @@ open class PageMenuController: UIViewController {
...
@@ -196,6 +196,7 @@ open class PageMenuController: UIViewController {
when subclassing.
when subclassing.
*/
*/
open
func
prepare
()
{
open
func
prepare
()
{
view
.
contentScaleFactor
=
Screen
.
scale
prepareScrollView
()
prepareScrollView
()
prepareViewControllers
()
prepareViewControllers
()
}
}
...
@@ -209,6 +210,7 @@ extension PageMenuController {
...
@@ -209,6 +210,7 @@ extension PageMenuController {
scrollView
.
isPagingEnabled
=
true
scrollView
.
isPagingEnabled
=
true
scrollView
.
showsVerticalScrollIndicator
=
false
scrollView
.
showsVerticalScrollIndicator
=
false
scrollView
.
showsHorizontalScrollIndicator
=
false
scrollView
.
showsHorizontalScrollIndicator
=
false
scrollView
.
contentScaleFactor
=
Screen
.
scale
view
.
addSubview
(
scrollView
)
view
.
addSubview
(
scrollView
)
}
}
...
@@ -287,6 +289,7 @@ extension PageMenuController {
...
@@ -287,6 +289,7 @@ extension PageMenuController {
tabBar
?
.
isLineAnimated
=
false
tabBar
?
.
isLineAnimated
=
false
tabBar
?
.
lineAlignment
=
.
top
tabBar
?
.
lineAlignment
=
.
top
view
.
addSubview
(
tabBar
!
)
view
.
addSubview
(
tabBar
!
)
prepareTabBarButtons
(
buttons
)
prepareTabBarButtons
(
buttons
)
}
}
...
@@ -350,10 +353,6 @@ extension PageMenuController {
...
@@ -350,10 +353,6 @@ extension PageMenuController {
- Parameter position: An Int for the position of the view controller.
- Parameter position: An Int for the position of the view controller.
*/
*/
fileprivate
func
layoutViewController
(
at
index
:
Int
,
position
:
Int
)
{
fileprivate
func
layoutViewController
(
at
index
:
Int
,
position
:
Int
)
{
guard
0
<=
index
&&
index
<
viewControllers
.
count
else
{
return
}
viewControllers
[
index
]
.
view
.
frame
=
CGRect
(
x
:
CGFloat
(
position
)
*
scrollView
.
width
,
y
:
0
,
width
:
scrollView
.
width
,
height
:
scrollView
.
height
)
viewControllers
[
index
]
.
view
.
frame
=
CGRect
(
x
:
CGFloat
(
position
)
*
scrollView
.
width
,
y
:
0
,
width
:
scrollView
.
width
,
height
:
scrollView
.
height
)
}
}
}
}
...
...
Sources/iOS/TabBar.swift
View file @
d75ed300
...
@@ -57,10 +57,33 @@ public protocol TabBarDelegate {
...
@@ -57,10 +57,33 @@ public protocol TabBarDelegate {
optional
func
tabBar
(
tabBar
:
TabBar
,
didSelect
button
:
UIButton
)
optional
func
tabBar
(
tabBar
:
TabBar
,
didSelect
button
:
UIButton
)
}
}
@objc(TabBarStyle)
public
enum
TabBarStyle
:
Int
{
case
normal
case
scrollable
}
open
class
TabBar
:
Bar
{
open
class
TabBar
:
Bar
{
/// A boolean indicating if the TabBar line is in an animation state.
/// A boolean indicating if the TabBar line is in an animation state.
open
internal(set)
var
isAnimating
=
false
open
internal(set)
var
isAnimating
=
false
/// Enables and disables bouncing when swiping.
open
var
isBounceEnabled
:
Bool
{
get
{
return
contentView
.
bounces
}
set
(
value
)
{
contentView
.
bounces
=
value
}
}
/// An enum that determines the tab bar style.
open
var
tabBarStyle
=
TabBarStyle
.
scrollable
{
didSet
{
layoutSubviews
()
}
}
/// A delegation reference.
/// A delegation reference.
open
weak
var
delegate
:
TabBarDelegate
?
open
weak
var
delegate
:
TabBarDelegate
?
...
@@ -116,8 +139,6 @@ open class TabBar: Bar {
...
@@ -116,8 +139,6 @@ open class TabBar: Bar {
b
.
removeFromSuperview
()
b
.
removeFromSuperview
()
}
}
centerViews
=
buttons
as
[
UIView
]
layoutSubviews
()
layoutSubviews
()
}
}
}
}
...
@@ -186,8 +207,25 @@ open class TabBar: Bar {
...
@@ -186,8 +207,25 @@ open class TabBar: Bar {
}
}
}
}
if
.
scrollable
==
tabBarStyle
{
var
w
:
CGFloat
=
0
for
b
in
buttons
{
let
width
=
b
.
sizeThatFits
(
CGSize
(
width
:
CGFloat
.
greatestFiniteMagnitude
,
height
:
contentView
.
height
))
.
width
+
interimSpace
contentView
.
addSubview
(
b
)
b
.
height
=
contentView
.
height
b
.
width
=
width
b
.
x
=
w
w
+=
width
}
print
(
w
,
contentView
.
width
)
if
w
>
contentView
.
width
{
contentView
.
contentSize
.
width
=
w
}
}
else
{
contentView
.
grid
.
axis
.
columns
=
buttons
.
count
contentView
.
grid
.
axis
.
columns
=
buttons
.
count
contentView
.
grid
.
reload
()
centerViews
=
buttons
}
if
nil
==
selected
{
if
nil
==
selected
{
selected
=
buttons
.
first
selected
=
buttons
.
first
...
@@ -205,8 +243,9 @@ open class TabBar: Bar {
...
@@ -205,8 +243,9 @@ open class TabBar: Bar {
*/
*/
open
override
func
prepare
()
{
open
override
func
prepare
()
{
super
.
prepare
()
super
.
prepare
()
isBounceEnabled
=
true
contentEdgeInsetsPreset
=
.
none
contentEdgeInsetsPreset
=
.
none
interimSpacePreset
=
.
none
interimSpacePreset
=
.
interimSpace5
prepareLine
()
prepareLine
()
prepareDivider
()
prepareDivider
()
}
}
...
...
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