mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: disable scroll when showing popuplist
This commit is contained in:
parent
6e71ec23a1
commit
27ea5a11a9
@ -106,13 +106,19 @@ void showPopupList(
|
||||
.removeListener(clearPopupList);
|
||||
editorState.service.selectionService.currentSelection
|
||||
.addListener(clearPopupList);
|
||||
|
||||
editorState.service.scrollService?.disable();
|
||||
}
|
||||
|
||||
void clearPopupList() {
|
||||
if (_popupListOverlay == null || _editorState == null) {
|
||||
return;
|
||||
}
|
||||
_popupListOverlay?.remove();
|
||||
_popupListOverlay = null;
|
||||
|
||||
_editorState?.service.keyboardService?.enable();
|
||||
_editorState?.service.scrollService?.enable();
|
||||
_editorState = null;
|
||||
}
|
||||
|
||||
@ -215,11 +221,13 @@ class _PopupListWidgetState extends State<PopupListWidget> {
|
||||
widget.items[selectedIndex].handler(widget.editorState);
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
}
|
||||
|
||||
if (event.logicalKey == LogicalKeyboardKey.escape) {
|
||||
} else if (event.logicalKey == LogicalKeyboardKey.escape) {
|
||||
clearPopupList();
|
||||
return KeyEventResult.handled;
|
||||
} else if (event.logicalKey == LogicalKeyboardKey.backspace) {
|
||||
clearPopupList();
|
||||
_deleteSlash();
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
|
||||
var newSelectedIndex = selectedIndex;
|
||||
|
@ -6,7 +6,8 @@ mixin FlowyScrollService<T extends StatefulWidget> on State<T> {
|
||||
|
||||
void scrollTo(double dy);
|
||||
|
||||
RenderObject? scrollRenderObject();
|
||||
void enable();
|
||||
void disable();
|
||||
}
|
||||
|
||||
class FlowyScroll extends StatefulWidget {
|
||||
@ -25,6 +26,8 @@ class _FlowyScrollState extends State<FlowyScroll> with FlowyScrollService {
|
||||
final _scrollController = ScrollController();
|
||||
final _scrollViewKey = GlobalKey();
|
||||
|
||||
bool _scrollEnabled = true;
|
||||
|
||||
@override
|
||||
double get dy => _scrollController.position.pixels;
|
||||
|
||||
@ -51,15 +54,22 @@ class _FlowyScrollState extends State<FlowyScroll> with FlowyScrollService {
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void disable() {
|
||||
_scrollEnabled = false;
|
||||
debugPrint('[scroll] $_scrollEnabled');
|
||||
}
|
||||
|
||||
@override
|
||||
void enable() {
|
||||
_scrollEnabled = true;
|
||||
debugPrint('[scroll] $_scrollEnabled');
|
||||
}
|
||||
|
||||
void _onPointerSignal(PointerSignalEvent event) {
|
||||
if (event is PointerScrollEvent) {
|
||||
if (event is PointerScrollEvent && _scrollEnabled) {
|
||||
final dy = (_scrollController.position.pixels + event.scrollDelta.dy);
|
||||
scrollTo(dy);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
RenderObject? scrollRenderObject() {
|
||||
return _scrollViewKey.currentContext?.findRenderObject();
|
||||
}
|
||||
}
|
||||
|
@ -267,6 +267,7 @@ class _FlowySelectionState extends State<FlowySelection>
|
||||
editorState.updateCursorSelection(selection);
|
||||
|
||||
editorState.service.keyboardService?.enable();
|
||||
editorState.service.scrollService?.enable();
|
||||
}
|
||||
|
||||
@override
|
||||
|
Loading…
Reference in New Issue
Block a user