Skip to content

Commit 3cdd666

Browse files
committed
chore: config checklist cell
1 parent 1ba2998 commit 3cdd666

File tree

2 files changed

+92
-22
lines changed

2 files changed

+92
-22
lines changed

frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/checklist_cell/checklist_cell_editor.dart

Lines changed: 79 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_servic
22
import 'package:app_flowy/plugins/grid/application/cell/checklist_cell_editor_bloc.dart';
33
import 'package:app_flowy/plugins/grid/presentation/layout/sizes.dart';
44
import 'package:app_flowy/plugins/grid/presentation/widgets/cell/checklist_cell/checklist_prograss_bar.dart';
5+
import 'package:app_flowy/plugins/grid/presentation/widgets/header/type_option/select_option_editor.dart';
6+
import 'package:appflowy_popover/appflowy_popover.dart';
7+
import 'package:flowy_infra/image.dart';
8+
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
9+
import 'package:flowy_infra_ui/style_widget/icon_button.dart';
510
import 'package:flowy_infra_ui/style_widget/scrolling/styled_list.dart';
611
import 'package:flowy_infra_ui/widget/spacing.dart';
712
import 'package:flutter/material.dart';
@@ -41,6 +46,8 @@ class _GridChecklistCellEditorState extends State<GridChecklistCellEditor> {
4146
builder: (context, state) {
4247
final List<Widget> slivers = [
4348
const SliverChecklistPrograssBar(),
49+
SliverToBoxAdapter(
50+
child: Container(color: Colors.red, height: 2, width: 2100)),
4451
SliverToBoxAdapter(
4552
child: ListView.separated(
4653
controller: ScrollController(),
@@ -55,27 +62,92 @@ class _GridChecklistCellEditorState extends State<GridChecklistCellEditor> {
5562
),
5663
),
5764
];
58-
return CustomScrollView(
59-
shrinkWrap: true,
60-
slivers: slivers,
61-
controller: ScrollController(),
62-
physics: StyledScrollPhysics(),
65+
return Padding(
66+
padding: const EdgeInsets.symmetric(horizontal: 8),
67+
child: CustomScrollView(
68+
shrinkWrap: true,
69+
slivers: slivers,
70+
controller: ScrollController(),
71+
physics: StyledScrollPhysics(),
72+
),
6373
);
6474
},
6575
),
6676
);
6777
}
6878
}
6979

70-
class _ChecklistOptionCell extends StatelessWidget {
80+
class _ChecklistOptionCell extends StatefulWidget {
7181
final ChecklistSelectOption option;
7282
const _ChecklistOptionCell({
7383
required this.option,
7484
Key? key,
7585
}) : super(key: key);
7686

87+
@override
88+
State<_ChecklistOptionCell> createState() => _ChecklistOptionCellState();
89+
}
90+
91+
class _ChecklistOptionCellState extends State<_ChecklistOptionCell> {
92+
late PopoverController _popoverController;
93+
94+
@override
95+
void initState() {
96+
_popoverController = PopoverController();
97+
super.initState();
98+
}
99+
77100
@override
78101
Widget build(BuildContext context) {
79-
return Container(height: 20, width: 100, color: Colors.red);
102+
final icon = widget.option.isSelected
103+
? svgWidget('editor/editor_check')
104+
: svgWidget('editor/editor_uncheck');
105+
return _wrapPopover(
106+
SizedBox(
107+
height: GridSize.typeOptionItemHeight,
108+
child: Row(
109+
children: [
110+
icon,
111+
const HSpace(6),
112+
FlowyText(widget.option.data.name),
113+
const Spacer(),
114+
_disclosureButton(),
115+
],
116+
),
117+
),
118+
);
119+
}
120+
121+
Widget _disclosureButton() {
122+
return FlowyIconButton(
123+
width: 20,
124+
onPressed: () => _popoverController.show(),
125+
hoverColor: Colors.transparent,
126+
iconPadding: const EdgeInsets.fromLTRB(4, 4, 4, 4),
127+
icon: svgWidget(
128+
"editor/details",
129+
color: Theme.of(context).colorScheme.onSurface,
130+
),
131+
);
132+
}
133+
134+
Widget _wrapPopover(Widget child) {
135+
return AppFlowyPopover(
136+
controller: _popoverController,
137+
offset: const Offset(20, 0),
138+
asBarrier: true,
139+
constraints: BoxConstraints.loose(const Size(200, 300)),
140+
child: child,
141+
popupBuilder: (BuildContext popoverContext) {
142+
return SelectOptionTypeOptionEditor(
143+
option: widget.option.data,
144+
onDeleted: () {},
145+
onUpdated: (updatedOption) {},
146+
key: ValueKey(
147+
widget.option.data.id,
148+
), // Use ValueKey to refresh the UI, otherwise, it will remain the old value.
149+
);
150+
},
151+
);
80152
}
81153
}

frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/checklist_cell/checklist_prograss_bar.dart

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class ChecklistPrograssBar extends StatelessWidget {
1717
return LinearPercentIndicator(
1818
lineHeight: 10.0,
1919
percent: percent,
20+
padding: EdgeInsets.zero,
2021
progressColor: Theme.of(context).colorScheme.primary,
2122
backgroundColor: AFThemeExtension.of(context).tint9,
2223
barRadius: const Radius.circular(5),
@@ -54,21 +55,18 @@ class _SliverChecklistPrograssBarDelegate
5455
padding: const EdgeInsets.symmetric(vertical: 8.0),
5556
child: ChecklistPrograssBar(percent: state.percent),
5657
),
57-
Padding(
58-
padding: const EdgeInsets.all(8.0),
59-
child: FlowyTextField(
60-
hintText: LocaleKeys.grid_checklist_panelTitle.tr(),
61-
onChanged: (text) {
62-
context
63-
.read<ChecklistCellEditorBloc>()
64-
.add(ChecklistCellEditorEvent.filterOption(text));
65-
},
66-
onSubmitted: (text) {
67-
context
68-
.read<ChecklistCellEditorBloc>()
69-
.add(ChecklistCellEditorEvent.newOption(text));
70-
},
71-
),
58+
FlowyTextField(
59+
hintText: LocaleKeys.grid_checklist_panelTitle.tr(),
60+
onChanged: (text) {
61+
context
62+
.read<ChecklistCellEditorBloc>()
63+
.add(ChecklistCellEditorEvent.filterOption(text));
64+
},
65+
onSubmitted: (text) {
66+
context
67+
.read<ChecklistCellEditorBloc>()
68+
.add(ChecklistCellEditorEvent.newOption(text));
69+
},
7270
)
7371
],
7472
);

0 commit comments

Comments
 (0)