Skip to content

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.

refactor: PopoverContainerState -> PopoverContainer

Vincent Chan286781f5cc81
diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_type_list.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_type_list.dart
index 5ad8fbf553..0cb18d411b 100644
--- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_type_list.dart
+++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_type_list.dart
@@ -26,7 +26,7 @@ class FieldTypeList extends StatelessWidget with FlowyOverlayDelegate {
fieldType: fieldType,
onSelectField: (fieldType) {
onSelectField(fieldType);
- PopoverContainerState.of(context).closeAll();
+ PopoverContainer.of(context).closeAll();
},
);
}).toList();
diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/date.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/date.dart
index ae3dcf8682..e9d34f6c36 100644
--- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/date.dart
+++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/date.dart
@@ -76,7 +76,7 @@ class DateTypeOptionWidget extends TypeOptionWidget {
context
.read<DateTypeOptionBloc>()
.add(DateTypeOptionEvent.didSelectDateFormat(format));
- PopoverContainerState.of(popoverContext).closeAll();
+ PopoverContainer.of(popoverContext).closeAll();
},
),
);
@@ -100,7 +100,7 @@ class DateTypeOptionWidget extends TypeOptionWidget {
context
.read<DateTypeOptionBloc>()
.add(DateTypeOptionEvent.didSelectTimeFormat(format));
- PopoverContainerState.of(popoverContext).closeAll();
+ PopoverContainer.of(popoverContext).closeAll();
}),
);
},
diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/multi_select.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/multi_select.dart
index 75ac6eeaa0..2dc804111d 100644
--- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/multi_select.dart
+++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/multi_select.dart
@@ -41,7 +41,7 @@ class MultiSelectTypeOptionWidget extends TypeOptionWidget {
return SelectOptionTypeOptionWidget(
options: selectOptionAction.typeOption.options,
beginEdit: () {
- PopoverContainerState.of(context).closeAll();
+ PopoverContainer.of(context).closeAll();
},
popoverMutex: popoverMutex,
typeOptionAction: selectOptionAction,
diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/number.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/number.dart
index cdc69eb4e6..fb5bc52dff 100644
--- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/number.dart
+++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/number.dart
@@ -83,7 +83,7 @@ class NumberTypeOptionWidget extends TypeOptionWidget {
context
.read<NumberTypeOptionBloc>()
.add(NumberTypeOptionEvent.didSelectFormat(format));
- PopoverContainerState.of(popoverContext).closeAll();
+ PopoverContainer.of(popoverContext).closeAll();
},
selectedFormat: state.typeOption.format,
),
diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/select_option.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/select_option.dart
index 7b0be75515..b4a0764cff 100644
--- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/select_option.dart
+++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/select_option.dart
@@ -208,13 +208,13 @@ class _OptionCellState extends State<_OptionCell> {
context
.read<SelectOptionTypeOptionBloc>()
.add(SelectOptionTypeOptionEvent.deleteOption(widget.option));
- PopoverContainerState.of(popoverContext).closeAll();
+ PopoverContainer.of(popoverContext).closeAll();
},
onUpdated: (updatedOption) {
context
.read<SelectOptionTypeOptionBloc>()
.add(SelectOptionTypeOptionEvent.updateOption(updatedOption));
- PopoverContainerState.of(popoverContext).closeAll();
+ PopoverContainer.of(popoverContext).closeAll();
},
key: ValueKey(widget.option.id),
),
diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/single_select.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/single_select.dart
index 27ffabb286..477e573ff2 100644
--- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/single_select.dart
+++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/type_option/single_select.dart
@@ -40,7 +40,7 @@ class SingleSelectTypeOptionWidget extends TypeOptionWidget {
return SelectOptionTypeOptionWidget(
options: selectOptionAction.typeOption.options,
beginEdit: () {
- PopoverContainerState.of(context).closeAll();
+ PopoverContainer.of(context).closeAll();
},
popoverMutex: popoverMutex,
typeOptionAction: selectOptionAction,
diff --git a/frontend/app_flowy/packages/appflowy_popover/lib/popover.dart b/frontend/app_flowy/packages/appflowy_popover/lib/popover.dart
index 2fc26aeb0c..77bc4896bc 100644
--- a/frontend/app_flowy/packages/appflowy_popover/lib/popover.dart
+++ b/frontend/app_flowy/packages/appflowy_popover/lib/popover.dart
@@ -284,6 +284,15 @@ class PopoverContainer extends StatefulWidget {
@override
State<StatefulWidget> createState() => PopoverContainerState();
+
+ static PopoverContainerState of(BuildContext context) {
+ if (context is StatefulElement && context.state is PopoverContainerState) {
+ return context.state as PopoverContainerState;
+ }
+ final PopoverContainerState? result =
+ context.findAncestorStateOfType<PopoverContainerState>();
+ return result!;
+ }
}
class PopoverContainerState extends State<PopoverContainer> {
@@ -302,13 +311,4 @@ class PopoverContainerState extends State<PopoverContainer> {
close() => widget.onClose();
closeAll() => widget.onCloseAll();
-
- static PopoverContainerState of(BuildContext context) {
- if (context is StatefulElement && context.state is PopoverContainerState) {
- return context.state as PopoverContainerState;
- }
- final PopoverContainerState? result =
- context.findAncestorStateOfType<PopoverContainerState>();
- return result!;
- }
}