From 356c671ae7e737cb2a616768e400a7092ec54f66 Mon Sep 17 00:00:00 2001
From: Daisy <>
Date: Fri, 21 Jun 2024 09:28:25 +0800
Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ios/Runner/Info.plist | 4 ++++
ios/Runner/XSFlutterManager.m | 17 ++++++++++----
.../exportSuccess/exportSuccess_page.dart | 2 +-
.../viewExportRecord_page.dart | 23 -------------------
lib/tools/NativeInteractionTool.dart | 10 ++++++--
pubspec.yaml | 1 +
6 files changed, 26 insertions(+), 31 deletions(-)
diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist
index 101a2449..4f61f0ae 100755
--- a/ios/Runner/Info.plist
+++ b/ios/Runner/Info.plist
@@ -121,6 +121,10 @@
UIViewControllerBasedStatusBarAppearance
+ NSFileProtectionKey
+ NSFileProtectionCompleteUntilFirstUserAuthentication
+ UIFileSharingEnabled
+
io.flutter.embedded_views_preview
diff --git a/ios/Runner/XSFlutterManager.m b/ios/Runner/XSFlutterManager.m
index e371a2c3..b33e8d5c 100755
--- a/ios/Runner/XSFlutterManager.m
+++ b/ios/Runner/XSFlutterManager.m
@@ -48,12 +48,19 @@
self.textToShare = paramDic[@"shareText"];
self.urlToShare = paramDic[@"urlToShare"];
}
- //分享的url
- NSURL *urlToShare = [NSURL URLWithString:self.urlToShare];
-// NSURL *urlToShare = [NSURL URLWithString:@"https://pre.lock.star-lock.cn:8093/login"];
+ if ([self.urlToShare isEqualToString:"fileShare"]) {
+ // 创建要分享或操作的文件对象
+ let fileURL = URL(fileURLWithPath: "/path/to/file.pdf")
- //在这里呢 如果想分享图片 就把图片添加进去 文字什么的通上
- NSArray *activityItems = @[self.textToShare,urlToShare];
+ // 将文件对象添加到数组中
+ let activityItems = [fileURL]
+ } else {
+ //分享的url
+ NSURL *urlToShare = [NSURL URLWithString:self.urlToShare];
+
+ //在这里呢 如果想分享图片 就把图片添加进去 文字什么的通上
+ NSArray *activityItems = @[self.textToShare,urlToShare];
+ }
UIActivityViewController *activityVC = [[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:nil];
diff --git a/lib/main/lockDetail/doorLockLog/exportSuccess/exportSuccess_page.dart b/lib/main/lockDetail/doorLockLog/exportSuccess/exportSuccess_page.dart
index ecea5606..c04aa30d 100644
--- a/lib/main/lockDetail/doorLockLog/exportSuccess/exportSuccess_page.dart
+++ b/lib/main/lockDetail/doorLockLog/exportSuccess/exportSuccess_page.dart
@@ -82,7 +82,7 @@ class _ExportSuccessPageState extends State with RouteAware {
SubmitBtn(
btnName: '立即查看'.tr,
onClick: () {
- // OpenFile.open(state.getFilePath.value);
+ OpenFile.open(state.getFilePath.value);
NativeInteractionTool()
.loadNativeFileShare(shareText: state.getFilePath.value);
diff --git a/lib/main/lockDetail/doorLockLog/viewExportRecord/viewExportRecord_page.dart b/lib/main/lockDetail/doorLockLog/viewExportRecord/viewExportRecord_page.dart
index 88319643..05c3c524 100644
--- a/lib/main/lockDetail/doorLockLog/viewExportRecord/viewExportRecord_page.dart
+++ b/lib/main/lockDetail/doorLockLog/viewExportRecord/viewExportRecord_page.dart
@@ -1,7 +1,6 @@
import 'dart:io';
import 'dart:typed_data';
-import 'package:excel/excel.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:path_provider/path_provider.dart';
@@ -26,28 +25,6 @@ class _ViewExportRecordPageState extends State
@override
void initState() {
super.initState();
- loadExcel();
- }
-
- Future loadExcel() async {
- try {
- final Directory appDocDir = await getApplicationDocumentsDirectory();
- final String appDocPath = appDocDir.path;
- final String filePath = '$appDocPath/exported_file.xlsx';
-
- final Uint8List bytes = File(filePath).readAsBytesSync();
- final Excel excel = Excel.decodeBytes(bytes);
-
- for (final String table in excel.tables.keys) {
- for (final List row in excel.tables[table]!.rows) {
- setState(() {
- state.excelData.add(row);
- });
- }
- }
- } catch (e) {
- print('Error reading Excel: $e');
- }
}
@override
diff --git a/lib/tools/NativeInteractionTool.dart b/lib/tools/NativeInteractionTool.dart
index 2b667a9d..e8b0f338 100755
--- a/lib/tools/NativeInteractionTool.dart
+++ b/lib/tools/NativeInteractionTool.dart
@@ -21,8 +21,14 @@ class NativeInteractionTool {
///加载原生分享
void loadNativeShare({required String shareText}) {
final String urlToShare = '${F.apiPrefix}/apps';
- sendChannel.invokeMethod(
- 'loadNativeShare', {'shareText': shareText,'urlToShare':urlToShare});
+ sendChannel.invokeMethod('loadNativeShare',
+ {'shareText': shareText, 'urlToShare': urlToShare});
+ }
+
+ ///加载原生文件分享
+ void loadNativeFileShare({required String shareText}) {
+ sendChannel.invokeMethod('loadNativeShare',
+ {'shareText': shareText, 'urlToShare': 'fileShare'});
}
///获取设备蓝牙状态
diff --git a/pubspec.yaml b/pubspec.yaml
index 5befe68e..84c22c7e 100755
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -217,6 +217,7 @@ dependencies:
file_picker: ^5.3.1
# 错误日志监控
flutter_bugly_plugin: ^0.0.9
+ open_file: ^3.3.2
dependency_overrides:
#强制设置google_maps_flutter_ios 为 2.5.2