generated from dellevin/template
bug修复
This commit is contained in:
@@ -318,7 +318,17 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
|
||||
theme: light,
|
||||
darkTheme: dark,
|
||||
themeMode: provider.themeMode,
|
||||
builder: (ctx, nav) => AppShell(child: nav!),
|
||||
builder: (ctx, nav) {
|
||||
Widget shell = AppShell(child: nav!);
|
||||
// Android: 点击空白区域收起键盘
|
||||
if (Platform.isAndroid) {
|
||||
shell = GestureDetector(
|
||||
onTap: () => FocusManager.instance.primaryFocus?.unfocus(),
|
||||
child: shell,
|
||||
);
|
||||
}
|
||||
return shell;
|
||||
},
|
||||
localizationsDelegates: const [
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
|
||||
@@ -64,6 +64,7 @@ class _NoteFormPageState extends State<NoteFormPage> {
|
||||
void dispose() {
|
||||
_autoSaveTimer?.cancel();
|
||||
_saveStatusTimer?.cancel();
|
||||
_scrollController.dispose();
|
||||
_titleController.dispose();
|
||||
_contentController.dispose();
|
||||
super.dispose();
|
||||
|
||||
@@ -153,6 +153,14 @@ class VditorEditorState extends State<VditorEditor> {
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
Future<void> _requestHeightUpdate() async {
|
||||
if (_controller == null || !_isReady) return;
|
||||
try {
|
||||
await Future.delayed(const Duration(milliseconds: 300));
|
||||
await _controller!.evaluateJavascript(source: 'requestHeightUpdate()');
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
void _onVditorReady() {
|
||||
if (_isReady) return;
|
||||
_fallbackTimer?.cancel();
|
||||
@@ -276,10 +284,13 @@ class VditorEditorState extends State<VditorEditor> {
|
||||
}
|
||||
debugPrint('[VditorEditor] loading: $initialUrl');
|
||||
|
||||
// 键盘弹出时,滚动到光标位置
|
||||
// 键盘弹出时,滚动到光标位置;键盘收起时,重新通知高度
|
||||
final keyboardH = MediaQuery.of(context).viewInsets.bottom;
|
||||
if (keyboardH > 0 && _lastKeyboardH == 0 && _isReady) {
|
||||
Future.microtask(() => _scrollToCursor());
|
||||
} else if (keyboardH == 0 && _lastKeyboardH > 0 && _isReady) {
|
||||
// 键盘收起,请求 JS 端重新计算高度
|
||||
Future.microtask(() => _requestHeightUpdate());
|
||||
}
|
||||
_lastKeyboardH = keyboardH;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user