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:
@@ -162,9 +162,9 @@ class DemoList extends Component {
|
||||
}
|
||||
|
||||
Widget buildDemo(SkyDemo demo) {
|
||||
return new Listener(
|
||||
return new GestureDetector(
|
||||
key: demo.key,
|
||||
onGestureTap: (_) => launch(demo.href, demo.bundle),
|
||||
onTap: () => launch(demo.href, demo.bundle),
|
||||
child: new Container(
|
||||
height: kCardHeight,
|
||||
child: new Card(
|
||||
|
||||
@@ -39,11 +39,8 @@ class DialogMenuItem extends ButtonBase {
|
||||
}
|
||||
|
||||
Widget buildContent() {
|
||||
return new Listener(
|
||||
onGestureTap: (_) {
|
||||
if (onPressed != null)
|
||||
onPressed();
|
||||
},
|
||||
return new GestureDetector(
|
||||
onTap: onPressed,
|
||||
child: new Container(
|
||||
height: 48.0,
|
||||
child: new InkWell(
|
||||
|
||||
@@ -56,10 +56,9 @@ class MealFragment extends StatefulComponent {
|
||||
|
||||
String _description = "";
|
||||
|
||||
EventDisposition _handleSave() {
|
||||
void _handleSave() {
|
||||
onCreated(new Meal(when: new DateTime.now(), description: _description));
|
||||
navigator.pop();
|
||||
return EventDisposition.processed;
|
||||
}
|
||||
|
||||
Widget buildToolBar() {
|
||||
@@ -69,8 +68,8 @@ class MealFragment extends StatefulComponent {
|
||||
onPressed: navigator.pop),
|
||||
center: new Text('New Meal'),
|
||||
right: [new InkWell(
|
||||
child: new Listener(
|
||||
onGestureTap: (_) => _handleSave(),
|
||||
child: new GestureDetector(
|
||||
onTap: _handleSave,
|
||||
child: new Text('SAVE')
|
||||
)
|
||||
)]
|
||||
|
||||
@@ -119,7 +119,7 @@ class MeasurementFragment extends StatefulComponent {
|
||||
DateTime _when = new DateTime.now();
|
||||
String _errorMessage = null;
|
||||
|
||||
EventDisposition _handleSave() {
|
||||
void _handleSave() {
|
||||
double parsedWeight;
|
||||
try {
|
||||
parsedWeight = double.parse(_weight);
|
||||
@@ -128,11 +128,9 @@ class MeasurementFragment extends StatefulComponent {
|
||||
setState(() {
|
||||
_errorMessage = "Save failed";
|
||||
});
|
||||
return EventDisposition.processed;
|
||||
}
|
||||
onCreated(new Measurement(when: _when, weight: parsedWeight));
|
||||
navigator.pop();
|
||||
return EventDisposition.processed;
|
||||
}
|
||||
|
||||
Widget buildToolBar() {
|
||||
@@ -142,8 +140,8 @@ class MeasurementFragment extends StatefulComponent {
|
||||
onPressed: navigator.pop),
|
||||
center: new Text('New Measurement'),
|
||||
right: [new InkWell(
|
||||
child: new Listener(
|
||||
onGestureTap: (_) => _handleSave(),
|
||||
child: new GestureDetector(
|
||||
onTap: _handleSave,
|
||||
child: new Text('SAVE')
|
||||
)
|
||||
)]
|
||||
@@ -158,7 +156,7 @@ class MeasurementFragment extends StatefulComponent {
|
||||
|
||||
static final GlobalKey weightKey = new GlobalKey();
|
||||
|
||||
EventDisposition _handleDatePressed(_) {
|
||||
void _handleDatePressed() {
|
||||
showDialog(navigator, (navigator) {
|
||||
return new MeasurementDateDialog(navigator: navigator, previousDate: _when);
|
||||
}).then((DateTime value) {
|
||||
@@ -168,7 +166,6 @@ class MeasurementFragment extends StatefulComponent {
|
||||
_when = value;
|
||||
});
|
||||
});
|
||||
return EventDisposition.processed;
|
||||
}
|
||||
|
||||
Widget buildBody() {
|
||||
@@ -179,8 +176,8 @@ class MeasurementFragment extends StatefulComponent {
|
||||
child: new Container(
|
||||
padding: const EdgeDims.all(20.0),
|
||||
child: new Column([
|
||||
new Listener(
|
||||
onGestureTap: _handleDatePressed,
|
||||
new GestureDetector(
|
||||
onTap: _handleDatePressed,
|
||||
child: new Container(
|
||||
height: 50.0,
|
||||
child: new Column([
|
||||
|
||||
@@ -107,19 +107,19 @@ class MineDiggerApp extends App {
|
||||
state = cells[iy][ix] ? CellState.shown : state;
|
||||
}
|
||||
if (state == CellState.covered) {
|
||||
row.add(new Listener(
|
||||
onPointerDown: _pointerDownHandlerFor(ix, iy),
|
||||
onGestureTap: (_) {
|
||||
probe(ix, iy);
|
||||
},
|
||||
onGestureLongPress: (_) {
|
||||
row.add(new GestureDetector(
|
||||
onTap: () => probe(ix, iy),
|
||||
onLongPress: () {
|
||||
activity.userFeedback.performHapticFeedback(activity.HapticFeedbackType_LONG_PRESS);
|
||||
flag(ix, iy);
|
||||
},
|
||||
child: new CoveredMineNode(
|
||||
flagged: false,
|
||||
posX: ix,
|
||||
posY: iy
|
||||
child: new Listener(
|
||||
onPointerDown: _pointerDownHandlerFor(ix, iy),
|
||||
child: new CoveredMineNode(
|
||||
flagged: false,
|
||||
posX: ix,
|
||||
posY: iy
|
||||
)
|
||||
)
|
||||
));
|
||||
// Mutating |hasCoveredCell| here is hacky, but convenient, same
|
||||
|
||||
@@ -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