Skip to content

Commit

Permalink
feat: disable cut if no content in clipboard
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasXu0 committed Dec 19, 2024
1 parent 1788adc commit 02126b6
Showing 1 changed file with 25 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/mobile/presentation/base/animated_gesture.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/copy_and_paste/clipboard_service.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/simple_table/simple_table.dart';
import 'package:appflowy/startup/startup.dart';
import 'package:appflowy_backend/log.dart';
import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
Expand Down Expand Up @@ -77,9 +79,16 @@ class SimpleTableQuickActions extends StatelessWidget {
type: SimpleTableMoreAction.copy,
onTap: () => _onActionTap(context, SimpleTableMoreAction.copy),
),
SimpleTableQuickAction(
type: SimpleTableMoreAction.paste,
onTap: () => _onActionTap(context, SimpleTableMoreAction.paste),
FutureBuilder(
future: getIt<ClipboardService>().getData(),
builder: (context, snapshot) {
final hasContent = snapshot.data?.tableJson != null;
return SimpleTableQuickAction(
type: SimpleTableMoreAction.paste,
onTap: () => _onActionTap(context, SimpleTableMoreAction.paste),
isEnabled: hasContent,
);
},
),
SimpleTableQuickAction(
type: SimpleTableMoreAction.delete,
Expand Down Expand Up @@ -184,20 +193,25 @@ class SimpleTableQuickAction extends StatelessWidget {
super.key,
required this.type,
required this.onTap,
this.isEnabled = true,
});

final SimpleTableMoreAction type;
final void Function() onTap;
final VoidCallback onTap;
final bool isEnabled;

@override
Widget build(BuildContext context) {
return Expanded(
child: AnimatedGestureDetector(
onTapUp: onTap,
child: FlowySvg(
type.leftIconSvg,
blendMode: null,
size: const Size.square(24),
return Opacity(
opacity: isEnabled ? 1.0 : 0.5,
child: Expanded(
child: AnimatedGestureDetector(
onTapUp: isEnabled ? onTap : null,
child: FlowySvg(
type.leftIconSvg,
blendMode: null,
size: const Size.square(24),
),
),
),
);
Expand Down

0 comments on commit 02126b6

Please sign in to comment.