implemented selection api

This commit is contained in:
Fabian Freund
2024-10-25 06:46:39 +02:00
parent 8d351e55c0
commit 6a0f0eb08c
15 changed files with 565 additions and 427 deletions
@@ -0,0 +1,61 @@
import 'package:flutter_mozilla_components/src/pigeons/gecko.g.dart';
typedef PerformAction = void Function(String selectedText);
class BaseSelectionAction extends CustomSelectionAction {
final PerformAction performAction;
BaseSelectionAction({
required super.id,
required super.title,
required this.performAction,
super.pattern,
});
}
class CallAction extends BaseSelectionAction {
CallAction(PerformAction action)
: super(
id: 'CUSTOM_CONTEXT_MENU_CALL',
title: 'Call',
pattern: SelectionPattern.phone,
performAction: action,
);
}
class EmailAction extends BaseSelectionAction {
EmailAction(PerformAction action)
: super(
id: 'CUSTOM_CONTEXT_MENU_EMAIL',
title: 'Email',
pattern: SelectionPattern.email,
performAction: action,
);
}
class SearchAction extends BaseSelectionAction {
SearchAction(PerformAction action)
: super(
id: 'CUSTOM_CONTEXT_MENU_SEARCH',
title: 'Search',
performAction: action,
);
}
class PrivateSearchAction extends BaseSelectionAction {
PrivateSearchAction(PerformAction action)
: super(
id: 'CUSTOM_CONTEXT_MENU_SEARCH_PRIVATELY',
title: 'Private Search',
performAction: action,
);
}
class ShareAction extends BaseSelectionAction {
ShareAction(PerformAction action)
: super(
id: 'CUSTOM_CONTEXT_MENU_SHARE',
title: 'Share',
performAction: action,
);
}