自习室优化ok
This commit is contained in:
26
lib/widgets/base/actionSheet/action_sheet.dart
Normal file
26
lib/widgets/base/actionSheet/action_sheet.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'action_sheet_ui.dart';
|
||||
import 'type.dart';
|
||||
|
||||
void showActionSheet(
|
||||
BuildContext context, {
|
||||
required List<ActionSheetItem> actions,
|
||||
bool showCancel = false,
|
||||
required Function(ActionSheetItem) onConfirm,
|
||||
}) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
backgroundColor: Colors.white,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
builder: (context) {
|
||||
return ActionSheetUi(
|
||||
actions: actions,
|
||||
showCancel: showCancel,
|
||||
onConfirm: onConfirm,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
65
lib/widgets/base/actionSheet/action_sheet_ui.dart
Normal file
65
lib/widgets/base/actionSheet/action_sheet_ui.dart
Normal file
@@ -0,0 +1,65 @@
|
||||
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("取消"),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
18
lib/widgets/base/actionSheet/type.dart
Normal file
18
lib/widgets/base/actionSheet/type.dart
Normal file
@@ -0,0 +1,18 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// 底部弹窗类型
|
||||
class ActionSheetItem {
|
||||
String title; //标题
|
||||
int value;
|
||||
bool disabled; //是否禁用
|
||||
Color color; //选项颜色
|
||||
Widget? child;
|
||||
|
||||
ActionSheetItem({
|
||||
required this.title,
|
||||
this.value = 0,
|
||||
this.disabled = false,
|
||||
this.color = Colors.black,
|
||||
this.child,
|
||||
});
|
||||
}
|
||||
@@ -6,18 +6,20 @@ import '../config/config.dart';
|
||||
class Button extends StatelessWidget {
|
||||
final double? width;
|
||||
final String text;
|
||||
final TextStyle textStyle;
|
||||
final ThemeType type;
|
||||
final BorderRadius radius;
|
||||
final VoidCallback onPressed;
|
||||
final VoidCallback? onPressed;
|
||||
final bool loading;
|
||||
final bool disabled;
|
||||
|
||||
const Button({
|
||||
super.key,
|
||||
this.width,
|
||||
this.textStyle = const TextStyle(),
|
||||
this.radius = const BorderRadius.all(Radius.circular(80)),
|
||||
required this.text,
|
||||
required this.onPressed,
|
||||
this.onPressed,
|
||||
this.type = ThemeType.primary,
|
||||
this.loading = false,
|
||||
this.disabled = false,
|
||||
@@ -34,7 +36,7 @@ class Button extends StatelessWidget {
|
||||
};
|
||||
|
||||
return Opacity(
|
||||
opacity: disabled || loading ? 0.5 : 1,
|
||||
opacity: disabled || loading ? 0.5 : 1,
|
||||
child: Container(
|
||||
width: width,
|
||||
decoration: bgDecoration.copyWith(borderRadius: radius),
|
||||
@@ -62,7 +64,7 @@ class Button extends StatelessWidget {
|
||||
),
|
||||
Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
style: textStyle.copyWith(
|
||||
color: type != ThemeType.info ? Colors.white : Colors.black,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
|
||||
Reference in New Issue
Block a user