106 lines
2.7 KiB
Dart
106 lines
2.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
BoxDecoration buildBoxDecoration() {
|
|
return BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(12),
|
|
border: Border.all(color: Colors.grey[200]!, width: 1),
|
|
);
|
|
}
|
|
|
|
class BuildCard extends StatelessWidget {
|
|
final Widget? child;
|
|
|
|
const BuildCard({super.key, this.child});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final colors = Theme.of(context).colorScheme;
|
|
|
|
return Container(
|
|
decoration: BoxDecoration(
|
|
color: colors.surface,
|
|
borderRadius: BorderRadius.circular(12),
|
|
border: Border.all(color: colors.outline.withAlpha(50), width: 1),
|
|
),
|
|
padding: const EdgeInsets.all(16),
|
|
child: child,
|
|
);
|
|
}
|
|
}
|
|
|
|
void buildModalBottom({
|
|
required BuildContext context,
|
|
required String title,
|
|
required Widget body,
|
|
}) {
|
|
showModalBottomSheet(
|
|
context: context,
|
|
isScrollControlled: true,
|
|
backgroundColor: Colors.transparent,
|
|
builder: (BuildContext context) {
|
|
return GestureDetector(
|
|
onTap: () => Navigator.of(context).pop(),
|
|
child: Container(
|
|
color: Color.fromRGBO(0, 0, 0, 0.001),
|
|
child: GestureDetector(
|
|
onTap: () {},
|
|
child: DraggableScrollableSheet(
|
|
initialChildSize: 0.6,
|
|
minChildSize: 0.4,
|
|
maxChildSize: 0.9,
|
|
builder: (_, controller) {
|
|
return Container(
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.only(
|
|
topLeft: Radius.circular(24),
|
|
topRight: Radius.circular(24),
|
|
),
|
|
),
|
|
child: buildModalBottomBody(context, title, body),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
Widget buildModalBottomBody(BuildContext context, String title, Widget body) {
|
|
return Column(
|
|
children: [
|
|
// 拖拽指示条
|
|
Container(
|
|
margin: EdgeInsets.only(top: 12, bottom: 4),
|
|
width: 48,
|
|
height: 4,
|
|
decoration: BoxDecoration(
|
|
color: Colors.grey[400],
|
|
borderRadius: BorderRadius.circular(2),
|
|
),
|
|
),
|
|
|
|
// 标题栏
|
|
Padding(
|
|
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Text(
|
|
title,
|
|
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w700),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
|
|
Divider(height: 1, thickness: 1),
|
|
|
|
Expanded(child: Padding(padding: EdgeInsets.all(12), child: body)),
|
|
],
|
|
);
|
|
}
|