From 102df2ef1cd76cebd06b4954ec49b074f0eff25f Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 27 Jul 2024 02:11:59 +0800 Subject: [PATCH] :sparkles: Share --- ios/Podfile.lock | 6 +++++ lib/bootstrapper.dart | 17 +++++++++----- lib/translations/en_us.dart | 3 +++ lib/translations/zh_cn.dart | 3 +++ lib/widgets/posts/post_action.dart | 23 ++++++++++++++++++- macos/Flutter/GeneratedPluginRegistrant.swift | 2 ++ macos/Podfile.lock | 6 +++++ pubspec.lock | 16 +++++++++++++ pubspec.yaml | 3 ++- .../flutter/generated_plugin_registrant.cc | 3 +++ windows/flutter/generated_plugins.cmake | 1 + 11 files changed, 75 insertions(+), 8 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 7eee836..982f754 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -143,6 +143,8 @@ PODS: - Flutter - FlutterMacOS - Sentry/HybridSDK (= 8.32.0) + - share_plus (0.0.1): + - Flutter - sqflite (0.0.3): - Flutter - FlutterMacOS @@ -176,6 +178,7 @@ DEPENDENCIES: - protocol_handler_ios (from `.symlinks/plugins/protocol_handler_ios/ios`) - screen_brightness_ios (from `.symlinks/plugins/screen_brightness_ios/ios`) - sentry_flutter (from `.symlinks/plugins/sentry_flutter/ios`) + - share_plus (from `.symlinks/plugins/share_plus/ios`) - sqflite (from `.symlinks/plugins/sqflite/darwin`) - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) - volume_controller (from `.symlinks/plugins/volume_controller/ios`) @@ -240,6 +243,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/screen_brightness_ios/ios" sentry_flutter: :path: ".symlinks/plugins/sentry_flutter/ios" + share_plus: + :path: ".symlinks/plugins/share_plus/ios" sqflite: :path: ".symlinks/plugins/sqflite/darwin" url_launcher_ios: @@ -283,6 +288,7 @@ SPEC CHECKSUMS: SDWebImage: 066c47b573f408f18caa467d71deace7c0f8280d Sentry: 96ae1dcdf01a644bc3a3b1dc279cecaf48a833fb sentry_flutter: f1d86adcb93a959bc47a40d8d55059bdf7569bc5 + share_plus: 8875f4f2500512ea181eef553c3e27dba5135aad sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec SwiftyGif: 706c60cf65fa2bc5ee0313beece843c8eb8194d4 url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe diff --git a/lib/bootstrapper.dart b/lib/bootstrapper.dart index 41c2ee8..825fe4c 100644 --- a/lib/bootstrapper.dart +++ b/lib/bootstrapper.dart @@ -6,6 +6,7 @@ import 'package:solian/providers/content/channel.dart'; import 'package:solian/providers/relation.dart'; import 'package:solian/providers/websocket.dart'; import 'package:solian/services.dart'; +import 'package:solian/widgets/sized_container.dart'; class BootstrapperShell extends StatefulWidget { final Widget child; @@ -129,12 +130,16 @@ class _BootstrapperShellState extends State { child: CircularProgressIndicator(strokeWidth: 3), ), const SizedBox(height: 12), - Text( - _subtitle ?? - '${_periods[_periodCursor].label.tr} (${_periodCursor + 1}/${_periods.length})', - style: TextStyle( - fontSize: 13, - color: _unFocusColor, + CenteredContainer( + maxWidth: 280, + child: Text( + _subtitle ?? + '${_periods[_periodCursor].label.tr} (${_periodCursor + 1}/${_periods.length})', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 13, + color: _unFocusColor, + ), ), ), ], diff --git a/lib/translations/en_us.dart b/lib/translations/en_us.dart index 4f84f36..cb97cc9 100644 --- a/lib/translations/en_us.dart +++ b/lib/translations/en_us.dart @@ -10,6 +10,7 @@ const messagesEnglish = { 'draft': 'Draft', 'draftSave': 'Save', 'draftBox': 'Draft Box', + 'share': 'Share', 'feed': 'Feed', 'feedSearch': 'Search Feed', 'feedSearchWithTag': 'Searching with tag #@key', @@ -282,4 +283,6 @@ const messagesEnglish = { 'bsEstablishingConn': 'Establishing Connection', 'bsPreparingData': 'Preparing User Data', 'bsRegisteringPushNotify': 'Enabling Push Notifications', + 'postShareContent': '@content\n\n@username on the Solar Network\nCheck it out: @link', + 'postShareSubject': '@username posted a post on the Solar Network', }; diff --git a/lib/translations/zh_cn.dart b/lib/translations/zh_cn.dart index 69cf180..8c68dfd 100644 --- a/lib/translations/zh_cn.dart +++ b/lib/translations/zh_cn.dart @@ -17,6 +17,7 @@ const simplifiedChineseMessages = { 'draft': '草稿', 'draftSave': '存为草稿', 'draftBox': '草稿箱', + 'share': '分享', 'feed': '资讯', 'feedSearch': '搜索资讯', 'feedSearchWithTag': '检索带有 #@key 标签的资讯', @@ -261,4 +262,6 @@ const simplifiedChineseMessages = { 'bsEstablishingConn': '部署连接中', 'bsPreparingData': '正在准备用户资料', 'bsRegisteringPushNotify': '正在启用推送通知', + 'postShareContent': '@content\n\n@username 在 Solar Network\n原帖地址:@link', + 'postShareSubject': '@username 在 Solar Network 上发布了一篇帖子', }; diff --git a/lib/widgets/posts/post_action.dart b/lib/widgets/posts/post_action.dart index 270ec19..61f85b1 100644 --- a/lib/widgets/posts/post_action.dart +++ b/lib/widgets/posts/post_action.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_animate/flutter_animate.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:get/get.dart'; +import 'package:share_plus/share_plus.dart'; import 'package:solian/exts.dart'; import 'package:solian/models/post.dart'; import 'package:solian/providers/auth.dart'; @@ -66,6 +67,25 @@ class _PostActionState extends State { Expanded( child: ListView( children: [ + ListTile( + contentPadding: const EdgeInsets.symmetric(horizontal: 24), + leading: const Icon(Icons.share), + title: Text('share'.tr), + onTap: () async { + await Share.share( + 'postShareContent'.trParams({ + 'username': widget.item.author.nick, + 'content': widget.item.body['text'], + 'link': + 'https://sn.solsynth.dev/posts/${widget.item.id}', + }), + subject: 'postShareSubject'.trParams({ + 'username': widget.item.author.nick, + }), + ); + Navigator.pop(context); + }, + ), if (!widget.noReact) ListTile( contentPadding: const EdgeInsets.symmetric(horizontal: 24), @@ -109,7 +129,8 @@ class _PostActionState extends State { : 'unpinPost'.tr, ), onTap: () async { - final client = Get.find().configureClient('interactive'); + final client = Get.find() + .configureClient('interactive'); await client.post('/posts/${widget.item.id}/pin', {}); Navigator.pop(context, true); }, diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index b792469..545592f 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -23,6 +23,7 @@ import path_provider_foundation import protocol_handler_macos import screen_brightness_macos import sentry_flutter +import share_plus import sqflite import url_launcher_macos import wakelock_plus @@ -46,6 +47,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { ProtocolHandlerMacosPlugin.register(with: registry.registrar(forPlugin: "ProtocolHandlerMacosPlugin")) ScreenBrightnessMacosPlugin.register(with: registry.registrar(forPlugin: "ScreenBrightnessMacosPlugin")) SentryFlutterPlugin.register(with: registry.registrar(forPlugin: "SentryFlutterPlugin")) + SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin")) SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) WakelockPlusMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockPlusMacosPlugin")) diff --git a/macos/Podfile.lock b/macos/Podfile.lock index e34afc3..f67d84c 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -109,6 +109,8 @@ PODS: - Flutter - FlutterMacOS - Sentry/HybridSDK (= 8.32.0) + - share_plus (0.0.1): + - FlutterMacOS - sqflite (0.0.3): - Flutter - FlutterMacOS @@ -139,6 +141,7 @@ DEPENDENCIES: - protocol_handler_macos (from `Flutter/ephemeral/.symlinks/plugins/protocol_handler_macos/macos`) - screen_brightness_macos (from `Flutter/ephemeral/.symlinks/plugins/screen_brightness_macos/macos`) - sentry_flutter (from `Flutter/ephemeral/.symlinks/plugins/sentry_flutter/macos`) + - share_plus (from `Flutter/ephemeral/.symlinks/plugins/share_plus/macos`) - sqflite (from `Flutter/ephemeral/.symlinks/plugins/sqflite/darwin`) - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) - wakelock_plus (from `Flutter/ephemeral/.symlinks/plugins/wakelock_plus/macos`) @@ -198,6 +201,8 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/screen_brightness_macos/macos sentry_flutter: :path: Flutter/ephemeral/.symlinks/plugins/sentry_flutter/macos + share_plus: + :path: Flutter/ephemeral/.symlinks/plugins/share_plus/macos sqflite: :path: Flutter/ephemeral/.symlinks/plugins/sqflite/darwin url_launcher_macos: @@ -236,6 +241,7 @@ SPEC CHECKSUMS: screen_brightness_macos: 2d6d3af2165592d9a55ffcd95b7550970e41ebda Sentry: 96ae1dcdf01a644bc3a3b1dc279cecaf48a833fb sentry_flutter: f1d86adcb93a959bc47a40d8d55059bdf7569bc5 + share_plus: 36537c04ce0c3e3f5bd297ce4318b6d5ee5fd6cf sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec url_launcher_macos: 5f437abeda8c85500ceb03f5c1938a8c5a705399 wakelock_plus: 4783562c9a43d209c458cb9b30692134af456269 diff --git a/pubspec.lock b/pubspec.lock index 21b044f..9157a6f 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1360,6 +1360,22 @@ packages: url: "https://pub.dev" source: hosted version: "8.5.0" + share_plus: + dependency: "direct main" + description: + name: share_plus + sha256: ef3489a969683c4f3d0239010cc8b7a2a46543a8d139e111c06c558875083544 + url: "https://pub.dev" + source: hosted + version: "9.0.0" + share_plus_platform_interface: + dependency: transitive + description: + name: share_plus_platform_interface + sha256: "0f9e4418835d1b2c3ae78fdb918251959106cefdbc4dd43526e182f80e82f6d4" + url: "https://pub.dev" + source: hosted + version: "4.0.0" shelf: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 290b9c7..0c2b3d5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: solian description: "The Solar Network App" publish_to: "none" -version: 1.1.0+46 +version: 1.1.0+47 environment: sdk: ">=3.3.4 <4.0.0" @@ -55,6 +55,7 @@ dependencies: badges: ^3.1.2 flutter_card_swiper: ^7.0.1 dismissible_page: ^1.0.2 + share_plus: ^9.0.0 dev_dependencies: flutter_test: diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index af6068c..944c2e7 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -21,6 +21,7 @@ #include #include #include +#include #include void RegisterPlugins(flutter::PluginRegistry* registry) { @@ -54,6 +55,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) { registry->GetRegistrarForPlugin("ScreenBrightnessWindowsPlugin")); SentryFlutterPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("SentryFlutterPlugin")); + SharePlusWindowsPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi")); UrlLauncherWindowsRegisterWithRegistrar( registry->GetRegistrarForPlugin("UrlLauncherWindows")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index ea1b98e..449dcf5 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -18,6 +18,7 @@ list(APPEND FLUTTER_PLUGIN_LIST protocol_handler_windows screen_brightness_windows sentry_flutter + share_plus url_launcher_windows )