Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: toolbar position at most top #214

Merged
merged 2 commits into from
Jun 20, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions lib/src/editor/toolbar/desktop/floating_toolbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ class _FloatingToolbarState extends State<FloatingToolbar>
}

final rect = _findSuitableRect(rects);
print(rect);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove the print function

final (top, left, right) = calculateToolbarOffset(rect);
print((top, left, right));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing them.

_toolbarContainer = OverlayEntry(
builder: (context) {
return Positioned(
Expand Down Expand Up @@ -210,15 +212,18 @@ class _FloatingToolbarState extends State<FloatingToolbar>
final right = (rect.right - editorCenter.dx).abs();
final width = editorSize.width;
final threshold = width / 3.0;
final top = rect.top < floatingToolbarHeight
? rect.bottom + floatingToolbarHeight
: rect.top;
if (rect.left >= threshold && rect.right <= threshold * 2.0) {
// show in center
return (rect.top, threshold, null);
return (top, threshold, null);
} else if (left >= right) {
// show in left
return (rect.top, rect.left, null);
return (top, rect.left, null);
} else {
// show in right
return (rect.top, null, editorRect.right - rect.right);
return (top, null, editorRect.right - rect.right);
}
}
}