diff --git a/lib/pages/paynym/paynym_home_view.dart b/lib/pages/paynym/paynym_home_view.dart index 4d4efeb0d..b34c05b12 100644 --- a/lib/pages/paynym/paynym_home_view.dart +++ b/lib/pages/paynym/paynym_home_view.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; +import 'package:share_plus/share_plus.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/pages/paynym/add_new_paynym_follow_view.dart'; import 'package:stackwallet/pages/paynym/dialogs/paynym_qr_popup.dart'; @@ -358,8 +359,25 @@ class _PaynymHomeViewState extends ConsumerState { .extension()! .textDark, ), - onPressed: () { - // copy to clipboard + onPressed: () async { + Rect? sharePositionOrigin; + if (await Util.isIPad) { + final box = + context.findRenderObject() as RenderBox?; + if (box != null) { + sharePositionOrigin = + box.localToGlobal(Offset.zero) & box.size; + } + } + + await Share.share( + ref + .read(myPaynymAccountStateProvider.state) + .state! + .codes + .first + .code, + sharePositionOrigin: sharePositionOrigin); }, ), ), diff --git a/lib/utilities/util.dart b/lib/utilities/util.dart index 2940b6d40..6a31fae04 100644 --- a/lib/utilities/util.dart +++ b/lib/utilities/util.dart @@ -1,5 +1,6 @@ import 'dart:io'; +import 'package:device_info_plus/device_info_plus.dart'; import 'package:flutter/material.dart'; abstract class Util { @@ -22,6 +23,14 @@ abstract class Util { return Platform.isLinux || Platform.isMacOS || Platform.isWindows; } + static Future get isIPad async { + final deviceInfo = (await DeviceInfoPlugin().deviceInfo); + if (deviceInfo is IosDeviceInfo) { + return (deviceInfo).name?.toLowerCase().contains("ipad") == true; + } + return false; + } + static MaterialColor createMaterialColor(Color color) { List strengths = [.05]; final swatch = {}; diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 59063791f..7c5023a1c 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -14,7 +14,7 @@ import flutter_secure_storage_macos import isar_flutter_libs import package_info_plus_macos import path_provider_macos -import share_plus_macos +import share_plus import shared_preferences_macos import stack_wallet_backup import url_launcher_macos diff --git a/pubspec.lock b/pubspec.lock index 073ef8a47..5949543b2 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1237,21 +1237,7 @@ packages: name: share_plus url: "https://pub.dartlang.org" source: hosted - version: "4.5.3" - share_plus_linux: - dependency: transitive - description: - name: share_plus_linux - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.1" - share_plus_macos: - dependency: transitive - description: - name: share_plus_macos - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.1" + version: "6.3.0" share_plus_platform_interface: dependency: transitive description: @@ -1259,20 +1245,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.2.0" - share_plus_web: - dependency: transitive - description: - name: share_plus_web - url: "https://pub.dartlang.org" - source: hosted - version: "3.1.0" - share_plus_windows: - dependency: transitive - description: - name: share_plus_windows - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.1" shared_preferences: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 6cba3b460..61c22e7aa 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -126,7 +126,7 @@ dependencies: tuple: ^2.0.0 flutter_riverpod: ^1.0.3 qr_flutter: ^4.0.0 - share_plus: ^4.0.10 + share_plus: ^6.3.0 emojis: ^0.9.9 pointycastle: ^3.6.0 package_info_plus: ^1.4.2 diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 98655fe05..e265edffe 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -26,6 +27,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) { registry->GetRegistrarForPlugin("IsarFlutterLibsPlugin")); PermissionHandlerWindowsPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin")); + SharePlusWindowsPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi")); StackWalletBackupPluginCApiRegisterWithRegistrar( registry->GetRegistrarForPlugin("StackWalletBackupPluginCApi")); UrlLauncherWindowsRegisterWithRegistrar( diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 4426d9497..6a4a3acbf 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -8,6 +8,7 @@ list(APPEND FLUTTER_PLUGIN_LIST flutter_secure_storage_windows isar_flutter_libs permission_handler_windows + share_plus stack_wallet_backup url_launcher_windows window_size