diff --git a/device_preview/example/lib/generated_plugin_registrant.dart b/device_preview/example/lib/generated_plugin_registrant.dart index 4253a240..133238c4 100644 --- a/device_preview/example/lib/generated_plugin_registrant.dart +++ b/device_preview/example/lib/generated_plugin_registrant.dart @@ -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(); } diff --git a/device_preview/lib/src/tool_bar/menus/screenshot.dart b/device_preview/lib/src/tool_bar/menus/screenshot.dart index 4cf08f89..e57f727f 100644 --- a/device_preview/lib/src/tool_bar/menus/screenshot.dart +++ b/device_preview/lib/src/tool_bar/menus/screenshot.dart @@ -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, + ), + ], + ), + ], + )), ); } } diff --git a/device_preview/pubspec.yaml b/device_preview/pubspec.yaml index f29f989a..6a9372e4 100644 --- a/device_preview/pubspec.yaml +++ b/device_preview/pubspec.yaml @@ -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.