Commit 97816e15 authored by Adam Barth's avatar Adam Barth Committed by GitHub

Rename Dismissable to Dismissible (#8919)

The latter is the proper spelling.

Fixes #8883
parent 11c2032a
......@@ -248,7 +248,7 @@ class CardCollectionState extends State<CardCollection> {
Widget _buildCard(BuildContext context, int index) {
final CardModel cardModel = _cardModels[index];
final Widget card = new Dismissable(
final Widget card = new Dismissible(
key: new ObjectKey(cardModel),
direction: _dismissDirection,
onDismissed: (DismissDirection direction) { dismissCard(cardModel); },
......@@ -313,7 +313,7 @@ class CardCollectionState extends State<CardCollection> {
final ThemeData theme = Theme.of(context);
final TextStyle backgroundTextStyle = theme.primaryTextTheme.title;
// The background Widget appears behind the Dismissable card when the card
// The background Widget appears behind the Dismissible card when the card
// moves to the left or right. The Positioned widget ensures that the
// size of the background,card Stack will be based only on the card. The
// Viewport ensures that when the card's resize animation occurs, the
......
......@@ -19,7 +19,7 @@ class _CupertinoDialogDemoState extends State<CupertinoDialogDemo> {
showDialog<T>(
context: context,
child: child,
barrierDismissable: false,
barrierDismissible: false,
)
.then<Null>((T value) { // The value passed to Navigator.pop() or null.
if (value != null) {
......
......@@ -85,7 +85,7 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> {
Widget buildItem(LeaveBehindItem item) {
final ThemeData theme = Theme.of(context);
return new Dismissable(
return new Dismissible(
key: new ObjectKey(item),
direction: _dismissDirection,
onDismissed: (DismissDirection direction) {
......
......@@ -215,7 +215,7 @@ class _ModalBottomSheetRoute<T> extends PopupRoute<T> {
Duration get transitionDuration => _kBottomSheetDuration;
@override
bool get barrierDismissable => true;
bool get barrierDismissible => true;
@override
Color get barrierColor => Colors.black54;
......
......@@ -317,10 +317,10 @@ class SimpleDialog extends StatelessWidget {
class _DialogRoute<T> extends PopupRoute<T> {
_DialogRoute({
@required this.theme,
bool barrierDismissable: true,
bool barrierDismissible: true,
@required this.child,
}) : _barrierDismissable = barrierDismissable {
assert(barrierDismissable != null);
}) : _barrierDismissible = barrierDismissible {
assert(barrierDismissible != null);
}
final Widget child;
......@@ -330,8 +330,8 @@ class _DialogRoute<T> extends PopupRoute<T> {
Duration get transitionDuration => const Duration(milliseconds: 150);
@override
bool get barrierDismissable => _barrierDismissable;
final bool _barrierDismissable;
bool get barrierDismissible => _barrierDismissible;
final bool _barrierDismissible;
@override
Color get barrierColor => Colors.black54;
......@@ -368,12 +368,12 @@ class _DialogRoute<T> extends PopupRoute<T> {
/// * <https://material.google.com/components/dialogs.html>
Future<T> showDialog<T>({
@required BuildContext context,
bool barrierDismissable: true,
bool barrierDismissible: true,
@required Widget child,
}) {
return Navigator.push(context, new _DialogRoute<T>(
child: child,
theme: Theme.of(context, shadowThemeOnly: true),
barrierDismissable: barrierDismissable,
barrierDismissible: barrierDismissible,
));
}
......@@ -307,7 +307,7 @@ class _DropdownRoute<T> extends PopupRoute<_DropdownRouteResult<T>> {
Duration get transitionDuration => _kDropdownMenuDuration;
@override
bool get barrierDismissable => true;
bool get barrierDismissible => true;
@override
Color get barrierColor => null;
......
......@@ -396,7 +396,7 @@ class _PopupMenuRoute<T> extends PopupRoute<T> {
Duration get transitionDuration => _kMenuDuration;
@override
bool get barrierDismissable => true;
bool get barrierDismissible => true;
@override
Color get barrierColor => null;
......
......@@ -231,8 +231,8 @@ class SnackBar extends StatelessWidget {
},
child: new Semantics(
container: true,
child: new Dismissable(
key: const Key('dismissable'),
child: new Dismissible(
key: const Key('dismissible'),
direction: DismissDirection.down,
resizeDuration: null,
onDismissed: (DismissDirection direction) {
......
......@@ -17,32 +17,32 @@ const double _kMinFlingVelocityDelta = 400.0;
const double _kFlingVelocityScale = 1.0 / 300.0;
const double _kDismissThreshold = 0.4;
/// Signature used by [Dismissable] to indicate that it has been dismissed in
/// Signature used by [Dismissible] to indicate that it has been dismissed in
/// the given `direction`.
///
/// Used by [Dismissable.onDismissed].
/// Used by [Dismissible.onDismissed].
typedef void DismissDirectionCallback(DismissDirection direction);
/// The direction in which a [Dismissable] can be dismissed.
/// The direction in which a [Dismissible] can be dismissed.
enum DismissDirection {
/// The [Dismissable] can be dismissed by dragging either up or down.
/// The [Dismissible] can be dismissed by dragging either up or down.
vertical,
/// The [Dismissable] can be dismissed by dragging either left or right.
/// The [Dismissible] can be dismissed by dragging either left or right.
horizontal,
/// The [Dismissable] can be dismissed by dragging in the reverse of the
/// The [Dismissible] can be dismissed by dragging in the reverse of the
/// reading direction (e.g., from right to left in left-to-right languages).
endToStart,
/// The [Dismissable] can be dismissed by dragging in the reading direction
/// The [Dismissible] can be dismissed by dragging in the reading direction
/// (e.g., from left to right in left-to-right languages).
startToEnd,
/// The [Dismissable] can be dismissed by dragging up only.
/// The [Dismissible] can be dismissed by dragging up only.
up,
/// The [Dismissable] can be dismissed by dragging down only.
/// The [Dismissible] can be dismissed by dragging down only.
down
}
......@@ -50,28 +50,28 @@ enum DismissDirection {
///
/// Dragging or flinging this widget in the [DismissDirection] causes the child
/// to slide out of view. Following the slide animation, if [resizeDuration] is
/// non-null, the Dismissable widget animates its height (or width, whichever is
/// non-null, the Dismissible widget animates its height (or width, whichever is
/// perpendicular to the dismiss direction) to zero over the [resizeDuration].
///
/// Backgrounds can be used to implement the "leave-behind" idiom. If a background
/// is specified it is stacked behind the Dismissable's child and is exposed when
/// is specified it is stacked behind the Dismissible's child and is exposed when
/// the child moves.
///
/// The widget calls the [onDimissed] callback either after its size has
/// collapsed to zero (if [resizeDuration] is non-null) or immediately after
/// the slide animation (if [resizeDuration] is null). If the Dismissable is a
/// the slide animation (if [resizeDuration] is null). If the Dismissible is a
/// list item, it must have a key that distinguishes it from the other items and
/// its [onDismissed] callback must remove the item from the list.
class Dismissable extends StatefulWidget {
class Dismissible extends StatefulWidget {
/// Creates a widget that can be dismissed.
///
/// The [key] argument must not be null because [Dismissable]s are commonly
/// The [key] argument must not be null because [Dismissible]s are commonly
/// used in lists and removed from the list when dismissed. Without keys, the
/// default behavior is to sync widgets based on their index in the list,
/// which means the item after the dismissed item would be synced with the
/// state of the dismissed item. Using keys causes the widgets to sync
/// according to their keys and avoids this pitfall.
Dismissable({
Dismissible({
@required Key key,
@required this.child,
this.background,
......@@ -123,11 +123,11 @@ class Dismissable extends StatefulWidget {
final Map<DismissDirection, double> dismissThresholds;
@override
_DismissableState createState() => new _DismissableState();
_DismissibleState createState() => new _DismissibleState();
}
class _DismissableClipper extends CustomClipper<Rect> {
_DismissableClipper({
class _DismissibleClipper extends CustomClipper<Rect> {
_DismissibleClipper({
this.axis,
this.moveAnimation
}) : super(reclip: moveAnimation) {
......@@ -160,13 +160,13 @@ class _DismissableClipper extends CustomClipper<Rect> {
Rect getApproximateClipRect(Size size) => getClip(size);
@override
bool shouldReclip(_DismissableClipper oldClipper) {
bool shouldReclip(_DismissibleClipper oldClipper) {
return oldClipper.axis != axis
|| oldClipper.moveAnimation.value != moveAnimation.value;
}
}
class _DismissableState extends State<Dismissable> with TickerProviderStateMixin {
class _DismissibleState extends State<Dismissible> with TickerProviderStateMixin {
@override
void initState() {
super.initState();
......@@ -377,8 +377,8 @@ class _DismissableState extends State<Dismissable> with TickerProviderStateMixin
if (_resizeAnimation.status != AnimationStatus.forward) {
assert(_resizeAnimation.status == AnimationStatus.completed);
throw new FlutterError(
'A dismissed Dismissable widget is still part of the tree.\n' +
'Make sure to implement the onDismissed handler and to immediately remove the Dismissable\n' +
'A dismissed Dismissible widget is still part of the tree.\n' +
'Make sure to implement the onDismissed handler and to immediately remove the Dismissible\n' +
'widget from the application once that handler has fired.'
);
}
......@@ -407,7 +407,7 @@ class _DismissableState extends State<Dismissable> with TickerProviderStateMixin
if (!_moveAnimation.isDismissed) {
children.add(new Positioned.fill(
child: new ClipRect(
clipper: new _DismissableClipper(
clipper: new _DismissibleClipper(
axis: _directionIsXAxis ? Axis.horizontal : Axis.vertical,
moveAnimation: _moveAnimation,
),
......
......@@ -15,14 +15,14 @@ class ModalBarrier extends StatelessWidget {
ModalBarrier({
Key key,
this.color,
this.dismissable: true
this.dismissible: true
}) : super(key: key);
/// If non-null, fill the barrier with this color.
final Color color;
/// Whether touching the barrier will pop the current route off the [Navigator].
final bool dismissable;
final bool dismissible;
@override
Widget build(BuildContext context) {
......@@ -30,7 +30,7 @@ class ModalBarrier extends StatelessWidget {
container: true,
child: new GestureDetector(
onTapDown: (TapDownDetails details) {
if (dismissable)
if (dismissible)
Navigator.pop(context);
},
behavior: HitTestBehavior.opaque,
......@@ -53,20 +53,20 @@ class AnimatedModalBarrier extends AnimatedWidget {
AnimatedModalBarrier({
Key key,
Animation<Color> color,
this.dismissable: true
this.dismissible: true
}) : super(key: key, listenable: color);
/// If non-null, fill the barrier with this color.
Animation<Color> get color => listenable;
/// Whether touching the barrier will pop the current route off the [Navigator].
final bool dismissable;
final bool dismissible;
@override
Widget build(BuildContext context) {
return new ModalBarrier(
color: color?.value,
dismissable: dismissable
dismissible: dismissible
);
}
}
......@@ -19,7 +19,7 @@ abstract class PageRoute<T> extends ModalRoute<T> {
bool get opaque => true;
@override
bool get barrierDismissable => false;
bool get barrierDismissible => false;
@override
bool canTransitionTo(TransitionRoute<dynamic> nextRoute) => nextRoute is PageRoute<dynamic>;
......@@ -64,7 +64,7 @@ Widget _defaultTransitionsBuilder(BuildContext context, Animation<double> animat
class PageRouteBuilder<T> extends PageRoute<T> {
/// Creates a route that deletates to builder callbacks.
///
/// The [pageBuilder], [transitionsBuilder], [opaque], [barrierDismissable],
/// The [pageBuilder], [transitionsBuilder], [opaque], [barrierDismissible],
/// and [maintainState] arguments must not be null.
PageRouteBuilder({
RouteSettings settings: const RouteSettings(),
......@@ -72,14 +72,14 @@ class PageRouteBuilder<T> extends PageRoute<T> {
this.transitionsBuilder: _defaultTransitionsBuilder,
this.transitionDuration: const Duration(milliseconds: 300),
this.opaque: true,
this.barrierDismissable: false,
this.barrierDismissible: false,
this.barrierColor: null,
this.maintainState: true,
}) : super(settings: settings) {
assert(pageBuilder != null);
assert(transitionsBuilder != null);
assert(opaque != null);
assert(barrierDismissable != null);
assert(barrierDismissible != null);
assert(maintainState != null);
}
......@@ -100,7 +100,7 @@ class PageRouteBuilder<T> extends PageRoute<T> {
final bool opaque;
@override
final bool barrierDismissable;
final bool barrierDismissible;
@override
final Color barrierColor;
......
......@@ -613,7 +613,7 @@ abstract class ModalRoute<T> extends TransitionRoute<T> with LocalHistoryRoute<T
// The API for subclasses to override - used by this class
/// Whether you can dismiss this route by tapping the modal barrier.
bool get barrierDismissable;
bool get barrierDismissible;
/// The color to use for the modal barrier. If this is null, the barrier will
/// be transparent.
......@@ -816,10 +816,10 @@ abstract class ModalRoute<T> extends TransitionRoute<T> with LocalHistoryRoute<T
));
barrier = new AnimatedModalBarrier(
color: color,
dismissable: barrierDismissable
dismissible: barrierDismissible
);
} else {
barrier = new ModalBarrier(dismissable: barrierDismissable);
barrier = new ModalBarrier(dismissible: barrierDismissible);
}
assert(animation.status != AnimationStatus.dismissed);
return new IgnorePointer(
......
......@@ -18,7 +18,7 @@ export 'src/widgets/basic.dart';
export 'src/widgets/binding.dart';
export 'src/widgets/container.dart';
export 'src/widgets/debug.dart';
export 'src/widgets/dismissable.dart';
export 'src/widgets/dismissible.dart';
export 'src/widgets/drag_target.dart';
export 'src/widgets/editable_text.dart';
export 'src/widgets/focus.dart';
......
......@@ -138,7 +138,7 @@ void main() {
expect(await result, equals(42));
});
testWidgets('Barrier dismissable', (WidgetTester tester) async {
testWidgets('Barrier dismissible', (WidgetTester tester) async {
await tester.pumpWidget(
new MaterialApp(
home: new Material(
......@@ -175,7 +175,7 @@ void main() {
showDialog<Null>(
context: context,
barrierDismissable: false,
barrierDismissible: false,
child: new Container(
width: 100.0,
height: 100.0,
......
......@@ -16,8 +16,8 @@ Widget background;
Widget buildTest({ double startToEndThreshold }) {
return new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
Widget buildDismissableItem(int item) {
return new Dismissable(
Widget buildDismissibleItem(int item) {
return new Dismissible(
key: new ValueKey<int>(item),
direction: dismissDirection,
onDismissed: (DismissDirection direction) {
......@@ -49,7 +49,7 @@ Widget buildTest({ double startToEndThreshold }) {
itemExtent: itemExtent,
children: <int>[0, 1, 2, 3, 4]
.where((int i) => !dismissedItems.contains(i))
.map(buildDismissableItem).toList(),
.map(buildDismissibleItem).toList(),
),
);
},
......@@ -66,7 +66,7 @@ Future<Null> dismissElement(WidgetTester tester, Finder finder, { DismissDirecti
switch (gestureDirection) {
case DismissDirection.endToStart:
// getTopRight() returns a point that's just beyond itemWidget's right
// edge and outside the Dismissable event listener's bounds.
// edge and outside the Dismissible event listener's bounds.
downLocation = tester.getTopRight(finder) + const Offset(-0.1, 0.0);
upLocation = tester.getTopLeft(finder);
break;
......@@ -77,7 +77,7 @@ Future<Null> dismissElement(WidgetTester tester, Finder finder, { DismissDirecti
break;
case DismissDirection.up:
// getBottomLeft() returns a point that's just below itemWidget's bottom
// edge and outside the Dismissable event listener's bounds.
// edge and outside the Dismissible event listener's bounds.
downLocation = tester.getBottomLeft(finder) + const Offset(0.0, -0.1);
upLocation = tester.getTopLeft(finder);
break;
......@@ -111,14 +111,14 @@ Future<Null> dismissItem(WidgetTester tester, int item, { DismissDirection gestu
await tester.pump(); // rebuild after the callback removes the entry
}
class Test1215DismissableWidget extends StatelessWidget {
Test1215DismissableWidget(this.text);
class Test1215DismissibleWidget extends StatelessWidget {
Test1215DismissibleWidget(this.text);
final String text;
@override
Widget build(BuildContext context) {
return new Dismissable(
return new Dismissible(
key: new ObjectKey(text),
child: new AspectRatio(
aspectRatio: 1.0,
......@@ -236,7 +236,7 @@ void main() {
expect(dismissedItems, equals(<int>[0]));
});
testWidgets('drag-left has no effect on dismissable with a high dismiss threshold', (WidgetTester tester) async {
testWidgets('drag-left has no effect on dismissible with a high dismiss threshold', (WidgetTester tester) async {
scrollDirection = Axis.vertical;
dismissDirection = DismissDirection.horizontal;
......@@ -282,7 +282,7 @@ void main() {
// now-obsolete URL https://github.com/flutter/engine/issues/1215 (the URL
// died in the migration to the new repo). Don't copy this test; it doesn't
// actually remove the dismissed widget, which is a violation of the
// Dismissable contract. This is not an example of good practice.
// Dismissible contract. This is not an example of good practice.
testWidgets('dismissing bottom then top (smoketest)', (WidgetTester tester) async {
await tester.pumpWidget(new Center(
child: new Container(
......@@ -290,8 +290,8 @@ void main() {
height: 1000.0,
child: new Column(
children: <Widget>[
new Test1215DismissableWidget('1'),
new Test1215DismissableWidget('2'),
new Test1215DismissibleWidget('1'),
new Test1215DismissibleWidget('2'),
],
),
),
......@@ -310,7 +310,7 @@ void main() {
expect(find.text('2'), findsNothing);
});
testWidgets('Dismissable starts from the full size when collapsing', (WidgetTester tester) async {
testWidgets('Dismissible starts from the full size when collapsing', (WidgetTester tester) async {
scrollDirection = Axis.vertical;
dismissDirection = DismissDirection.horizontal;
background = new Text('background');
......
......@@ -28,7 +28,7 @@ void main() {
final Widget subject = new Stack(
children: <Widget>[
tapTarget,
new ModalBarrier(dismissable: false),
new ModalBarrier(dismissible: false),
]
);
......@@ -42,7 +42,7 @@ void main() {
testWidgets('ModalBarrier does not prevent interactions with widgets in front of it', (WidgetTester tester) async {
final Widget subject = new Stack(
children: <Widget>[
new ModalBarrier(dismissable: false),
new ModalBarrier(dismissible: false),
tapTarget,
]
);
......@@ -99,7 +99,7 @@ class SecondWidget extends StatelessWidget {
Widget build(BuildContext context) {
return new ModalBarrier(
key: const ValueKey<String>('barrier'),
dismissable: true
dismissible: true
);
}
}
......@@ -532,7 +532,7 @@
"fixedId": true,
"id": "libraries/35",
"name": "",
"uri": "package:flutter/src/widgets/dismissable.dart"
"uri": "package:flutter/src/widgets/dismissible.dart"
},
{
"type": "@Library",
......
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