自习室优化ok

This commit is contained in:
zhutao
2025-11-28 13:31:23 +08:00
parent 4ecb0c35d6
commit 57305c5804
57 changed files with 2500 additions and 597 deletions

View 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,
);
},
);
}

View 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("取消"),
),
),
],
),
),
],
),
);
}
}

View 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,
});
}

View File

@@ -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,