Skip to content

Commit

Permalink
Merge branch 'AppFlowy-IO:main' into l10n
Browse files Browse the repository at this point in the history
  • Loading branch information
sun-jiao authored Sep 15, 2023
2 parents bdac9cc + f5b3ea8 commit 4c4848a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ void main() {
}

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
const MyApp({super.key});

@override
Widget build(BuildContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,21 @@ class EditorScrollController {
}
}

void jumpTo({
required double offset,
}) async {
if (shrinkWrap) {
return scrollController.jumpTo(
offset.clamp(
scrollController.position.minScrollExtent,
scrollController.position.maxScrollExtent,
),
);
}

scrollOffsetController.jumpTo(offset: max(0, offset));
}

void jumpToTop() {
if (shrinkWrap) {
scrollController.jumpTo(0);
Expand Down
20 changes: 7 additions & 13 deletions lib/src/editor/editor_component/service/scroll_service_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,32 +105,26 @@ class _ScrollServiceWidgetState extends State<ScrollServiceWidget>

if (editorState.selectionUpdateReason ==
SelectionUpdateReason.searchNavigate) {
widget.editorScrollController.animateTo(
offset: endTouchPoint.dy - 100,
duration: const Duration(microseconds: 1),
);
return;
return widget.editorScrollController
.jumpTo(offset: endTouchPoint.dy - 100);
}

if (selection.isCollapsed) {
if (PlatformExtension.isMobile) {
// soft keyboard
// workaround: wait for the soft keyboard to show up
Future.delayed(const Duration(milliseconds: 300), () {
return Future.delayed(const Duration(milliseconds: 300), () {
startAutoScroll(endTouchPoint, edgeOffset: 50);
});
} else {
startAutoScroll(
endTouchPoint,
edgeOffset: 100,
duration: Duration.zero,
);
}
} else {

startAutoScroll(
endTouchPoint,
edgeOffset: 100,
duration: Duration.zero,
);
} else {
startAutoScroll(endTouchPoint, duration: Duration.zero);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@ class ScrollOffsetController {
);
}

void jumpTo({required double offset}) =>
_scrollableListState!.primary.scrollController.jumpTo(offset);

_ScrollablePositionedListState? _scrollableListState;

void _attach(_ScrollablePositionedListState scrollableListState) {
Expand Down

0 comments on commit 4c4848a

Please sign in to comment.