1
This commit is contained in:
48
lib/page/plan/widgets/edit_desc_dialog.dart
Normal file
48
lib/page/plan/widgets/edit_desc_dialog.dart
Normal file
@@ -0,0 +1,48 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
void showEditDescDialog(
|
||||
BuildContext context, {
|
||||
String value = "",
|
||||
required void Function(String) onConfirm,
|
||||
}) {
|
||||
final controller = TextEditingController(text: value);
|
||||
final focusNode = FocusNode();
|
||||
showCupertinoDialog(
|
||||
context: context,
|
||||
builder: (_) {
|
||||
// 确保弹窗显示后再获取焦点
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
focusNode.requestFocus();
|
||||
});
|
||||
|
||||
return CupertinoAlertDialog(
|
||||
title: Text("编辑摘要"),
|
||||
content: Padding(
|
||||
padding: EdgeInsets.only(top: 15),
|
||||
child: CupertinoTextField(
|
||||
controller: controller,
|
||||
focusNode: focusNode,
|
||||
placeholder: "edit...",
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
},
|
||||
child: Text('取消'),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
isDefaultAction: true,
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
onConfirm(controller.text);
|
||||
},
|
||||
child: Text('确认'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user