This commit is contained in:
zhutao
2025-09-09 14:07:38 +08:00
parent 71aa4a6790
commit 900dc025d7
24 changed files with 383 additions and 91 deletions

View File

@@ -94,6 +94,7 @@ class _AvatarCardState extends State<AvatarCard> with SingleTickerProviderStateM
child: Stack(
children: [
Container(
width: double.infinity,
padding: EdgeInsets.all(4),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(3),
@@ -119,7 +120,7 @@ class _AvatarCardState extends State<AvatarCard> with SingleTickerProviderStateM
child: Stack(
alignment: Alignment.bottomCenter,
children: [
Image.asset("assets/image/xiaozhi.png", height: 100),
Image.asset("assets/image/kbn.png", height: 100),
Positioned(
top: 20,
child: Transform.translate(

View File

@@ -21,7 +21,7 @@ class _CoachMessageState extends State<CoachMessage> {
child: Column(
children: [
Text(
"你的教练正在拆分",
"Organizing your plan…",
style: Theme.of(context).textTheme.bodyMedium,
),
Text(

View File

@@ -10,6 +10,8 @@ import 'package:plan/widgets/business/delete_row_item.dart';
import 'package:provider/provider.dart';
import 'package:remixicon/remixicon.dart';
import '../other/edit_popup.dart';
class PlanList extends StatefulWidget {
const PlanList({super.key});
@@ -30,7 +32,7 @@ class _PlanListState extends State<PlanList> {
dto.stepsList = dto.stepsList.where((element) => element.id != id).toList();
});
await editPlanStepApi(
int.parse(store.planId),
store.planId,
act: PlanActionType.delete,
stepId: id,
);
@@ -42,37 +44,56 @@ class _PlanListState extends State<PlanList> {
store.updatePlanDetail((dto) {
dto.stepsList = list;
});
await editPlanStepOrderApi(int.parse(store.planId), list);
await editPlanStepOrderApi(store.planId, list);
}
///确认完成或者取消
void _handComplete(int id) async {
void _handComplete(PlanStepDto newStep) async {
HapticFeedback.vibrate();
var store = context.read<PlanDetailStore>();
newStep.stepStatus = newStep.stepStatus == 2 ? 0 : 2;
//更新数据
store.updateStep(newStep);
//接口更新
editPlanStepApi(
store.planId,
act: PlanActionType.complete,
stepId: newStep.id,
);
}
store.updatePlanDetail((dto) {
dto.stepsList = dto.stepsList.map((step) {
if (step.id == id) {
// 只更新匹配的项
step.stepStatus = step.stepStatus == 2 ? 0 : 2;
editPlanStepApi(
int.parse(store.planId),
act: PlanActionType.complete,
stepId: id,
);
}
return step;
}).toList();
});
///打开编辑
void _handEditDialog(PlanStepDto step) {
showModalBottomSheet(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (_) {
return EditPopup(
step: step,
onEdit: (newStep) {
var store = context.read<PlanDetailStore>();
store.updateStep(newStep);
// 接口
editPlanStepApi(
store.planId,
act: PlanActionType.edit,
stepId: newStep.id,
content: newStep.stepContent,
explain: newStep.stepExplain,
);
},
);
},
);
}
@override
Widget build(BuildContext context) {
final isEdit = context.select<PlanDetailStore, bool>((s) => s.isEdit);
return Selector<PlanDetailStore, List<String>>(
selector: (_, store) => store.planDetail.stepsList
.map((e) => '${e.id}_${e.stepExplain}_${e.stepStatus}')
.toList(),
selector: (_, store) =>
store.planDetail.stepsList.map((e) => e.toJson().toString()).toList(),
builder: (context, list, _) {
final list = context.read<PlanDetailStore>().planDetail.stepsList;
return AnimatedReorderableListView(
@@ -87,6 +108,7 @@ class _PlanListState extends State<PlanList> {
isEdit: isEdit,
onDelete: _handDelete,
onComplete: _handComplete,
onEdit: _handEditDialog,
);
},
enterTransition: [SlideInDown()],
@@ -116,7 +138,8 @@ class PlanItem extends StatelessWidget {
final PlanStepDto step;
final bool isEdit;
final Function(int) onDelete;
final Function(int) onComplete;
final Function(PlanStepDto) onComplete;
final Function(PlanStepDto) onEdit;
const PlanItem({
super.key,
@@ -124,6 +147,7 @@ class PlanItem extends StatelessWidget {
this.isEdit = false,
required this.onDelete,
required this.onComplete,
required this.onEdit,
});
@override
@@ -131,7 +155,7 @@ class PlanItem extends StatelessWidget {
return GestureDetector(
onTap: () {
if (!isEdit) {
onComplete(step.id!);
onComplete(step);
}
},
child: Container(
@@ -184,12 +208,17 @@ class PlanItem extends StatelessWidget {
SizeTransition(
axis: Axis.horizontal,
sizeFactor: animate,
child: Container(
alignment: Alignment.center,
margin: EdgeInsets.only(left: 10),
child: Opacity(
opacity: 0.4,
child: Icon(RemixIcons.menu_line),
child: GestureDetector(
onTap: () {
onEdit(step);
},
child: Container(
alignment: Alignment.center,
margin: EdgeInsets.only(left: 10),
child: Opacity(
opacity: 0.4,
child: Icon(RemixIcons.edit_box_line),
),
),
),
),

View File

@@ -37,7 +37,7 @@ class SuggestedTitle extends StatelessWidget {
color: Theme.of(context).colorScheme.surfaceContainerHigh,
),
Text(
"额外建议",
"Additional Suggestions",
style: Theme.of(context).textTheme.titleSmall,
),
Container(