1
This commit is contained in:
@@ -2,7 +2,8 @@ enum PlanActionType {
|
|||||||
delete(1), //删除
|
delete(1), //删除
|
||||||
complete(2), //完成
|
complete(2), //完成
|
||||||
edit(3), //编辑
|
edit(3), //编辑
|
||||||
completeAll(99); //全部完成
|
completeAll(99), //全部完成
|
||||||
|
cancelAll(88); //全部未完成
|
||||||
|
|
||||||
final int value;
|
final int value;
|
||||||
|
|
||||||
|
|||||||
92
lib/page/plan/detail/other/footer_btn.dart
Normal file
92
lib/page/plan/detail/other/footer_btn.dart
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.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';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:remixicon/remixicon.dart';
|
||||||
|
|
||||||
|
class FooterBtn extends StatefulWidget {
|
||||||
|
const FooterBtn({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<FooterBtn> createState() => _FooterBtnState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _FooterBtnState extends State<FooterBtn> {
|
||||||
|
///切换全部完成、或者全部不完成
|
||||||
|
void _toggleAllDone() {
|
||||||
|
final store = context.read<PlanDetailStore>();
|
||||||
|
final allDone = store.planDetail.stepsList.every((item) => item.stepStatus == 2);
|
||||||
|
//刷新ui
|
||||||
|
store.updatePlanDetail((dto) {
|
||||||
|
dto.stepsList = store.planDetail.stepsList.map((item) {
|
||||||
|
return item.copyWith(stepStatus: allDone ? 0 : 2);
|
||||||
|
}).toList();
|
||||||
|
});
|
||||||
|
//接口
|
||||||
|
editPlanStepApi(
|
||||||
|
store.planId,
|
||||||
|
act: allDone ? PlanActionType.cancelAll : PlanActionType.completeAll,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Consumer<PlanDetailStore>(
|
||||||
|
builder: (context, store, _) {
|
||||||
|
bool oneDone = store.planDetail.stepsList.any((item) => item.stepStatus == 2);
|
||||||
|
//是否全部完成
|
||||||
|
bool allDone = store.planDetail.stepsList.every((item) => item.stepStatus == 2);
|
||||||
|
return AnimatedSize(
|
||||||
|
duration: Duration(milliseconds: 300),
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.symmetric(vertical: 10, horizontal: 15),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border(
|
||||||
|
top: BorderSide(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainerLow,
|
||||||
|
// color: CupertinoColors.,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
height: oneDone ? null : 0,
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: _toggleAllDone,
|
||||||
|
child: Container(
|
||||||
|
height: 45,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(5),
|
||||||
|
color: Colors.white,
|
||||||
|
border: Border.all(color: Colors.black),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
spacing: 10,
|
||||||
|
children: [
|
||||||
|
Visibility(
|
||||||
|
visible: !allDone,
|
||||||
|
replacement: Icon(
|
||||||
|
CupertinoIcons.refresh_circled,
|
||||||
|
size: 20,
|
||||||
|
),
|
||||||
|
child: Icon(
|
||||||
|
CupertinoIcons.checkmark_circle_fill,
|
||||||
|
color: Colors.green,
|
||||||
|
size: 20,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
allDone ? "Try again" : "All done!",
|
||||||
|
style: TextStyle(fontWeight: FontWeight.w700),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import 'package:plan/theme/decorations/app_shadows.dart';
|
|||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import 'other/bar_actions.dart';
|
import 'other/bar_actions.dart';
|
||||||
|
import 'other/footer_btn.dart';
|
||||||
import 'widgets/avatar_card.dart';
|
import 'widgets/avatar_card.dart';
|
||||||
import 'widgets/coach_message.dart';
|
import 'widgets/coach_message.dart';
|
||||||
import 'widgets/plan_list.dart';
|
import 'widgets/plan_list.dart';
|
||||||
@@ -27,7 +28,6 @@ class PlanDetailPage extends StatefulWidget {
|
|||||||
|
|
||||||
class _PlanDetailPageState extends State<PlanDetailPage> {
|
class _PlanDetailPageState extends State<PlanDetailPage> {
|
||||||
final ScrollController scrollController = ScrollController();
|
final ScrollController scrollController = ScrollController();
|
||||||
|
|
||||||
///store对象
|
///store对象
|
||||||
late PlanDetailStore store;
|
late PlanDetailStore store;
|
||||||
|
|
||||||
@@ -54,10 +54,13 @@ class _PlanDetailPageState extends State<PlanDetailPage> {
|
|||||||
AvatarCard(),
|
AvatarCard(),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(15),
|
padding: EdgeInsets.only(left: 15, right: 15, bottom: 1),
|
||||||
child: ScrollBox(
|
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: shadowDecoration,
|
decoration: shadowDecoration,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: ScrollBox(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
CoachMessage(),
|
CoachMessage(),
|
||||||
@@ -68,6 +71,10 @@ class _PlanDetailPageState extends State<PlanDetailPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
FooterBtn()
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -100,7 +100,11 @@ class _AvatarCardState extends State<AvatarCard> with SingleTickerProviderStateM
|
|||||||
borderRadius: BorderRadius.circular(3),
|
borderRadius: BorderRadius.circular(3),
|
||||||
border: Border.all(color: Colors.black, width: 1),
|
border: Border.all(color: Colors.black, width: 1),
|
||||||
),
|
),
|
||||||
child: Text(_dialog, style: TextStyle(fontSize: 12)),
|
child: Text(
|
||||||
|
_dialog,
|
||||||
|
style: TextStyle(fontSize: 12),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
@@ -200,11 +204,11 @@ class BothSizeTransition extends StatelessWidget {
|
|||||||
animation: animation,
|
animation: animation,
|
||||||
builder: (_, child) {
|
builder: (_, child) {
|
||||||
return Align(
|
return Align(
|
||||||
alignment: Alignment(0.7, 1),
|
alignment: Alignment(0.3, 1),
|
||||||
child: Opacity(
|
child: Opacity(
|
||||||
opacity: animation.value,
|
opacity: animation.value,
|
||||||
child: Transform(
|
child: Transform(
|
||||||
alignment: Alignment(0.5, 1),
|
alignment: Alignment(0, 1),
|
||||||
transform: Matrix4.identity()
|
transform: Matrix4.identity()
|
||||||
..translate(
|
..translate(
|
||||||
offset.dx * (1 - animation.value),
|
offset.dx * (1 - animation.value),
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ class ScrollBox extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
child: Scrollbar(
|
child: Scrollbar(
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
|
physics: const BouncingScrollPhysics(),
|
||||||
child: child,
|
child: child,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
///阴影卡片
|
///阴影卡片
|
||||||
final shadowDecoration = BoxDecoration(
|
final shadowDecoration = BoxDecoration(
|
||||||
border: Border.all(color: Colors.black, width: 2),
|
border: Border.all(color: Colors.black, width: 1.5),
|
||||||
borderRadius: BorderRadius.circular(5),
|
borderRadius: BorderRadius.circular(5),
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
boxShadow: const [
|
boxShadow: const [
|
||||||
|
|||||||
Reference in New Issue
Block a user