1
This commit is contained in:
80
lib/page/plan/detail/navigation/bar_actions.dart
Normal file
80
lib/page/plan/detail/navigation/bar_actions.dart
Normal file
@@ -0,0 +1,80 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:plan/api/endpoints/plan_api.dart';
|
||||
import 'package:plan/widgets/ui_kit/popup/popup_action.dart';
|
||||
import 'package:remixicon/remixicon.dart';
|
||||
|
||||
import '../../widgets/edit_desc_dialog.dart';
|
||||
import '../viewmodel/plan_detail_store.dart';
|
||||
|
||||
class BarActions extends StatefulWidget {
|
||||
final PlanDetailStore store;
|
||||
|
||||
const BarActions({super.key, required this.store});
|
||||
|
||||
@override
|
||||
State<BarActions> createState() => _BarActionsState();
|
||||
}
|
||||
|
||||
class _BarActionsState extends State<BarActions> {
|
||||
///popup菜单
|
||||
void _onPopupActionSelected(String value) {
|
||||
if (value == 'edit_step') {
|
||||
widget.store.setEdit(true);
|
||||
} else if (value == 'edit_desc') {
|
||||
showEditDescDialog(
|
||||
context,
|
||||
value: widget.store.planDetail.summary ?? "",
|
||||
onConfirm: (value) async {
|
||||
widget.store.updatePlanDetail((dto) {
|
||||
dto.summary = value;
|
||||
});
|
||||
await editPlanSummaryApi(int.parse(widget.store.planId), value);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
///取消编辑
|
||||
void _cancelEdit() {
|
||||
widget.store.setEdit(false);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min, // 关键:Row 只占实际内容宽度
|
||||
children: [
|
||||
AnimatedSwitcher(
|
||||
duration: Duration(milliseconds: 300),
|
||||
transitionBuilder: (child, animation) {
|
||||
// 仅使用渐变动画
|
||||
return FadeTransition(
|
||||
opacity: animation,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
child: widget.store.isEdit
|
||||
? InkWell(
|
||||
onTap: _cancelEdit,
|
||||
child: Icon(RemixIcons.check_fill),
|
||||
)
|
||||
: PopupAction(
|
||||
onSelected: _onPopupActionSelected,
|
||||
items: [
|
||||
PopupMenuItem(
|
||||
value: 'edit_step',
|
||||
child: Text("编辑步骤"),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'edit_desc',
|
||||
child: Text("编辑摘要"),
|
||||
),
|
||||
],
|
||||
child: Icon(RemixIcons.more_fill),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user