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