Skip to content

Commit b7f09fe

Browse files
authored
Merge pull request #41 from FlutterOpen/dev
add the GestureDetector, Dismissible widget.
2 parents 4614ffe + 1a196e7 commit b7f09fe

File tree

6 files changed

+105
-1
lines changed

6 files changed

+105
-1
lines changed

lib/const/page_item_const.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,4 +257,14 @@ const PAGE_ITEMS = [
257257
"img": PageImage.FLUTTER_OPEN,
258258
"click": PageName.INTER_DRAG,
259259
},
260+
{
261+
"title": PageName.INTER_GESTURE,
262+
"img": PageImage.FLUTTER_OPEN,
263+
"click": PageName.INTER_GESTURE,
264+
},
265+
{
266+
"title": PageName.INTER_DISMISSIBLE,
267+
"img": PageImage.FLUTTER_OPEN,
268+
"click": PageName.INTER_DISMISSIBLE,
269+
},
260270
];

lib/const/page_name_const.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,6 @@ class PageName {
5656
static const ANIM_PYH_MODEL = "PyhModel";
5757
static const ANIM_OPACITY = "OpacityPage";
5858
static const INTER_DRAG = "Draggable";
59+
static const INTER_GESTURE = "Gesture";
60+
static const INTER_DISMISSIBLE = "Dismissible";
5961
}

lib/main.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ class FlutterOpenApp extends StatelessWidget {
7070
PageName.ANIM_PYH_MODEL: (context) => PyhModelPage(),
7171
PageName.ANIM_OPACITY: (context) => AnimOpacityPage(),
7272
PageName.INTER_DRAG: (context) => DraggablePage(),
73+
PageName.INTER_GESTURE: (context) => GesturePage(),
74+
PageName.INTER_DISMISSIBLE: (context) => DismissiblePage(),
7375
},
7476
);
7577
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
///
2+
/// Created by NieBin on 2019/6/12
3+
/// Github: https://github.com/nb312
4+
/// Email: niebin312@gmail.com
5+
///
6+
import "package:flutter/material.dart";
7+
import "package:flutter_widgets/const/_const.dart";
8+
9+
class DismissiblePage extends StatefulWidget {
10+
@override
11+
_DismissibleState createState() => _DismissibleState();
12+
}
13+
14+
class _DismissibleState extends State<DismissiblePage> {
15+
var _key = GlobalKey();
16+
17+
@override
18+
Widget build(BuildContext context) {
19+
return Scaffold(
20+
appBar: AppBar(
21+
title: Text(PageName.INTER_DISMISSIBLE),
22+
),
23+
body: Dismissible(
24+
key: _key,
25+
child: Container(
26+
constraints: BoxConstraints.expand(height: 100),
27+
alignment: Alignment.center,
28+
child: Text(
29+
"Hello",
30+
style: TextStyle(color: TEXT_BLACK, fontSize: 20),
31+
),
32+
color: BLUE,
33+
),
34+
background: Container(
35+
color: RED_LIGHT,
36+
constraints: BoxConstraints.expand(height: 100, width: 40),
37+
alignment: Alignment.center,
38+
child: Text(
39+
"Remove",
40+
style: TextStyle(color: TEXT_BLACK_LIGHT, fontSize: 10),
41+
),
42+
),
43+
direction: DismissDirection.startToEnd,
44+
onDismissed: (direction) {
45+
print("Dissmiss");
46+
_key.currentState.dispose();
47+
}),
48+
);
49+
}
50+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
///
2+
/// Created by NieBin on 2019/6/12
3+
/// Github: https://github.com/nb312
4+
/// Email: niebin312@gmail.com
5+
6+
import "package:flutter/material.dart";
7+
import "package:flutter_widgets/const/_const.dart";
8+
9+
class GesturePage extends StatefulWidget {
10+
@override
11+
_GestureState createState() => _GestureState();
12+
}
13+
14+
class _GestureState extends State<GesturePage> {
15+
Widget _gesture(context) => GestureDetector(
16+
child: Text("You can tab me then look the log."),
17+
onTap: () {
18+
print("Hello world");
19+
Scaffold.of(context).showSnackBar(
20+
SnackBar(
21+
content: Text("You have click me."),
22+
),
23+
);
24+
},
25+
);
26+
27+
@override
28+
Widget build(BuildContext context) {
29+
return Scaffold(
30+
appBar: AppBar(
31+
title: Text(PageName.INTER_GESTURE),
32+
),
33+
body: Builder(
34+
builder: (context) => _gesture(context),
35+
),
36+
);
37+
}
38+
}

lib/page/interation/_interaction.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
/// Github: https://github.com/nb312
44
/// Email: niebin312@gmail.com
55
///
6-
export "DraggablePage.dart";
6+
export "DraggablePage.dart";
7+
export "GesturePage.dart";
8+
export "DismissiblePage.dart";

0 commit comments

Comments
 (0)