mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Rename all the scrollable classes
Block -> BlockBody ScrollableBlock -> Block FixedHeightScrollable -> ScrollableWidgetList VariableHeightScrollable -> ScrollableMixedWidgetList BlockViewport -> MixedViewport
This commit is contained in:
parent
ed3ea8cf31
commit
c354abc7e0
@ -54,7 +54,7 @@ class AddressBookApp extends App {
|
||||
showDialog(navigator, (navigator) {
|
||||
return new Dialog(
|
||||
title: new Text("Describe your picture"),
|
||||
content: new ScrollableBlock([
|
||||
content: new Block([
|
||||
new Field(inputKey: fillKey, icon: "editor/format_color_fill", placeholder: "Color"),
|
||||
new Field(inputKey: emoticonKey, icon: "editor/insert_emoticon", placeholder: "Emotion"),
|
||||
]),
|
||||
@ -88,7 +88,7 @@ class AddressBookApp extends App {
|
||||
|
||||
Widget buildBody(Navigator navigator) {
|
||||
return new Material(
|
||||
child: new ScrollableBlock([
|
||||
child: new Block([
|
||||
new AspectRatio(
|
||||
aspectRatio: 16.0 / 9.0,
|
||||
child: new Container(
|
||||
|
||||
@ -324,7 +324,7 @@ class AddItemDialog extends StatefulComponent {
|
||||
}
|
||||
return new Dialog(
|
||||
title: new Text("What are you doing?"),
|
||||
content: new ScrollableBlock(menuItems),
|
||||
content: new Block(menuItems),
|
||||
onDismiss: navigator.pop,
|
||||
actions: [
|
||||
new FlatButton(
|
||||
|
||||
@ -92,7 +92,7 @@ class MealFragment extends StatefulComponent {
|
||||
child: new ScrollableViewport(
|
||||
child: new Container(
|
||||
padding: const EdgeDims.all(20.0),
|
||||
child: new Block([
|
||||
child: new BlockBody([
|
||||
new Text(meal.displayDate),
|
||||
new Input(
|
||||
key: descriptionKey,
|
||||
|
||||
@ -114,7 +114,7 @@ class MeasurementFragment extends StatefulComponent {
|
||||
child: new ScrollableViewport(
|
||||
child: new Container(
|
||||
padding: const EdgeDims.all(20.0),
|
||||
child: new Block([
|
||||
child: new BlockBody([
|
||||
new Text(measurement.displayDate),
|
||||
new Input(
|
||||
key: weightKey,
|
||||
|
||||
@ -109,7 +109,7 @@ class SettingsFragment extends StatefulComponent {
|
||||
child: new ScrollableViewport(
|
||||
child: new Container(
|
||||
padding: const EdgeDims.symmetric(vertical: 20.0),
|
||||
child: new Block([
|
||||
child: new BlockBody([
|
||||
new DrawerItem(
|
||||
onPressed: () { _handleBackupChanged(!(userData.backupMode == BackupMode.enabled)); },
|
||||
children: [
|
||||
|
||||
@ -98,7 +98,7 @@ class StockSettings extends StatefulComponent {
|
||||
child: new ScrollableViewport(
|
||||
child: new Container(
|
||||
padding: const EdgeDims.symmetric(vertical: 20.0),
|
||||
child: new Block([
|
||||
child: new BlockBody([
|
||||
new DrawerItem(
|
||||
icon: 'action/thumb_up',
|
||||
onPressed: () => _confirmOptimismChange(),
|
||||
|
||||
@ -24,7 +24,7 @@ class CardCollectionApp extends App {
|
||||
final TextStyle backgroundTextStyle =
|
||||
typography.white.title.copyWith(textAlign: TextAlign.center);
|
||||
|
||||
BlockViewportLayoutState layoutState = new BlockViewportLayoutState();
|
||||
MixedViewportLayoutState layoutState = new MixedViewportLayoutState();
|
||||
List<CardModel> cardModels;
|
||||
|
||||
void initState() {
|
||||
@ -102,7 +102,7 @@ class CardCollectionApp extends App {
|
||||
Widget cardCollection = new Container(
|
||||
padding: const EdgeDims.symmetric(vertical: 12.0, horizontal: 8.0),
|
||||
decoration: new BoxDecoration(backgroundColor: Theme.of(this).primarySwatch[50]),
|
||||
child: new VariableHeightScrollable(
|
||||
child: new ScrollableMixedWidgetList(
|
||||
builder: builder,
|
||||
token: cardModels.length,
|
||||
layoutState: layoutState
|
||||
|
||||
@ -24,7 +24,7 @@ class EnsureVisibleApp extends App {
|
||||
const TextStyle(color: colors.white, fontSize: 24.0, fontWeight: bold);
|
||||
|
||||
List<CardModel> cardModels;
|
||||
BlockViewportLayoutState layoutState = new BlockViewportLayoutState();
|
||||
MixedViewportLayoutState layoutState = new MixedViewportLayoutState();
|
||||
CardModel selectedCardModel;
|
||||
|
||||
void initState() {
|
||||
@ -74,7 +74,7 @@ class EnsureVisibleApp extends App {
|
||||
Widget cardCollection = new Container(
|
||||
padding: const EdgeDims.symmetric(vertical: 12.0, horizontal: 8.0),
|
||||
decoration: new BoxDecoration(backgroundColor: Theme.of(this).primarySwatch[50]),
|
||||
child: new VariableHeightScrollable(
|
||||
child: new ScrollableMixedWidgetList(
|
||||
builder: builder,
|
||||
token: cardModels.length,
|
||||
layoutState: layoutState
|
||||
|
||||
@ -42,7 +42,7 @@ class HorizontalScrollingApp extends App {
|
||||
child: new Container(
|
||||
height: 50.0,
|
||||
child: new Flex([
|
||||
new ScrollableBlock(circles, scrollDirection: ScrollDirection.horizontal)
|
||||
new Block(circles, scrollDirection: ScrollDirection.horizontal)
|
||||
], justifyContent: FlexJustifyContent.end)
|
||||
)
|
||||
);
|
||||
|
||||
@ -6,9 +6,9 @@ import 'dart:math' as math;
|
||||
|
||||
import 'package:sky/widgets.dart';
|
||||
|
||||
class BlockViewportApp extends App {
|
||||
class MixedViewportApp extends App {
|
||||
|
||||
BlockViewportLayoutState layoutState = new BlockViewportLayoutState();
|
||||
MixedViewportLayoutState layoutState = new MixedViewportLayoutState();
|
||||
List<double> lengths = <double>[];
|
||||
double offset = 0.0;
|
||||
|
||||
@ -87,7 +87,7 @@ class BlockViewportApp extends App {
|
||||
border: new Border.all(color: new Color(0xFF000000))
|
||||
),
|
||||
padding: new EdgeDims.all(16.0),
|
||||
child: new BlockViewport(
|
||||
child: new MixedViewport(
|
||||
builder: builder,
|
||||
startOffset: offset,
|
||||
token: lengths.length,
|
||||
@ -124,7 +124,7 @@ class BlockViewportApp extends App {
|
||||
}
|
||||
|
||||
void main() {
|
||||
runApp(new BlockViewportApp());
|
||||
runApp(new MixedViewportApp());
|
||||
// scheduler.addPersistentFrameCallback((_) {
|
||||
// SkyBinding.instance.debugDumpRenderTree();
|
||||
// });
|
||||
@ -71,7 +71,7 @@ class OverlayGeometryApp extends App {
|
||||
const TextStyle(color: colors.white, fontSize: 18.0, fontWeight: bold);
|
||||
|
||||
List<CardModel> cardModels;
|
||||
BlockViewportLayoutState layoutState = new BlockViewportLayoutState();
|
||||
MixedViewportLayoutState layoutState = new MixedViewportLayoutState();
|
||||
Map<MarkerType, Point> markers = new Map<MarkerType, Point>();
|
||||
double markersScrollOffset;
|
||||
ScrollListener scrollListener;
|
||||
@ -138,7 +138,7 @@ class OverlayGeometryApp extends App {
|
||||
}
|
||||
|
||||
Widget build() {
|
||||
Scrollable scrollable = new VariableHeightScrollable(
|
||||
Scrollable scrollable = new ScrollableMixedWidgetList(
|
||||
builder: builder,
|
||||
token: cardModels.length,
|
||||
layoutState: layoutState
|
||||
|
||||
@ -91,7 +91,7 @@ class ExampleApp extends App {
|
||||
body: new MimicOverlay(
|
||||
overlay: _overlay,
|
||||
duration: const Duration(milliseconds: 500),
|
||||
children: [ new ScrollableBlock(cards) ]
|
||||
children: [ new Block(cards) ]
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@ -7,7 +7,6 @@
|
||||
export 'widgets/animated_component.dart';
|
||||
export 'widgets/animated_container.dart';
|
||||
export 'widgets/basic.dart';
|
||||
export 'widgets/block_viewport.dart';
|
||||
export 'widgets/button_base.dart';
|
||||
export 'widgets/card.dart';
|
||||
export 'widgets/checkbox.dart';
|
||||
@ -30,6 +29,7 @@ export 'widgets/material.dart';
|
||||
export 'widgets/material_button.dart';
|
||||
export 'widgets/mimic.dart';
|
||||
export 'widgets/mimic_overlay.dart';
|
||||
export 'widgets/mixed_viewport.dart';
|
||||
export 'widgets/modal_overlay.dart';
|
||||
export 'widgets/navigator.dart';
|
||||
export 'widgets/popup_menu.dart';
|
||||
|
||||
@ -407,8 +407,8 @@ class Container extends Component {
|
||||
|
||||
// LAYOUT NODES
|
||||
|
||||
class Block extends MultiChildRenderObjectWrapper {
|
||||
Block(List<Widget> children, {
|
||||
class BlockBody extends MultiChildRenderObjectWrapper {
|
||||
BlockBody(List<Widget> children, {
|
||||
Key key,
|
||||
this.direction: BlockDirection.vertical
|
||||
}) : super(key: key, children: children);
|
||||
|
||||
@ -99,7 +99,7 @@ class Dialog extends Component {
|
||||
level: 4,
|
||||
color: _color,
|
||||
child: new ShrinkWrapWidth(
|
||||
child: new ScrollableBlock(dialogBody)
|
||||
child: new Block(dialogBody)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@ -105,7 +105,7 @@ class Drawer extends StatefulComponent {
|
||||
backgroundColor: Theme.of(this).canvasColor,
|
||||
boxShadow: shadows[level]),
|
||||
width: _kWidth,
|
||||
child: new ScrollableBlock(children)
|
||||
child: new Block(children)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@ -24,8 +24,8 @@ class _Key {
|
||||
|
||||
typedef void LayoutChangedCallback();
|
||||
|
||||
class BlockViewportLayoutState {
|
||||
BlockViewportLayoutState()
|
||||
class MixedViewportLayoutState {
|
||||
MixedViewportLayoutState()
|
||||
: _childOffsets = <double>[0.0],
|
||||
_firstVisibleChildIndex = 0,
|
||||
_visibleChildCount = 0,
|
||||
@ -77,8 +77,8 @@ class BlockViewportLayoutState {
|
||||
}
|
||||
}
|
||||
|
||||
class BlockViewport extends RenderObjectWrapper {
|
||||
BlockViewport({ this.builder, this.startOffset, this.token, this.layoutState, Key key })
|
||||
class MixedViewport extends RenderObjectWrapper {
|
||||
MixedViewport({ this.builder, this.startOffset, this.token, this.layoutState, Key key })
|
||||
: super(key: key) {
|
||||
assert(this.layoutState != null);
|
||||
}
|
||||
@ -86,7 +86,7 @@ class BlockViewport extends RenderObjectWrapper {
|
||||
IndexedBuilder builder;
|
||||
double startOffset;
|
||||
Object token;
|
||||
BlockViewportLayoutState layoutState;
|
||||
MixedViewportLayoutState layoutState;
|
||||
|
||||
RenderBlockViewport get renderObject => super.renderObject;
|
||||
RenderBlockViewport createNode() => new RenderBlockViewport();
|
||||
@ -144,7 +144,7 @@ class BlockViewport extends RenderObjectWrapper {
|
||||
return right;
|
||||
}
|
||||
|
||||
bool retainStatefulNodeIfPossible(BlockViewport newNode) {
|
||||
bool retainStatefulNodeIfPossible(MixedViewport newNode) {
|
||||
assert(layoutState == newNode.layoutState);
|
||||
retainStatefulRenderObjectWrapper(newNode);
|
||||
if (startOffset != newNode.startOffset) {
|
||||
@ -162,7 +162,7 @@ class BlockViewport extends RenderObjectWrapper {
|
||||
return true;
|
||||
}
|
||||
|
||||
void syncRenderObject(BlockViewport old) {
|
||||
void syncRenderObject(MixedViewport old) {
|
||||
super.syncRenderObject(old);
|
||||
if (layoutState._dirty || !layoutState.isValid) {
|
||||
renderObject.markNeedsLayout();
|
||||
@ -142,7 +142,7 @@ class PopupMenu extends StatefulComponent {
|
||||
horizontal: _kMenuHorizontalPadding,
|
||||
vertical: _kMenuVerticalPadding
|
||||
),
|
||||
child: new Block(children)
|
||||
child: new BlockBody(children)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@ -16,11 +16,11 @@ import 'package:sky/rendering/box.dart';
|
||||
import 'package:sky/rendering/viewport.dart';
|
||||
import 'package:sky/theme/view_configuration.dart' as config;
|
||||
import 'package:sky/widgets/basic.dart';
|
||||
import 'package:sky/widgets/block_viewport.dart';
|
||||
import 'package:sky/widgets/scrollable.dart';
|
||||
import 'package:sky/widgets/framework.dart';
|
||||
import 'package:sky/widgets/mixed_viewport.dart';
|
||||
import 'package:sky/widgets/scrollable.dart';
|
||||
|
||||
export 'package:sky/widgets/block_viewport.dart' show BlockViewportLayoutState;
|
||||
export 'package:sky/widgets/mixed_viewport.dart' show MixedViewportLayoutState;
|
||||
|
||||
|
||||
// The GestureEvent velocity properties are pixels/second, config min,max limits are pixels/ms
|
||||
@ -314,11 +314,11 @@ class ScrollableViewport extends Scrollable {
|
||||
}
|
||||
}
|
||||
|
||||
/// A mashup of [ScrollableViewport] and [Block]. Useful when you have a small,
|
||||
/// A mashup of [ScrollableViewport] and [BlockBody]. Useful when you have a small,
|
||||
/// fixed number of children that you wish to arrange in a block layout and that
|
||||
/// might exceed the height of its container (and therefore need to scroll).
|
||||
class ScrollableBlock extends Component {
|
||||
ScrollableBlock(this.children, {
|
||||
class Block extends Component {
|
||||
Block(this.children, {
|
||||
Key key,
|
||||
this.scrollDirection: ScrollDirection.vertical
|
||||
}) : super(key: key);
|
||||
@ -335,7 +335,7 @@ class ScrollableBlock extends Component {
|
||||
Widget build() {
|
||||
return new ScrollableViewport(
|
||||
scrollDirection: scrollDirection,
|
||||
child: new Block(children, direction: _direction)
|
||||
child: new BlockBody(children, direction: _direction)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -345,9 +345,9 @@ class ScrollableBlock extends Component {
|
||||
/// ScrollDirection.vertical itemExtent is the height of each item. Use this
|
||||
/// widget when you have a large number of children or when you are concerned
|
||||
// about offscreen widgets consuming resources.
|
||||
abstract class FixedHeightScrollable extends Scrollable {
|
||||
abstract class ScrollableWidgetList extends Scrollable {
|
||||
|
||||
FixedHeightScrollable({
|
||||
ScrollableWidgetList({
|
||||
Key key,
|
||||
ScrollDirection scrollDirection: ScrollDirection.vertical,
|
||||
this.itemExtent,
|
||||
@ -360,12 +360,12 @@ abstract class FixedHeightScrollable extends Scrollable {
|
||||
double itemExtent;
|
||||
Size containerSize = Size.zero;
|
||||
|
||||
/// Subclasses must implement `get itemCount` to tell FixedHeightScrollable
|
||||
/// Subclasses must implement `get itemCount` to tell ScrollableWidgetList
|
||||
/// how many items there are in the list.
|
||||
int get itemCount;
|
||||
int _previousItemCount;
|
||||
|
||||
void syncFields(FixedHeightScrollable source) {
|
||||
void syncFields(ScrollableWidgetList source) {
|
||||
bool scrollBehaviorUpdateNeeded =
|
||||
padding != source.padding ||
|
||||
itemExtent != source.itemExtent ||
|
||||
@ -478,7 +478,7 @@ abstract class FixedHeightScrollable extends Scrollable {
|
||||
: BlockDirection.horizontal;
|
||||
|
||||
// TODO(ianh): Refactor this so that it does the building in the
|
||||
// same frame as the size observing, similar to BlockViewport, but
|
||||
// same frame as the size observing, similar to MixedViewport, but
|
||||
// keeping the fixed-height optimisations.
|
||||
return new SizeObserver(
|
||||
callback: _handleSizeChanged,
|
||||
@ -487,7 +487,7 @@ abstract class FixedHeightScrollable extends Scrollable {
|
||||
scrollOffset: viewportOffset,
|
||||
child: new Container(
|
||||
padding: _crossAxisPadding,
|
||||
child: new Block(items, direction: blockDirection)
|
||||
child: new BlockBody(items, direction: blockDirection)
|
||||
)
|
||||
)
|
||||
);
|
||||
@ -499,10 +499,10 @@ abstract class FixedHeightScrollable extends Scrollable {
|
||||
|
||||
typedef Widget ItemBuilder<T>(T item);
|
||||
|
||||
/// A wrapper around [FixedHeightScrollable] that helps you translate a list of
|
||||
/// A wrapper around [ScrollableWidgetList] that helps you translate a list of
|
||||
/// model objects into a scrollable list of widgets. Assumes all the widgets
|
||||
/// have the same height.
|
||||
class ScrollableList<T> extends FixedHeightScrollable {
|
||||
class ScrollableList<T> extends ScrollableWidgetList {
|
||||
ScrollableList({
|
||||
Key key,
|
||||
ScrollDirection scrollDirection: ScrollDirection.vertical,
|
||||
@ -588,11 +588,11 @@ class PageableList<T> extends ScrollableList<T> {
|
||||
}
|
||||
|
||||
/// A general scrollable list for a large number of children that might not all
|
||||
/// have the same height. Prefer [FixedHeightScrollable] when all the children
|
||||
/// have the same height. Prefer [ScrollableWidgetList] when all the children
|
||||
/// have the same height because it can use that property to be more efficient.
|
||||
/// Prefer [ScrollableViewport] with a single child.
|
||||
class VariableHeightScrollable extends Scrollable {
|
||||
VariableHeightScrollable({
|
||||
class ScrollableMixedWidgetList extends Scrollable {
|
||||
ScrollableMixedWidgetList({
|
||||
Key key,
|
||||
this.builder,
|
||||
this.token,
|
||||
@ -601,7 +601,7 @@ class VariableHeightScrollable extends Scrollable {
|
||||
|
||||
IndexedBuilder builder;
|
||||
Object token;
|
||||
BlockViewportLayoutState layoutState;
|
||||
MixedViewportLayoutState layoutState;
|
||||
|
||||
// When the token changes the scrollable's contents may have
|
||||
// changed. Remember as much so that after the new contents
|
||||
@ -624,7 +624,7 @@ class VariableHeightScrollable extends Scrollable {
|
||||
super.didUnmount();
|
||||
}
|
||||
|
||||
void syncFields(VariableHeightScrollable source) {
|
||||
void syncFields(ScrollableMixedWidgetList source) {
|
||||
builder = source.builder;
|
||||
if (token != source.token)
|
||||
_contentsChanged = true;
|
||||
@ -661,7 +661,7 @@ class VariableHeightScrollable extends Scrollable {
|
||||
Widget buildContent() {
|
||||
return new SizeObserver(
|
||||
callback: _handleSizeChanged,
|
||||
child: new BlockViewport(
|
||||
child: new MixedViewport(
|
||||
builder: builder,
|
||||
layoutState: layoutState,
|
||||
startOffset: scrollOffset,
|
||||
|
||||
@ -59,14 +59,6 @@ Layout models
|
||||
`right` and `left` properties to non-null values will force the child to
|
||||
have a particular width.
|
||||
|
||||
- `Block` Layout a list of child widgets in a vertical line. Each child's width
|
||||
is set to the widget of the block, and each child is positioned directly
|
||||
below the previous child. The block's height is set to the total height of
|
||||
all of its children. A block can be used only in locations that offer an
|
||||
unbounded amount of vertical space (e.g., inside a `Viewport`). Rather than
|
||||
using `Block` directly, most client should use `ScrollableBlock`, which
|
||||
combines `Block` with `Viewport` and scrolling physics.
|
||||
|
||||
Positioning and sizing
|
||||
----------------------
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user