bar_bottom_sheet.dart
3.52 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../../modal_bottom_sheet.dart';
import '../bottom_sheet_route.dart';
const Radius _default_bar_top_radius = Radius.circular(15);
class BarBottomSheet extends StatelessWidget {
final Widget child;
final Widget control;
final Clip clipBehavior;
final double elevation;
final ShapeBorder shape;
const BarBottomSheet(
{Key key,
this.child,
this.control,
this.clipBehavior,
this.shape,
this.elevation})
: super(key: key);
@override
Widget build(BuildContext context) {
return AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle.light,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(height: 12),
SafeArea(
bottom: false,
child: control ??
Container(
height: 6,
width: 40,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(6)),
),
),
SizedBox(height: 8),
Flexible(
flex: 1,
fit: FlexFit.loose,
child: Material(
shape: shape ?? RoundedRectangleBorder(
side: BorderSide(),
borderRadius: BorderRadius.only(
topLeft: _default_bar_top_radius,
topRight: _default_bar_top_radius),
),
clipBehavior: clipBehavior ?? Clip.hardEdge,
elevation: elevation ?? 2,
child: SizedBox(
width: double.infinity,
child: MediaQuery.removePadding(
context: context, removeTop: true, child: child),
),
),
),
]),
);
}
}
Future<T> showBarModalBottomSheet<T>({
@required BuildContext context,
@required ScrollWidgetBuilder builder,
Color backgroundColor,
double elevation,
ShapeBorder shape,
double closeProgressThreshold,
Clip clipBehavior,
Color barrierColor = Colors.black87,
bool bounce = true,
bool expand = false,
AnimationController secondAnimation,
Curve animationCurve,
bool useRootNavigator = false,
bool isDismissible = true,
bool enableDrag = true,
Widget topControl,
Duration duration,
}) async {
assert(context != null);
assert(builder != null);
assert(expand != null);
assert(useRootNavigator != null);
assert(isDismissible != null);
assert(enableDrag != null);
assert(debugCheckHasMediaQuery(context));
assert(debugCheckHasMaterialLocalizations(context));
final result = await Navigator.of(context, rootNavigator: useRootNavigator)
.push(ModalBottomSheetRoute<T>(
builder: builder,
bounce: bounce,
closeProgressThreshold: closeProgressThreshold,
containerBuilder: (_, __, child) => BarBottomSheet(
child: child,
control: topControl,
clipBehavior: clipBehavior,
shape: shape,
elevation: elevation,
),
secondAnimationController: secondAnimation,
expanded: expand,
barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
isDismissible: isDismissible,
modalBarrierColor: barrierColor,
enableDrag: enableDrag,
animationCurve: animationCurve,
duration: duration,
));
return result;
}