Files
plan_flutter/lib/page/plan/detail/other/bar_actions.dart
2025-09-09 14:07:38 +08:00

80 lines
2.2 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:flutter/material.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(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("Edit Steps"),
),
PopupMenuItem(
value: 'edit_desc',
child: Text("Edit Summary"),
),
],
child: Icon(RemixIcons.more_fill),
),
),
],
);
}
}