forked from firka/flutter
Use GestureDetector in the framework and examples
We're now using it at the widget layer for everything except scrolling and flinging.
This commit is contained in:
@@ -41,13 +41,11 @@ class EnsureVisibleApp extends App {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
EventDisposition handleTap(Widget card, CardModel cardModel) {
|
||||
void handleTap(Widget card, CardModel cardModel) {
|
||||
ensureWidgetIsVisible(card, duration: const Duration(milliseconds: 200))
|
||||
.then((_) {
|
||||
setState(() { selectedCardModel = cardModel; });
|
||||
});
|
||||
|
||||
return EventDisposition.processed;
|
||||
}
|
||||
|
||||
Widget builder(int index) {
|
||||
@@ -63,9 +61,9 @@ class EnsureVisibleApp extends App {
|
||||
child: new Center(child: new Text(cardModel.label, style: style))
|
||||
)
|
||||
);
|
||||
return new Listener(
|
||||
return new GestureDetector(
|
||||
key: cardModel.key,
|
||||
onGestureTap: (_) { return handleTap(card, cardModel); },
|
||||
onTap: () => handleTap(card, cardModel),
|
||||
child: card
|
||||
);
|
||||
}
|
||||
|
||||
@@ -106,17 +106,15 @@ class MixedViewportApp extends App {
|
||||
Widget builder(int index) {
|
||||
if (index >= lengths.length)
|
||||
return null;
|
||||
return new Listener(
|
||||
return new GestureDetector(
|
||||
key: new Key.stringify(lengths[index]),
|
||||
onTap: () => removeBox(index),
|
||||
child: new Container(
|
||||
decoration: new BoxDecoration(
|
||||
backgroundColor: new Color((0xFF000000 + 0xFFFFFF * lengths[index] / kMaxLength).round())
|
||||
),
|
||||
height: lengths[index] + 12.0
|
||||
),
|
||||
onGestureTap: (_) {
|
||||
removeBox(index);
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -124,7 +122,4 @@ class MixedViewportApp extends App {
|
||||
|
||||
void main() {
|
||||
runApp(new MixedViewportApp());
|
||||
// scheduler.addPersistentFrameCallback((_) {
|
||||
// SkyBinding.instance.debugDumpRenderTree();
|
||||
// });
|
||||
}
|
||||
|
||||
@@ -46,8 +46,8 @@ class ExampleApp extends App {
|
||||
GlobalKey _overlay;
|
||||
|
||||
Widget _buildCard(CardData cardData) {
|
||||
return new Listener(
|
||||
onGestureTap: (_) {
|
||||
return new GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_overlay = cardData.key;
|
||||
});
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:sky' as sky;
|
||||
|
||||
import 'package:sky/animation/animation_performance.dart';
|
||||
import 'package:sky/animation/animated_value.dart';
|
||||
import 'package:sky/animation/curves.dart';
|
||||
@@ -28,7 +26,7 @@ class ProgressIndicatorApp extends App {
|
||||
);
|
||||
}
|
||||
|
||||
void handleTap(sky.GestureEvent event) {
|
||||
void handleTap() {
|
||||
if (valueAnimation.isAnimating)
|
||||
valueAnimation.stop();
|
||||
else
|
||||
@@ -73,8 +71,8 @@ class ProgressIndicatorApp extends App {
|
||||
}
|
||||
|
||||
Widget build() {
|
||||
Widget body = new Listener(
|
||||
onGestureTap: (e) { handleTap(e); },
|
||||
Widget body = new GestureDetector(
|
||||
onTap: handleTap,
|
||||
child: new Container(
|
||||
padding: const EdgeDims.symmetric(vertical: 12.0, horizontal: 8.0),
|
||||
decoration: new BoxDecoration(backgroundColor: Theme.of(this).cardColor),
|
||||
|
||||
Reference in New Issue
Block a user