mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-11-19 11:57:57 +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,
|
fieldType: fieldType,
|
||||||
onSelectField: (fieldType) {
|
onSelectField: (fieldType) {
|
||||||
onSelectField(fieldType);
|
onSelectField(fieldType);
|
||||||
PopoverContainerState.of(context).closeAll();
|
PopoverContainer.of(context).closeAll();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
|
|||||||
@ -76,7 +76,7 @@ class DateTypeOptionWidget extends TypeOptionWidget {
|
|||||||
context
|
context
|
||||||
.read<DateTypeOptionBloc>()
|
.read<DateTypeOptionBloc>()
|
||||||
.add(DateTypeOptionEvent.didSelectDateFormat(format));
|
.add(DateTypeOptionEvent.didSelectDateFormat(format));
|
||||||
PopoverContainerState.of(popoverContext).closeAll();
|
PopoverContainer.of(popoverContext).closeAll();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -100,7 +100,7 @@ class DateTypeOptionWidget extends TypeOptionWidget {
|
|||||||
context
|
context
|
||||||
.read<DateTypeOptionBloc>()
|
.read<DateTypeOptionBloc>()
|
||||||
.add(DateTypeOptionEvent.didSelectTimeFormat(format));
|
.add(DateTypeOptionEvent.didSelectTimeFormat(format));
|
||||||
PopoverContainerState.of(popoverContext).closeAll();
|
PopoverContainer.of(popoverContext).closeAll();
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@ -41,7 +41,7 @@ class MultiSelectTypeOptionWidget extends TypeOptionWidget {
|
|||||||
return SelectOptionTypeOptionWidget(
|
return SelectOptionTypeOptionWidget(
|
||||||
options: selectOptionAction.typeOption.options,
|
options: selectOptionAction.typeOption.options,
|
||||||
beginEdit: () {
|
beginEdit: () {
|
||||||
PopoverContainerState.of(context).closeAll();
|
PopoverContainer.of(context).closeAll();
|
||||||
},
|
},
|
||||||
popoverMutex: popoverMutex,
|
popoverMutex: popoverMutex,
|
||||||
typeOptionAction: selectOptionAction,
|
typeOptionAction: selectOptionAction,
|
||||||
|
|||||||
@ -83,7 +83,7 @@ class NumberTypeOptionWidget extends TypeOptionWidget {
|
|||||||
context
|
context
|
||||||
.read<NumberTypeOptionBloc>()
|
.read<NumberTypeOptionBloc>()
|
||||||
.add(NumberTypeOptionEvent.didSelectFormat(format));
|
.add(NumberTypeOptionEvent.didSelectFormat(format));
|
||||||
PopoverContainerState.of(popoverContext).closeAll();
|
PopoverContainer.of(popoverContext).closeAll();
|
||||||
},
|
},
|
||||||
selectedFormat: state.typeOption.format,
|
selectedFormat: state.typeOption.format,
|
||||||
),
|
),
|
||||||
|
|||||||
@ -208,13 +208,13 @@ class _OptionCellState extends State<_OptionCell> {
|
|||||||
context
|
context
|
||||||
.read<SelectOptionTypeOptionBloc>()
|
.read<SelectOptionTypeOptionBloc>()
|
||||||
.add(SelectOptionTypeOptionEvent.deleteOption(widget.option));
|
.add(SelectOptionTypeOptionEvent.deleteOption(widget.option));
|
||||||
PopoverContainerState.of(popoverContext).closeAll();
|
PopoverContainer.of(popoverContext).closeAll();
|
||||||
},
|
},
|
||||||
onUpdated: (updatedOption) {
|
onUpdated: (updatedOption) {
|
||||||
context
|
context
|
||||||
.read<SelectOptionTypeOptionBloc>()
|
.read<SelectOptionTypeOptionBloc>()
|
||||||
.add(SelectOptionTypeOptionEvent.updateOption(updatedOption));
|
.add(SelectOptionTypeOptionEvent.updateOption(updatedOption));
|
||||||
PopoverContainerState.of(popoverContext).closeAll();
|
PopoverContainer.of(popoverContext).closeAll();
|
||||||
},
|
},
|
||||||
key: ValueKey(widget.option.id),
|
key: ValueKey(widget.option.id),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -40,7 +40,7 @@ class SingleSelectTypeOptionWidget extends TypeOptionWidget {
|
|||||||
return SelectOptionTypeOptionWidget(
|
return SelectOptionTypeOptionWidget(
|
||||||
options: selectOptionAction.typeOption.options,
|
options: selectOptionAction.typeOption.options,
|
||||||
beginEdit: () {
|
beginEdit: () {
|
||||||
PopoverContainerState.of(context).closeAll();
|
PopoverContainer.of(context).closeAll();
|
||||||
},
|
},
|
||||||
popoverMutex: popoverMutex,
|
popoverMutex: popoverMutex,
|
||||||
typeOptionAction: selectOptionAction,
|
typeOptionAction: selectOptionAction,
|
||||||
|
|||||||
@ -284,6 +284,15 @@ class PopoverContainer extends StatefulWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() => PopoverContainerState();
|
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> {
|
class PopoverContainerState extends State<PopoverContainer> {
|
||||||
@ -302,13 +311,4 @@ class PopoverContainerState extends State<PopoverContainer> {
|
|||||||
close() => widget.onClose();
|
close() => widget.onClose();
|
||||||
|
|
||||||
closeAll() => widget.onCloseAll();
|
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