Skip to content

Commit

Permalink
fix: cursor height is inconsistent after upgrading to Flutter 3.22 (#…
Browse files Browse the repository at this point in the history
…5574)

* fix: cursor height is inconsistent after upgrading to Flutter 3.22

* fix: cursor height is inconsistent after upgrading to Flutter 3.22

* fix: android toolbar height issue
  • Loading branch information
LucasXu0 authored Jun 19, 2024
1 parent fa86480 commit 8557383
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,15 @@ class _MobileToolbarState extends State<_MobileToolbar>
builder: (_, height, ___) {
var paddingHeight = height;
if (Platform.isAndroid) {
paddingHeight += MediaQuery.of(context).viewPadding.bottom;
// use the viewInsets to get the keyboard height on Android
paddingHeight = MediaQuery.of(context).viewInsets.bottom;
// if the padding height is 0 and the keyboard height is not 0,
// use the keyboard height
if (paddingHeight == 0 && height != 0) {
paddingHeight = height + MediaQuery.of(context).viewPadding.bottom;
}
}
debugPrint('Keyboard height: $paddingHeight');
return AnimatedContainer(
duration: const Duration(microseconds: 110),
height: paddingHeight,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:appflowy/startup/tasks/prelude.dart';
import 'dart:io';

import 'package:keyboard_height_plugin/keyboard_height_plugin.dart';

typedef KeyboardHeightCallback = void Function(double height);
Expand All @@ -9,8 +10,6 @@ class KeyboardHeightObserver {
KeyboardHeightObserver._() {
_keyboardHeightPlugin.onKeyboardHeightChanged((height) {
notify(height);

currentKeyboardHeight = height;
});
}

Expand All @@ -34,14 +33,13 @@ class KeyboardHeightObserver {
}

void notify(double height) {
// the keyboard height will notify twice with the same value on Android 14
if (ApplicationInfo.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) {
return;
}
for (final listener in _listeners) {
listener(height);
}
currentKeyboardHeight = height;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class EditorStyleCustomizer {
DefaultAppearanceSettings.getDefaultSelectionColor(context),
defaultTextDirection: appearance.defaultTextDirection,
textStyleConfiguration: TextStyleConfiguration(
lineHeight: 1.4,
applyHeightToFirstAscent: true,
applyHeightToLastDescent: true,
text: baseTextStyle(fontFamily).copyWith(
fontSize: fontSize,
color: afThemeExtension.onBackground,
Expand Down
4 changes: 2 additions & 2 deletions frontend/appflowy_flutter/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ packages:
dependency: "direct main"
description:
path: "."
ref: d6388a4
resolved-ref: d6388a485789e1414a098366e0f38f14e86a0660
ref: "64c0be8"
resolved-ref: "64c0be88a113c2eece5512701527e7d11b8c9239"
url: "https://github.com/AppFlowy-IO/appflowy-editor.git"
source: git
version: "2.5.1"
Expand Down
2 changes: 1 addition & 1 deletion frontend/appflowy_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ dependency_overrides:
appflowy_editor:
git:
url: https://github.com/AppFlowy-IO/appflowy-editor.git
ref: "d6388a4"
ref: "64c0be8"

appflowy_editor_plugins:
git:
Expand Down

0 comments on commit 8557383

Please sign in to comment.