Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
feat: segmented checklist progress bar (#3770)
Shreesh Nautiyalc2eb2014a3e9
diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/cells/checklist_card_cell.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/cells/checklist_card_cell.dartindex 2d1deb0055..4e3e50c237 100644--- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/cells/checklist_card_cell.dart+++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/cells/checklist_card_cell.dart@@ -38,7 +38,10 @@ class _ChecklistCellState extends State<ChecklistCardCell> {}return Padding(padding: const EdgeInsets.symmetric(vertical: 4),- child: ChecklistProgressBar(percent: state.percent),+ child: ChecklistProgressBar(+ tasks: state.tasks,+ percent: state.percent,+ ),);},),diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checklist_cell/checklist_cell.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checklist_cell/checklist_cell.dartindex dce1ec7382..6bb070735d 100644--- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checklist_cell/checklist_cell.dart+++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checklist_cell/checklist_cell.dart@@ -94,7 +94,10 @@ class GridChecklistCellState extends GridCellState<GridChecklistCell> {mainAxisSize: MainAxisSize.min,children: [Flexible(- child: ChecklistProgressBar(percent: state.percent),+ child: ChecklistProgressBar(+ tasks: state.tasks,+ percent: state.percent,+ ),),const HSpace(6.0),FlowyIconButton(@@ -154,7 +157,10 @@ class GridChecklistCellState extends GridCellState<GridChecklistCell> {widget.cellStyle.placeholder,color: Theme.of(context).hintColor,)- : ChecklistProgressBar(percent: state.percent),+ : ChecklistProgressBar(+ tasks: state.tasks,+ percent: state.percent,+ ),),),);diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checklist_cell/checklist_cell_editor.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checklist_cell/checklist_cell_editor.dartindex fd388d93bf..9db75375cb 100644--- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checklist_cell/checklist_cell_editor.dart+++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checklist_cell/checklist_cell_editor.dart@@ -69,6 +69,7 @@ class _GridChecklistCellState extends State<GridChecklistCellEditor> {: Padding(padding: const EdgeInsets.fromLTRB(16, 16, 16, 4),child: ChecklistProgressBar(+ tasks: state.tasks,percent: state.percent,),),diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checklist_cell/checklist_progress_bar.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checklist_cell/checklist_progress_bar.dartindex 289d84b25b..6e66eb5d6b 100644--- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checklist_cell/checklist_progress_bar.dart+++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checklist_cell/checklist_progress_bar.dart@@ -2,11 +2,18 @@ import 'package:flowy_infra/theme_extension.dart';import 'package:flowy_infra_ui/flowy_infra_ui.dart';import 'package:flutter/material.dart';import 'package:percent_indicator/percent_indicator.dart';+import 'checklist_cell_bloc.dart';class ChecklistProgressBar extends StatefulWidget {+ final List<ChecklistSelectOption> tasks;final double percent;- const ChecklistProgressBar({required this.percent, Key? key})- : super(key: key);+ final int segmentLimit = 5;++ const ChecklistProgressBar({+ required this.tasks,+ required this.percent,+ Key? key,+ }) : super(key: key);@overrideState<ChecklistProgressBar> createState() => _ChecklistProgressBarState();@@ -15,16 +22,45 @@ class ChecklistProgressBar extends StatefulWidget {class _ChecklistProgressBarState extends State<ChecklistProgressBar> {@overrideWidget build(BuildContext context) {+ final int finishedTasks = widget.tasks.where((e) => e.isSelected).length;+return Row(children: [Expanded(- child: LinearPercentIndicator(- lineHeight: 4.0,- percent: widget.percent,- padding: EdgeInsets.zero,- progressColor: Theme.of(context).colorScheme.primary,- backgroundColor: AFThemeExtension.of(context).progressBarBGColor,- barRadius: const Radius.circular(5),+ child: Row(+ children: [+ if (widget.tasks.isNotEmpty &&+ widget.tasks.length <= widget.segmentLimit)+ ...List<Widget>.generate(+ widget.tasks.length,+ (index) => Flexible(+ child: Container(+ decoration: BoxDecoration(+ borderRadius:+ const BorderRadius.all(Radius.circular(5)),+ color: index < finishedTasks+ ? Theme.of(context).colorScheme.primary+ : AFThemeExtension.of(context).progressBarBGColor,+ ),+ margin: const EdgeInsets.symmetric(horizontal: 1),+ height: 4.0,+ ),+ ),+ )+ else ...[+ Expanded(+ child: LinearPercentIndicator(+ lineHeight: 4.0,+ percent: widget.percent,+ padding: EdgeInsets.zero,+ progressColor: Theme.of(context).colorScheme.primary,+ backgroundColor:+ AFThemeExtension.of(context).progressBarBGColor,+ barRadius: const Radius.circular(5),+ ),+ ),+ ]+ ],),),SizedBox(