Commit b6aec82e authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

AppBar -> PersistentHeader (#7899)

parent 53fc96da
...@@ -45,12 +45,12 @@ export 'src/rendering/rotated_box.dart'; ...@@ -45,12 +45,12 @@ export 'src/rendering/rotated_box.dart';
export 'src/rendering/semantics.dart'; export 'src/rendering/semantics.dart';
export 'src/rendering/shifted_box.dart'; export 'src/rendering/shifted_box.dart';
export 'src/rendering/sliver.dart'; export 'src/rendering/sliver.dart';
export 'src/rendering/sliver_app_bar.dart';
export 'src/rendering/sliver_fixed_extent_list.dart'; export 'src/rendering/sliver_fixed_extent_list.dart';
export 'src/rendering/sliver_grid.dart'; export 'src/rendering/sliver_grid.dart';
export 'src/rendering/sliver_list.dart'; export 'src/rendering/sliver_list.dart';
export 'src/rendering/sliver_multi_box_adaptor.dart'; export 'src/rendering/sliver_multi_box_adaptor.dart';
export 'src/rendering/sliver_padding.dart'; export 'src/rendering/sliver_padding.dart';
export 'src/rendering/sliver_persistent_header.dart';
export 'src/rendering/stack.dart'; export 'src/rendering/stack.dart';
export 'src/rendering/table.dart'; export 'src/rendering/table.dart';
export 'src/rendering/tweens.dart'; export 'src/rendering/tweens.dart';
......
...@@ -21,10 +21,10 @@ import 'sliver.dart'; ...@@ -21,10 +21,10 @@ import 'sliver.dart';
/// passed on to the child. /// passed on to the child.
/// ///
/// Applying this to anything but the most mundane sliver is likely to have /// Applying this to anything but the most mundane sliver is likely to have
/// undesired effects. For example, wrapping a [RenderSliverPinnedAppBar] will /// undesired effects. For example, wrapping a
/// cause the app bar to overlap earlier slivers (contrary to the normal /// [RenderSliverPinnedPersistentHeader] will cause the app bar to overlap
/// behavior of pinned app bars), and while the app bar is pinned, the padding /// earlier slivers (contrary to the normal behavior of pinned app bars), and
/// will scroll away. /// while the app bar is pinned, the padding will scroll away.
class RenderSliverPadding extends RenderSliver with RenderObjectWithChildMixin<RenderSliver> { class RenderSliverPadding extends RenderSliver with RenderObjectWithChildMixin<RenderSliver> {
/// Creates a render object that insets its child in a viewport. /// Creates a render object that insets its child in a viewport.
/// ///
......
...@@ -15,8 +15,8 @@ import 'object.dart'; ...@@ -15,8 +15,8 @@ import 'object.dart';
import 'sliver.dart'; import 'sliver.dart';
import 'viewport_offset.dart'; import 'viewport_offset.dart';
abstract class RenderSliverAppBar extends RenderSliver with RenderObjectWithChildMixin<RenderBox>, RenderSliverHelpers { abstract class RenderSliverPersistentHeader extends RenderSliver with RenderObjectWithChildMixin<RenderBox>, RenderSliverHelpers {
RenderSliverAppBar({ RenderBox child }) { RenderSliverPersistentHeader({ RenderBox child }) {
this.child = child; this.child = child;
} }
...@@ -76,8 +76,9 @@ abstract class RenderSliverAppBar extends RenderSliver with RenderObjectWithChil ...@@ -76,8 +76,9 @@ abstract class RenderSliverAppBar extends RenderSliver with RenderObjectWithChil
/// Call this whenever [updateChild] would change or mutate the child even if /// Call this whenever [updateChild] would change or mutate the child even if
/// given the same `shrinkOffset` as the last time it was called. /// given the same `shrinkOffset` as the last time it was called.
/// ///
/// This must be implemented by [RenderSliverAppBar] subclasses such that the /// This must be implemented by [RenderSliverPersistentHeader] subclasses such
/// next layout after this call will result in [updateChild] being called. /// that the next layout after this call will result in [updateChild] being
/// called.
@protected @protected
void markNeedsUpdate() { void markNeedsUpdate() {
markNeedsLayout(); markNeedsLayout();
...@@ -129,7 +130,7 @@ abstract class RenderSliverAppBar extends RenderSliver with RenderObjectWithChil ...@@ -129,7 +130,7 @@ abstract class RenderSliverAppBar extends RenderSliver with RenderObjectWithChil
/// ///
/// The argument must be the value of the [child] property. /// The argument must be the value of the [child] property.
/// ///
/// This must be implemented by [RenderSliverAppBar] subclasses. /// This must be implemented by [RenderSliverPersistentHeader] subclasses.
/// ///
/// If there is no child, this should return 0.0. /// If there is no child, this should return 0.0.
@override @override
...@@ -193,8 +194,8 @@ abstract class RenderSliverAppBar extends RenderSliver with RenderObjectWithChil ...@@ -193,8 +194,8 @@ abstract class RenderSliverAppBar extends RenderSliver with RenderObjectWithChil
/// a minimum size before continuing to scroll. /// a minimum size before continuing to scroll.
/// ///
/// This sliver makes no effort to avoid overlapping other content. /// This sliver makes no effort to avoid overlapping other content.
abstract class RenderSliverScrollingAppBar extends RenderSliverAppBar { abstract class RenderSliverScrollingPersistentHeader extends RenderSliverPersistentHeader {
RenderSliverScrollingAppBar({ RenderSliverScrollingPersistentHeader({
RenderBox child, RenderBox child,
}) : super(child: child); }) : super(child: child);
...@@ -228,8 +229,8 @@ abstract class RenderSliverScrollingAppBar extends RenderSliverAppBar { ...@@ -228,8 +229,8 @@ abstract class RenderSliverScrollingAppBar extends RenderSliverAppBar {
/// then shrinks as the viewport continues to scroll. /// then shrinks as the viewport continues to scroll.
/// ///
/// This sliver avoids overlapping other earlier slivers where possible. /// This sliver avoids overlapping other earlier slivers where possible.
abstract class RenderSliverPinnedAppBar extends RenderSliverAppBar { abstract class RenderSliverPinnedPersistentHeader extends RenderSliverPersistentHeader {
RenderSliverPinnedAppBar({ RenderSliverPinnedPersistentHeader({
RenderBox child, RenderBox child,
}) : super(child: child); }) : super(child: child);
...@@ -253,8 +254,8 @@ abstract class RenderSliverPinnedAppBar extends RenderSliverAppBar { ...@@ -253,8 +254,8 @@ abstract class RenderSliverPinnedAppBar extends RenderSliverAppBar {
} }
} }
abstract class RenderSliverFloatingAppBar extends RenderSliverAppBar { abstract class RenderSliverFloatingPersistentHeader extends RenderSliverPersistentHeader {
RenderSliverFloatingAppBar({ RenderSliverFloatingPersistentHeader({
RenderBox child, RenderBox child,
}) : super(child: child); }) : super(child: child);
......
...@@ -11,8 +11,9 @@ import 'package:meta/meta.dart'; ...@@ -11,8 +11,9 @@ import 'package:meta/meta.dart';
/// This contrasts to [GrowthDirection] in that it has a third value, [idle], /// This contrasts to [GrowthDirection] in that it has a third value, [idle],
/// for the case where no scroll is occurring. /// for the case where no scroll is occurring.
/// ///
/// This is used by [RenderSliverFloatingAppBar] to only expand when the user is /// This is used by [RenderSliverFloatingPersistentHeader] to only expand when
/// scrolling in the same direction as the detected scroll offset change. /// the user is scrolling in the same direction as the detected scroll offset
/// change.
enum ScrollDirection { enum ScrollDirection {
/// No scrolling is underway. /// No scrolling is underway.
idle, idle,
...@@ -101,9 +102,9 @@ abstract class ViewportOffset extends ChangeNotifier { ...@@ -101,9 +102,9 @@ abstract class ViewportOffset extends ChangeNotifier {
/// the viewport's [RenderViewport2.axisDirection]. /// the viewport's [RenderViewport2.axisDirection].
/// ///
/// This is used by some slivers to determine how to react to a change in /// This is used by some slivers to determine how to react to a change in
/// scroll offset. For example, [RenderSliverFloatingAppBar] will only expand /// scroll offset. For example, [RenderSliverFloatingPersistentHeader] will
/// a floating app bar when the [userScrollDirection] is in the positive /// only expand a floating app bar when the [userScrollDirection] is in the
/// scroll offset direction. /// positive scroll offset direction.
ScrollDirection get userScrollDirection; ScrollDirection get userScrollDirection;
@override @override
......
...@@ -7,20 +7,20 @@ import 'package:flutter/rendering.dart'; ...@@ -7,20 +7,20 @@ import 'package:flutter/rendering.dart';
import 'framework.dart'; import 'framework.dart';
abstract class SliverAppBarDelegate { abstract class SliverPersistentHeaderDelegate {
/// Abstract const constructor. This constructor enables subclasses to provide /// Abstract const constructor. This constructor enables subclasses to provide
/// const constructors so that they can be used in const expressions. /// const constructors so that they can be used in const expressions.
const SliverAppBarDelegate(); const SliverPersistentHeaderDelegate();
Widget build(BuildContext context, double shrinkOffset); Widget build(BuildContext context, double shrinkOffset);
double get maxExtent; double get maxExtent;
bool shouldRebuild(@checked SliverAppBarDelegate oldDelegate); bool shouldRebuild(@checked SliverPersistentHeaderDelegate oldDelegate);
} }
class SliverAppBar extends StatelessWidget { class SliverPersistentHeader extends StatelessWidget {
SliverAppBar({ SliverPersistentHeader({
Key key, Key key,
@required this.delegate, @required this.delegate,
this.pinned: false, this.pinned: false,
...@@ -32,7 +32,7 @@ class SliverAppBar extends StatelessWidget { ...@@ -32,7 +32,7 @@ class SliverAppBar extends StatelessWidget {
assert(!pinned || !floating); assert(!pinned || !floating);
} }
final SliverAppBarDelegate delegate; final SliverPersistentHeaderDelegate delegate;
final bool pinned; final bool pinned;
...@@ -41,10 +41,10 @@ class SliverAppBar extends StatelessWidget { ...@@ -41,10 +41,10 @@ class SliverAppBar extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (pinned) if (pinned)
return new _SliverPinnedAppBar(delegate: delegate); return new _SliverPinnedPersistentHeader(delegate: delegate);
if (floating) if (floating)
return new _SliverFloatingAppBar(delegate: delegate); return new _SliverFloatingPersistentHeader(delegate: delegate);
return new _SliverScrollingAppBar(delegate: delegate); return new _SliverScrollingPersistentHeader(delegate: delegate);
} }
@override @override
...@@ -62,14 +62,14 @@ class SliverAppBar extends StatelessWidget { ...@@ -62,14 +62,14 @@ class SliverAppBar extends StatelessWidget {
} }
} }
class _SliverAppBarElement extends RenderObjectElement { class _SliverPersistentHeaderElement extends RenderObjectElement {
_SliverAppBarElement(_SliverAppBarRenderObjectWidget widget) : super(widget); _SliverPersistentHeaderElement(_SliverPersistentHeaderRenderObjectWidget widget) : super(widget);
@override @override
_SliverAppBarRenderObjectWidget get widget => super.widget; _SliverPersistentHeaderRenderObjectWidget get widget => super.widget;
@override @override
_RenderSliverAppBarForWidgetsMixin get renderObject => super.renderObject; _RenderSliverPersistentHeaderForWidgetsMixin get renderObject => super.renderObject;
@override @override
void mount(Element parent, dynamic newSlot) { void mount(Element parent, dynamic newSlot) {
...@@ -84,11 +84,11 @@ class _SliverAppBarElement extends RenderObjectElement { ...@@ -84,11 +84,11 @@ class _SliverAppBarElement extends RenderObjectElement {
} }
@override @override
void update(_SliverAppBarRenderObjectWidget newWidget) { void update(_SliverPersistentHeaderRenderObjectWidget newWidget) {
final _SliverAppBarRenderObjectWidget oldWidget = widget; final _SliverPersistentHeaderRenderObjectWidget oldWidget = widget;
super.update(newWidget); super.update(newWidget);
final SliverAppBarDelegate newDelegate = newWidget.delegate; final SliverPersistentHeaderDelegate newDelegate = newWidget.delegate;
final SliverAppBarDelegate oldDelegate = oldWidget.delegate; final SliverPersistentHeaderDelegate oldDelegate = oldWidget.delegate;
if (newDelegate != oldDelegate && if (newDelegate != oldDelegate &&
(newDelegate.runtimeType != oldDelegate.runtimeType || newDelegate.shouldRebuild(oldDelegate))) (newDelegate.runtimeType != oldDelegate.runtimeType || newDelegate.shouldRebuild(oldDelegate)))
renderObject.triggerRebuild(); renderObject.triggerRebuild();
...@@ -134,21 +134,21 @@ class _SliverAppBarElement extends RenderObjectElement { ...@@ -134,21 +134,21 @@ class _SliverAppBarElement extends RenderObjectElement {
} }
} }
abstract class _SliverAppBarRenderObjectWidget extends RenderObjectWidget { abstract class _SliverPersistentHeaderRenderObjectWidget extends RenderObjectWidget {
_SliverAppBarRenderObjectWidget({ _SliverPersistentHeaderRenderObjectWidget({
Key key, Key key,
@required this.delegate, @required this.delegate,
}) : super(key: key) { }) : super(key: key) {
assert(delegate != null); assert(delegate != null);
} }
final SliverAppBarDelegate delegate; final SliverPersistentHeaderDelegate delegate;
@override @override
_SliverAppBarElement createElement() => new _SliverAppBarElement(this); _SliverPersistentHeaderElement createElement() => new _SliverPersistentHeaderElement(this);
@override @override
_RenderSliverAppBarForWidgetsMixin createRenderObject(BuildContext context); _RenderSliverPersistentHeaderForWidgetsMixin createRenderObject(BuildContext context);
@override @override
void debugFillDescription(List<String> description) { void debugFillDescription(List<String> description) {
...@@ -157,8 +157,8 @@ abstract class _SliverAppBarRenderObjectWidget extends RenderObjectWidget { ...@@ -157,8 +157,8 @@ abstract class _SliverAppBarRenderObjectWidget extends RenderObjectWidget {
} }
} }
abstract class _RenderSliverAppBarForWidgetsMixin implements RenderSliverAppBar { abstract class _RenderSliverPersistentHeaderForWidgetsMixin implements RenderSliverPersistentHeader {
_SliverAppBarElement _element; _SliverPersistentHeaderElement _element;
@override @override
double get maxExtent => _element.widget.delegate.maxExtent; double get maxExtent => _element.widget.delegate.maxExtent;
...@@ -175,54 +175,54 @@ abstract class _RenderSliverAppBarForWidgetsMixin implements RenderSliverAppBar ...@@ -175,54 +175,54 @@ abstract class _RenderSliverAppBarForWidgetsMixin implements RenderSliverAppBar
} }
} }
class _SliverScrollingAppBar extends _SliverAppBarRenderObjectWidget { class _SliverScrollingPersistentHeader extends _SliverPersistentHeaderRenderObjectWidget {
_SliverScrollingAppBar({ _SliverScrollingPersistentHeader({
Key key, Key key,
@required SliverAppBarDelegate delegate, @required SliverPersistentHeaderDelegate delegate,
}) : super(key: key, delegate: delegate); }) : super(key: key, delegate: delegate);
@override @override
_RenderSliverAppBarForWidgetsMixin createRenderObject(BuildContext context) { _RenderSliverPersistentHeaderForWidgetsMixin createRenderObject(BuildContext context) {
return new _RenderSliverScrollingAppBarForWidgets(); return new _RenderSliverScrollingPersistentHeaderForWidgets();
} }
} }
// This class exists to work around https://github.com/dart-lang/sdk/issues/15101 // This class exists to work around https://github.com/dart-lang/sdk/issues/15101
abstract class _RenderSliverScrollingAppBar extends RenderSliverScrollingAppBar { } abstract class _RenderSliverScrollingPersistentHeader extends RenderSliverScrollingPersistentHeader { }
class _RenderSliverScrollingAppBarForWidgets extends _RenderSliverScrollingAppBar class _RenderSliverScrollingPersistentHeaderForWidgets extends _RenderSliverScrollingPersistentHeader
with _RenderSliverAppBarForWidgetsMixin { } with _RenderSliverPersistentHeaderForWidgetsMixin { }
class _SliverPinnedAppBar extends _SliverAppBarRenderObjectWidget { class _SliverPinnedPersistentHeader extends _SliverPersistentHeaderRenderObjectWidget {
_SliverPinnedAppBar({ _SliverPinnedPersistentHeader({
Key key, Key key,
@required SliverAppBarDelegate delegate, @required SliverPersistentHeaderDelegate delegate,
}) : super(key: key, delegate: delegate); }) : super(key: key, delegate: delegate);
@override @override
_RenderSliverAppBarForWidgetsMixin createRenderObject(BuildContext context) { _RenderSliverPersistentHeaderForWidgetsMixin createRenderObject(BuildContext context) {
return new _RenderSliverPinnedAppBarForWidgets(); return new _RenderSliverPinnedPersistentHeaderForWidgets();
} }
} }
// This class exists to work around https://github.com/dart-lang/sdk/issues/15101 // This class exists to work around https://github.com/dart-lang/sdk/issues/15101
abstract class _RenderSliverPinnedAppBar extends RenderSliverPinnedAppBar { } abstract class _RenderSliverPinnedPersistentHeader extends RenderSliverPinnedPersistentHeader { }
class _RenderSliverPinnedAppBarForWidgets extends _RenderSliverPinnedAppBar with _RenderSliverAppBarForWidgetsMixin { } class _RenderSliverPinnedPersistentHeaderForWidgets extends _RenderSliverPinnedPersistentHeader with _RenderSliverPersistentHeaderForWidgetsMixin { }
class _SliverFloatingAppBar extends _SliverAppBarRenderObjectWidget { class _SliverFloatingPersistentHeader extends _SliverPersistentHeaderRenderObjectWidget {
_SliverFloatingAppBar({ _SliverFloatingPersistentHeader({
Key key, Key key,
@required SliverAppBarDelegate delegate, @required SliverPersistentHeaderDelegate delegate,
}) : super(key: key, delegate: delegate); }) : super(key: key, delegate: delegate);
@override @override
_RenderSliverAppBarForWidgetsMixin createRenderObject(BuildContext context) { _RenderSliverPersistentHeaderForWidgetsMixin createRenderObject(BuildContext context) {
return new _RenderSliverFloatingAppBarForWidgets(); return new _RenderSliverFloatingPersistentHeaderForWidgets();
} }
} }
// This class exists to work around https://github.com/dart-lang/sdk/issues/15101 // This class exists to work around https://github.com/dart-lang/sdk/issues/15101
abstract class _RenderSliverFloatingAppBar extends RenderSliverFloatingAppBar { } abstract class _RenderSliverFloatingPersistentHeader extends RenderSliverFloatingPersistentHeader { }
class _RenderSliverFloatingAppBarForWidgets extends _RenderSliverFloatingAppBar with _RenderSliverAppBarForWidgetsMixin { } class _RenderSliverFloatingPersistentHeaderForWidgets extends _RenderSliverFloatingPersistentHeader with _RenderSliverPersistentHeaderForWidgetsMixin { }
...@@ -10,7 +10,6 @@ library widgets; ...@@ -10,7 +10,6 @@ library widgets;
export 'src/widgets/animated_cross_fade.dart'; export 'src/widgets/animated_cross_fade.dart';
export 'src/widgets/animated_size.dart'; export 'src/widgets/animated_size.dart';
export 'src/widgets/app.dart'; export 'src/widgets/app.dart';
export 'src/widgets/app_bar.dart';
export 'src/widgets/async.dart'; export 'src/widgets/async.dart';
export 'src/widgets/banner.dart'; export 'src/widgets/banner.dart';
export 'src/widgets/basic.dart'; export 'src/widgets/basic.dart';
...@@ -60,6 +59,7 @@ export 'src/widgets/semantics_debugger.dart'; ...@@ -60,6 +59,7 @@ export 'src/widgets/semantics_debugger.dart';
export 'src/widgets/single_child_scroll_view.dart'; export 'src/widgets/single_child_scroll_view.dart';
export 'src/widgets/size_changed_layout_notifier.dart'; export 'src/widgets/size_changed_layout_notifier.dart';
export 'src/widgets/sliver.dart'; export 'src/widgets/sliver.dart';
export 'src/widgets/sliver_persistent_header.dart';
export 'src/widgets/status_transitions.dart'; export 'src/widgets/status_transitions.dart';
export 'src/widgets/table.dart'; export 'src/widgets/table.dart';
export 'src/widgets/text.dart'; export 'src/widgets/text.dart';
......
...@@ -32,7 +32,7 @@ void main() { ...@@ -32,7 +32,7 @@ void main() {
axisDirection: AxisDirection.down, axisDirection: AxisDirection.down,
slivers: <Widget>[ slivers: <Widget>[
new BigSliver(height: bigHeight), new BigSliver(height: bigHeight),
new SliverAppBar(delegate: new TestDelegate(), floating: true), new SliverPersistentHeader(delegate: new TestDelegate(), floating: true),
new BigSliver(height: bigHeight), new BigSliver(height: bigHeight),
], ],
), ),
...@@ -60,7 +60,7 @@ void main() { ...@@ -60,7 +60,7 @@ void main() {
axisDirection: AxisDirection.down, axisDirection: AxisDirection.down,
slivers: <Widget>[ slivers: <Widget>[
new BigSliver(key: key1 = new GlobalKey(), height: bigHeight), new BigSliver(key: key1 = new GlobalKey(), height: bigHeight),
new SliverAppBar(key: key2 = new GlobalKey(), delegate: delegate, floating: true), new SliverPersistentHeader(key: key2 = new GlobalKey(), delegate: delegate, floating: true),
new BigSliver(key: key3 = new GlobalKey(), height: bigHeight), new BigSliver(key: key3 = new GlobalKey(), height: bigHeight),
], ],
), ),
...@@ -130,7 +130,7 @@ void main() { ...@@ -130,7 +130,7 @@ void main() {
axisDirection: AxisDirection.down, axisDirection: AxisDirection.down,
slivers: <Widget>[ slivers: <Widget>[
new BigSliver(key: key1 = new GlobalKey(), height: bigHeight), new BigSliver(key: key1 = new GlobalKey(), height: bigHeight),
new SliverAppBar(key: key2 = new GlobalKey(), delegate: delegate, floating: true), new SliverPersistentHeader(key: key2 = new GlobalKey(), delegate: delegate, floating: true),
new BigSliver(key: key3 = new GlobalKey(), height: bigHeight), new BigSliver(key: key3 = new GlobalKey(), height: bigHeight),
], ],
), ),
...@@ -163,7 +163,7 @@ void main() { ...@@ -163,7 +163,7 @@ void main() {
axisDirection: AxisDirection.down, axisDirection: AxisDirection.down,
slivers: <Widget>[ slivers: <Widget>[
new BigSliver(key: key1 = new GlobalKey(), height: bigHeight), new BigSliver(key: key1 = new GlobalKey(), height: bigHeight),
new SliverAppBar(key: key2 = new GlobalKey(), delegate: delegate, floating: true), new SliverPersistentHeader(key: key2 = new GlobalKey(), delegate: delegate, floating: true),
new BigSliver(key: key3 = new GlobalKey(), height: bigHeight), new BigSliver(key: key3 = new GlobalKey(), height: bigHeight),
], ],
), ),
...@@ -190,7 +190,7 @@ void main() { ...@@ -190,7 +190,7 @@ void main() {
}); });
} }
class TestDelegate extends SliverAppBarDelegate { class TestDelegate extends SliverPersistentHeaderDelegate {
@override @override
double get maxExtent => 200.0; double get maxExtent => 200.0;
......
...@@ -33,8 +33,8 @@ void main() { ...@@ -33,8 +33,8 @@ void main() {
axisDirection: AxisDirection.down, axisDirection: AxisDirection.down,
slivers: <Widget>[ slivers: <Widget>[
new BigSliver(key: key1 = new GlobalKey(), height: bigHeight), new BigSliver(key: key1 = new GlobalKey(), height: bigHeight),
new SliverAppBar(key: key2 = new GlobalKey(), delegate: new TestDelegate(), pinned: true), new SliverPersistentHeader(key: key2 = new GlobalKey(), delegate: new TestDelegate(), pinned: true),
new SliverAppBar(key: key3 = new GlobalKey(), delegate: new TestDelegate(), pinned: true), new SliverPersistentHeader(key: key3 = new GlobalKey(), delegate: new TestDelegate(), pinned: true),
new BigSliver(key: key4 = new GlobalKey(), height: bigHeight), new BigSliver(key: key4 = new GlobalKey(), height: bigHeight),
new BigSliver(key: key5 = new GlobalKey(), height: bigHeight), new BigSliver(key: key5 = new GlobalKey(), height: bigHeight),
], ],
...@@ -67,8 +67,8 @@ void main() { ...@@ -67,8 +67,8 @@ void main() {
axisDirection: AxisDirection.down, axisDirection: AxisDirection.down,
slivers: <Widget>[ slivers: <Widget>[
new BigSliver(key: key1 = new GlobalKey(), height: bigHeight), new BigSliver(key: key1 = new GlobalKey(), height: bigHeight),
new SliverAppBar(key: key2 = new GlobalKey(), delegate: new TestDelegate(), pinned: true), new SliverPersistentHeader(key: key2 = new GlobalKey(), delegate: new TestDelegate(), pinned: true),
new SliverAppBar(key: key3 = new GlobalKey(), delegate: new TestDelegate(), pinned: true), new SliverPersistentHeader(key: key3 = new GlobalKey(), delegate: new TestDelegate(), pinned: true),
new BigSliver(key: key4 = new GlobalKey(), height: bigHeight), new BigSliver(key: key4 = new GlobalKey(), height: bigHeight),
new BigSliver(key: key5 = new GlobalKey(), height: bigHeight), new BigSliver(key: key5 = new GlobalKey(), height: bigHeight),
], ],
...@@ -157,8 +157,8 @@ void main() { ...@@ -157,8 +157,8 @@ void main() {
axisDirection: AxisDirection.down, axisDirection: AxisDirection.down,
slivers: <Widget>[ slivers: <Widget>[
new BigSliver(key: key1 = new GlobalKey(), height: bigHeight), new BigSliver(key: key1 = new GlobalKey(), height: bigHeight),
new SliverAppBar(key: key2 = new GlobalKey(), delegate: new TestDelegate(), pinned: true), new SliverPersistentHeader(key: key2 = new GlobalKey(), delegate: new TestDelegate(), pinned: true),
new SliverAppBar(key: key3 = new GlobalKey(), delegate: new TestDelegate(), pinned: true), new SliverPersistentHeader(key: key3 = new GlobalKey(), delegate: new TestDelegate(), pinned: true),
new BigSliver(key: key4 = new GlobalKey(), height: bigHeight), new BigSliver(key: key4 = new GlobalKey(), height: bigHeight),
new BigSliver(key: key5 = new GlobalKey(), height: bigHeight), new BigSliver(key: key5 = new GlobalKey(), height: bigHeight),
], ],
...@@ -184,7 +184,7 @@ void main() { ...@@ -184,7 +184,7 @@ void main() {
}); });
} }
class TestDelegate extends SliverAppBarDelegate { class TestDelegate extends SliverPersistentHeaderDelegate {
@override @override
double get maxExtent => 200.0; double get maxExtent => 200.0;
......
...@@ -24,8 +24,8 @@ void main() { ...@@ -24,8 +24,8 @@ void main() {
axisDirection: AxisDirection.down, axisDirection: AxisDirection.down,
slivers: <Widget>[ slivers: <Widget>[
new BigSliver(key: key1 = new GlobalKey()), new BigSliver(key: key1 = new GlobalKey()),
new SliverAppBar(key: key2 = new GlobalKey(), delegate: new TestDelegate()), new SliverPersistentHeader(key: key2 = new GlobalKey(), delegate: new TestDelegate()),
new SliverAppBar(key: key3 = new GlobalKey(), delegate: new TestDelegate()), new SliverPersistentHeader(key: key3 = new GlobalKey(), delegate: new TestDelegate()),
new BigSliver(key: key4 = new GlobalKey()), new BigSliver(key: key4 = new GlobalKey()),
new BigSliver(key: key5 = new GlobalKey()), new BigSliver(key: key5 = new GlobalKey()),
], ],
...@@ -58,7 +58,7 @@ void main() { ...@@ -58,7 +58,7 @@ void main() {
axisDirection: AxisDirection.down, axisDirection: AxisDirection.down,
slivers: <Widget>[ slivers: <Widget>[
new BigSliver(), new BigSliver(),
new SliverAppBar(key: key, delegate: delegate), new SliverPersistentHeader(key: key, delegate: delegate),
new BigSliver(), new BigSliver(),
new BigSliver(), new BigSliver(),
], ],
...@@ -73,7 +73,7 @@ void main() { ...@@ -73,7 +73,7 @@ void main() {
}); });
} }
class TestDelegate extends SliverAppBarDelegate { class TestDelegate extends SliverPersistentHeaderDelegate {
@override @override
double get maxExtent => 200.0; double get maxExtent => 200.0;
......
...@@ -9,8 +9,8 @@ import 'package:flutter/material.dart'; ...@@ -9,8 +9,8 @@ import 'package:flutter/material.dart';
import 'test_widgets.dart'; import 'test_widgets.dart';
class TestSliverAppBarDelegate extends SliverAppBarDelegate { class TestSliverPersistentHeaderDelegate extends SliverPersistentHeaderDelegate {
TestSliverAppBarDelegate(this._maxExtent); TestSliverPersistentHeaderDelegate(this._maxExtent);
final double _maxExtent; final double _maxExtent;
...@@ -28,7 +28,7 @@ class TestSliverAppBarDelegate extends SliverAppBarDelegate { ...@@ -28,7 +28,7 @@ class TestSliverAppBarDelegate extends SliverAppBarDelegate {
} }
@override @override
bool shouldRebuild(TestSliverAppBarDelegate oldDelegate) => false; bool shouldRebuild(TestSliverPersistentHeaderDelegate oldDelegate) => false;
} }
class TestBehavior extends ScrollBehavior2 { class TestBehavior extends ScrollBehavior2 {
...@@ -84,38 +84,38 @@ void main() { ...@@ -84,38 +84,38 @@ void main() {
new SliverToBoxAdapter(child: new Container(height: 520.0)), new SliverToBoxAdapter(child: new Container(height: 520.0)),
new SliverToBoxAdapter(child: new Container(height: 520.0)), new SliverToBoxAdapter(child: new Container(height: 520.0)),
new SliverToBoxAdapter(child: new Container(height: 520.0)), new SliverToBoxAdapter(child: new Container(height: 520.0)),
new SliverAppBar(delegate: new TestSliverAppBarDelegate(150.0), pinned: true), new SliverPersistentHeader(delegate: new TestSliverPersistentHeaderDelegate(150.0), pinned: true),
new SliverToBoxAdapter(child: new Container(height: 520.0)), new SliverToBoxAdapter(child: new Container(height: 520.0)),
new SliverPadding( new SliverPadding(
padding: new EdgeInsets.all(50.0), padding: new EdgeInsets.all(50.0),
child: new SliverToBoxAdapter(child: new Container(height: 520.0)), child: new SliverToBoxAdapter(child: new Container(height: 520.0)),
), ),
new SliverToBoxAdapter(child: new Container(height: 520.0)), new SliverToBoxAdapter(child: new Container(height: 520.0)),
new SliverAppBar(delegate: new TestSliverAppBarDelegate(150.0), floating: true), new SliverPersistentHeader(delegate: new TestSliverPersistentHeaderDelegate(150.0), floating: true),
new SliverToBoxAdapter(child: new Container(height: 520.0)), new SliverToBoxAdapter(child: new Container(height: 520.0)),
new SliverToBoxAdapter(key: centerKey, child: new Container(height: 520.0)), // ------------------------ CENTER ------------------------ new SliverToBoxAdapter(key: centerKey, child: new Container(height: 520.0)), // ------------------------ CENTER ------------------------
new SliverAppBar(delegate: new TestSliverAppBarDelegate(150.0), pinned: true), new SliverPersistentHeader(delegate: new TestSliverPersistentHeaderDelegate(150.0), pinned: true),
new SliverToBoxAdapter(child: new Container(height: 520.0)), new SliverToBoxAdapter(child: new Container(height: 520.0)),
new SliverToBoxAdapter(child: new Container(height: 520.0)), new SliverToBoxAdapter(child: new Container(height: 520.0)),
new SliverToBoxAdapter(child: new Container(height: 520.0)), new SliverToBoxAdapter(child: new Container(height: 520.0)),
new SliverPadding( new SliverPadding(
padding: new EdgeInsets.all(50.0), padding: new EdgeInsets.all(50.0),
child: new SliverAppBar(delegate: new TestSliverAppBarDelegate(250.0), pinned: true), child: new SliverPersistentHeader(delegate: new TestSliverPersistentHeaderDelegate(250.0), pinned: true),
), ),
new SliverToBoxAdapter(child: new Container(height: 520.0)), new SliverToBoxAdapter(child: new Container(height: 520.0)),
new SliverAppBar(delegate: new TestSliverAppBarDelegate(250.0), pinned: true), new SliverPersistentHeader(delegate: new TestSliverPersistentHeaderDelegate(250.0), pinned: true),
new SliverToBoxAdapter(child: new Container(height: 5.0)), new SliverToBoxAdapter(child: new Container(height: 5.0)),
new SliverAppBar(delegate: new TestSliverAppBarDelegate(250.0), pinned: true), new SliverPersistentHeader(delegate: new TestSliverPersistentHeaderDelegate(250.0), pinned: true),
new SliverToBoxAdapter(child: new Container(height: 5.0)), new SliverToBoxAdapter(child: new Container(height: 5.0)),
new SliverAppBar(delegate: new TestSliverAppBarDelegate(250.0), pinned: true), new SliverPersistentHeader(delegate: new TestSliverPersistentHeaderDelegate(250.0), pinned: true),
new SliverAppBar(delegate: new TestSliverAppBarDelegate(250.0), pinned: true), new SliverPersistentHeader(delegate: new TestSliverPersistentHeaderDelegate(250.0), pinned: true),
new SliverToBoxAdapter(child: new Container(height: 5.0)), new SliverToBoxAdapter(child: new Container(height: 5.0)),
new SliverAppBar(delegate: new TestSliverAppBarDelegate(250.0), pinned: true), new SliverPersistentHeader(delegate: new TestSliverPersistentHeaderDelegate(250.0), pinned: true),
new SliverAppBar(delegate: new TestSliverAppBarDelegate(250.0)), new SliverPersistentHeader(delegate: new TestSliverPersistentHeaderDelegate(250.0)),
new SliverToBoxAdapter(child: new Container(height: 520.0)), new SliverToBoxAdapter(child: new Container(height: 520.0)),
new SliverAppBar(delegate: new TestSliverAppBarDelegate(150.0), floating: true), new SliverPersistentHeader(delegate: new TestSliverPersistentHeaderDelegate(150.0), floating: true),
new SliverToBoxAdapter(child: new Container(height: 520.0)), new SliverToBoxAdapter(child: new Container(height: 520.0)),
new SliverAppBar(delegate: new TestSliverAppBarDelegate(150.0), floating: true), new SliverPersistentHeader(delegate: new TestSliverPersistentHeaderDelegate(150.0), floating: true),
new SliverToBoxAdapter(child: new Container(height: 5.0)), new SliverToBoxAdapter(child: new Container(height: 5.0)),
new SliverList( new SliverList(
delegate: new SliverChildListDelegate(<Widget>[ delegate: new SliverChildListDelegate(<Widget>[
...@@ -136,9 +136,9 @@ void main() { ...@@ -136,9 +136,9 @@ void main() {
new Container(height: 50.0), new Container(height: 50.0),
]), ]),
), ),
new SliverAppBar(delegate: new TestSliverAppBarDelegate(250.0)), new SliverPersistentHeader(delegate: new TestSliverPersistentHeaderDelegate(250.0)),
new SliverAppBar(delegate: new TestSliverAppBarDelegate(250.0)), new SliverPersistentHeader(delegate: new TestSliverPersistentHeaderDelegate(250.0)),
new SliverAppBar(delegate: new TestSliverAppBarDelegate(250.0)), new SliverPersistentHeader(delegate: new TestSliverPersistentHeaderDelegate(250.0)),
new SliverPadding( new SliverPadding(
padding: new EdgeInsets.symmetric(horizontal: 50.0), padding: new EdgeInsets.symmetric(horizontal: 50.0),
child: new SliverToBoxAdapter(child: new Container(height: 520.0)), child: new SliverToBoxAdapter(child: new Container(height: 520.0)),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment