From c371c6cd63d5b0d01e5c0afcd6203af029c497ed Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Thu, 22 Aug 2024 11:38:50 +0800 Subject: [PATCH] fix: ai writer generate button color (#6035) * fix: ai writer generate button color * fix: replace ai writer button with outlined rounded button --- .../widgets/auto_completion_node_widget.dart | 54 ++++++++++++------- .../menu/sidebar/space/shared_widget.dart | 42 +++------------ .../workspace/_sidebar_workspace_actions.dart | 22 ++++---- .../shared/single_setting_action.dart | 4 ++ .../lib/style_widget/button.dart | 3 +- .../style_widget/primary_rounded_button.dart | 43 +++++++++++++++ 6 files changed, 102 insertions(+), 66 deletions(-) diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/openai/widgets/auto_completion_node_widget.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/openai/widgets/auto_completion_node_widget.dart index f33d4b5342..63735fe3b6 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/openai/widgets/auto_completion_node_widget.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/openai/widgets/auto_completion_node_widget.dart @@ -140,9 +140,12 @@ class _AutoCompletionBlockComponentState if (PlatformExtension.isMobile) { return const SizedBox.shrink(); } - - return Card( + + final child = Card( elevation: 5, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), color: Theme.of(context).colorScheme.surface, child: Container( margin: const EdgeInsets.all(10), @@ -169,6 +172,11 @@ class _AutoCompletionBlockComponentState ), ), ); + + return Padding( + padding: const EdgeInsets.only(left: 40), + child: child, + ); } Widget _buildInputWidget(BuildContext context) { @@ -474,16 +482,23 @@ class AutoCompletionInputFooter extends StatelessWidget { return Row( mainAxisSize: MainAxisSize.min, children: [ - FlowyTextButton.primary( + PrimaryRoundedButton( text: LocaleKeys.button_generate.tr(), - context: context, - onPressed: onGenerate, + margin: const EdgeInsets.symmetric( + horizontal: 16.0, + vertical: 10.0, + ), + radius: 8.0, + onTap: onGenerate, ), const Space(10, 0), - FlowyTextButton.secondary( + OutlinedRoundedButton( text: LocaleKeys.button_cancel.tr(), - context: context, - onPressed: onExit, + margin: const EdgeInsets.symmetric( + horizontal: 16.0, + vertical: 10.0, + ), + onTap: onExit, ), Flexible( child: Container( @@ -517,22 +532,23 @@ class AutoCompletionFooter extends StatelessWidget { Widget build(BuildContext context) { return Row( children: [ - FlowyTextButton.primary( - context: context, + PrimaryRoundedButton( text: LocaleKeys.button_keep.tr(), - onPressed: onKeep, + margin: const EdgeInsets.symmetric( + horizontal: 16.0, + vertical: 9.0, + ), + onTap: onKeep, ), - const Space(10, 0), - FlowyTextButton.secondary( - context: context, + const HSpace(10), + OutlinedRoundedButton( text: LocaleKeys.document_plugins_autoGeneratorRewrite.tr(), - onPressed: onRewrite, + onTap: onRewrite, ), - const Space(10, 0), - FlowyTextButton.secondary( - context: context, + const HSpace(10), + OutlinedRoundedButton( text: LocaleKeys.button_discard.tr(), - onPressed: onDiscard, + onTap: onDiscard, ), ], ); diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/shared_widget.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/shared_widget.dart index 992647bc08..bfe836ba46 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/shared_widget.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/shared_widget.dart @@ -185,22 +185,9 @@ class SpaceCancelOrConfirmButton extends StatelessWidget { return Row( mainAxisAlignment: MainAxisAlignment.end, children: [ - DecoratedBox( - decoration: ShapeDecoration( - shape: RoundedRectangleBorder( - side: const BorderSide(color: Color(0x1E14171B)), - borderRadius: BorderRadius.circular(8), - ), - ), - child: FlowyButton( - useIntrinsicWidth: true, - margin: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 9.0), - text: FlowyText.regular( - LocaleKeys.button_cancel.tr(), - lineHeight: 1.0, - ), - onTap: onCancel, - ), + OutlinedRoundedButton( + text: LocaleKeys.button_cancel.tr(), + onTap: onCancel, ), const HSpace(12.0), DecoratedBox( @@ -244,24 +231,11 @@ class SpaceOkButton extends StatelessWidget { return Row( mainAxisAlignment: MainAxisAlignment.end, children: [ - DecoratedBox( - decoration: ShapeDecoration( - color: confirmButtonColor ?? Theme.of(context).colorScheme.primary, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8), - ), - ), - child: FlowyButton( - useIntrinsicWidth: true, - margin: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 9.0), - radius: BorderRadius.circular(8), - text: FlowyText.regular( - confirmButtonName, - lineHeight: 1.0, - color: Colors.white, - ), - onTap: onConfirm, - ), + PrimaryRoundedButton( + text: confirmButtonName, + margin: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 9.0), + radius: 8.0, + onTap: onConfirm, ), ], ); diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_actions.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_actions.dart index 5aaae7eec4..fa2893535a 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_actions.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_actions.dart @@ -133,17 +133,17 @@ class _WorkspaceMoreActionWrapper extends CustomActionCell { }, ).show(context); case WorkspaceMoreAction.leave: - await showDialog( + await showConfirmDialog( context: context, - builder: (_) => NavigatorOkCancelDialog( - message: LocaleKeys.workspace_leaveCurrentWorkspacePrompt.tr(), - onOkPressed: () { - workspaceBloc.add( - UserWorkspaceEvent.leaveWorkspace(workspace.workspaceId), - ); - }, - okTitle: LocaleKeys.button_yes.tr(), - ), + title: LocaleKeys.workspace_leaveCurrentWorkspace.tr(), + description: + LocaleKeys.workspace_leaveCurrentWorkspacePrompt.tr(), + confirmLabel: LocaleKeys.button_yes.tr(), + onConfirm: () { + workspaceBloc.add( + UserWorkspaceEvent.leaveWorkspace(workspace.workspaceId), + ); + }, ); } }, @@ -175,7 +175,7 @@ class _WorkspaceMoreActionWrapper extends CustomActionCell { case WorkspaceMoreAction.leave: return FlowySvg( FlowySvgs.logout_s, - color: Theme.of(context).colorScheme.error, + color: onHover ? Theme.of(context).colorScheme.error : null, ); case WorkspaceMoreAction.divider: return const SizedBox.shrink(); diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/shared/single_setting_action.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/shared/single_setting_action.dart index 95fd067265..bc48db3e9f 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/settings/shared/single_setting_action.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/settings/shared/single_setting_action.dart @@ -128,6 +128,10 @@ class SingleSettingAction extends StatelessWidget { } Color? hoverColor(BuildContext context) { + if (buttonType.isDangerous) { + return Theme.of(context).colorScheme.error.withOpacity(0.1); + } + if (buttonType.isPrimary) { return Theme.of(context).colorScheme.primary.withOpacity(0.9); } diff --git a/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/button.dart b/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/button.dart index be69e14375..3b9ba09430 100644 --- a/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/button.dart +++ b/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/button.dart @@ -263,8 +263,7 @@ class FlowyButton extends StatelessWidget { (Platform.isIOS || Platform.isAndroid) ? BoxDecoration( border: Border.all( - color: borderColor ?? - Theme.of(context).colorScheme.outline, + color: borderColor ?? Theme.of(context).colorScheme.outline, width: 1.0, ), borderRadius: radius, diff --git a/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/primary_rounded_button.dart b/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/primary_rounded_button.dart index 4593ee1d22..af76b2cd6a 100644 --- a/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/primary_rounded_button.dart +++ b/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/primary_rounded_button.dart @@ -54,3 +54,46 @@ class PrimaryRoundedButton extends StatelessWidget { ); } } + +class OutlinedRoundedButton extends StatelessWidget { + const OutlinedRoundedButton({ + super.key, + required this.text, + this.onTap, + this.margin, + this.radius, + }); + + final String text; + final VoidCallback? onTap; + final EdgeInsets? margin; + final double? radius; + + @override + Widget build(BuildContext context) { + return DecoratedBox( + decoration: ShapeDecoration( + shape: RoundedRectangleBorder( + side: Theme.of(context).brightness == Brightness.light + ? const BorderSide(color: Color(0x1E14171B)) + : const BorderSide(color: Colors.white10), + borderRadius: BorderRadius.circular(radius ?? 8), + ), + ), + child: FlowyButton( + useIntrinsicWidth: true, + margin: margin ?? + const EdgeInsets.symmetric( + horizontal: 16.0, + vertical: 9.0, + ), + radius: BorderRadius.circular(radius ?? 8), + text: FlowyText.regular( + text, + lineHeight: 1.0, + ), + onTap: onTap, + ), + ); + } +}