1
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:plan/api/endpoints/plan_api.dart';
|
||||
import 'package:plan/data/models/plan_acttion_type.dart';
|
||||
import 'package:plan/page/plan/detail/viewmodel/plan_detail_store.dart';
|
||||
@@ -18,6 +19,11 @@ class _FooterBtnState extends State<FooterBtn> {
|
||||
void _toggleAllDone() {
|
||||
final store = context.read<PlanDetailStore>();
|
||||
final allDone = store.planDetail.stepsList.every((item) => item.stepStatus == 2);
|
||||
//如果是新增,再点击会首页
|
||||
if (store.isNew && allDone) {
|
||||
context.pop();
|
||||
return;
|
||||
}
|
||||
//刷新ui
|
||||
store.updatePlanDetail((dto) {
|
||||
dto.stepsList = store.planDetail.stepsList.map((item) {
|
||||
@@ -38,6 +44,12 @@ class _FooterBtnState extends State<FooterBtn> {
|
||||
bool oneDone = store.planDetail.stepsList.any((item) => item.stepStatus == 2);
|
||||
//是否全部完成
|
||||
bool allDone = store.planDetail.stepsList.every((item) => item.stepStatus == 2);
|
||||
//按钮文字
|
||||
var btnText = allDone ? "Try again" : "All done!";
|
||||
if (store.isNew && allDone) {
|
||||
btnText = "add new plan";
|
||||
}
|
||||
|
||||
return AnimatedSize(
|
||||
duration: Duration(milliseconds: 300),
|
||||
child: Container(
|
||||
@@ -77,7 +89,7 @@ class _FooterBtnState extends State<FooterBtn> {
|
||||
),
|
||||
),
|
||||
Text(
|
||||
allDone ? "Try again" : "All done!",
|
||||
btnText,
|
||||
style: TextStyle(fontWeight: FontWeight.w700),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -13,6 +13,7 @@ class PlanDetailStore extends ChangeNotifier {
|
||||
}) {
|
||||
//如果没有id进行初始化
|
||||
if (planId == 0) {
|
||||
isNew = true;
|
||||
createPlan();
|
||||
} else {
|
||||
//获取详情
|
||||
@@ -36,6 +37,9 @@ class PlanDetailStore extends ChangeNotifier {
|
||||
///计划的内容,只有新增时才会有
|
||||
String planContent = "";
|
||||
|
||||
///是否是新增
|
||||
bool isNew = false;
|
||||
|
||||
///计划id
|
||||
int planId;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user