feat(scribe-mobile): Display the result prompt modal in the correct position relative to the inline scribe button on tablet
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import 'dart:math';
|
import 'dart:math' hide log;
|
||||||
|
|
||||||
import 'package:core/presentation/resources/image_paths.dart';
|
import 'package:core/presentation/resources/image_paths.dart';
|
||||||
|
import 'package:core/utils/platform_info.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:pointer_interceptor/pointer_interceptor.dart';
|
import 'package:pointer_interceptor/pointer_interceptor.dart';
|
||||||
import 'package:scribe/scribe.dart';
|
import 'package:scribe/scribe.dart';
|
||||||
@@ -87,6 +88,11 @@ class _AiScribeSuggestionWidgetState extends State<AiScribeSuggestionWidget>
|
|||||||
padding: AIScribeSizes.screenEdgePadding,
|
padding: AIScribeSizes.screenEdgePadding,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
final modalStartOffset = layout.left;
|
||||||
|
final modalBottomOffset =
|
||||||
|
_isMobileView ? null : layout.bottom + keyboardHeightWithSpacing;
|
||||||
|
final modalTopOffset = _isMobileView ? widget.buttonPosition!.dy : null;
|
||||||
|
|
||||||
return PointerInterceptor(
|
return PointerInterceptor(
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
@@ -97,11 +103,12 @@ class _AiScribeSuggestionWidgetState extends State<AiScribeSuggestionWidget>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
PositionedDirectional(
|
PositionedDirectional(
|
||||||
start: layout.left,
|
start: modalStartOffset,
|
||||||
// layout.bottom is calculated by taking keyboard into account
|
// layout.bottom is calculated by taking keyboard into account
|
||||||
// but positionned without taking keyboard into account
|
// but positioned without taking keyboard into account
|
||||||
// that's why we need to add keyboard height here
|
// that's why we need to add keyboard height here
|
||||||
bottom: layout.bottom + keyboardHeightWithSpacing,
|
top: modalTopOffset,
|
||||||
|
bottom: modalBottomOffset,
|
||||||
child: _buildModalContainer(
|
child: _buildModalContainer(
|
||||||
width: modalWidth,
|
width: modalWidth,
|
||||||
maxHeight: layout.availableHeight,
|
maxHeight: layout.availableHeight,
|
||||||
@@ -160,6 +167,9 @@ class _AiScribeSuggestionWidgetState extends State<AiScribeSuggestionWidget>
|
|||||||
bool get _hasAnchor =>
|
bool get _hasAnchor =>
|
||||||
widget.buttonPosition != null && widget.buttonSize != null;
|
widget.buttonPosition != null && widget.buttonSize != null;
|
||||||
|
|
||||||
|
bool get _isMobileView =>
|
||||||
|
PlatformInfo.isMobile || PlatformInfo.isWebTouchDevice;
|
||||||
|
|
||||||
void _handleClickOutside() {
|
void _handleClickOutside() {
|
||||||
final shouldDismiss = suggestionState.value.fold(
|
final shouldDismiss = suggestionState.value.fold(
|
||||||
(failure) => failure is GenerateAITextFailure,
|
(failure) => failure is GenerateAITextFailure,
|
||||||
|
|||||||
Reference in New Issue
Block a user