This commit is contained in:
zhutao
2025-09-04 17:57:35 +08:00
parent 4d12f8afc2
commit 0231dcfe1a
34 changed files with 1339 additions and 368 deletions

View File

@@ -1,8 +1,9 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:remixicon/remixicon.dart';
import 'widgets/history_item.dart';
import 'widgets/popup_action.dart';
import '../../../widgets/ui_kit/popup/popup_action.dart';
class PlanHistoryPage extends StatefulWidget {
const PlanHistoryPage({super.key});
@@ -42,22 +43,19 @@ class _PlanHistoryPageState extends State<PlanHistoryPage> {
return CupertinoPageScaffold(
backgroundColor: Theme.of(context).colorScheme.surfaceContainer,
navigationBar: CupertinoNavigationBar(
middle: Text("计划历史"),
trailing: CupertinoNavigationBar(
transitionBetweenRoutes: false,
middle: const Text("计划历史"),
trailing: PopupAction(
onSelected: _onPopupActionSelected,
items: [
PopupMenuItem(
value: 'edit',
child: Text(
_isDelete ? "完成" : "编辑",
style: TextStyle(color: Colors.black),
),
middle: const Text("计划历史"),
trailing: PopupAction(
onSelected: _onPopupActionSelected,
items: [
PopupMenuItem(
value: 'edit',
child: Text(
_isDelete ? "完成" : "编辑",
style: TextStyle(color: Colors.black),
),
],
),
),
],
child: Icon(RemixIcons.more_fill),
),
),
child: SafeArea(

View File

@@ -1,7 +1,7 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:plan/router/config/route_paths.dart';
import 'package:plan/widgets/business/delete_row_item.dart';
import 'package:remixicon/remixicon.dart';
class HistoryItem extends StatefulWidget {
@@ -18,76 +18,15 @@ class HistoryItem extends StatefulWidget {
State<HistoryItem> createState() => _HistoryItemState();
}
class _HistoryItemState extends State<HistoryItem> with TickerProviderStateMixin {
late AnimationController _controller;
late Animation<double> _animation;
class _HistoryItemState extends State<HistoryItem> {
@override
void initState() {
super.initState();
_controller = AnimationController(
vsync: this,
duration: Duration(milliseconds: 300),
);
_animation = CurvedAnimation(
parent: _controller,
curve: Curves.easeInOut,
);
if (widget.showDelete) {
_controller.forward();
}
}
@override
void didUpdateWidget(covariant HistoryItem oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.showDelete != widget.showDelete) {
if (widget.showDelete) {
_controller.forward();
} else {
_controller.reverse();
}
}
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
///点击删除
void _handleDelete() {
showCupertinoDialog(
context: context,
builder: (_) {
return CupertinoAlertDialog(
title: Text("删除计划"),
actions: [
CupertinoDialogAction(
child: Text("取消"),
onPressed: () {
context.pop();
},
),
CupertinoDialogAction(
isDestructiveAction: true,
onPressed: () {
context.pop();
widget.onDelete(0);
},
child: Text("确定"),
),
],
);
},
);
}
///跳转详情
void _goDetail() {
context.push(RoutePaths.planDetail);
context.push(RoutePaths.planDetail(1));
}
@override
@@ -98,62 +37,53 @@ class _HistoryItemState extends State<HistoryItem> with TickerProviderStateMixin
width: double.infinity,
padding: EdgeInsets.symmetric(vertical: 15),
color: Colors.white,
child: Row(
children: [
SizeTransition(
axis: Axis.horizontal,
sizeFactor: _animation,
axisAlignment: -1, // 从左向右展开
child: InkWell(
onTap: _handleDelete,
child: Container(
margin: EdgeInsets.only(right: 10),
child: Icon(
RemixIcons.indeterminate_circle_fill,
color: Colors.red,
),
),
),
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
margin: EdgeInsets.only(bottom: 5),
child: Text("开始学习软件开发"),
),
Container(
margin: EdgeInsets.only(bottom: 5),
child: Text(
"创建于 2025/9/3 9:40:51 教练:W教练",
style: Theme.of(context).textTheme.labelSmall,
child: DeleteRowItem(
showDelete: widget.showDelete,
onDelete: () {
widget.onDelete(0);
},
builder: (_, __) {
return [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
margin: EdgeInsets.only(bottom: 5),
child: Text("开始学习软件开发"),
),
),
Row(
spacing: 10,
children: [
Expanded(
child: LinearProgressIndicator(
value: 0.5,
borderRadius: BorderRadius.circular(5),
),
),
Text(
"0/7",
Container(
margin: EdgeInsets.only(bottom: 5),
child: Text(
"创建于 2025/9/3 9:40:51 教练:W教练",
style: Theme.of(context).textTheme.labelSmall,
),
],
),
],
),
Row(
spacing: 10,
children: [
Expanded(
child: LinearProgressIndicator(
value: 0.5,
borderRadius: BorderRadius.circular(5),
),
),
Text(
"0/7",
style: Theme.of(context).textTheme.labelSmall,
),
],
),
],
),
),
),
Icon(
RemixIcons.arrow_right_s_line,
size: 30,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
],
Icon(
RemixIcons.arrow_right_s_line,
size: 30,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
];
},
),
),
);

View File

@@ -1,32 +0,0 @@
import 'package:flutter/material.dart';
import 'package:remixicon/remixicon.dart';
class PopupAction extends StatelessWidget {
final List<PopupMenuEntry<String>> items;
final Function(String) onSelected;
const PopupAction({
super.key,
required this.items,
required this.onSelected,
});
@override
Widget build(BuildContext context) {
return PopupMenuButton<String>(
color: Colors.white,
offset: Offset(0, 30),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12), // 圆角
),
constraints: BoxConstraints(
minWidth: 200,
),
elevation: 6,
shadowColor: Colors.black87,
onSelected:onSelected,
itemBuilder: (context) => items,
child: const Icon(RemixIcons.more_fill),
);
}
}