Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
2a420955
Commit
2a420955
authored
Aug 05, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support horizontal scrolling in ScrollableViewport
parent
5923d03c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
21 deletions
+39
-21
box.dart
packages/flutter/lib/rendering/box.dart
+3
-3
basic.dart
packages/flutter/lib/widgets/basic.dart
+12
-6
scrollable.dart
packages/flutter/lib/widgets/scrollable.dart
+23
-11
tabs.dart
packages/flutter/lib/widgets/tabs.dart
+1
-1
No files found.
packages/flutter/lib/rendering/box.dart
View file @
2a420955
...
...
@@ -1128,10 +1128,10 @@ class RenderViewport extends RenderBox with RenderObjectWithChildMixin<RenderBox
RenderViewport
({
RenderBox
child
,
Offset
scrollOffset
,
ViewportScrollDirection
d
irection:
ViewportScrollDirection
.
vertical
ViewportScrollDirection
scrollD
irection:
ViewportScrollDirection
.
vertical
})
:
_scrollOffset
=
scrollOffset
,
_scrollDirection
=
d
irection
{
assert
(
_offsetIsSane
(
scrollOffset
,
d
irection
));
_scrollDirection
=
scrollD
irection
{
assert
(
_offsetIsSane
(
scrollOffset
,
scrollD
irection
));
this
.
child
=
child
;
}
...
...
packages/flutter/lib/widgets/basic.dart
View file @
2a420955
...
...
@@ -20,7 +20,7 @@ import 'package:sky/widgets/default_text_style.dart';
import
'package:sky/widgets/framework.dart'
;
export
'package:sky/base/hit_test.dart'
show
EventDisposition
,
combineEventDispositions
;
export
'package:sky/rendering/box.dart'
show
BackgroundImage
,
BoxConstraints
,
BoxDecoration
,
Border
,
BorderSide
,
EdgeDims
;
export
'package:sky/rendering/box.dart'
show
BackgroundImage
,
BoxConstraints
,
BoxDecoration
,
Border
,
BorderSide
,
EdgeDims
,
ViewportScrollDirection
;
export
'package:sky/rendering/flex.dart'
show
FlexDirection
,
FlexJustifyContent
,
FlexAlignItems
;
export
'package:sky/rendering/object.dart'
show
Point
,
Offset
,
Size
,
Rect
,
Color
,
Paint
,
Path
;
export
'package:sky/rendering/toggleable.dart'
show
ValueChanged
;
...
...
@@ -268,17 +268,23 @@ class Baseline extends OneChildRenderObjectWrapper {
}
class
Viewport
extends
OneChildRenderObjectWrapper
{
Viewport
({
Key
key
,
this
.
offset
:
0.0
,
Widget
child
})
:
super
(
key:
key
,
child:
child
);
Viewport
({
Key
key
,
this
.
scrollOffset
:
Offset
.
zero
,
this
.
scrollDirection
:
ViewportScrollDirection
.
vertical
,
Widget
child
})
:
super
(
key:
key
,
child:
child
);
final
double
offset
;
final
Offset
scrollOffset
;
final
ViewportScrollDirection
scrollDirection
;
RenderViewport
createNode
()
=>
new
RenderViewport
(
scrollOffset:
new
Offset
(
0.0
,
offset
)
);
RenderViewport
createNode
()
=>
new
RenderViewport
(
scrollOffset:
scrollOffset
,
scrollDirection:
scrollDirection
);
RenderViewport
get
root
=>
super
.
root
;
void
syncRenderObject
(
Viewport
old
)
{
super
.
syncRenderObject
(
old
);
root
.
scrollOffset
=
new
Offset
(
0.0
,
offset
);
root
.
scrollOffset
=
scrollOffset
;
root
.
scrollDirection
=
scrollDirection
;
}
}
...
...
packages/flutter/lib/widgets/scrollable.dart
View file @
2a420955
...
...
@@ -31,18 +31,19 @@ abstract class ScrollClient {
bool
ancestorScrolled
(
Scrollable
ancestor
);
}
enum
ScrollDirection
{
vertical
,
horizontal
}
/// A base class for scrollable widgets that reacts to user input and generates
/// a scrollOffset.
abstract
class
Scrollable
extends
StatefulComponent
{
Scrollable
({
Key
key
,
this
.
direction
:
ScrollDirection
.
vertical
})
:
super
(
key:
key
);
this
.
scrollDirection
:
ViewportScrollDirection
.
vertical
})
:
super
(
key:
key
)
{
assert
(
scrollDirection
==
ViewportScrollDirection
.
vertical
||
scrollDirection
==
ViewportScrollDirection
.
horizontal
);
}
ScrollDirection
d
irection
;
ViewportScrollDirection
scrollD
irection
;
AnimatedSimulation
_toEndAnimation
;
// See _startToEndAnimation()
AnimationPerformance
_toOffsetAnimation
;
// Started by scrollTo(offset, duration: d)
...
...
@@ -57,12 +58,18 @@ abstract class Scrollable extends StatefulComponent {
}
void
syncFields
(
Scrollable
source
)
{
direction
==
source
.
d
irection
;
scrollDirection
==
source
.
scrollD
irection
;
}
double
_scrollOffset
=
0.0
;
double
get
scrollOffset
=>
_scrollOffset
;
Offset
get
scrollOffsetVector
{
if
(
scrollDirection
==
ViewportScrollDirection
.
horizontal
)
return
new
Offset
(
scrollOffset
,
0.0
);
return
new
Offset
(
0.0
,
scrollOffset
);
}
ScrollBehavior
_scrollBehavior
;
ScrollBehavior
createScrollBehavior
();
ScrollBehavior
get
scrollBehavior
{
...
...
@@ -188,12 +195,12 @@ abstract class Scrollable extends StatefulComponent {
}
EventDisposition
_handleScrollUpdate
(
sky
.
GestureEvent
event
)
{
scrollBy
(
direction
==
ScrollDirection
.
horizontal
?
event
.
dx
:
-
event
.
dy
);
scrollBy
(
scrollDirection
==
Viewport
ScrollDirection
.
horizontal
?
event
.
dx
:
-
event
.
dy
);
return
EventDisposition
.
processed
;
}
EventDisposition
_handleFlingStart
(
sky
.
GestureEvent
event
)
{
double
eventVelocity
=
direction
==
ScrollDirection
.
horizontal
double
eventVelocity
=
scrollDirection
==
Viewport
ScrollDirection
.
horizontal
?
-
event
.
velocityX
:
-
event
.
velocityY
;
_startToEndAnimation
(
velocity:
_velocityForFlingGesture
(
eventVelocity
));
...
...
@@ -225,7 +232,11 @@ abstract class Scrollable extends StatefulComponent {
/// A simple scrollable widget that has a single child. Use this component if
/// you are not worried about offscreen widgets consuming resources.
class
ScrollableViewport
extends
Scrollable
{
ScrollableViewport
({
Key
key
,
this
.
child
})
:
super
(
key:
key
);
ScrollableViewport
({
Key
key
,
this
.
child
,
ViewportScrollDirection
scrollDirection:
ViewportScrollDirection
.
vertical
})
:
super
(
key:
key
,
scrollDirection:
scrollDirection
);
Widget
child
;
...
...
@@ -258,7 +269,8 @@ class ScrollableViewport extends Scrollable {
return
new
SizeObserver
(
callback:
_handleViewportSizeChanged
,
child:
new
Viewport
(
offset:
scrollOffset
,
scrollOffset:
scrollOffsetVector
,
scrollDirection:
scrollDirection
,
child:
new
SizeObserver
(
callback:
_handleChildSizeChanged
,
child:
child
...
...
@@ -370,7 +382,7 @@ abstract class FixedHeightScrollable extends Scrollable {
return
new
SizeObserver
(
callback:
_handleSizeChanged
,
child:
new
Viewport
(
offset:
offsetY
,
scrollOffset:
new
Offset
(
0.0
,
offsetY
)
,
child:
new
Container
(
padding:
padding
,
child:
new
Block
(
items
)
...
...
packages/flutter/lib/widgets/tabs.dart
View file @
2a420955
...
...
@@ -396,7 +396,7 @@ class TabBar extends Scrollable {
this
.
selectedIndex
:
0
,
this
.
onChanged
,
this
.
isScrollable
:
false
})
:
super
(
key:
key
,
direction:
ScrollDirection
.
horizontal
);
})
:
super
(
key:
key
,
scrollDirection:
Viewport
ScrollDirection
.
horizontal
);
Iterable
<
TabLabel
>
labels
;
int
selectedIndex
;
...
...
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