1
This commit is contained in:
@@ -9,7 +9,9 @@ import 'package:remixicon/remixicon.dart';
|
||||
import '../widgets/edit_desc_dialog.dart';
|
||||
import 'widgets/avatar_card.dart';
|
||||
import 'widgets/coach_message.dart';
|
||||
import 'widgets/plan_list.dart';
|
||||
import 'widgets/scroll_box.dart';
|
||||
import 'widgets/suggested.dart';
|
||||
|
||||
class PlanDetailPage extends StatefulWidget {
|
||||
final String? id;
|
||||
@@ -27,6 +29,20 @@ class PlanDetailPage extends StatefulWidget {
|
||||
|
||||
class _PlanDetailPageState extends State<PlanDetailPage> {
|
||||
bool _isEdit = false;
|
||||
final ScrollController scrollController = ScrollController();
|
||||
|
||||
///store对象
|
||||
late PlanDetailStore store;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
store = PlanDetailStore(
|
||||
planId: widget.id.toString(),
|
||||
planContent: widget.planName ?? "",
|
||||
scrollController: scrollController,
|
||||
);
|
||||
}
|
||||
|
||||
///popup菜单
|
||||
void _onPopupActionSelected(String value) {
|
||||
@@ -54,51 +70,9 @@ class _PlanDetailPageState extends State<PlanDetailPage> {
|
||||
Widget build(BuildContext context) {
|
||||
return ChangeNotifierProvider<PlanDetailStore>(
|
||||
create: (_) {
|
||||
return PlanDetailStore(
|
||||
planId: widget.id.toString(),
|
||||
planContent: widget.planName ?? "",
|
||||
showRoleTalk: widget.planName == null,
|
||||
);
|
||||
return store;
|
||||
},
|
||||
child: CupertinoPageScaffold(
|
||||
backgroundColor: Colors.white,
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
middle: Text('计划详情'),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min, // 关键:Row 只占实际内容宽度
|
||||
children: [
|
||||
AnimatedSwitcher(
|
||||
duration: Duration(milliseconds: 300),
|
||||
transitionBuilder: (child, animation) {
|
||||
// 仅使用渐变动画
|
||||
return FadeTransition(
|
||||
opacity: animation,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
child: _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),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
child: Consumer<PlanDetailStore>(
|
||||
child: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
@@ -110,33 +84,12 @@ class _PlanDetailPageState extends State<PlanDetailPage> {
|
||||
child: Container(
|
||||
decoration: shadowDecoration,
|
||||
child: CustomScrollView(
|
||||
controller: scrollController,
|
||||
slivers: [
|
||||
CoachMessage(),
|
||||
// SliverToBoxAdapter(
|
||||
// child: SizedBox(height: 20),
|
||||
// ),
|
||||
// SliverList.builder(
|
||||
// itemBuilder: (BuildContext context, int index) {
|
||||
// return PlanItem(
|
||||
// showEdit: _isEdit,
|
||||
// title: "测试 ${index + 1}",
|
||||
// desc: "测测 ${index + 1}",
|
||||
// onDelete: (id) {},
|
||||
// );
|
||||
// },
|
||||
// itemCount: 10,
|
||||
// ),
|
||||
// SliverToBoxAdapter(
|
||||
// child: SuggestedTitle(),
|
||||
// ),
|
||||
// SliverList.builder(
|
||||
// itemBuilder: (BuildContext context, int index) {
|
||||
// return SuggestedItem(
|
||||
// title: "测试",
|
||||
// );
|
||||
// },
|
||||
// itemCount: 5,
|
||||
// ),
|
||||
PlanList(),
|
||||
SuggestedTitle(),
|
||||
SuggestedList(),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -146,6 +99,49 @@ class _PlanDetailPageState extends State<PlanDetailPage> {
|
||||
],
|
||||
),
|
||||
),
|
||||
builder: (context, store, child) {
|
||||
return CupertinoPageScaffold(
|
||||
backgroundColor: Colors.white,
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
middle: Text(store.planDetail.summary ?? ""),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min, // 关键:Row 只占实际内容宽度
|
||||
children: [
|
||||
AnimatedSwitcher(
|
||||
duration: Duration(milliseconds: 300),
|
||||
transitionBuilder: (child, animation) {
|
||||
// 仅使用渐变动画
|
||||
return FadeTransition(
|
||||
opacity: animation,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
child: _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),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
child: child!,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user