feat(ai-scribe): Auto hide Replace action when perform prompt in new email without content
This commit is contained in:
@@ -86,7 +86,9 @@ class _AiScribeSuggestionWidgetState extends State<AiScribeSuggestionWidget> {
|
|||||||
AIScribeSizes.suggestionModalMaxHeight,
|
AIScribeSizes.suggestionModalMaxHeight,
|
||||||
);
|
);
|
||||||
|
|
||||||
final dialogContent = _buildDialogContent(context);
|
final hasContent = widget.content?.trim().isNotEmpty == true;
|
||||||
|
|
||||||
|
final dialogContent = _buildDialogContent(context, hasContent);
|
||||||
|
|
||||||
if (!_hasAnchor) {
|
if (!_hasAnchor) {
|
||||||
return Center(
|
return Center(
|
||||||
@@ -128,7 +130,7 @@ class _AiScribeSuggestionWidgetState extends State<AiScribeSuggestionWidget> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildDialogContent(BuildContext context) {
|
Widget _buildDialogContent(BuildContext context, bool hasContent) {
|
||||||
final localizations = ScribeLocalizations.of(context);
|
final localizations = ScribeLocalizations.of(context);
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
@@ -153,6 +155,7 @@ class _AiScribeSuggestionWidgetState extends State<AiScribeSuggestionWidget> {
|
|||||||
return AiScribeSuggestionSuccess(
|
return AiScribeSuggestionSuccess(
|
||||||
imagePaths: widget.imagePaths,
|
imagePaths: widget.imagePaths,
|
||||||
suggestionText: value.response.result,
|
suggestionText: value.response.result,
|
||||||
|
hasContent: hasContent,
|
||||||
onSelectAction: widget.onSelectAiScribeSuggestionAction,
|
onSelectAction: widget.onSelectAiScribeSuggestionAction,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+3
@@ -5,6 +5,7 @@ import 'package:scribe/scribe.dart';
|
|||||||
class AiScribeSuggestionSuccess extends StatelessWidget {
|
class AiScribeSuggestionSuccess extends StatelessWidget {
|
||||||
final ImagePaths imagePaths;
|
final ImagePaths imagePaths;
|
||||||
final String suggestionText;
|
final String suggestionText;
|
||||||
|
final bool hasContent;
|
||||||
final OnSelectAiScribeSuggestionAction onSelectAction;
|
final OnSelectAiScribeSuggestionAction onSelectAction;
|
||||||
|
|
||||||
const AiScribeSuggestionSuccess({
|
const AiScribeSuggestionSuccess({
|
||||||
@@ -12,6 +13,7 @@ class AiScribeSuggestionSuccess extends StatelessWidget {
|
|||||||
required this.imagePaths,
|
required this.imagePaths,
|
||||||
required this.suggestionText,
|
required this.suggestionText,
|
||||||
required this.onSelectAction,
|
required this.onSelectAction,
|
||||||
|
this.hasContent = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -38,6 +40,7 @@ class AiScribeSuggestionSuccess extends StatelessWidget {
|
|||||||
AiScribeSuggestionSuccessListActions(
|
AiScribeSuggestionSuccessListActions(
|
||||||
imagePaths: imagePaths,
|
imagePaths: imagePaths,
|
||||||
suggestionText: suggestionText,
|
suggestionText: suggestionText,
|
||||||
|
hasContent: hasContent,
|
||||||
onSelectAction: onSelectAction,
|
onSelectAction: onSelectAction,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
+18
-15
@@ -12,6 +12,7 @@ typedef OnSelectAiScribeSuggestionAction = void Function(
|
|||||||
class AiScribeSuggestionSuccessListActions extends StatelessWidget {
|
class AiScribeSuggestionSuccessListActions extends StatelessWidget {
|
||||||
final ImagePaths imagePaths;
|
final ImagePaths imagePaths;
|
||||||
final String suggestionText;
|
final String suggestionText;
|
||||||
|
final bool hasContent;
|
||||||
final OnSelectAiScribeSuggestionAction onSelectAction;
|
final OnSelectAiScribeSuggestionAction onSelectAction;
|
||||||
|
|
||||||
const AiScribeSuggestionSuccessListActions({
|
const AiScribeSuggestionSuccessListActions({
|
||||||
@@ -19,6 +20,7 @@ class AiScribeSuggestionSuccessListActions extends StatelessWidget {
|
|||||||
required this.imagePaths,
|
required this.imagePaths,
|
||||||
required this.suggestionText,
|
required this.suggestionText,
|
||||||
required this.onSelectAction,
|
required this.onSelectAction,
|
||||||
|
this.hasContent = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -29,23 +31,24 @@ class AiScribeSuggestionSuccessListActions extends StatelessWidget {
|
|||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
spacing: 8,
|
spacing: 8,
|
||||||
children: [
|
children: [
|
||||||
Flexible(
|
if (hasContent)
|
||||||
child: Container(
|
Flexible(
|
||||||
constraints: const BoxConstraints(minWidth: 67),
|
child: Container(
|
||||||
height: 36,
|
constraints: const BoxConstraints(minWidth: 67),
|
||||||
child: ConfirmDialogButton(
|
height: 36,
|
||||||
label: AiScribeSuggestionActions.replace.getLabel(localizations),
|
child: ConfirmDialogButton(
|
||||||
textColor: AppColor.primaryMain,
|
label: AiScribeSuggestionActions.replace.getLabel(localizations),
|
||||||
onTapAction: () {
|
textColor: AppColor.primaryMain,
|
||||||
Navigator.of(context).pop();
|
onTapAction: () {
|
||||||
onSelectAction(
|
Navigator.of(context).pop();
|
||||||
AiScribeSuggestionActions.replace,
|
onSelectAction(
|
||||||
suggestionText,
|
AiScribeSuggestionActions.replace,
|
||||||
);
|
suggestionText,
|
||||||
},
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
Flexible(
|
Flexible(
|
||||||
child: Container(
|
child: Container(
|
||||||
constraints: const BoxConstraints(minWidth: 72),
|
constraints: const BoxConstraints(minWidth: 72),
|
||||||
|
|||||||
Reference in New Issue
Block a user