Merge branch 'release' of https://gitee.com/starlock-cn/app-starlock into release
This commit is contained in:
commit
97efbedfb1
@ -1,70 +1,62 @@
|
||||
//
|
||||
// XSFlutterManager.m
|
||||
// Runner
|
||||
//
|
||||
// Created by DaisyWu on 2023/10/14.
|
||||
//
|
||||
|
||||
#import "XSFlutterManager.h"
|
||||
#include "GeneratedPluginRegistrant.h"
|
||||
#import "CommonDefine.h"
|
||||
|
||||
|
||||
@interface XSFlutterManager ()
|
||||
|
||||
@property(nonatomic,strong) FlutterMethodChannel* methodChannel;
|
||||
@property (nonatomic, copy) NSString *textToShare;
|
||||
@property (nonatomic, copy) NSString *urlToShare;
|
||||
@property(nonatomic, strong) FlutterMethodChannel *methodChannel;
|
||||
@property(nonatomic, copy) NSString *textToShare;
|
||||
@property(nonatomic, copy) NSString *urlToShare;
|
||||
@property(nonatomic, copy) NSArray *activityItems;
|
||||
|
||||
@end
|
||||
|
||||
@implementation XSFlutterManager{
|
||||
}
|
||||
|
||||
@implementation XSFlutterManager
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
self.textToShare = [[NSString alloc] init];
|
||||
self.textToShare = [[NSString alloc] init];
|
||||
self.urlToShare = [[NSString alloc] init];
|
||||
self.activityItems = [[NSArray alloc] init];
|
||||
|
||||
[self methodChannelFunction];
|
||||
}
|
||||
|
||||
- (void)methodChannelFunction {
|
||||
// 创建 FlutterMethodChannel
|
||||
self.methodChannel = [FlutterMethodChannel methodChannelWithName:XSflutterMethodChannel binaryMessenger:self];
|
||||
|
||||
//创建 FlutterMethodChannel
|
||||
self.methodChannel = [FlutterMethodChannel
|
||||
methodChannelWithName:XSflutterMethodChannel binaryMessenger:self];
|
||||
//设置监听
|
||||
[self.methodChannel setMethodCallHandler:^(FlutterMethodCall* methodCall, FlutterResult result) {
|
||||
// TODO
|
||||
NSString *method=methodCall.method;
|
||||
//调用系统分享
|
||||
// 设置监听
|
||||
[self.methodChannel setMethodCallHandler:^(FlutterMethodCall *methodCall, FlutterResult result) {
|
||||
NSString *method = methodCall.method;
|
||||
// 调用系统分享
|
||||
if ([method isEqualToString:XSflutterMethodSharePassword]) {
|
||||
id params = methodCall.arguments;
|
||||
self.textToShare = @"您好,您的密码是:";
|
||||
if ([params isKindOfClass:[NSDictionary class]]) {
|
||||
NSDictionary *paramDic = (NSDictionary *)params;
|
||||
//分享的标题
|
||||
// 分享的标题
|
||||
self.textToShare = paramDic[@"shareText"];
|
||||
self.urlToShare = paramDic[@"urlToShare"];
|
||||
}
|
||||
if ([self.urlToShare isEqualToString:"fileShare"]) {
|
||||
|
||||
if ([self.urlToShare isEqualToString:@"fileShare"]) {
|
||||
// 创建要分享或操作的文件对象
|
||||
let fileURL = URL(fileURLWithPath: "/path/to/file.pdf")
|
||||
NSURL *fileURL = [NSURL fileURLWithPath:self.textToShare];
|
||||
|
||||
// 将文件对象添加到数组中
|
||||
let activityItems = [fileURL]
|
||||
self.activityItems = @[fileURL];
|
||||
} else {
|
||||
//分享的url
|
||||
// 分享的 URL
|
||||
NSURL *urlToShare = [NSURL URLWithString:self.urlToShare];
|
||||
|
||||
//在这里呢 如果想分享图片 就把图片添加进去 文字什么的通上
|
||||
NSArray *activityItems = @[self.textToShare,urlToShare];
|
||||
// 在这里呢 如果想分享图片 就把图片添加进去 文字什么的通上
|
||||
self.activityItems = @[self.textToShare, urlToShare];
|
||||
}
|
||||
|
||||
UIActivityViewController *activityVC = [[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:nil];
|
||||
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:self.activityItems applicationActivities:nil];
|
||||
|
||||
//不出现在活动项目
|
||||
// 不出现在活动项目
|
||||
activityVC.excludedActivityTypes = @[UIActivityTypePrint];
|
||||
[self presentViewController:activityVC animated:YES completion:nil];
|
||||
|
||||
@ -72,40 +64,37 @@
|
||||
activityVC.completionWithItemsHandler = ^(UIActivityType _Nullable activityType, BOOL completed, NSArray * _Nullable returnedItems, NSError * _Nullable activityError) {
|
||||
if (completed) {
|
||||
NSLog(@"completed");
|
||||
//分享 成功
|
||||
} else {
|
||||
NSLog(@"cancled");
|
||||
//分享 取消
|
||||
// 分享成功
|
||||
} else {
|
||||
NSLog(@"canceled");
|
||||
// 分享取消
|
||||
}
|
||||
};
|
||||
result(@"push返回到flutter");
|
||||
}
|
||||
}];
|
||||
|
||||
[GeneratedPluginRegistrant registerWithRegistry:self];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
-(void)viewWillAppear:(BOOL)animated{
|
||||
- (void)viewWillAppear:(BOOL)animated {
|
||||
[super viewWillAppear:animated];
|
||||
[self.navigationController setNavigationBarHidden:YES];
|
||||
}
|
||||
|
||||
-(void)viewWillDisappear:(BOOL)animated{
|
||||
- (void)viewWillDisappear:(BOOL)animated {
|
||||
[super viewWillDisappear:animated];
|
||||
[self.navigationController setNavigationBarHidden:NO];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
#pragma mark - Navigation
|
||||
|
||||
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
||||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
||||
// Get the new view controller using [segue destinationViewController].
|
||||
// Pass the selected object to the new view controller.
|
||||
}
|
||||
*/
|
||||
#pragma mark - Navigation
|
||||
|
||||
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
||||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
||||
// Get the new view controller using [segue destinationViewController].
|
||||
// Pass the selected object to the new view controller.
|
||||
}
|
||||
*/
|
||||
|
||||
@end
|
||||
|
||||
@ -38,7 +38,8 @@ class BatchExportLogLogic extends BaseGetXController {
|
||||
final http.Response response = await http.get(Uri.parse(url));
|
||||
if (response.statusCode == 200) {
|
||||
final Directory directory = await getApplicationDocumentsDirectory();
|
||||
final File file = File('${directory.path}/exported_file.pdf');
|
||||
final File file = File(
|
||||
'${directory.path}/record${DateTime.now().millisecondsSinceEpoch}.xlsx');
|
||||
await file.writeAsBytes(response.bodyBytes);
|
||||
return file.path;
|
||||
} else {
|
||||
|
||||
@ -225,7 +225,7 @@ class __DerivedRecordWidgetState extends State<_DerivedRecordWidget> {
|
||||
final http.Response response = await http.get(Uri.parse(url));
|
||||
if (response.statusCode == 200) {
|
||||
final Directory directory = await getApplicationDocumentsDirectory();
|
||||
final File file = File('${directory.path}/exported_file.xlsx');
|
||||
final File file = File('${directory.path}/record.xlsx');
|
||||
await file.writeAsBytes(response.bodyBytes);
|
||||
return file.path;
|
||||
} else {
|
||||
|
||||
@ -3,17 +3,15 @@ import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:open_file/open_file.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:star_lock/appRouters.dart';
|
||||
import 'package:star_lock/app_settings/app_colors.dart';
|
||||
import 'package:star_lock/main/lockDetail/doorLockLog/exportSuccess/exportSuccess_logic.dart';
|
||||
import 'package:star_lock/main/lockDetail/doorLockLog/exportSuccess/exportSuccess_state.dart';
|
||||
import 'package:star_lock/tools/NativeInteractionTool.dart';
|
||||
import 'package:star_lock/tools/commonDataManage.dart';
|
||||
import 'package:star_lock/tools/submitBtn.dart';
|
||||
import 'package:star_lock/tools/titleAppBar.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:open_file/open_file.dart';
|
||||
|
||||
class ExportSuccessPage extends StatefulWidget {
|
||||
const ExportSuccessPage({Key? key}) : super(key: key);
|
||||
@ -40,7 +38,6 @@ class _ExportSuccessPageState extends State<ExportSuccessPage> with RouteAware {
|
||||
}
|
||||
|
||||
// 导出成功
|
||||
|
||||
Widget sendElectronicKeySucceed() {
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
@ -83,19 +80,6 @@ class _ExportSuccessPageState extends State<ExportSuccessPage> with RouteAware {
|
||||
btnName: '立即查看'.tr,
|
||||
onClick: () {
|
||||
OpenFile.open(state.getFilePath.value);
|
||||
NativeInteractionTool()
|
||||
.loadNativeFileShare(shareText: state.getFilePath.value);
|
||||
|
||||
// openFile(state.getFilePath.value);
|
||||
// previewFile();
|
||||
// Get.toNamed(Routers.viewExportRecordPage,
|
||||
// arguments: <String, Object>{
|
||||
// 'filePath': state.getFilePath.value,
|
||||
// });
|
||||
// Get.toNamed(Routers.webviewShowPage, arguments: <String, Object>{
|
||||
// 'url': state.getFilePath.value,
|
||||
// 'title': '查看操作记录'.tr
|
||||
// });
|
||||
}),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
@ -103,27 +87,19 @@ class _ExportSuccessPageState extends State<ExportSuccessPage> with RouteAware {
|
||||
OutLineBtn(
|
||||
btnName: '分享'.tr,
|
||||
onClick: () {
|
||||
_openModalBottomSheet();
|
||||
NativeInteractionTool()
|
||||
.loadNativeFileShare(shareText: state.getFilePath.value);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// Future<void> openFile(String filePath) async {
|
||||
// final File file = File(filePath);
|
||||
// if (await file.exists()) {
|
||||
// await launchUrl(Uri.parse('file://$filePath'));
|
||||
// } else {
|
||||
// throw 'File not found';
|
||||
// }
|
||||
// }
|
||||
|
||||
Future<void> previewFile() async {
|
||||
// 获取本地文件路径
|
||||
final Directory appDocDir = await getApplicationDocumentsDirectory();
|
||||
final String appDocPath = appDocDir.path;
|
||||
final String filePath = '$appDocPath/exported_file.xlsx';
|
||||
final String filePath = '$appDocPath/record.xlsx';
|
||||
|
||||
// 检查文件是否存在
|
||||
final File file = File(filePath);
|
||||
@ -137,107 +113,4 @@ class _ExportSuccessPageState extends State<ExportSuccessPage> with RouteAware {
|
||||
print('File does not exist');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _openModalBottomSheet() async {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadiusDirectional.circular(10)),
|
||||
constraints: BoxConstraints(maxHeight: 270.h),
|
||||
builder: (BuildContext context) {
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
width: ScreenUtil().screenWidth,
|
||||
height: 160.h,
|
||||
child: ListView(
|
||||
scrollDirection: Axis.horizontal, //横向滚动
|
||||
children: initBottomSheetList()),
|
||||
),
|
||||
Container(
|
||||
height: 8.h,
|
||||
color: AppColors.greyBackgroundColor,
|
||||
),
|
||||
TextButton(
|
||||
style: ButtonStyle(
|
||||
overlayColor:
|
||||
MaterialStateProperty.all<Color>(Colors.white)),
|
||||
child: Text(
|
||||
'取消'.tr,
|
||||
style: TextStyle(
|
||||
color: Colors.black, fontSize: ScreenUtil().setSp(24)),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
)
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
List<Widget> initBottomSheetList() {
|
||||
final List<Widget> widgetList = <Widget>[];
|
||||
|
||||
widgetList.add(buildCenter3('images/icon_wechat.png', '微信好友'.tr, 0));
|
||||
widgetList.add(buildCenter3('images/icon_message.png', '短信'.tr, 1));
|
||||
widgetList.add(buildCenter3('images/icon_email.png', '邮件'.tr, 2));
|
||||
widgetList.add(buildCenter3('images/icon_more.png', '更多'.tr, 3));
|
||||
|
||||
return widgetList;
|
||||
}
|
||||
|
||||
GestureDetector buildCenter3(
|
||||
String imageName, String titleStr, int itemIndex) {
|
||||
return GestureDetector(
|
||||
child: Container(
|
||||
width: 120.w,
|
||||
// height: 64.h,
|
||||
margin:
|
||||
EdgeInsets.only(top: 20.w, bottom: 20.w, left: 10.w, right: 10.w),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Image.asset(
|
||||
imageName,
|
||||
width: 50.w,
|
||||
height: 50.h,
|
||||
),
|
||||
SizedBox(
|
||||
height: 16.w,
|
||||
),
|
||||
Text(
|
||||
titleStr,
|
||||
style: TextStyle(
|
||||
fontSize: ScreenUtil().setSp(20), color: Colors.black),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
onTap: () => jumpSmartDeviceRoute(itemIndex),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> jumpSmartDeviceRoute(int itemIndex) async {
|
||||
Get.back();
|
||||
// final String pwdShareStr = logic.getShareContentStr();
|
||||
switch (itemIndex) {
|
||||
case 0: //微信好友
|
||||
// NativeInteractionTool().loadNativeShare(shareText: pwdShareStr);
|
||||
break;
|
||||
case 1: //短信
|
||||
case 2: //邮件
|
||||
Get.toNamed(Routers.sendEmailNotificationPage,
|
||||
arguments: <String, Object?>{
|
||||
'receiver': '',
|
||||
'channelType': itemIndex == 1 ? 1 : 2,
|
||||
'keyId': CommonDataManage().currentKeyInfo.keyId,
|
||||
});
|
||||
break;
|
||||
case 3: //更多
|
||||
// NativeInteractionTool().loadNativeShare(shareText: pwdShareStr);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +1,6 @@
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:star_lock/app_settings/app_colors.dart';
|
||||
import 'package:star_lock/app_settings/app_settings.dart';
|
||||
import 'package:star_lock/main/lockDetail/doorLockLog/viewExportRecord/viewExportRecord_logic.dart';
|
||||
import 'package:star_lock/main/lockDetail/doorLockLog/viewExportRecord/viewExportRecord_state.dart';
|
||||
import 'package:star_lock/tools/titleAppBar.dart';
|
||||
|
||||
39
pre_build.sh
Normal file
39
pre_build.sh
Normal file
@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 废弃 api 检测脚本+项目编译脚本
|
||||
# 首次使用记得安装jq: brew install jq
|
||||
#
|
||||
|
||||
# 设置
|
||||
environment="xhj"
|
||||
main_file="lib/main_xhj_full.dart"
|
||||
version_string="1.0.51"
|
||||
file_path="lib/network/api.dart"
|
||||
|
||||
urls=$(curl -s -X POST -d "version=$version_string" 'https://lock.xhjcn.ltd/api/app/getDeprecatedApiList' | jq -r '.data[].url')
|
||||
echo "* 成功获取废弃 api 数据"
|
||||
|
||||
string_array=()
|
||||
# 使用egrep搜索被单引号包裹的字符串
|
||||
while IFS= read -r line; do
|
||||
string_array+=("$line")
|
||||
done < <(egrep -o "'[^']*'" "$file_path")
|
||||
echo "* 解析 api 文件数据,开始对比"
|
||||
|
||||
# 比较urls和string_array中的元素
|
||||
for url in $urls; do
|
||||
for string in "${string_array[@]}"; do
|
||||
# 移除单引号以便比较
|
||||
cleaned_string=$(echo "$string" | tr -d "'")
|
||||
if [[ "$cleaned_string" == "$url" ]]; then
|
||||
echo "错误: 存在废弃 api: $url"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
done
|
||||
echo "* 没有发现 废弃 api,开始编译"
|
||||
|
||||
flutter clean && flutter pub get
|
||||
flutter build apk --flavor $environment -t $main_file
|
||||
flutter build ios --flavor $environment -t $main_file
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user