Prechádzať zdrojové kódy

[new]ios新增分享

Destiny 1 rok pred
rodič
commit
e88f1f27f4

+ 6 - 0
ios/Podfile.lock

@@ -74,6 +74,8 @@ PODS:
   - SDWebImage (5.19.0):
     - SDWebImage/Core (= 5.19.0)
   - SDWebImage/Core (5.19.0)
+  - share_plus (0.0.1):
+    - Flutter
   - shared_preferences_foundation (0.0.1):
     - Flutter
     - FlutterMacOS
@@ -121,6 +123,7 @@ DEPENDENCIES:
   - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
   - photo_manager (from `.symlinks/plugins/photo_manager/ios`)
   - record_darwin (from `.symlinks/plugins/record_darwin/ios`)
+  - share_plus (from `.symlinks/plugins/share_plus/ios`)
   - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
   - shortcut (from `.symlinks/plugins/shortcut/ios`)
   - sqflite_darwin (from `.symlinks/plugins/sqflite_darwin/darwin`)
@@ -173,6 +176,8 @@ EXTERNAL SOURCES:
     :path: ".symlinks/plugins/photo_manager/ios"
   record_darwin:
     :path: ".symlinks/plugins/record_darwin/ios"
+  share_plus:
+    :path: ".symlinks/plugins/share_plus/ios"
   shared_preferences_foundation:
     :path: ".symlinks/plugins/shared_preferences_foundation/darwin"
   shortcut:
@@ -214,6 +219,7 @@ SPEC CHECKSUMS:
   photo_manager: ff695c7a1dd5bc379974953a2b5c0a293f7c4c8a
   record_darwin: df0a677188e5fed18472550298e675f19ddaffbe
   SDWebImage: 981fd7e860af070920f249fd092420006014c3eb
+  share_plus: 8875f4f2500512ea181eef553c3e27dba5135aad
   shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
   shortcut: 4fb7f85e55054fc349f3adc91dc852871ebc28b9
   sqflite_darwin: a553b1fd6fe66f53bbb0fe5b4f5bab93f08d7a13

+ 3 - 1
lib/dialog/show_update_version_dialog.dart

@@ -180,7 +180,9 @@ class UpdateVersionDialog {
         ToastUtil.showToast('更新失败');
       }
     } else if (Platform.isIOS) {
-      //TODO ios 跳转苹果商店下载
+      // ios 跳转苹果商店
+      LauncherUrlUtil.launchHttpUrl(
+          'itms-apps://itunes.apple.com/us/app/apple-store/6683306440');
     }
   }
 }

+ 55 - 21
lib/dialog/talk_share_dialog.dart

@@ -83,26 +83,60 @@ void showTalkShareDialog(String? title, TalkShareCallback callback) {
                     );
                   }),
                   SizedBox(height: 16.h),
-                  Text(
-                    '发送至',
-                    style: TextStyle(
-                        fontSize: 14.sp, color: ColorName.secondaryTextColor),
-                  ),
-                  SizedBox(height: 8.h),
-                  Row(
-                    children: [
-                      _buildShareItem(StringName.dialogSendFriend.tr,
-                          Assets.images.iconWx.provider(), () {
-                        callback(shareType.value, ShareTo.wechat, getFileName(),
-                            tag);
-                      }),
-                      _buildShareItem(StringName.dialogSendFriend.tr,
-                          Assets.images.iconQq.provider(), () {
-                        callback(
-                            shareType.value, ShareTo.qq, getFileName(), tag);
-                      }),
-                    ],
-                  )
+                  GetPlatform.isIOS
+                      ? GestureDetector(
+                          onTap: () {
+                            callback(shareType.value, ShareTo.ios, tag);
+                          },
+                          child: Container(
+                            margin: EdgeInsets.only(top: 8.h),
+                            decoration: BoxDecoration(
+                              borderRadius: BorderRadius.circular(8),
+                              gradient: LinearGradient(
+                                colors: [
+                                  '#6177F2'.toColor(),
+                                  '#8B9DFF'.toColor()
+                                ],
+                                begin: Alignment.centerLeft,
+                                end: Alignment.centerRight,
+                                stops: const [0, 1.0],
+                              ),
+                            ),
+                            // width: 240.w,
+                            height: 48.w,
+                            child: Center(
+                              child: Text(
+                                "分享",
+                                style: TextStyle(
+                                    fontSize: 16.sp, color: ColorName.white),
+                              ),
+                            ),
+                          ),
+                        )
+                      : Column(
+                          children: [
+                            Text(
+                              '发送至',
+                              style: TextStyle(
+                                  fontSize: 14.sp,
+                                  color: ColorName.secondaryTextColor),
+                            ),
+                            SizedBox(height: 8.h),
+                            Row(
+                              children: [
+                                _buildShareItem(StringName.dialogSendFriend.tr,
+                                    Assets.images.iconWx.provider(), () {
+                                  callback(
+                                      shareType.value, ShareTo.wechat, tag);
+                                }),
+                                _buildShareItem(StringName.dialogSendFriend.tr,
+                                    Assets.images.iconQq.provider(), () {
+                                  callback(shareType.value, ShareTo.qq, tag);
+                                }),
+                              ],
+                            )
+                          ],
+                        ),
                 ],
               ),
             ),
