Skip to content

Commit 73360ef

Browse files
committed
Add a Copy to Clipboard action
CopyToClipboardAction copies a text (with variables and formulas), e.g. a home's share link. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0186HDSCvPDpNcgTDiXgg3qb
1 parent fb9b0fd commit 73360ef

27 files changed

Lines changed: 155 additions & 1 deletion

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
action.
1515
- `ShowDialogAction.fullHeight` for a bottom sheet whose layout scrolls its
1616
own content.
17+
- `CopyToClipboardAction` (`ActionType.copyToClipboard`) copies a text, with
18+
variables and formulas.
1719

1820
### Data
1921

‎lib/src/api/models/action/action.dart‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ enum ActionType {
6464
cloudData,
6565

6666
/// Write several cloud documents together.
67-
cloudBatch;
67+
cloudBatch,
68+
69+
/// Copy a text to the clipboard.
70+
copyToClipboard;
6871

6972
/// Displayable string representation of the [ActionType].
7073
String get prettify {
@@ -111,6 +114,8 @@ enum ActionType {
111114
return 'Cloud Data';
112115
case ActionType.cloudBatch:
113116
return 'Cloud Batch';
117+
case ActionType.copyToClipboard:
118+
return 'Copy to Clipboard';
114119
}
115120
}
116121
}
@@ -202,6 +207,8 @@ abstract class ActionModel with SerializableMixin {
202207
return CloudDataAction.fromJson(json);
203208
case ActionType.cloudBatch:
204209
return CloudBatchAction.fromJson(json);
210+
case ActionType.copyToClipboard:
211+
return CopyToClipboardAction.fromJson(json);
205212
}
206213
}
207214

‎lib/src/api/models/action/api_call_action.g.dart‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/src/api/models/action/auth_action.g.dart‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/src/api/models/action/call_function_action.g.dart‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/src/api/models/action/cloud_data_action.g.dart‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/src/api/models/action/cloud_files_action.g.dart‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/src/api/models/action/conditional_action.g.dart‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/src/api/models/action/confirm_action.g.dart‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import 'package:equatable/equatable.dart';
2+
import 'package:json_annotation/json_annotation.dart';
3+
4+
import '../../mixins.dart';
5+
import '../models.dart';
6+
7+
part 'copy_to_clipboard_action.g.dart';
8+
9+
/// Copies a text to the clipboard, e.g. a link to share. Pair it with a
10+
/// toast to say so.
11+
@JsonSerializable()
12+
class CopyToClipboardAction extends ActionModel
13+
with Equatable, SerializableMixin {
14+
/// The text to copy. Supports variables and formulas, e.g.
15+
/// `https://nook.homes/homes/${route.homeId}`.
16+
final String text;
17+
18+
/// Creates a [CopyToClipboardAction].
19+
CopyToClipboardAction({this.text = '', super.nonBlocking, super.enabled})
20+
: super(type: ActionType.copyToClipboard);
21+
22+
/// Duplicates this action with the given values replaced.
23+
CopyToClipboardAction copyWith({String? text}) => CopyToClipboardAction(
24+
text: text ?? this.text,
25+
nonBlocking: nonBlocking,
26+
enabled: enabled,
27+
);
28+
29+
@override
30+
List<Object?> get props => [text];
31+
32+
/// Creates an instance from a JSON object.
33+
factory CopyToClipboardAction.fromJson(Map json) =>
34+
_$CopyToClipboardActionFromJson(json);
35+
36+
@override
37+
Map toJson() => _$CopyToClipboardActionOmitDefaults(
38+
this,
39+
_$CopyToClipboardActionToJson(this),
40+
);
41+
42+
@override
43+
R? accept<R>(ActionVisitor<R> visitor) =>
44+
visitor.visitCopyToClipboardAction(this);
45+
}

0 commit comments

Comments
 (0)