fix: 私信页面表情面板 issues #588

This commit is contained in:
guozhigq
2024-03-01 00:14:42 +08:00
parent ce1c80fd86
commit be56fb721f
2 changed files with 37 additions and 26 deletions

View File

@ -109,21 +109,24 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
@override @override
void didChangeMetrics() { void didChangeMetrics() {
super.didChangeMetrics(); super.didChangeMetrics();
WidgetsBinding.instance.addPostFrameCallback((_) { final String routePath = Get.currentRoute;
// 键盘高度 if (mounted && routePath.startsWith('/video')) {
final viewInsets = EdgeInsets.fromViewPadding( WidgetsBinding.instance.addPostFrameCallback((_) {
View.of(context).viewInsets, View.of(context).devicePixelRatio); // 键盘高度
_debouncer.run(() { final viewInsets = EdgeInsets.fromViewPadding(
if (mounted) { View.of(context).viewInsets, View.of(context).devicePixelRatio);
if (keyboardHeight == 0 && emoteHeight == 0) { _debouncer.run(() {
setState(() { if (mounted) {
emoteHeight = keyboardHeight = if (keyboardHeight == 0 && emoteHeight == 0) {
keyboardHeight == 0.0 ? viewInsets.bottom : keyboardHeight; setState(() {
}); emoteHeight = keyboardHeight =
keyboardHeight == 0.0 ? viewInsets.bottom : keyboardHeight;
});
}
} }
} });
}); });
}); }
} }
@override @override
@ -131,11 +134,15 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
WidgetsBinding.instance.removeObserver(this); WidgetsBinding.instance.removeObserver(this);
_replyContentController.dispose(); _replyContentController.dispose();
replyContentFocusNode.removeListener(() {}); replyContentFocusNode.removeListener(() {});
replyContentFocusNode.dispose();
super.dispose(); super.dispose();
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
double keyboardHeight = EdgeInsets.fromViewPadding(
View.of(context).viewInsets, View.of(context).devicePixelRatio)
.bottom;
return Container( return Container(
clipBehavior: Clip.hardEdge, clipBehavior: Clip.hardEdge,
decoration: BoxDecoration( decoration: BoxDecoration(

View File

@ -51,27 +51,31 @@ class _WhisperDetailPageState extends State<WhisperDetailPage>
@override @override
void didChangeMetrics() { void didChangeMetrics() {
super.didChangeMetrics(); super.didChangeMetrics();
WidgetsBinding.instance.addPostFrameCallback((_) { final String routePath = Get.currentRoute;
// 键盘高度 if (mounted && routePath.startsWith('/whisper_detail')) {
final viewInsets = EdgeInsets.fromViewPadding( WidgetsBinding.instance.addPostFrameCallback((_) {
View.of(context).viewInsets, View.of(context).devicePixelRatio); // 键盘高度
_debouncer.run(() { final viewInsets = EdgeInsets.fromViewPadding(
if (mounted) { View.of(context).viewInsets, View.of(context).devicePixelRatio);
if (keyboardHeight == 0) { _debouncer.run(() {
setState(() { if (mounted) {
emoteHeight = keyboardHeight = if (keyboardHeight == 0) {
keyboardHeight == 0.0 ? viewInsets.bottom : keyboardHeight; setState(() {
}); emoteHeight = keyboardHeight =
keyboardHeight == 0.0 ? viewInsets.bottom : keyboardHeight;
});
}
} }
} });
}); });
}); }
} }
@override @override
void dispose() { void dispose() {
WidgetsBinding.instance.removeObserver(this); WidgetsBinding.instance.removeObserver(this);
replyContentFocusNode.removeListener(() {}); replyContentFocusNode.removeListener(() {});
replyContentFocusNode.dispose();
super.dispose(); super.dispose();
} }