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.dart index 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 { } 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.dart index 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 { 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 { 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.dart index 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 { : 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.dart index 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 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); @override State createState() => _ChecklistProgressBarState(); @@ -15,16 +22,45 @@ class ChecklistProgressBar extends StatefulWidget { class _ChecklistProgressBarState extends State { @override Widget 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.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(