Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to Copy to Clipboard #40

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions device_preview/example/lib/generated_plugin_registrant.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
import 'dart:ui';

import 'package:shared_preferences_web/shared_preferences_web.dart';
import 'package:url_launcher_web/url_launcher_web.dart';

import 'package:flutter_web_plugins/flutter_web_plugins.dart';

// ignore: public_member_api_docs
void registerPlugins(PluginRegistry registry) {
SharedPreferencesPlugin.registerWith(registry.registrarFor(SharedPreferencesPlugin));
UrlLauncherPlugin.registerWith(registry.registrarFor(UrlLauncherPlugin));
registry.registerMessageHandler();
}
53 changes: 45 additions & 8 deletions device_preview/lib/src/tool_bar/menus/screenshot.dart
Original file line number Diff line number Diff line change
@@ -1,23 +1,60 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_clipboard_manager/flutter_clipboard_manager.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:url_launcher/url_launcher.dart';

import '../../device_preview_style.dart';
import '../button.dart';

class ScreenshotPopOver extends StatelessWidget {
final String message;

const ScreenshotPopOver(this.message);

void launchUrl() async {
String url = message.split(' ')[6];
if (await canLaunch(url)) {
await launch(url);
}
}

void copyToClipboard() {
String url = message.split(' ')[6];
FlutterClipboardManager.copyToClipBoard(url);
}

@override
Widget build(BuildContext context) {
final toolBarStyle = DevicePreviewTheme.of(context).toolBar;
return Padding(
padding: const EdgeInsets.all(10.0),
child: Text(
message,
style: TextStyle(
color: toolBarStyle.foregroundColor,
),
),
return Center(
child: Padding(
padding: const EdgeInsets.all(10),
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
GestureDetector(
onTap: launchUrl,
child: Text(
message,
textAlign: TextAlign.center,
style: TextStyle(
color: toolBarStyle.foregroundColor,
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ToolBarButton(
title: 'Copy To Clipboard',
icon: FontAwesomeIcons.clipboard,
onTap: copyToClipboard,
),
],
),
],
)),
);
}
}
3 changes: 3 additions & 0 deletions device_preview/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ dependencies:
meta: ^1.1.8
shared_preferences: ^0.5.6+3
shared_preferences_macos: ^0.0.1+6
url_launcher: ^5.4.5
flutter_clipboard_manager: ^0.0.2


# This is a temporary hack to enable Windows to work. It is not recommended
# since this package may change at any time in ways that break.
Expand Down