💄 Optimize thought input space to avoid input cover message

This commit is contained in:
2025-11-16 11:22:47 +08:00
parent 9a75228e38
commit 40c0e052cf
3 changed files with 19 additions and 3 deletions

View File

@@ -102,7 +102,7 @@ class ThoughtScreen extends HookConsumerWidget {
} catch (e) { } catch (e) {
showSnackBar('Failed to retry billing'); showSnackBar('Failed to retry billing');
} }
hideLoadingModal(context); if (context.mounted) hideLoadingModal(context);
}, },
[context, ref], [context, ref],
); );

View File

@@ -62,7 +62,7 @@ class ThoughtSheet extends HookConsumerWidget {
} catch (e) { } catch (e) {
showSnackBar('Failed to retry billing'); showSnackBar('Failed to retry billing');
} }
hideLoadingModal(context); if (context.mounted) hideLoadingModal(context);
}, },
[context, ref], [context, ref],
); );

View File

@@ -401,6 +401,9 @@ class ThoughtChatInterface extends HookConsumerWidget {
@override @override
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
final inputKey = useMemoized(() => GlobalKey());
final inputHeight = useState<double>(80.0);
final chatState = useThoughtChat( final chatState = useThoughtChat(
ref, ref,
initialThoughts: initialThoughts, initialThoughts: initialThoughts,
@@ -409,6 +412,17 @@ class ThoughtChatInterface extends HookConsumerWidget {
attachedPosts: attachedPosts, attachedPosts: attachedPosts,
); );
useEffect(() {
WidgetsBinding.instance.addPostFrameCallback((_) {
final renderBox =
inputKey.currentContext?.findRenderObject() as RenderBox?;
if (renderBox != null) {
inputHeight.value = renderBox.size.height;
}
});
return null;
}, []);
return Stack( return Stack(
children: [ children: [
// Thoughts list // Thoughts list
@@ -425,7 +439,8 @@ class ThoughtChatInterface extends HookConsumerWidget {
top: 16, top: 16,
bottom: bottom:
MediaQuery.of(context).padding.bottom + MediaQuery.of(context).padding.bottom +
80, // Leave space for thought input 56 +
inputHeight.value, // Leave space for thought input
), ),
reverse: true, reverse: true,
itemCount: itemCount:
@@ -492,6 +507,7 @@ class ThoughtChatInterface extends HookConsumerWidget {
child: Container( child: Container(
constraints: BoxConstraints(maxWidth: 640), constraints: BoxConstraints(maxWidth: 640),
child: ThoughtInput( child: ThoughtInput(
key: inputKey,
messageController: chatState.messageController, messageController: chatState.messageController,
isStreaming: chatState.isStreaming.value, isStreaming: chatState.isStreaming.value,
onSend: chatState.sendMessage, onSend: chatState.sendMessage,