bar_bottom_sheet.dart
3.73 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
122
123
124
125
126
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 kDefaultBarTopRadius = Radius.circular(15);
class BarBottomSheet extends StatelessWidget {
final Widget child;
final Widget? control;
final Clip? clipBehavior;
final Color? backgroundColor;
final double? elevation;
final ShapeBorder? shape;
final SystemUiOverlayStyle? overlayStyle;
const BarBottomSheet({
Key? key,
required this.child,
this.control,
this.clipBehavior,
this.shape,
this.backgroundColor,
this.elevation,
this.overlayStyle,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return AnnotatedRegion<SystemUiOverlayStyle>(
value: overlayStyle ?? 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: kDefaultBarTopRadius,
topRight: kDefaultBarTopRadius),
),
clipBehavior: clipBehavior ?? Clip.hardEdge,
color: backgroundColor ?? Colors.white,
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 WidgetBuilder builder,
Color? backgroundColor,
double? elevation,
ShapeBorder? shape,
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,
RouteSettings? settings,
SystemUiOverlayStyle? overlayStyle,
double? closeProgressThreshold,
}) async {
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,
backgroundColor: backgroundColor,
elevation: elevation,
overlayStyle: overlayStyle,
),
secondAnimationController: secondAnimation,
expanded: expand,
barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
isDismissible: isDismissible,
modalBarrierColor: barrierColor,
enableDrag: enableDrag,
animationCurve: animationCurve,
duration: duration,
settings: settings,
));
return result;
}