基本完成除了详情

This commit is contained in:
zhutao
2025-09-04 10:16:11 +08:00
commit 4d12f8afc2
110 changed files with 4729 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:remixicon/remixicon.dart';
class PlanDetailPage extends StatefulWidget {
const PlanDetailPage({super.key});
@override
State<PlanDetailPage> createState() => _PlanDetailPageState();
}
class _PlanDetailPageState extends State<PlanDetailPage> {
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
backgroundColor: Colors.white,
navigationBar: CupertinoNavigationBar(
middle: Text('计划详情'),
trailing: Row(
mainAxisSize: MainAxisSize.min, // 关键Row 只占实际内容宽度
children: [
Icon(RemixIcons.more_fill),
],
),
),
child: Column(),
);
}
}

View File

@@ -0,0 +1,112 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'widgets/history_item.dart';
import 'widgets/popup_action.dart';
class PlanHistoryPage extends StatefulWidget {
const PlanHistoryPage({super.key});
@override
State<PlanHistoryPage> createState() => _PlanHistoryPageState();
}
class _PlanHistoryPageState extends State<PlanHistoryPage> {
///是否显示删除
bool _isDelete = false;
///刷新
Future<void> _onRefresh() async {
//模拟网络请求
await Future.delayed(Duration(milliseconds: 1000));
//结束刷新
return Future.value(true);
}
///popup事件
void _onPopupActionSelected(String value) {
switch (value) {
case 'edit':
setState(() {
_isDelete = !_isDelete;
});
break;
}
}
///确认删除
void _confirmDelete(int id) {}
@override
Widget build(BuildContext context) {
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),
),
),
],
),
),
),
child: SafeArea(
child: CustomScrollView(
physics: AlwaysScrollableScrollPhysics(
parent: BouncingScrollPhysics(),
),
slivers: <Widget>[
//下拉刷新组件
CupertinoSliverRefreshControl(
onRefresh: _onRefresh,
),
//列表
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.all(15),
child: Container(
padding: EdgeInsets.symmetric(horizontal: 15),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
),
child: CustomScrollView(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
slivers: [
SliverList.separated(
itemBuilder: (BuildContext context, int index) {
return HistoryItem(
showDelete: _isDelete,
onDelete: _confirmDelete,
);
},
separatorBuilder: (BuildContext context, int index) {
return Divider(
height: 1,
color: Theme.of(context).colorScheme.surfaceContainer,
);
},
itemCount: 5,
),
],
),
),
),
),
],
),
),
);
}
}

View File

@@ -0,0 +1,161 @@
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:remixicon/remixicon.dart';
class HistoryItem extends StatefulWidget {
final bool showDelete;
final Function(int) onDelete;
const HistoryItem({
super.key,
this.showDelete = false,
required this.onDelete,
});
@override
State<HistoryItem> createState() => _HistoryItemState();
}
class _HistoryItemState extends State<HistoryItem> with TickerProviderStateMixin {
late AnimationController _controller;
late Animation<double> _animation;
@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);
}
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: _goDetail,
child: Container(
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,
),
),
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,
),
],
),
),
);
}
}

View File

@@ -0,0 +1,32 @@
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),
);
}
}