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
6dfc14d5
Commit
6dfc14d5
authored
Aug 09, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated scrolling behaviour for TabBar when rotating
parent
ffd475b2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
11 deletions
+41
-11
Sources/Info.plist
+1
-1
Sources/iOS/ChipBar.swift
+24
-7
Sources/iOS/TabBar.swift
+16
-3
No files found.
Sources/Info.plist
View file @
6dfc14d5
...
@@ -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.9.
0
<
/string
>
<
string
>
2.9.
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/ChipBar.swift
View file @
6dfc14d5
...
@@ -51,6 +51,11 @@ open class ChipItem: FlatButton {
...
@@ -51,6 +51,11 @@ open class ChipItem: FlatButton {
super
.
layoutSubviews
()
super
.
layoutSubviews
()
layoutChipItemStyle
()
layoutChipItemStyle
()
}
}
open
override
func
prepare
()
{
super
.
prepare
()
pulseAnimation
=
.
none
}
}
}
fileprivate
extension
ChipItem
{
fileprivate
extension
ChipItem
{
...
@@ -113,9 +118,6 @@ public enum ChipBarStyle: Int {
...
@@ -113,9 +118,6 @@ public enum ChipBarStyle: Int {
}
}
open
class
ChipBar
:
Bar
{
open
class
ChipBar
:
Bar
{
/// A boolean indicating if the ChipBar is in an animation state.
open
fileprivate
(
set
)
var
isAnimating
=
false
/// The total width of the chipItems.
/// The total width of the chipItems.
fileprivate
var
chipItemsTotalWidth
:
CGFloat
{
fileprivate
var
chipItemsTotalWidth
:
CGFloat
{
var
w
:
CGFloat
=
0
var
w
:
CGFloat
=
0
...
@@ -156,6 +158,9 @@ open class ChipBar: Bar {
...
@@ -156,6 +158,9 @@ open class ChipBar: Bar {
/// A delegation reference.
/// A delegation reference.
open
weak
var
delegate
:
ChipBarDelegate
?
open
weak
var
delegate
:
ChipBarDelegate
?
/// The currently selected chipItem.
open
fileprivate
(
set
)
var
selectedChipItem
:
ChipItem
?
/// A preset wrapper around chipItems contentEdgeInsets.
/// A preset wrapper around chipItems contentEdgeInsets.
open
var
chipItemsContentEdgeInsetsPreset
:
EdgeInsetsPreset
{
open
var
chipItemsContentEdgeInsetsPreset
:
EdgeInsetsPreset
{
get
{
get
{
...
@@ -217,6 +222,8 @@ open class ChipBar: Bar {
...
@@ -217,6 +222,8 @@ open class ChipBar: Bar {
}
}
layoutScrollView
()
layoutScrollView
()
updateScrollView
()
}
}
open
override
func
prepare
()
{
open
override
func
prepare
()
{
...
@@ -351,11 +358,21 @@ fileprivate extension ChipBar {
...
@@ -351,11 +358,21 @@ fileprivate extension ChipBar {
delegate
?
.
chipBar
?(
chipBar
:
self
,
willSelect
:
chipItem
)
delegate
?
.
chipBar
?(
chipBar
:
self
,
willSelect
:
chipItem
)
}
}
isAnimating
=
true
selectedChipItem
=
chipItem
updateScrollView
()
}
}
fileprivate
extension
ChipBar
{
/// Updates the scrollView.
func
updateScrollView
()
{
guard
let
v
=
selectedChipItem
else
{
return
}
if
!
scrollView
.
frame
.
contains
(
chipItem
.
frame
)
{
if
!
scrollView
.
bounds
.
contains
(
v
.
frame
)
{
let
contentOffsetX
=
(
chipItem
.
x
<
scrollView
.
frame
.
minX
)
?
chipItem
.
x
:
chipItem
.
frame
.
maxX
-
scrollView
.
width
let
contentOffsetX
=
(
v
.
x
<
scrollView
.
bounds
.
minX
)
?
v
.
x
:
v
.
frame
.
maxX
-
scrollView
.
bounds
.
width
let
normalizedOffsetX
=
min
(
max
(
contentOffsetX
,
0
),
scrollView
.
contentSize
.
width
-
scrollView
.
width
)
let
normalizedOffsetX
=
min
(
max
(
contentOffsetX
,
0
),
scrollView
.
contentSize
.
width
-
scrollView
.
bounds
.
width
)
scrollView
.
setContentOffset
(
CGPoint
(
x
:
normalizedOffsetX
,
y
:
0
),
animated
:
true
)
scrollView
.
setContentOffset
(
CGPoint
(
x
:
normalizedOffsetX
,
y
:
0
),
animated
:
true
)
}
}
}
}
...
...
Sources/iOS/TabBar.swift
View file @
6dfc14d5
...
@@ -210,6 +210,8 @@ open class TabBar: Bar {
...
@@ -210,6 +210,8 @@ open class TabBar: Bar {
layoutScrollView
()
layoutScrollView
()
layoutLine
()
layoutLine
()
updateScrollView
()
}
}
open
override
func
prepare
()
{
open
override
func
prepare
()
{
...
@@ -401,9 +403,20 @@ fileprivate extension TabBar {
...
@@ -401,9 +403,20 @@ fileprivate extension TabBar {
completion
?(
tabItem
)
completion
?(
tabItem
)
})
})
if
!
scrollView
.
frame
.
contains
(
tabItem
.
frame
)
{
updateScrollView
()
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
)
}
fileprivate
extension
TabBar
{
/// Updates the scrollView.
func
updateScrollView
()
{
guard
let
v
=
selectedTabItem
else
{
return
}
if
!
scrollView
.
bounds
.
contains
(
v
.
frame
)
{
let
contentOffsetX
=
(
v
.
x
<
scrollView
.
bounds
.
minX
)
?
v
.
x
:
v
.
frame
.
maxX
-
scrollView
.
bounds
.
width
let
normalizedOffsetX
=
min
(
max
(
contentOffsetX
,
0
),
scrollView
.
contentSize
.
width
-
scrollView
.
bounds
.
width
)
scrollView
.
setContentOffset
(
CGPoint
(
x
:
normalizedOffsetX
,
y
:
0
),
animated
:
true
)
scrollView
.
setContentOffset
(
CGPoint
(
x
:
normalizedOffsetX
,
y
:
0
),
animated
:
true
)
}
}
}
}
...
...
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