Skip to content

Commit bda16b1

Browse files
committed
chore: replace Popover with Appflowy style popover and fix some bugs
1 parent c493ba7 commit bda16b1

File tree

8 files changed

+51
-67
lines changed

8 files changed

+51
-67
lines changed

frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_cell.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:app_flowy/plugins/grid/application/field/field_service.dart';
33
import 'package:appflowy_popover/popover.dart';
44
import 'package:flowy_infra/image.dart';
55
import 'package:flowy_infra/theme.dart';
6+
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
67
import 'package:flowy_infra_ui/style_widget/button.dart';
78
import 'package:flowy_infra_ui/style_widget/hover.dart';
89
import 'package:flowy_infra_ui/style_widget/text.dart';
@@ -29,7 +30,8 @@ class GridFieldCell extends StatelessWidget {
2930
},
3031
child: BlocBuilder<FieldCellBloc, FieldCellState>(
3132
builder: (context, state) {
32-
final button = Popover(
33+
final button = AppFlowyStylePopover(
34+
constraints: BoxConstraints.loose(const Size(240, 840)),
3335
direction: PopoverDirection.bottomWithLeftAligned,
3436
triggerActions: PopoverTriggerActionFlags.click,
3537
offset: const Offset(0, 10),

frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_cell_action_sheet.dart

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import 'package:app_flowy/plugins/grid/presentation/widgets/header/field_editor.
33
import 'package:app_flowy/startup/startup.dart';
44
import 'package:app_flowy/plugins/grid/application/prelude.dart';
55
import 'package:app_flowy/workspace/presentation/widgets/dialogs.dart';
6+
import 'package:appflowy_popover/popover.dart';
67
import 'package:flowy_infra/image.dart';
78
import 'package:flowy_infra/theme.dart';
8-
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
99
import 'package:flowy_infra_ui/style_widget/button.dart';
1010
import 'package:flowy_infra_ui/style_widget/text.dart';
1111
import 'package:flowy_infra_ui/widget/spacing.dart';
@@ -32,38 +32,32 @@ class _GridFieldCellActionSheetState extends State<GridFieldCellActionSheet> {
3232
Widget build(BuildContext context) {
3333
if (_showFieldEditor) {
3434
final field = widget.cellContext.field;
35-
return OverlayContainer(
36-
constraints: BoxConstraints.loose(const Size(240, 200)),
37-
child: FieldEditor(
35+
return FieldEditor(
36+
gridId: widget.cellContext.gridId,
37+
fieldName: field.name,
38+
typeOptionLoader: FieldTypeOptionLoader(
3839
gridId: widget.cellContext.gridId,
39-
fieldName: field.name,
40-
typeOptionLoader: FieldTypeOptionLoader(
41-
gridId: widget.cellContext.gridId,
42-
field: field,
43-
),
40+
field: field,
4441
),
4542
);
4643
}
4744
return BlocProvider(
4845
create: (context) =>
4946
getIt<FieldActionSheetBloc>(param1: widget.cellContext),
50-
child: OverlayContainer(
51-
constraints: BoxConstraints.loose(const Size(240, 200)),
52-
child: SingleChildScrollView(
53-
child: Column(
54-
children: [
55-
_EditFieldButton(
56-
cellContext: widget.cellContext,
57-
onTap: () {
58-
setState(() {
59-
_showFieldEditor = true;
60-
});
61-
},
62-
),
63-
const VSpace(6),
64-
_FieldOperationList(widget.cellContext, () {}),
65-
],
66-
),
47+
child: SingleChildScrollView(
48+
child: Column(
49+
children: [
50+
_EditFieldButton(
51+
cellContext: widget.cellContext,
52+
onTap: () {
53+
setState(() {
54+
_showFieldEditor = true;
55+
});
56+
},
57+
),
58+
const VSpace(6),
59+
_FieldOperationList(widget.cellContext, () {}),
60+
],
6761
),
6862
),
6963
);
@@ -159,17 +153,22 @@ class FieldActionCell extends StatelessWidget {
159153
Widget build(BuildContext context) {
160154
final theme = context.watch<AppTheme>();
161155
return FlowyButton(
162-
text: FlowyText.medium(action.title(),
163-
fontSize: 12, color: enable ? null : theme.shader4),
156+
text: FlowyText.medium(
157+
action.title(),
158+
fontSize: 12,
159+
color: enable ? null : theme.shader4,
160+
),
164161
hoverColor: theme.hover,
165162
onTap: () {
166163
if (enable) {
167164
action.run(context);
168165
onTap();
169166
}
170167
},
171-
leftIcon: svgWidget(action.iconName(),
172-
color: enable ? theme.iconColor : theme.disableIconColor),
168+
leftIcon: svgWidget(
169+
action.iconName(),
170+
color: enable ? theme.iconColor : theme.disableIconColor,
171+
),
173172
);
174173
}
175174
}
@@ -216,6 +215,7 @@ extension _FieldActionExtension on FieldAction {
216215
.add(const FieldActionSheetEvent.duplicateField());
217216
break;
218217
case FieldAction.delete:
218+
PopoverContainer.of(context).close();
219219
NavigatorAlertDialog(
220220
title: LocaleKeys.grid_field_deleteFieldPromptMessage.tr(),
221221
confirm: () {

frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_editor.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class _FieldEditorState extends State<FieldEditor> {
7070
),
7171
const VSpace(10),
7272
_FieldNameTextField(popoverMutex: popoverMutex),
73+
const VSpace(10),
7374
..._addDeleteFieldButton(state),
7475
_FieldTypeOptionCell(popoverMutex: popoverMutex),
7576
],
@@ -84,7 +85,6 @@ class _FieldEditorState extends State<FieldEditor> {
8485
return [];
8586
}
8687
return [
87-
const VSpace(10),
8888
_DeleteFieldButton(
8989
popoverMutex: popoverMutex,
9090
onDeleted: () {

frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_type_list.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ class FieldTypeList extends StatelessWidget with FlowyOverlayDelegate {
4747
),
4848
);
4949
}
50-
51-
static String identifier() {
52-
return (FieldTypeList).toString();
53-
}
5450
}
5551

5652
class FieldTypeCell extends StatelessWidget {

frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/date.dart

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class DateTypeOptionWidget extends TypeOptionWidget {
7575
context
7676
.read<DateTypeOptionBloc>()
7777
.add(DateTypeOptionEvent.didSelectDateFormat(format));
78-
PopoverContainer.of(popoverContext).closeAll();
78+
PopoverContainer.of(popoverContext).close();
7979
},
8080
);
8181
},
@@ -97,7 +97,7 @@ class DateTypeOptionWidget extends TypeOptionWidget {
9797
context
9898
.read<DateTypeOptionBloc>()
9999
.add(DateTypeOptionEvent.didSelectTimeFormat(format));
100-
PopoverContainer.of(popoverContext).closeAll();
100+
PopoverContainer.of(popoverContext).close();
101101
},
102102
);
103103
},
@@ -201,12 +201,10 @@ class DateFormatList extends StatelessWidget {
201201
Widget build(BuildContext context) {
202202
final cells = DateFormat.values.map((format) {
203203
return DateFormatCell(
204-
dateFormat: format,
205-
onSelected: (format) {
206-
onSelected(format);
207-
FlowyOverlay.of(context).remove(DateFormatList.identifier());
208-
},
209-
isSelected: selectedFormat == format);
204+
dateFormat: format,
205+
onSelected: onSelected,
206+
isSelected: selectedFormat == format,
207+
);
210208
}).toList();
211209

212210
return SizedBox(
@@ -224,10 +222,6 @@ class DateFormatList extends StatelessWidget {
224222
),
225223
);
226224
}
227-
228-
static String identifier() {
229-
return (DateFormatList).toString();
230-
}
231225
}
232226

233227
class DateFormatCell extends StatelessWidget {
@@ -291,12 +285,10 @@ class TimeFormatList extends StatelessWidget {
291285
Widget build(BuildContext context) {
292286
final cells = TimeFormat.values.map((format) {
293287
return TimeFormatCell(
294-
isSelected: format == selectedFormat,
295-
timeFormat: format,
296-
onSelected: (format) {
297-
onSelected(format);
298-
FlowyOverlay.of(context).remove(TimeFormatList.identifier());
299-
});
288+
isSelected: format == selectedFormat,
289+
timeFormat: format,
290+
onSelected: onSelected,
291+
);
300292
}).toList();
301293

302294
return SizedBox(
@@ -314,10 +306,6 @@ class TimeFormatList extends StatelessWidget {
314306
),
315307
);
316308
}
317-
318-
static String identifier() {
319-
return (TimeFormatList).toString();
320-
}
321309
}
322310

323311
class TimeFormatCell extends StatelessWidget {

frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/number.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class NumberTypeOptionWidget extends TypeOptionWidget {
8282
context
8383
.read<NumberTypeOptionBloc>()
8484
.add(NumberTypeOptionEvent.didSelectFormat(format));
85-
PopoverContainer.of(popoverContext).closeAll();
85+
PopoverContainer.of(popoverContext).close();
8686
},
8787
selectedFormat: state.typeOption.format,
8888
);
@@ -145,10 +145,6 @@ class NumberFormatList extends StatelessWidget {
145145
),
146146
);
147147
}
148-
149-
static String identifier() {
150-
return (NumberFormatList).toString();
151-
}
152148
}
153149

154150
class NumberFormatCell extends StatelessWidget {

frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/select_option.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,13 @@ class _OptionCellState extends State<_OptionCell> {
207207
context
208208
.read<SelectOptionTypeOptionBloc>()
209209
.add(SelectOptionTypeOptionEvent.deleteOption(widget.option));
210-
PopoverContainer.of(popoverContext).closeAll();
210+
PopoverContainer.of(popoverContext).close();
211211
},
212212
onUpdated: (updatedOption) {
213213
context
214214
.read<SelectOptionTypeOptionBloc>()
215215
.add(SelectOptionTypeOptionEvent.updateOption(updatedOption));
216-
PopoverContainer.of(popoverContext).closeAll();
216+
PopoverContainer.of(popoverContext).close();
217217
},
218218
key: ValueKey(widget.option.id),
219219
);

frontend/app_flowy/lib/plugins/grid/presentation/widgets/toolbar/grid_property.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,10 @@ class _GridPropertyCell extends StatelessWidget {
131131
return FieldEditor(
132132
gridId: gridId,
133133
fieldName: fieldContext.name,
134-
typeOptionLoader:
135-
FieldTypeOptionLoader(gridId: gridId, field: fieldContext.field),
134+
typeOptionLoader: FieldTypeOptionLoader(
135+
gridId: gridId,
136+
field: fieldContext.field,
137+
),
136138
);
137139
},
138140
);

0 commit comments

Comments
 (0)