Skip to content

Commit a68e2e9

Browse files
Merge pull request #1 from rows/get-ready-opensource
Getting ready to opensource
2 parents 57a6c47 + 7c913f7 commit a68e2e9

File tree

90 files changed

+235
-156
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+235
-156
lines changed

Diff for: packages/LICENSE renamed to LICENSE

File renamed without changes.

Diff for: README.md

+20-2

Diff for: packages/clipboard_api/README.md

-4
This file was deleted.
File renamed without changes.

Diff for: packages/ditto/README.md

+42
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: example/lib/main.dart renamed to packages/ditto/example/lib/main.dart

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'package:clipboard_api/clipboard.dart';
1+
import 'package:ditto/ditto.dart';
22
import 'package:flutter/material.dart';
33

44
void main() {
@@ -90,23 +90,23 @@ class _MyAppState extends State<MyApp> {
9090
}
9191

9292
Future _paste() async {
93-
final data = await Clipboard.instance.getClipboardData(_clipboardDataType);
93+
final data = await Ditto.instance.getClipboardData(_clipboardDataType);
9494
_textEditingController.text = data!;
9595
}
9696

9797
Future _pasteRaw() async {
98-
final data = await Clipboard.instance.getClipboardRawData(
98+
final data = await Ditto.instance.getClipboardRawData(
9999
_clipboardDataType,
100100
);
101101
_textEditingController.text = data!;
102102
}
103103

104-
Future _copy() => Clipboard.instance.setClipboard(
104+
Future _copy() => Ditto.instance.setClipboard(
105105
_clipboardDataType,
106106
_textEditingController.text,
107107
);
108108

109-
Future _copyAllFormats() => Clipboard.instance.setClipboardData({
109+
Future _copyAllFormats() => Ditto.instance.setClipboardData({
110110
for (var type in ClipboardDataType.values)
111111
type: _textEditingController.text
112112
});
File renamed without changes.

Diff for: example/macos/Flutter/GeneratedPluginRegistrant.swift renamed to packages/ditto/example/macos/Flutter/GeneratedPluginRegistrant.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import FlutterMacOS
66
import Foundation
77

8-
import clipboard_macos
8+
import ditto_macos
99

1010
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
1111
ClipboardMacosPlugin.register(with: registry.registrar(forPlugin: "ClipboardMacosPlugin"))
File renamed without changes.

Diff for: example/macos/Podfile.lock renamed to packages/ditto/example/macos/Podfile.lock

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
PODS:
2-
- clipboard_macos (0.0.1):
2+
- ditto_macos (0.0.1):
33
- FlutterMacOS
44
- FlutterMacOS (1.0.0)
55

66
DEPENDENCIES:
7-
- clipboard_macos (from `Flutter/ephemeral/.symlinks/plugins/clipboard_macos/macos`)
7+
- ditto_macos (from `Flutter/ephemeral/.symlinks/plugins/ditto_macos/macos`)
88
- FlutterMacOS (from `Flutter/ephemeral`)
99

1010
EXTERNAL SOURCES:
11-
clipboard_macos:
12-
:path: Flutter/ephemeral/.symlinks/plugins/clipboard_macos/macos
11+
ditto_macos:
12+
:path: Flutter/ephemeral/.symlinks/plugins/ditto_macos/macos
1313
FlutterMacOS:
1414
:path: Flutter/ephemeral
1515

1616
SPEC CHECKSUMS:
17-
clipboard_macos: 88b70e7f3e97b9eae929fbecebc65a5476b5b872
17+
ditto_macos: 54d70189aec432dd44b5374bf6eba58e8f0ff018
1818
FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424
1919

2020
PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c

Diff for: example/macos/Runner.xcodeproj/project.pbxproj renamed to packages/ditto/example/macos/Runner.xcodeproj/project.pbxproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@
184184
33CC10EB2044A3C60003C045 /* Resources */,
185185
33CC110E2044A8840003C045 /* Bundle Framework */,
186186
3399D490228B24CF009A79C7 /* ShellScript */,
187-
DD5BF84EB732122B646CDDDB /* [CP] Embed Pods Frameworks */,
187+
B535ED8D89CFFE7BD6F36E52 /* [CP] Embed Pods Frameworks */,
188188
);
189189
buildRules = (
190190
);
@@ -313,7 +313,7 @@
313313
shellPath = /bin/sh;
314314
shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire";
315315
};
316-
DD5BF84EB732122B646CDDDB /* [CP] Embed Pods Frameworks */ = {
316+
B535ED8D89CFFE7BD6F36E52 /* [CP] Embed Pods Frameworks */ = {
317317
isa = PBXShellScriptBuildPhase;
318318
buildActionMask = 2147483647;
319319
files = (
File renamed without changes.

Diff for: example/pubspec.lock renamed to packages/ditto/example/pubspec.lock

+29-28
Original file line numberDiff line numberDiff line change
@@ -29,34 +29,6 @@ packages:
2929
url: "https://pub.dartlang.org"
3030
source: hosted
3131
version: "1.3.1"
32-
clipboard:
33-
dependency: "direct main"
34-
description:
35-
path: ".."
36-
relative: true
37-
source: path
38-
version: "0.0.1"
39-
clipboard_api:
40-
dependency: "direct overridden"
41-
description:
42-
path: "../packages/clipboard_api"
43-
relative: true
44-
source: path
45-
version: "0.0.1"
46-
clipboard_macos:
47-
dependency: "direct overridden"
48-
description:
49-
path: "../packages/clipboard_macos"
50-
relative: true
51-
source: path
52-
version: "0.0.1"
53-
clipboard_windows:
54-
dependency: "direct overridden"
55-
description:
56-
path: "../packages/clipboard_windows"
57-
relative: true
58-
source: path
59-
version: "0.0.1"
6032
clock:
6133
dependency: transitive
6234
description:
@@ -78,6 +50,34 @@ packages:
7850
url: "https://pub.dartlang.org"
7951
source: hosted
8052
version: "1.0.4"
53+
ditto:
54+
dependency: "direct main"
55+
description:
56+
path: ".."
57+
relative: true
58+
source: path
59+
version: "0.1.0"
60+
ditto_interface:
61+
dependency: transitive
62+
description:
63+
path: "../../ditto_interface"
64+
relative: true
65+
source: path
66+
version: "0.1.0"
67+
ditto_macos:
68+
dependency: transitive
69+
description:
70+
path: "../../ditto_macos"
71+
relative: true
72+
source: path
73+
version: "1.0.0"
74+
ditto_windows:
75+
dependency: transitive
76+
description:
77+
path: "../../ditto_windows"
78+
relative: true
79+
source: path
80+
version: "1.0.0"
8181
effective_dart:
8282
dependency: transitive
8383
description:
@@ -193,3 +193,4 @@ packages:
193193
version: "2.1.2"
194194
sdks:
195195
dart: ">=2.17.0-0 <3.0.0"
196+
flutter: ">=2.5.0"

Diff for: example/pubspec.yaml renamed to packages/ditto/example/pubspec.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
name: clipboard_plugin_example
2-
description: Demonstrates how to use the clipboard_plugin plugin.
3-
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
2+
description: Demonstrates how to use the ditto clipboard plugin.
3+
publish_to: 'none'
44

55
environment:
66
sdk: ">=2.12.0 <3.0.0"
77

88
dependencies:
99
flutter:
1010
sdk: flutter
11-
clipboard:
11+
ditto:
1212
path: ../
1313

1414
cupertino_icons: ^1.0.2
File renamed without changes.
File renamed without changes.

Diff for: example/windows/flutter/generated_plugin_registrant.cc renamed to packages/ditto/example/windows/flutter/generated_plugin_registrant.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#include "generated_plugin_registrant.h"
88

9-
#include <clipboard_windows/clipboard_plugin.h>
9+
#include <ditto_windows/clipboard_plugin.h>
1010

1111
void RegisterPlugins(flutter::PluginRegistry* registry) {
1212
ClipboardPluginRegisterWithRegistrar(

Diff for: example/windows/flutter/generated_plugins.cmake renamed to packages/ditto/example/windows/flutter/generated_plugins.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44

55
list(APPEND FLUTTER_PLUGIN_LIST
6-
clipboard_windows
6+
ditto_windows
77
)
88

99
list(APPEND FLUTTER_FFI_PLUGIN_LIST
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: packages/ditto/lib/ditto.dart

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export 'package:ditto_interface/ditto.dart';

Diff for: packages/ditto/pubspec.yaml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: ditto
2+
description: The common API for clipboard platform plugins
3+
version: 0.1.0
4+
publish_to: 'none'
5+
6+
environment:
7+
sdk: ">=2.12.0 <3.0.0"
8+
flutter: ">=1.17.0"
9+
10+
dependencies:
11+
ditto_interface:
12+
path: ../ditto_interface
13+
ditto_macos:
14+
path: ../ditto_macos
15+
ditto_windows:
16+
path: ../ditto_windows
17+
18+
flutter:
19+
sdk: flutter
20+
21+
dev_dependencies:
22+
rows_lint: 0.1.1
23+
24+
flutter:
25+
plugin:
26+
platforms:
27+
windows:
28+
default_package: ditto_windows
29+
macos:
30+
default_package: ditto_macos
File renamed without changes.

Diff for: packages/ditto_interface/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import 'dart:async';
22

3+
import 'package:flutter/services.dart';
4+
35
enum ClipboardDataType { text, html }
46

57
/// A class to interact with the clipboard supporting multiple data formats.
6-
/// Use [Clipboard.instance] to interact with the system's clipboard.
7-
abstract class Clipboard {
8+
/// Use [Ditto.instance] to interact with the system's clipboard.
9+
abstract class Ditto {
810
/// Platform-specific plugins should set this with their own platform-specific
9-
/// class that extends [Clipboard] when they register themselves.
10-
static Clipboard instance = _UnsupportedPlatformClipboard();
11+
/// class that extends [Ditto] when they register themselves.
12+
static Ditto instance = _FallbackPlatformClipboard();
1113

1214
/// Checks if the current clipboard content supports the given [type].
1315
Future<bool> hasDataType(ClipboardDataType type);
@@ -40,41 +42,28 @@ abstract class Clipboard {
4042
Future<String?> get clipboardHtml => getClipboardData(ClipboardDataType.html);
4143
}
4244

43-
/// Empty clipboard implementation that throws an exception for unsupported
44-
/// platforms.
45-
class _UnsupportedPlatformClipboard extends Clipboard {
45+
/// A Ditto implementation for platforms where the plugin is not available.
46+
/// Falls back to Flutter default clipboard implementation.
47+
class _FallbackPlatformClipboard extends Ditto {
4648
@override
47-
Future<String?> getClipboardData(ClipboardDataType dataType) {
48-
throw UnimplementedError(
49-
'Clipboard plugin not implemented in this platform.',
50-
);
49+
Future<String?> getClipboardData(ClipboardDataType dataType) async {
50+
final data = await Clipboard.getData(Clipboard.kTextPlain);
51+
return data?.text;
5152
}
5253

5354
@override
54-
Future<bool> hasDataType(ClipboardDataType type) {
55-
throw UnimplementedError(
56-
'Clipboard plugin not implemented in this platform.',
57-
);
58-
}
55+
Future<bool> hasDataType(ClipboardDataType type) =>
56+
Future.value(type == ClipboardDataType.text);
5957

6058
@override
61-
Future<void> setClipboard(ClipboardDataType dataType, String content) {
62-
throw UnimplementedError(
63-
'Clipboard plugin not implemented in this platform.',
64-
);
65-
}
59+
Future<void> setClipboard(ClipboardDataType dataType, String content) =>
60+
Clipboard.setData(ClipboardData(text: content));
6661

6762
@override
68-
Future<void> setClipboardData(Map<ClipboardDataType, String> data) {
69-
throw UnimplementedError(
70-
'Clipboard plugin not implemented in this platform.',
71-
);
72-
}
63+
Future<void> setClipboardData(Map<ClipboardDataType, String> data) =>
64+
Clipboard.setData(ClipboardData(text: data.values.first));
7365

7466
@override
75-
Future<String?> getClipboardRawData(ClipboardDataType dataType) {
76-
throw UnimplementedError(
77-
'Clipboard plugin not implemented in this platform.',
78-
);
79-
}
67+
Future<String?> getClipboardRawData(ClipboardDataType dataType) =>
68+
getClipboardData(dataType);
8069
}

Diff for: packages/clipboard_api/pubspec.yaml renamed to packages/ditto_interface/pubspec.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
name: clipboard_api
1+
name: ditto_interface
22
description: The common API for clipboard platform plugins
3-
version: 0.0.1
3+
version: 0.1.0
44
publish_to: 'none'
55

66
environment:
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)