mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
refactor: PopoverContainerState -> PopoverContainer
This commit is contained in:
parent
cc0d408775
commit
286781f5cc
@ -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();
|
||||
|
@ -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();
|
||||
}),
|
||||
);
|
||||
},
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
),
|
||||
|
@ -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),
|
||||
),
|
||||
|
@ -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,
|
||||
|
@ -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!;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user