feat:更新菜谱表单
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'index.dart';
|
||||
|
||||
/// 通用输入框样式
|
||||
InputDecoration buildInputDecoration({
|
||||
required BuildContext context,
|
||||
@@ -87,40 +89,19 @@ Widget buildFormButtonGroup({
|
||||
|
||||
/// 取消按钮
|
||||
Widget _buildCancelButton(BuildContext context) {
|
||||
return ElevatedButton(
|
||||
onPressed: () => Navigator.pop(context), // 直接使用传入的context返回
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||
foregroundColor: const Color(0xFF4E5969),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||
elevation: 0,
|
||||
),
|
||||
child: const Text('取消'),
|
||||
return buildInfoButton(
|
||||
context: context,
|
||||
text: '取消',
|
||||
onPressed: () => Navigator.pop(context),
|
||||
);
|
||||
}
|
||||
|
||||
/// 提交按钮
|
||||
Widget _buildSubmitButton(BuildContext context, VoidCallback onConfirm) {
|
||||
return ElevatedButton(
|
||||
onPressed: () => onConfirm(),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||
elevation: 0,
|
||||
),
|
||||
child: const Text('提交', style: TextStyle(color: Colors.white)),
|
||||
);
|
||||
return buildPrimaryButton(context: context, text: '提交', onPressed: onConfirm);
|
||||
}
|
||||
|
||||
/// 删除按钮
|
||||
Widget _buildDeleteButton(BuildContext context, VoidCallback onDelete) {
|
||||
return ElevatedButton(
|
||||
onPressed: () => onDelete(),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.red,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||
elevation: 0,
|
||||
),
|
||||
child: const Text('删除', style: TextStyle(color: Colors.white)),
|
||||
);
|
||||
return buildErrorButton(text: '删除', onPressed: onDelete);
|
||||
}
|
||||
|
||||
@@ -92,13 +92,50 @@ Widget buildTag(BuildContext context, String title) {
|
||||
);
|
||||
}
|
||||
|
||||
/// 确认按钮样式
|
||||
ButtonStyle primaryButtonStyle() {
|
||||
return ButtonStyle(
|
||||
backgroundColor: WidgetStateProperty.all(Colors.green),
|
||||
shape: WidgetStateProperty.all(
|
||||
RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||
Widget buildPrimaryButton({
|
||||
required BuildContext context,
|
||||
required String text,
|
||||
required VoidCallback onPressed,
|
||||
}) {
|
||||
return ElevatedButton(
|
||||
onPressed: () => onPressed(),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||
elevation: 0,
|
||||
),
|
||||
child: Text(text, style: TextStyle(color: Colors.white)),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildErrorButton({
|
||||
required String text,
|
||||
required VoidCallback onPressed,
|
||||
}) {
|
||||
return ElevatedButton(
|
||||
onPressed: () => onPressed(),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.red,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||
elevation: 0,
|
||||
),
|
||||
child: Text(text, style: TextStyle(color: Colors.white)),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildInfoButton({
|
||||
required BuildContext context,
|
||||
required String text,
|
||||
required VoidCallback onPressed,
|
||||
}) {
|
||||
return ElevatedButton(
|
||||
onPressed: () => onPressed(),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||
elevation: 0,
|
||||
),
|
||||
child: Text(text, style: TextStyle(color: Colors.white)),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user