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: the toolbar will be blocked if the scroll bar is hidden #839

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
38 changes: 26 additions & 12 deletions lib/src/editor/toolbar/mobile/mobile_toolbar_v2.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:math';

import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:appflowy_editor/src/editor/toolbar/mobile/utils/keyboard_height_observer.dart';
import 'package:flutter/foundation.dart';
Expand Down Expand Up @@ -274,6 +276,12 @@

if (canUpdateCachedKeyboardHeight) {
cachedKeyboardHeight.value = height;
if (defaultTargetPlatform == TargetPlatform.android) {
if (cachedKeyboardHeight.value != 0) {
cachedKeyboardHeight.value +=
MediaQuery.of(context).viewPadding.bottom;

Check warning on line 282 in lib/src/editor/toolbar/mobile/mobile_toolbar_v2.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/editor/toolbar/mobile/mobile_toolbar_v2.dart#L279-L282

Added lines #L279 - L282 were not covered by tests
}
}
}

if (height == 0) {
Expand Down Expand Up @@ -385,24 +393,30 @@
return ValueListenableBuilder(
valueListenable: showMenuNotifier,
builder: (_, showingMenu, __) {
var toolbarHeight = height;
var keyboardHeight = height;
if (defaultTargetPlatform == TargetPlatform.android) {
toolbarHeight += MediaQuery.of(context).viewPadding.bottom;
if (!showingMenu) {
keyboardHeight = max(

Check warning on line 399 in lib/src/editor/toolbar/mobile/mobile_toolbar_v2.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/editor/toolbar/mobile/mobile_toolbar_v2.dart#L399

Added line #L399 was not covered by tests
keyboardHeight,
MediaQuery.of(context).viewInsets.bottom,

Check warning on line 401 in lib/src/editor/toolbar/mobile/mobile_toolbar_v2.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/editor/toolbar/mobile/mobile_toolbar_v2.dart#L401

Added line #L401 was not covered by tests
);
}
}
return SizedBox(
height: toolbarHeight,
height: keyboardHeight,
child: (showingMenu && selectedMenuIndex != null)
? MobileToolbarItemMenu(
editorState: widget.editorState,
itemMenuBuilder: () =>
widget
.toolbarItems[selectedMenuIndex!].itemMenuBuilder!
.call(
context,
widget.editorState,
this,
) ??
const SizedBox.shrink(),
itemMenuBuilder: () {
final menu = widget
.toolbarItems[selectedMenuIndex!].itemMenuBuilder!
.call(

Check warning on line 413 in lib/src/editor/toolbar/mobile/mobile_toolbar_v2.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/editor/toolbar/mobile/mobile_toolbar_v2.dart#L410-L413

Added lines #L410 - L413 were not covered by tests
context,
widget.editorState,

Check warning on line 415 in lib/src/editor/toolbar/mobile/mobile_toolbar_v2.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/editor/toolbar/mobile/mobile_toolbar_v2.dart#L415

Added line #L415 was not covered by tests
this,
);
return menu ?? const SizedBox.shrink();
},
)
: const SizedBox.shrink(),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,9 @@
}

void notify(double height) {
// the keyboard height will notify twice with the same value on Android 14
if (androidSDKVersion == 34) {
if (height == 0 && currentKeyboardHeight == 0) {
return;
}
// the keyboard height will notify twice with the same value on Android
if (Platform.isAndroid && height == currentKeyboardHeight) {

Check warning on line 47 in lib/src/editor/toolbar/mobile/utils/keyboard_height_observer.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/editor/toolbar/mobile/utils/keyboard_height_observer.dart#L47

Added line #L47 was not covered by tests
return;
}

for (final listener in _listeners) {
Expand Down
Loading