@@ -159,4 +193,4 @@ Widget _buildShareItem(
 
 enum ShareTalkType { summary, original }
 
-enum ShareTo { wechat, qq }
+enum ShareTo { wechat, qq, ios }

+ 5 - 1
lib/module/talk/controller.dart

@@ -42,6 +42,7 @@ import '../../utils/system_share_util.dart';
 import '../../utils/toast_util.dart';
 import '../record/controller.dart';
 import 'original/view.dart';
+import 'package:share_plus/share_plus.dart';
 
 class TalkController extends BaseController {
   static const String argumentItem = 'argument_item';
@@ -566,7 +567,10 @@ class TalkController extends BaseController {
       talkRepository
           .talkExport(talkBean.value!.id, fileName, type)
           .then((file) async {
-        if (shareTo == ShareTo.wechat) {
+        if (shareTo == ShareTo.ios) {
+          final result = await Share.shareXFiles([XFile(file.path)]);
+          // Share.share('check out my website https://example.com');
+        } else if (shareTo == ShareTo.wechat) {
           await SystemShareUtil.shareWechatFile(file.path);
         } else {
           await SystemShareUtil.shareQQFile(file.path);

+ 6 - 4
lib/utils/desktop_shortcut_utils.dart

@@ -5,6 +5,7 @@ import 'package:app_links/app_links.dart';
 import 'package:electronic_assistant/base/base_controller.dart';
 import 'package:electronic_assistant/main.dart';
 import 'package:electronic_assistant/router/app_pages.dart';
+import 'package:electronic_assistant/utils/launcher_url_util.dart';
 import 'package:electronic_assistant/utils/mmkv_util.dart';
 import 'package:electronic_assistant/utils/toast_util.dart';
 import 'package:flutter/material.dart';
@@ -71,10 +72,11 @@ class DesktopShortcutUtils {
   }
 
   static Future<void> _launchUrl() async {
-    final Uri url = Uri.parse('https://xiaoting.atmob.com/record');
-    if (!await launchUrl(url, mode: LaunchMode.externalApplication)) {
-      throw Exception('Could not launch');
-    }
+    LauncherUrlUtil.launchHttpUrl('https://xiaoting.atmob.com/record');
+    // final Uri url = Uri.parse('https://xiaoting.atmob.com/record');
+    // if (!await launchUrl(url, mode: LaunchMode.externalApplication)) {
+    //   throw Exception('Could not launch');
+    // }
   }
 
   static bool _isShow() {

+ 16 - 0
pubspec.lock

@@ -1195,6 +1195,22 @@ packages:
       url: "https://pub.dev"
     source: hosted
     version: "0.28.0"
+  share_plus:
+    dependency: "direct main"
+    description:
+      name: share_plus
+      sha256: fec12c3c39f01e4df1ec6ad92b6e85503c5ca64ffd6e28d18c9ffe53fcc4cb11
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "10.0.3"
+  share_plus_platform_interface:
+    dependency: transitive
+    description:
+      name: share_plus_platform_interface
+      sha256: c57c0bbfec7142e3a0f55633be504b796af72e60e3c791b44d5a017b985f7a48
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "5.0.1"
   shared_preferences:
     dependency: transitive
     description:

+ 2 - 0
pubspec.yaml

@@ -120,6 +120,8 @@ dependencies:
   #跳转浏览器
   url_launcher: ^6.3.1
 
+  share_plus: ^10.0.3
+
   #快捷方式
   shortcut:
     path: plugin/shortcut