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
ffd475b2
Commit
ffd475b2
authored
Aug 09, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed line layout rotation issue for TabBar
parent
366df6a0
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
21 deletions
+35
-21
Sources/iOS/Card.swift
+1
-1
Sources/iOS/ChipBar.swift
+15
-11
Sources/iOS/TabBar.swift
+18
-9
Sources/iOS/TabBarController.swift
+1
-0
No files found.
Sources/iOS/Card.swift
View file @
ffd475b2
...
...
@@ -228,7 +228,7 @@ open class Card: PulseView {
if
0
==
h
||
nil
!=
view
as?
UILabel
{
(
view
as?
UILabel
)?
.
sizeToFit
()
h
=
view
.
sizeThatFits
(
CGSize
(
width
:
w
,
height
:
CGFloat
.
greatestFiniteMagnitude
))
.
height
h
=
view
.
sizeThatFits
(
CGSize
(
width
:
w
,
height
:
.
greatestFiniteMagnitude
))
.
height
}
view
.
width
=
w
...
...
Sources/iOS/ChipBar.swift
View file @
ffd475b2
...
...
@@ -119,11 +119,17 @@ open class ChipBar: Bar {
/// The total width of the chipItems.
fileprivate
var
chipItemsTotalWidth
:
CGFloat
{
var
w
:
CGFloat
=
0
let
q
=
2
*
chipItemsInterimSpace
let
p
=
q
+
chipItemsInterimSpace
for
v
in
chipItems
{
w
+=
v
.
sizeThatFits
(
CGSize
(
width
:
CGFloat
.
greatestFiniteMagnitude
,
height
:
contentView
.
height
))
.
width
+
interimSpace
let
x
=
v
.
sizeThatFits
(
CGSize
(
width
:
.
greatestFiniteMagnitude
,
height
:
scrollView
.
height
))
.
width
w
+=
x
w
+=
p
}
w
-=
chipItemsInterimSpace
return
w
}
...
...
@@ -150,9 +156,6 @@ open class ChipBar: Bar {
/// A delegation reference.
open
weak
var
delegate
:
ChipBarDelegate
?
/// The currently selected chipItem.
open
fileprivate
(
set
)
var
selected
:
ChipItem
?
/// A preset wrapper around chipItems contentEdgeInsets.
open
var
chipItemsContentEdgeInsetsPreset
:
EdgeInsetsPreset
{
get
{
...
...
@@ -266,13 +269,15 @@ fileprivate extension ChipBar {
fileprivate
extension
ChipBar
{
/// Layout the scrollView.
func
layoutScrollView
()
{
if
.
scrollable
==
chipBarStyle
||
(
.
auto
==
chipBarStyle
&&
chipItemsTotalWidth
>
bounds
.
width
)
{
contentView
.
grid
.
reload
()
if
.
scrollable
==
chipBarStyle
||
(
.
auto
==
chipBarStyle
&&
chipItemsTotalWidth
>
scrollView
.
width
)
{
var
w
:
CGFloat
=
0
let
q
=
2
*
chipItemsInterimSpace
let
p
=
q
+
chipItemsInterimSpace
for
v
in
chipItems
{
let
x
=
v
.
sizeThatFits
(
CGSize
(
width
:
CGFloat
.
greatestFiniteMagnitude
,
height
:
scrollView
.
height
))
.
width
let
x
=
v
.
sizeThatFits
(
CGSize
(
width
:
.
greatestFiniteMagnitude
,
height
:
scrollView
.
height
))
.
width
v
.
height
=
scrollView
.
height
v
.
width
=
x
+
q
v
.
x
=
w
...
...
@@ -296,7 +301,7 @@ fileprivate extension ChipBar {
scrollView
.
grid
.
contentEdgeInsets
=
chipItemsContentEdgeInsets
scrollView
.
grid
.
interimSpace
=
chipItemsInterimSpace
scrollView
.
grid
.
commit
()
scrollView
.
contentSize
=
scrollView
.
bounds
.
size
scrollView
.
contentSize
=
scrollView
.
frame
.
size
}
}
}
...
...
@@ -346,12 +351,11 @@ fileprivate extension ChipBar {
delegate
?
.
chipBar
?(
chipBar
:
self
,
willSelect
:
chipItem
)
}
selected
=
chipItem
isAnimating
=
true
if
!
scrollView
.
bounds
.
contains
(
chipItem
.
frame
)
{
let
contentOffsetX
=
(
chipItem
.
x
<
scrollView
.
bounds
.
minX
)
?
chipItem
.
x
:
chipItem
.
frame
.
maxX
-
scrollView
.
bounds
.
width
let
normalizedOffsetX
=
min
(
max
(
contentOffsetX
,
0
),
scrollView
.
contentSize
.
width
-
scrollView
.
bounds
.
width
)
if
!
scrollView
.
frame
.
contains
(
chipItem
.
frame
)
{
let
contentOffsetX
=
(
chipItem
.
x
<
scrollView
.
frame
.
minX
)
?
chipItem
.
x
:
chipItem
.
frame
.
maxX
-
scrollView
.
width
let
normalizedOffsetX
=
min
(
max
(
contentOffsetX
,
0
),
scrollView
.
contentSize
.
width
-
scrollView
.
width
)
scrollView
.
setContentOffset
(
CGPoint
(
x
:
normalizedOffsetX
,
y
:
0
),
animated
:
true
)
}
}
...
...
Sources/iOS/TabBar.swift
View file @
ffd475b2
...
...
@@ -78,11 +78,17 @@ open class TabBar: Bar {
/// The total width of the tabItems.
fileprivate
var
tabItemsTotalWidth
:
CGFloat
{
var
w
:
CGFloat
=
0
let
q
=
2
*
tabItemsInterimSpace
let
p
=
q
+
tabItemsInterimSpace
for
v
in
tabItems
{
w
+=
v
.
sizeThatFits
(
CGSize
(
width
:
CGFloat
.
greatestFiniteMagnitude
,
height
:
contentView
.
height
))
.
width
+
interimSpace
let
x
=
v
.
sizeThatFits
(
CGSize
(
width
:
.
greatestFiniteMagnitude
,
height
:
scrollView
.
height
))
.
width
w
+=
x
w
+=
p
}
w
-=
tabItemsInterimSpace
return
w
}
...
...
@@ -237,7 +243,6 @@ fileprivate extension TabBar {
func
prepareTabItems
()
{
for
v
in
tabItems
{
v
.
grid
.
columns
=
0
v
.
cornerRadius
=
0
v
.
contentEdgeInsets
=
.
zero
prepareLineAnimationHandler
(
tabItem
:
v
)
...
...
@@ -273,13 +278,15 @@ fileprivate extension TabBar {
fileprivate
extension
TabBar
{
/// Layout the scrollView.
func
layoutScrollView
()
{
if
.
scrollable
==
tabBarStyle
||
(
.
auto
==
tabBarStyle
&&
tabItemsTotalWidth
>
bounds
.
width
)
{
contentView
.
grid
.
reload
()
if
.
scrollable
==
tabBarStyle
||
(
.
auto
==
tabBarStyle
&&
tabItemsTotalWidth
>
scrollView
.
width
)
{
var
w
:
CGFloat
=
0
let
q
=
2
*
tabItemsInterimSpace
let
p
=
q
+
tabItemsInterimSpace
for
v
in
tabItems
{
let
x
=
v
.
sizeThatFits
(
CGSize
(
width
:
CGFloat
.
greatestFiniteMagnitude
,
height
:
scrollView
.
height
))
.
width
let
x
=
v
.
sizeThatFits
(
CGSize
(
width
:
.
greatestFiniteMagnitude
,
height
:
scrollView
.
height
))
.
width
v
.
height
=
scrollView
.
height
v
.
width
=
x
+
q
v
.
x
=
w
...
...
@@ -303,7 +310,7 @@ fileprivate extension TabBar {
scrollView
.
grid
.
contentEdgeInsets
=
tabItemsContentEdgeInsets
scrollView
.
grid
.
interimSpace
=
tabItemsInterimSpace
scrollView
.
grid
.
commit
()
scrollView
.
contentSize
=
scrollView
.
bounds
.
size
scrollView
.
contentSize
=
scrollView
.
frame
.
size
}
}
...
...
@@ -313,7 +320,9 @@ fileprivate extension TabBar {
return
}
line
.
frame
=
CGRect
(
x
:
v
.
x
,
y
:
.
bottom
==
lineAlignment
?
height
-
lineHeight
:
0
,
width
:
v
.
width
,
height
:
lineHeight
)
line
.
animate
(
.
duration
(
0
),
.
size
(
CGSize
(
width
:
v
.
width
,
height
:
lineHeight
)),
.
position
(
CGPoint
(
x
:
v
.
center
.
x
,
y
:
.
bottom
==
lineAlignment
?
height
-
lineHeight
/
2
:
lineHeight
/
2
)))
}
}
...
...
@@ -392,9 +401,9 @@ fileprivate extension TabBar {
completion
?(
tabItem
)
})
if
!
scrollView
.
bounds
.
contains
(
tabItem
.
frame
)
{
let
contentOffsetX
=
(
tabItem
.
x
<
scrollView
.
bounds
.
minX
)
?
tabItem
.
x
:
tabItem
.
frame
.
maxX
-
scrollView
.
bounds
.
width
let
normalizedOffsetX
=
min
(
max
(
contentOffsetX
,
0
),
scrollView
.
contentSize
.
width
-
scrollView
.
bounds
.
width
)
if
!
scrollView
.
frame
.
contains
(
tabItem
.
frame
)
{
let
contentOffsetX
=
(
tabItem
.
x
<
scrollView
.
frame
.
minX
)
?
tabItem
.
x
:
tabItem
.
frame
.
maxX
-
scrollView
.
width
let
normalizedOffsetX
=
min
(
max
(
contentOffsetX
,
0
),
scrollView
.
contentSize
.
width
-
scrollView
.
width
)
scrollView
.
setContentOffset
(
CGPoint
(
x
:
normalizedOffsetX
,
y
:
0
),
animated
:
true
)
}
}
...
...
Sources/iOS/TabBarController.swift
View file @
ffd475b2
...
...
@@ -161,6 +161,7 @@ open class TabBarController: UIViewController {
open
func
prepare
()
{
view
.
backgroundColor
=
.
white
view
.
contentScaleFactor
=
Screen
.
scale
prepareTabBar
()
prepareTabBarItems
()
prepareContainer
()
...
...
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