Display Scribe modals correctly when a keyboard is opened

This commit is contained in:
Théo Poizat
2026-02-10 14:18:50 +01:00
committed by Dat H. Pham
parent 7b3e3e1b16
commit 269ca7116c
2 changed files with 10 additions and 4 deletions
@@ -72,6 +72,10 @@ class AiScribeModalWidget extends StatelessWidget {
); );
if (buttonPosition != null && buttonSize != null) { if (buttonPosition != null && buttonSize != null) {
final keyboardHeight = MediaQuery.of(context).viewInsets.bottom;
final screenSize = MediaQuery.of(context).size;
final availableHeight = screenSize.height - keyboardHeight;
final maxHeightModal = hasContent final maxHeightModal = hasContent
? AIScribeSizes.searchBarMinHeight + ? AIScribeSizes.searchBarMinHeight +
AIScribeSizes.fieldSpacing + AIScribeSizes.fieldSpacing +
@@ -81,7 +85,7 @@ class AiScribeModalWidget extends StatelessWidget {
final layoutResult = AnchoredModalLayoutCalculator.calculate( final layoutResult = AnchoredModalLayoutCalculator.calculate(
input: AnchoredModalLayoutInput( input: AnchoredModalLayoutInput(
screenSize: MediaQuery.of(context).size, screenSize: Size(screenSize.width, availableHeight),
anchorPosition: buttonPosition!, anchorPosition: buttonPosition!,
anchorSize: buttonSize!, anchorSize: buttonSize!,
menuSize: Size( menuSize: Size(
@@ -49,7 +49,9 @@ class _AiScribeSuggestionWidgetState extends State<AiScribeSuggestionWidget>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final screenSize = MediaQuery.sizeOf(context); final keyboardHeight = MediaQuery.of(context).viewInsets.bottom;
final screenSize = MediaQuery.of(context).size;
final availableHeight = screenSize.height - keyboardHeight;
final modalWidth = min( final modalWidth = min(
screenSize.width * AIScribeSizes.mobileFactor, screenSize.width * AIScribeSizes.mobileFactor,
@@ -57,7 +59,7 @@ class _AiScribeSuggestionWidgetState extends State<AiScribeSuggestionWidget>
); );
final modalMaxHeight = min( final modalMaxHeight = min(
screenSize.height * AIScribeSizes.mobileFactor, availableHeight * AIScribeSizes.mobileFactor,
AIScribeSizes.suggestionModalMaxHeight, AIScribeSizes.suggestionModalMaxHeight,
); );
@@ -76,7 +78,7 @@ class _AiScribeSuggestionWidgetState extends State<AiScribeSuggestionWidget>
} }
final layout = AnchoredModalLayoutCalculator.calculateAnchoredSuggestLayout( final layout = AnchoredModalLayoutCalculator.calculateAnchoredSuggestLayout(
screenSize: screenSize, screenSize: Size(screenSize.width, availableHeight),
anchorPosition: widget.buttonPosition!, anchorPosition: widget.buttonPosition!,
anchorSize: widget.buttonSize!, anchorSize: widget.buttonSize!,
menuSize: Size(modalWidth, modalMaxHeight), menuSize: Size(modalWidth, modalMaxHeight),