66 lines
1.6 KiB
Dart
66 lines
1.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
import 'type.dart';
|
|
|
|
class ActionSheetUi extends StatelessWidget {
|
|
final List<ActionSheetItem> actions;
|
|
final bool showCancel;
|
|
final double actionHeight = 50;
|
|
final Function(ActionSheetItem) onConfirm;
|
|
|
|
const ActionSheetUi({
|
|
super.key,
|
|
required this.actions,
|
|
this.showCancel = false,
|
|
required this.onConfirm,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SizedBox(
|
|
width: double.infinity,
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
...actions.map((item) {
|
|
return InkWell(
|
|
onTap: () {
|
|
onConfirm(item);
|
|
context.pop();
|
|
},
|
|
child: Container(
|
|
height: actionHeight,
|
|
alignment: Alignment.center,
|
|
child: Text(item.title),
|
|
),
|
|
);
|
|
}),
|
|
Visibility(
|
|
visible: showCancel,
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
width: double.infinity,
|
|
height: 8,
|
|
color: const Color.fromRGBO(238, 239, 243, 1.0),
|
|
),
|
|
InkWell(
|
|
onTap: () {
|
|
context.pop();
|
|
},
|
|
child: Container(
|
|
height: actionHeight,
|
|
alignment: Alignment.center,
|
|
child: const Text("取消"),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|