forked from mcrovero/rubber
-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.dart
81 lines (72 loc) · 1.9 KB
/
menu.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import 'package:flutter/material.dart';
import 'package:rubber/rubber.dart';
class MenuPage extends StatefulWidget {
MenuPage({Key key}) : super(key: key);
@override
_MenuPageState createState() => _MenuPageState();
}
class _MenuPageState extends State<MenuPage>
with SingleTickerProviderStateMixin {
RubberAnimationController _controller;
@override
void initState() {
_controller = RubberAnimationController(
vsync: this,
dismissable: true,
lowerBoundValue: AnimationControllerValue(pixel: 100),
upperBoundValue: AnimationControllerValue(pixel: 400),
duration: Duration(milliseconds: 200),
);
super.initState();
}
void _expand() {
print("expand");
_controller.launchTo(_controller.value, _controller.upperBound,
velocity: 2);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
"Menu",
style: TextStyle(color: Colors.cyan[900]),
),
),
body: Container(
child: RubberBottomSheet(
lowerLayer: _getLowerLayer(),
upperLayer: _getUpperLayer(),
menuLayer: _getMenuLayer(),
animationController: _controller,
),
),
floatingActionButton: FloatingActionButton(
heroTag: "flt3",
onPressed: _expand,
backgroundColor: Colors.cyan[900],
foregroundColor: Colors.cyan[400],
child: Icon(Icons.vertical_align_top),
),
);
}
Widget _getLowerLayer() {
return Container(
decoration: BoxDecoration(color: Colors.cyan[100]),
);
}
Widget _getUpperLayer() {
return Container(
decoration: BoxDecoration(color: Colors.cyan),
);
}
Widget _getMenuLayer() {
return Container(
height: 100,
child: Center(
child: Text("MENU"),
),
decoration: BoxDecoration(color: Colors.red),
);
}
}