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
610a1db9
Commit
610a1db9
authored
Jul 29, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
issue-815: fixed alignment issues on rotation
parent
74b26971
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
82 additions
and
75 deletions
+82
-75
Sources/Info.plist
+1
-1
Sources/iOS/Bar.swift
+0
-4
Sources/iOS/SearchBar.swift
+2
-2
Sources/iOS/Snackbar.swift
+2
-2
Sources/iOS/TabBar.swift
+57
-41
Sources/iOS/TabsController.swift
+18
-23
Sources/iOS/Toolbar.swift
+2
-2
No files found.
Sources/Info.plist
View file @
610a1db9
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
<
k
e
y
>
CFBundlePackageType
<
/k
e
y
>
<
k
e
y
>
CFBundlePackageType
<
/k
e
y
>
<
string
>
FMWK
<
/string
>
<
string
>
FMWK
<
/string
>
<
k
e
y
>
CFBundleShortVersionString
<
/k
e
y
>
<
k
e
y
>
CFBundleShortVersionString
<
/k
e
y
>
<
string
>
2.8.
0
<
/string
>
<
string
>
2.8.
1
<
/string
>
<
k
e
y
>
CFBundleSignature
<
/k
e
y
>
<
k
e
y
>
CFBundleSignature
<
/k
e
y
>
<
string
>
????
<
/string
>
<
string
>
????
<
/string
>
<
k
e
y
>
CFBundleVersion
<
/k
e
y
>
<
k
e
y
>
CFBundleVersion
<
/k
e
y
>
...
...
Sources/iOS/Bar.swift
View file @
610a1db9
...
@@ -179,10 +179,6 @@ open class Bar: View {
...
@@ -179,10 +179,6 @@ open class Bar: View {
open
override
func
layoutSubviews
()
{
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
super
.
layoutSubviews
()
layoutBarSubviews
()
}
open
func
layoutBarSubviews
()
{
guard
willLayout
else
{
guard
willLayout
else
{
return
return
}
}
...
...
Sources/iOS/SearchBar.swift
View file @
610a1db9
...
@@ -142,8 +142,8 @@ open class SearchBar: Bar {
...
@@ -142,8 +142,8 @@ open class SearchBar: Bar {
super
.
init
(
frame
:
frame
)
super
.
init
(
frame
:
frame
)
}
}
open
override
func
layout
Bar
Subviews
()
{
open
override
func
layoutSubviews
()
{
super
.
layout
Bar
Subviews
()
super
.
layoutSubviews
()
guard
willLayout
else
{
guard
willLayout
else
{
return
return
}
}
...
...
Sources/iOS/Snackbar.swift
View file @
610a1db9
...
@@ -81,8 +81,8 @@ open class Snackbar: Bar {
...
@@ -81,8 +81,8 @@ open class Snackbar: Bar {
return
super
.
hitTest
(
point
,
with
:
event
)
return
super
.
hitTest
(
point
,
with
:
event
)
}
}
open
override
func
layout
Bar
Subviews
()
{
open
override
func
layoutSubviews
()
{
super
.
layout
Bar
Subviews
()
super
.
layoutSubviews
()
guard
willLayout
else
{
guard
willLayout
else
{
return
return
}
}
...
...
Sources/iOS/TabBar.swift
View file @
610a1db9
...
@@ -68,6 +68,17 @@ open class TabBar: Bar {
...
@@ -68,6 +68,17 @@ 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
fileprivate
(
set
)
var
isAnimating
=
false
open
fileprivate
(
set
)
var
isAnimating
=
false
/// The total width of the buttons.
fileprivate
var
buttonsTotalWidth
:
CGFloat
{
var
w
:
CGFloat
=
0
for
v
in
buttons
{
w
+=
v
.
sizeThatFits
(
CGSize
(
width
:
CGFloat
.
greatestFiniteMagnitude
,
height
:
contentView
.
height
))
.
width
+
interimSpace
}
return
w
}
/// Enables and disables bouncing when swiping.
/// Enables and disables bouncing when swiping.
open
var
isBounceEnabled
:
Bool
{
open
var
isBounceEnabled
:
Bool
{
get
{
get
{
...
@@ -150,6 +161,7 @@ open class TabBar: Bar {
...
@@ -150,6 +161,7 @@ open class TabBar: Bar {
b
.
removeFromSuperview
()
b
.
removeFromSuperview
()
}
}
prepareButtons
()
layoutSubviews
()
layoutSubviews
()
}
}
}
}
...
@@ -198,7 +210,8 @@ open class TabBar: Bar {
...
@@ -198,7 +210,8 @@ open class TabBar: Bar {
}
}
}
}
open
override
func
layoutBarSubviews
()
{
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
guard
willLayout
else
{
guard
willLayout
else
{
return
return
}
}
...
@@ -273,21 +286,9 @@ open class TabBar: Bar {
...
@@ -273,21 +286,9 @@ open class TabBar: Bar {
}
}
grid
.
axis
.
columns
=
columns
grid
.
axis
.
columns
=
columns
grid
.
commit
()
contentView
.
grid
.
commit
()
layoutDivider
()
var
w
:
CGFloat
=
0
for
v
in
buttons
{
if
.
scrollable
==
tabBarStyle
||
(
.
auto
==
tabBarStyle
&&
buttonsTotalWidth
>
bounds
.
width
)
{
w
+=
v
.
sizeThatFits
(
CGSize
(
width
:
CGFloat
.
greatestFiniteMagnitude
,
height
:
contentView
.
height
))
.
width
+
interimSpace
var
w
:
CGFloat
=
0
}
if
.
scrollable
==
tabBarStyle
||
(
w
>
bounds
.
width
&&
.
auto
==
tabBarStyle
)
{
scrollView
.
frame
=
CGRect
(
x
:
l
,
y
:
0
,
width
:
p
,
height
:
height
)
w
=
0
for
v
in
buttons
{
for
v
in
buttons
{
let
x
=
v
.
sizeThatFits
(
CGSize
(
width
:
CGFloat
.
greatestFiniteMagnitude
,
height
:
contentView
.
height
))
.
width
+
interimSpace
let
x
=
v
.
sizeThatFits
(
CGSize
(
width
:
CGFloat
.
greatestFiniteMagnitude
,
height
:
contentView
.
height
))
.
width
+
interimSpace
scrollView
.
addSubview
(
v
)
scrollView
.
addSubview
(
v
)
...
@@ -298,40 +299,24 @@ open class TabBar: Bar {
...
@@ -298,40 +299,24 @@ open class TabBar: Bar {
}
}
scrollView
.
contentSize
=
CGSize
(
width
:
w
,
height
:
height
)
scrollView
.
contentSize
=
CGSize
(
width
:
w
,
height
:
height
)
scrollView
.
addSubview
(
line
)
}
else
{
}
else
{
contentView
.
grid
.
axis
.
columns
=
buttons
.
count
scrollView
.
grid
.
views
=
buttons
centerViews
=
buttons
scrollView
.
grid
.
axis
.
columns
=
buttons
.
count
addSubview
(
line
)
scrollView
.
contentSize
=
CGSize
(
width
:
scrollView
.
width
,
height
:
height
)
}
}
updateSelectionLine
()
grid
.
commit
()
contentView
.
grid
.
commit
()
layoutDivider
()
layoutLine
()
}
}
private
func
updateSelectionLine
()
{
for
b
in
buttons
{
b
.
grid
.
columns
=
0
b
.
cornerRadius
=
0
b
.
contentEdgeInsets
=
.
zero
if
isLineAnimated
{
prepareLineAnimationHandler
(
button
:
b
)
}
}
scrollView
.
frame
=
contentView
.
bounds
if
nil
==
selected
{
selected
=
buttons
.
first
}
line
.
frame
=
CGRect
(
x
:
selected
!.
x
,
y
:
.
bottom
==
lineAlignment
?
height
-
lineHeight
:
0
,
width
:
selected
!.
width
,
height
:
lineHeight
)
}
open
override
func
prepare
()
{
open
override
func
prepare
()
{
super
.
prepare
()
super
.
prepare
()
contentEdgeInsetsPreset
=
.
none
contentEdgeInsetsPreset
=
.
none
interimSpacePreset
=
.
interimSpace6
interimSpacePreset
=
.
interimSpace6
prepareContentView
()
prepareContentView
()
prepareScrollView
()
prepareScrollView
()
prepareDivider
()
prepareDivider
()
...
@@ -353,6 +338,19 @@ fileprivate extension TabBar {
...
@@ -353,6 +338,19 @@ fileprivate extension TabBar {
dividerAlignment
=
.
top
dividerAlignment
=
.
top
}
}
/// Prepares the buttons.
func
prepareButtons
()
{
for
v
in
buttons
{
v
.
grid
.
columns
=
0
v
.
cornerRadius
=
0
v
.
contentEdgeInsets
=
.
zero
if
isLineAnimated
{
prepareLineAnimationHandler
(
button
:
v
)
}
}
}
/**
/**
Prepares the line animation handlers.
Prepares the line animation handlers.
- Parameter button: A UIButton.
- Parameter button: A UIButton.
...
@@ -372,7 +370,25 @@ fileprivate extension TabBar {
...
@@ -372,7 +370,25 @@ fileprivate extension TabBar {
scrollView
.
isPagingEnabled
=
false
scrollView
.
isPagingEnabled
=
false
scrollView
.
showsVerticalScrollIndicator
=
false
scrollView
.
showsVerticalScrollIndicator
=
false
scrollView
.
showsHorizontalScrollIndicator
=
false
scrollView
.
showsHorizontalScrollIndicator
=
false
contentView
.
addSubview
(
scrollView
)
scrollView
.
addSubview
(
line
)
centerViews
=
[
scrollView
]
}
}
fileprivate
extension
TabBar
{
/// Layout the line view.
func
layoutLine
()
{
guard
0
<
buttons
.
count
else
{
return
}
if
nil
==
selected
{
selected
=
buttons
.
first
}
line
.
animate
(
.
duration
(
0
),
.
size
(
CGSize
(
width
:
selected
!.
width
,
height
:
lineHeight
)),
.
position
(
CGPoint
(
x
:
selected
!.
center
.
x
,
y
:
.
bottom
==
lineAlignment
?
height
-
lineHeight
/
2
:
lineHeight
/
2
)))
}
}
}
}
...
...
Sources/iOS/TabsController.swift
View file @
610a1db9
...
@@ -166,43 +166,35 @@ open class TabsController: UIViewController {
...
@@ -166,43 +166,35 @@ open class TabsController: UIViewController {
view
.
contentScaleFactor
=
Screen
.
scale
view
.
contentScaleFactor
=
Screen
.
scale
prepareContainer
()
prepareContainer
()
prepareTabBar
()
prepareTabBar
()
prepareTabBarButtons
()
prepareViewControllers
()
prepareViewControllers
()
}
}
}
}
fileprivate
extension
TabsController
{
fileprivate
extension
TabsController
{
/**
/// Prepares the container view.
Prepares the tabBar buttons.
func
prepareContainer
()
{
- Parameter _ buttons: An Array of UIButtons.
view
.
addSubview
(
container
)
*/
func
prepareTabBarButtons
(
_
buttons
:
[
UIButton
])
{
tabBar
.
buttons
=
buttons
for
b
in
tabBar
.
buttons
{
b
.
removeTarget
(
self
,
action
:
#selector(
handleTabBarButton(button:)
)
,
for
:
.
touchUpInside
)
b
.
addTarget
(
self
,
action
:
#selector(
handleTabBarButton(button:)
)
,
for
:
.
touchUpInside
)
}
}
}
/// Prepares the TabBar.
/// Prepares the TabBar.
func
prepareTabBar
()
{
func
prepareTabBar
()
{
tabBar
.
lineAlignment
=
.
bottom
==
tabBarAlignment
?
.
top
:
.
bottom
view
.
addSubview
(
tabBar
)
}
/// Prepares the tabBar buttons.
func
prepareTabBarButtons
()
{
var
buttons
=
[
UIButton
]()
var
buttons
=
[
UIButton
]()
for
v
in
viewControllers
{
for
v
in
viewControllers
{
let
button
=
v
.
tabItem
as
UIButton
let
b
=
v
.
tabItem
v
.
isMotionEnabled
=
true
b
.
removeTarget
(
self
,
action
:
#selector(
handleTabBarButton(button:)
)
,
for
:
.
touchUpInside
)
buttons
.
append
(
button
)
b
.
addTarget
(
self
,
action
:
#selector(
handleTabBarButton(button:)
)
,
for
:
.
touchUpInside
)
buttons
.
append
(
b
)
}
}
tabBar
.
lineAlignment
=
.
bottom
==
tabBarAlignment
?
.
top
:
.
bottom
tabBar
.
buttons
=
buttons
view
.
addSubview
(
tabBar
)
prepareTabBarButtons
(
buttons
)
}
/// Prepares the container view.
func
prepareContainer
()
{
view
.
addSubview
(
container
)
}
}
/// Prepares all the view controllers.
/// Prepares all the view controllers.
...
@@ -212,6 +204,7 @@ fileprivate extension TabsController {
...
@@ -212,6 +204,7 @@ fileprivate extension TabsController {
continue
continue
}
}
viewControllers
[
i
]
.
view
.
isHidden
=
true
prepareViewController
(
at
:
i
)
prepareViewController
(
at
:
i
)
}
}
...
@@ -232,6 +225,7 @@ fileprivate extension TabsController {
...
@@ -232,6 +225,7 @@ fileprivate extension TabsController {
addChildViewController
(
vc
)
addChildViewController
(
vc
)
vc
.
didMove
(
toParentViewController
:
self
)
vc
.
didMove
(
toParentViewController
:
self
)
vc
.
isMotionEnabled
=
true
vc
.
view
.
clipsToBounds
=
true
vc
.
view
.
clipsToBounds
=
true
vc
.
view
.
contentScaleFactor
=
Screen
.
scale
vc
.
view
.
contentScaleFactor
=
Screen
.
scale
container
.
addSubview
(
vc
.
view
)
container
.
addSubview
(
vc
.
view
)
...
@@ -328,6 +322,7 @@ fileprivate extension TabsController {
...
@@ -328,6 +322,7 @@ fileprivate extension TabsController {
let
fvc
=
viewControllers
[
selectedIndex
]
let
fvc
=
viewControllers
[
selectedIndex
]
let
tvc
=
viewControllers
[
i
]
let
tvc
=
viewControllers
[
i
]
tvc
.
view
.
isHidden
=
false
tvc
.
view
.
frame
.
size
=
container
.
bounds
.
size
tvc
.
view
.
frame
.
size
=
container
.
bounds
.
size
tvc
.
motionModalTransitionType
=
motionTransitionType
tvc
.
motionModalTransitionType
=
motionTransitionType
...
...
Sources/iOS/Toolbar.swift
View file @
610a1db9
...
@@ -95,8 +95,8 @@ open class Toolbar: Bar {
...
@@ -95,8 +95,8 @@ open class Toolbar: Bar {
contentViewAlignment
=
.
center
==
titleLabel
.
textAlignment
?
.
center
:
.
full
contentViewAlignment
=
.
center
==
titleLabel
.
textAlignment
?
.
center
:
.
full
}
}
open
override
func
layout
Bar
Subviews
()
{
open
override
func
layoutSubviews
()
{
super
.
layout
Bar
Subviews
()
super
.
layoutSubviews
()
guard
willLayout
else
{
guard
willLayout
else
{
return
return
}
}
...
...
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