添加安卓分享,调试消息接口

This commit is contained in:
魏少阳 2024-01-24 18:44:34 +08:00
parent 6e88b01f6d
commit 760f0e95ca
25 changed files with 627 additions and 154 deletions

View File

@ -1,10 +1,14 @@
package cn.starlock.lock
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.util.Log
import com.alibaba.sdk.android.push.noonesdk.PushServiceFactory
import com.aliyun.ams.emas.push.CommonCallback
import io.flutter.embedding.android.FlutterActivity
import io.flutter.plugin.common.MethodChannel
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.plugins.GeneratedPluginRegistrant
@ -12,6 +16,29 @@ class MainActivity: FlutterActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
initAliyunPushService()
GeneratedPluginRegistrant.registerWith(flutterEngine!!)
MethodChannel(flutterEngine?.dartExecutor!!.binaryMessenger, "starLockFlutterSend").setMethodCallHandler { call, result ->
if (call.method == "loadNativeShare") {
var map = call.arguments as Map<String, String>
shareText(map["shareText"], "分享")
} else {
result.notImplemented() // 没有实现的方法
}
}
}
fun shareText(text: String?, subject: String = "", imageUrl: String = "") {
val shareIntent = Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_TEXT, text)
type = "text/plain"
// putExtra(Intent.EXTRA_SUBJECT, subject)
// putExtra(Intent.EXTRA_STREAM, Uri.parse(imageUrl))
// type = "image/*"
// addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
}
startActivity(Intent.createChooser(shareIntent, null))
}
private fun initAliyunPushService() {
@ -30,4 +57,18 @@ class MainActivity: FlutterActivity() {
pushService.register(applicationContext,callback)
}
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine);
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "starLockFlutterSend").setMethodCallHandler {
call, result ->
println("methodmethodmethod: ${call.method}")
// 在这里处理从 Flutter 发送过来的方法调用
if (call.method == "loadNativeShare") {
println("methodmethodmethod: ${call.method}")
} else {
result.notImplemented()
}
}
}
}

View File

@ -60,7 +60,7 @@
"pleaseNameYourPassword":"请给密码命名",
"pleaseEnterDigitsNumber":"请输入6-9位数字",
"getPasswordTip1":"密码在24小时内至少要使用过一次否则将无效",
"getPasswordTip2":"限时密码可以再有下期内不限次数使用 \n密码在生效后的24小时内至少要使用过一次否则将失效",
"getPasswordTip2":"限时密码可以在有效期内不限次数使用 \n密码在生效后的24小时内至少要使用过一次否则将失效",
"getPasswordTip3":"密码有限期为6个小时只能使用一次",
"getPasswordTip4":"手动输入6-9位数字作为密码。可在锁旁边通过手机蓝牙添加也可以通过网关远程添加",
"getPasswordTip5":"限时密码可以再有下期内不限次数使用 \n密码在生效后的24小时内至少要使用过一次,否则将失效",

View File

@ -63,7 +63,7 @@ PODS:
- Flutter
- google_maps_flutter_ios (0.0.1):
- Flutter
- GoogleMaps (< 8.0)
- GoogleMaps (< 9.0)
- GoogleMaps (6.2.1):
- GoogleMaps/Maps (= 6.2.1)
- GoogleMaps/Base (6.2.1)
@ -85,7 +85,7 @@ PODS:
- FlutterMacOS
- permission_handler_apple (9.1.1):
- Flutter
- Protobuf (3.25.0)
- Protobuf (3.25.1)
- ReachabilitySwift (5.0.0)
- reactive_ble_mobile (0.0.1):
- Flutter
@ -97,7 +97,7 @@ PODS:
- sqflite (0.0.3):
- Flutter
- FMDB (>= 2.7.5)
- SwiftProtobuf (1.25.1)
- SwiftProtobuf (1.25.2)
- Toast (4.0.0)
- url_launcher_ios (0.0.1):
- Flutter
@ -241,7 +241,7 @@ SPEC CHECKSUMS:
audio_session: 4f3e461722055d21515cf3261b64c973c062f345
audioplayers_darwin: 877d9a4d06331c5c374595e46e16453ac7eafa40
auto_orientation: 102ed811a5938d52c86520ddd7ecd3a126b5d39d
camera_avfoundation: 3125e8cd1a4387f6f31c6c63abb8a55892a9eeeb
camera_avfoundation: 8b8d780bcfb6a4a02b0fbe2b4bd17b5b71946e68
connectivity_plus: bf0076dd84a130856aa636df1c71ccaff908fa1d
device_info_plus: e5c5da33f982a436e103237c0c85f9031142abed
EMASRest: 8df6f87836767a9415ad5cc4af739bc9d215b475
@ -251,30 +251,30 @@ SPEC CHECKSUMS:
flutter_sound: c60effa2a350fb977885f0db2fbc4c1ad5160900
flutter_sound_core: 26c10e5832e76aaacfae252d8925232281c486ae
flutter_voice_processor: 53afbf59ad3feb82f4a379fea9ed8dc98495210f
fluttertoast: fafc4fa4d01a6a9e4f772ecd190ffa525e9e2d9c
fluttertoast: 31b00dabfa7fb7bacd9e7dbee580d7a2ff4bf265
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
g711_flutter: 8f2769052d2cf3549f83d11e1c42d81d94441123
google_maps_flutter_ios: abdac20d6ce8931f6ebc5f46616df241bfaa2cfd
google_maps_flutter_ios: d1318b4ff711612cab16862d7a87e31a7403d458
GoogleMaps: 20d7b12be49a14287f797e88e0e31bc4156aaeb4
image_gallery_saver: cb43cc43141711190510e92c460eb1655cd343cb
image_picker_ios: 4a8aadfbb6dc30ad5141a2ce3832af9214a705b5
image_picker_ios: 99dfe1854b4fa34d0364e74a78448a0151025425
ios-voice-processor: 8e32d7f980a06d392d128ef1cd19cf6ddcaca3c1
just_audio: baa7252489dbcf47a4c7cc9ca663e9661c99aafa
network_info_plus: 6d0c3eb8367b8164fa3fb0c19875e3f59d49697f
package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6
Protobuf: 6a4183ec1d51649eb2be7b86ccc286e5c539219c
Protobuf: d94761c33f1239c0a43a0817ca1a5f7f7c900241
ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825
reactive_ble_mobile: 9ce6723d37ccf701dbffd202d487f23f5de03b4c
shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126
shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695
sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a
SwiftProtobuf: 69f02cd54fb03201c5e6bf8b76f687c5ef7541a3
SwiftProtobuf: 407a385e97fd206c4fbe880cc84123989167e0d1
Toast: 91b396c56ee72a5790816f40d3a94dd357abc196
url_launcher_ios: bf5ce03e0e2088bad9cc378ea97fa0ed5b49673b
url_launcher_ios: bbd758c6e7f9fd7b5b1d4cde34d2b95fcce5e812
video_player_avfoundation: 81e49bb3d9fb63dccf9fa0f6d877dc3ddbeac126
webview_flutter_wkwebview: 2e2d318f21a5e036e2c3f26171342e95908bd60a
webview_flutter_wkwebview: 4f3e50f7273d31e5500066ed267e3ae4309c5ae4
PODFILE CHECKSUM: 42aa7ffc6134b996f93caa6a9b6a2b5b580ff28a
COCOAPODS: 1.12.1
COCOAPODS: 1.14.3

View File

@ -10,9 +10,9 @@
/** 信号通道须与flutter里一致*/
#define XSflutterMethodChannel @"talkPlugin"
#define XSflutterMethodChannel @"starLockFlutterSend"
/** 交互方法字段名须与flutter里一致*/
#define XSflutterMethodSharePassword @"flutter_sharePassword_to_ios"//分享密码
#define XSflutterMethodSharePassword @"loadNativeShare"//分享密码
#define XSflutterMethodPresent @"flutter_present_to_ios"
#define XSflutterMethodVideoTalk @"videoTalk"//视频对讲

View File

@ -50,7 +50,7 @@
if ([params isKindOfClass:[NSDictionary class]]) {
NSDictionary *paramDic = (NSDictionary *)params;
//
self.textToShare = paramDic[@"pwdShareStr"];
self.textToShare = paramDic[@"shareText"];
}
//url
NSURL *urlToShare = [NSURL URLWithString:@"https://pre.lock.star-lock.cn:8093/login"];

View File

@ -146,7 +146,8 @@ import 'mine/gateway/gatewayConnectionLock/gatewayConnectionLockList_page.dart';
import 'mine/gateway/gatewayDetail/gatewayDetail_page.dart';
import 'mine/gateway/gatewayList/gatewayList_page.dart';
import 'mine/mall/mall_page.dart';
import 'mine/message/messageList_page.dart';
import 'mine/message/messageDetail/messageDetail_page.dart';
import 'mine/message/messageList/messageList_page.dart';
import 'mine/mine/starLockMine_page.dart';
import 'mine/mineMultiLanguage/mineMultiLanguage_page.dart';
import 'mine/minePersonInfo/minePersonInfoPage/minePersonInfo_page.dart';
@ -305,6 +306,7 @@ abstract class Routers {
'/GatewayConfigurationWifiPage'; // -wifi
static const messageListPage = '/MessageListPage'; // -
static const messageDetailPage = '/MessageDetailPage'; // -
static const supportStaffPage = '/SupportStaffPage'; // -
static const valueAddedServicesPage = '/ValueAddedServicesPage'; // -
static const aboutPage = '/AboutPage'; // -
@ -1019,5 +1021,6 @@ abstract class AppRouters {
GetPage(name: Routers.videoSlotPage, page: (() => const VideoSlotPage())),
GetPage(name: Routers.liveVideoPage, page: (() => const LiveVideoPage())),
GetPage(name: Routers.faceDetailPage, page: (() => const FaceDetailPage())),
GetPage(name: Routers.messageDetailPage, page: (() => const MessageDetailPage())),
];
}

View File

@ -13,6 +13,7 @@ import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
import 'package:star_lock/tools/storage.dart';
import '../../../../../appRouters.dart';
import '../../../../../tools/NativeInteractionTool.dart';
import '../../../../../tools/commonItem.dart';
import '../../../../../tools/submitBtn.dart';
import '../../../../../translations/trans_lib.dart';
@ -29,7 +30,6 @@ class SendElectronicKeyPage extends StatefulWidget {
class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
final logic = Get.put(SendElectronicKeyLogic());
final state = Get.find<SendElectronicKeyLogic>().state;
static const methodChannel = MethodChannel('talkPlugin');
bool isDemoMode = false;
@override
@ -551,7 +551,7 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
context: context,
shape: RoundedRectangleBorder(
borderRadius: BorderRadiusDirectional.circular(10)),
constraints: BoxConstraints(maxHeight: 260.h),
constraints: BoxConstraints(maxHeight: 270.h),
builder: (BuildContext context) {
return Column(
children: [
@ -627,44 +627,36 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
}
_jumpSmartDeviceRoute(int itemIndex) {
Get.back();
switch (itemIndex) {
case 0:
//
{
Navigator.pop(context);
String pwdShareStr = '您好,您的电子钥匙生成成功';
tokNative('flutter_sharePassword_to_ios',
arguments: {'pwdShareStr': pwdShareStr}).then((result) {
print('$result');
});
print('与原生交互');
NativeInteractionTool.loadNativeShare(shareText:pwdShareStr);
}
break;
case 1:
//
{}
{
String pwdShareStr = '您好,您的电子钥匙生成成功';
NativeInteractionTool.loadNativeShare(shareText:pwdShareStr);
}
break;
case 2:
//
{
Navigator.pop(context);
Navigator.pushNamed(context, Routers.sendEmailNotificationPage);
Get.toNamed(Routers.sendEmailNotificationPage);
}
break;
case 3:
//
{}
{
String pwdShareStr = '您好,您的电子钥匙生成成功';
NativeInteractionTool.loadNativeShare(shareText:pwdShareStr);
}
break;
default:
}
}
static Future<dynamic> tokNative(String method,
{required Map arguments}) async {
if (arguments == null) {
return await methodChannel.invokeMethod(method);
} else {
return await methodChannel.invokeMethod(method, arguments);
}
}
}

View File

@ -31,7 +31,6 @@ class _LockDetailPageState extends State<LockDetailPage>
// with RouteAware
final logic = Get.put(LockDetailLogic());
final state = Get.find<LockDetailLogic>().state;
static const methodChannel = MethodChannel('talkPlugin');
@override
void initState() {
@ -393,11 +392,6 @@ class _LockDetailPageState extends State<LockDetailPage>
Get.toNamed(Routers.faceList, arguments: {
"lockId": widget.lockListInfoItemEntity.lockId,
}); // Toast.show(msg: "功能暂未开放");
// tokNative('videoTalk',
// arguments: {'videoTalk': 'videoTalk'}).then((result) {
// print('$result');
// });
}),
);
}
@ -520,15 +514,6 @@ class _LockDetailPageState extends State<LockDetailPage>
return 'images/main/icon_lockElectricLevel_5.png';
}
static Future<dynamic> tokNative(String method,
{required Map arguments}) async {
if (arguments == null) {
return await methodChannel.invokeMethod(method);
} else {
return await methodChannel.invokeMethod(method, arguments);
}
}
//
void _showFullScreenOverlay(BuildContext context) {
showModalBottomSheet(

View File

@ -48,7 +48,7 @@ class PasswordKeyDetailLogic extends BaseGetXController {
}
}
//使
//使
String getUseDateStr() {
int? getPwdType = state.itemData.value.keyboardPwdType;
String useDateStr = '';
@ -125,4 +125,79 @@ class PasswordKeyDetailLogic extends BaseGetXController {
return useDateStr;
}
String getShareContentStr() {
int? getPwdType = state.itemData.value.keyboardPwdType;
String useDateStr = '';
DateTime startDateStr =
DateTime.fromMillisecondsSinceEpoch(state.itemData.value.startDate!);
DateTime endDateStr =
DateTime.fromMillisecondsSinceEpoch(state.itemData.value.endDate!);
int starHour = startDateStr.hour;
int endHour = endDateStr.hour;
switch (getPwdType) {
case 1:
// 1 6使
useDateStr =
'类型:永久\n有效期:${startDateStr.toLocal().toString().substring(0, 16)} -- ${endDateStr.toLocal().toString().substring(0, 16)}';
break;
case 2:
// 2 24使
useDateStr = '类型:永久';
break;
case 3:
// 3 24使
useDateStr =
'类型:限时\n有效期:${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}';
break;
case 4:
// 4 使使
useDateStr = '类型:清空';
break;
case 5:
// 5
useDateStr = '类型:循环\n 周末 $starHour:00-$endHour:00';
break;
case 6:
// 6
useDateStr = '类型:循环\n周日 $starHour:00-$endHour:00';
break;
case 7:
// 7
useDateStr = '类型:循环\n工作日 $starHour:00-$endHour:00';
break;
case 8:
// 8
useDateStr = '类型:循环\n周一 $starHour:00-$endHour:00';
break;
case 9:
// 9
useDateStr = '类型:循环\n周二 $starHour:00-$endHour:00';
break;
case 10:
// 10
useDateStr = '类型:循环\n周三 $starHour:00-$endHour:00';
break;
case 11:
// 11
useDateStr = '类型:循环\n周四 $starHour:00 -$endHour:00';
break;
case 12:
// 12
useDateStr = '类型:循环\n周五 $starHour:00-$endHour:00';
break;
case 13:
// 13
useDateStr = '类型:循环\n周六 $starHour:00-$endHour:00';
break;
case 14:
// 14
useDateStr = '类型:循环\n周天 $starHour:00-$endHour:00';
break;
default:
}
return "您好,您的密码是:${state.itemData.value.keyboardPwd}\n$useDateStr\n密码名字:${state.itemData.value.keyboardPwdName}";
}
}

View File

@ -8,6 +8,7 @@ import 'package:star_lock/tools/showTFView.dart';
import '../../../../appRouters.dart';
import '../../../../app_settings/app_colors.dart';
import '../../../../tools/NativeInteractionTool.dart';
import '../../../../tools/commonItem.dart';
import '../../../../tools/showIosTipView.dart';
import '../../../../tools/submitBtn.dart';
@ -22,7 +23,6 @@ class PasswordKeyDetailPage extends StatefulWidget {
}
class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
static const methodChannel = MethodChannel('talkPlugin');
final logic = Get.put(PasswordKeyDetailLogic());
final state = Get.find<PasswordKeyDetailLogic>().state;
@ -313,48 +313,37 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
}
_jumpSmartDeviceRoute(int itemIndex) {
Get.back();
String pwdShareStr = logic.getShareContentStr();
switch (itemIndex) {
case 0:
//
{
Navigator.pop(context);
String pwdShareStr =
'您好,您的密码是:${state.itemData.value.keyboardPwd}\n生效时间:${state.itemData.value.startDate}\n类型:永久\n锁名:${state.itemData.value.keyboardPwdName}';
tokNative('flutter_sharePassword_to_ios',
arguments: {'pwdShareStr': pwdShareStr}).then((result) {
print('$result');
});
print('与原生交互');
NativeInteractionTool.loadNativeShare(shareText:pwdShareStr);
}
break;
case 1:
//
{}
{
NativeInteractionTool.loadNativeShare(shareText:pwdShareStr);
}
break;
case 2:
//
{
Navigator.pop(context);
Navigator.pushNamed(context, Routers.sendEmailNotificationPage);
Get.toNamed(Routers.sendEmailNotificationPage);
}
break;
case 3:
//
{}
{
NativeInteractionTool.loadNativeShare(shareText:pwdShareStr);
}
break;
default:
}
}
static Future<dynamic> tokNative(String method,
{required Map arguments}) async {
if (arguments == null) {
return await methodChannel.invokeMethod(method);
} else {
return await methodChannel.invokeMethod(method, arguments);
}
}
void showIosTipViewDialog(BuildContext context) {
showDialog(
context: context,

View File

@ -113,6 +113,7 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
print('获取密码成功');
state.isSendSuccess.value = true;
state.sendSucceedType.value = state.widgetType.value;
state.pwdNameStr = state.nameController.text;
state.nameController.text = "";
state.pwdController.text = "";
if (entity.data != null) {
@ -154,6 +155,7 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
print('获取密码成功');
state.isSendSuccess.value = true;
state.sendSucceedType.value = state.widgetType.value;
state.pwdNameStr = state.nameController.text;
state.nameController.text = "";
state.pwdController.text = "";
if (entity.data != null) {
@ -185,6 +187,9 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
case 0x00:
//
print("${reply.commandType!.typeValue} 数据解析成功");
state.sureBtnState.value = 0;
dismissEasyLoading();
cancelBlueConnetctToastTimer();
addKeyboardPwdRequest();
break;
case 0x06:
@ -235,6 +240,16 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
//
Future<void> senderCustomPasswords() async {
if(state.sureBtnState.value == 1){
return;
}
state.sureBtnState.value = 1;
showEasyLoading();
showBlueConnetctToastTimer(action: (){
dismissEasyLoading();
state.sureBtnState.value = 0;
});
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
if (deviceConnectionState == DeviceConnectionState.connected) {
var signKey = await Storage.getStringList(saveBlueSignKey);
@ -259,10 +274,62 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
signKey: signKeyDataList,
privateKey: getPrivateKeyList,
token: getTokenList);
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
dismissEasyLoading();
cancelBlueConnetctToastTimer();
state.sureBtnState.value = 0;
if(state.ifCurrentScreen.value == true){
showBlueConnetctToast();
}
}
});
}
String getShareContentStr() {
int? getPwdType = state.widgetType.value;
String useDateStr = '';
// DateTime startDateStr = DateTime.fromMillisecondsSinceEpoch(state.itemData.value.startDate!);
// DateTime endDateStr = DateTime.fromMillisecondsSinceEpoch(state.itemData.value.endDate!);
// int starHour = startDateStr.hour;
// int endHour = endDateStr.hour;
switch (getPwdType) {
case 0:
// 24使
useDateStr = '类型:永久';
break;
case 1:
// 24使
useDateStr =
'类型:限时\n有效期:${state.selectEffectiveDate.value} -- ${state.selectFailureDate.value}';
break;
case 2:
// 6使
useDateStr =
'类型:单次\n有效期:${state.selectEffectiveDate.value} -- ${state.selectFailureDate.value}';
break;
case 3:
//
if (state.isPermanent.value == false) {
'类型:自定义-限时\n有效期:${state.selectEffectiveDate.value} -- ${state.selectFailureDate.value}';
} else {
useDateStr = '类型:自定义-永久';
}
break;
case 4:
//
useDateStr = '类型:循环\n${state.loopModeStr.value} ${state.loopEffectiveDate.value}:00-${state.loopFailureDate.value}';
break;
case 5:
// 4 使使
useDateStr = '类型:清空';
break;
default:
}
return "您好,您的密码是:${state.getPwdStr.value}\n$useDateStr\n密码名字:${state.pwdNameStr}";
}
@override
void onReady() {
// TODO: implement onReady

View File

@ -2,6 +2,7 @@ import 'package:date_format/date_format.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/app_settings/app_colors.dart';
@ -12,6 +13,9 @@ import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
import 'package:star_lock/tools/storage.dart';
import '../../../../appRouters.dart';
import '../../../../blue/blue_manage.dart';
import '../../../../tools/NativeInteractionTool.dart';
import '../../../../tools/appRouteObserver.dart';
import '../../../../tools/commonItem.dart';
import '../../../../tools/submitBtn.dart';
@ -31,12 +35,10 @@ class PasswordKeyPerpetualPage extends StatefulWidget {
_PasswordKeyPerpetualPageState();
}
class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> with RouteAware{
final logic = Get.put(PasswordKeyPerpetualLogic());
final state = Get.find<PasswordKeyPerpetualLogic>().state;
static const methodChannel = MethodChannel('talkPlugin');
@override
void initState() {
super.initState();
@ -598,7 +600,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
context: context,
shape: RoundedRectangleBorder(
borderRadius: BorderRadiusDirectional.circular(10)),
constraints: BoxConstraints(maxHeight: 260.h),
constraints: BoxConstraints(maxHeight: 270.h),
builder: (BuildContext context) {
return Column(
children: [
@ -675,21 +677,20 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
//\n生效时间${itemData.startDate}\n类型\n锁名${itemData.keyboardPwdName}
_jumpSmartDeviceRoute(int itemIndex) {
Get.back();
String pwdShareStr = logic.getShareContentStr();
switch (itemIndex) {
case 0:
//
{
String pwdShareStr = '您好,您的密码是:${state.getPwdStr.value}';
tokNative('flutter_sharePassword_to_ios',
arguments: {'pwdShareStr': pwdShareStr}).then((result) {
print('$result');
});
print('与原生交互');
NativeInteractionTool.loadNativeShare(shareText:pwdShareStr);
}
break;
case 1:
//
{}
{
NativeInteractionTool.loadNativeShare(shareText:pwdShareStr);
}
break;
case 2:
//
@ -699,18 +700,59 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
break;
case 3:
//
{}
{
NativeInteractionTool.loadNativeShare(shareText:pwdShareStr);
}
break;
default:
}
}
static Future<dynamic> tokNative(String method,
{required Map arguments}) async {
if (arguments == null) {
return await methodChannel.invokeMethod(method);
} else {
return await methodChannel.invokeMethod(method, arguments);
}
@override
void dispose() {
// TODO: implement dispose
///
AppRouteObserver().routeObserver.unsubscribe(this);
super.dispose();
}
///
@override
void didPush() {
super.didPush();
print("lockSet===didPush");
state.ifCurrentScreen.value = true;
}
///
@override
void didPop() {
super.didPop();
print("lockSet===didPop");
logic.cancelBlueConnetctToastTimer();
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
BlueManage().stopScan();
state.ifCurrentScreen.value = false;
state.sureBtnState.value = 0;
}
///
@override
void didPopNext() {
super.didPopNext();
print("lockSet===didPopNext");
state.ifCurrentScreen.value = true;
}
///
@override
void didPushNext() {
super.didPushNext();
print("lockSet===didPushNext");
logic.cancelBlueConnetctToastTimer();
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
BlueManage().stopScan();
state.ifCurrentScreen.value = false;
state.sureBtnState.value = 0;
}
}

View File

@ -11,31 +11,13 @@ class PasswordKeyPerpetualState {
final isSendSuccess = false.obs; //
final isPermanent = true.obs; //
var getPwdStr = ''.obs;
var pwdNameStr = '';
final effectiveDateTime = DateTime.now().obs;
final failureDateTime = DateTime.now().obs;
var selectEffectiveDate = "${formatDate(DateTime.now(), [
yyyy,
'-',
mm,
'-',
dd,
' ',
HH,
])}:00"
.obs; //
var selectFailureDate = "${formatDate(DateTime.now(), [
yyyy,
'-',
mm,
'-',
dd,
' ',
HH,
])}:00"
.obs; //
var selectEffectiveDate = "${formatDate(DateTime.now(), [yyyy,'-',mm,'-', dd, ' ', HH,])}:00".obs; //
var selectFailureDate = "${formatDate(DateTime.now(), [yyyy, '-', mm, '-', dd, ' ', HH,])}:00".obs; //
var loopEffectiveDate = "${formatDate(DateTime.now(), [HH])}:00".obs; //
var loopFailureDate = "${formatDate(DateTime.now(), [HH])}:00".obs; //
@ -46,4 +28,7 @@ class PasswordKeyPerpetualState {
final widgetType = 0.obs;
final sendSucceedType = 0.obs;
final keyInfo = LockListInfoItemEntity().obs;
var ifCurrentScreen = true.obs; // ,
var sureBtnState = 0.obs;// 0() 1()
}

View File

@ -0,0 +1,37 @@
import 'package:star_lock/tools/baseGetXController.dart';
import '../../../network/api_repository.dart';
import '../../../tools/eventBusEventManage.dart';
import '../messageList/messageList_entity.dart';
import 'messageDetail_state.dart';
class MessageDetailLogic extends BaseGetXController {
final MessageDetailState state = MessageDetailState();
//
void readMessageDataRequest() async {
MessageListEntity entity = await ApiRepository.to.readMessageLoadData(messageId:state.itemData.value.id!);
if (entity.errorCode!.codeIsSuccessful) {
eventBus.fire(ReadMessageRefreshUI());
}
}
@override
void onReady() {
// TODO: implement onReady
super.onReady();
readMessageDataRequest();
}
@override
void onInit() {
// TODO: implement onInit
super.onInit();
}
@override
void onClose() {
// TODO: implement onClose
super.onClose();
}
}

View File

@ -0,0 +1,49 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import '../../../app_settings/app_colors.dart';
import '../../../tools/dateTool.dart';
import '../../../tools/titleAppBar.dart';
import 'messageDetail_logic.dart';
class MessageDetailPage extends StatefulWidget {
const MessageDetailPage({Key? key}) : super(key: key);
@override
State<MessageDetailPage> createState() => _MessageDetailPageState();
}
class _MessageDetailPageState extends State<MessageDetailPage> {
final logic = Get.put(MessageDetailLogic());
final state = Get.find<MessageDetailLogic>().state;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(
barTitle: "消息详情",
haveBack: true,
backgroundColor: AppColors.mainColor),
body: Container(
margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.h),
child: Obx(() => Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"创建时间:${DateTool().dateToYMDHNString(state.itemData.value.createdAt!.toString())}",
style: TextStyle(fontSize: 22.sp, color: AppColors.placeholderTextColor),
),
SizedBox(height: 20.h),
Text(
state.itemData.value.data!,
style: TextStyle(fontSize: 22.sp, color: AppColors.placeholderTextColor),
),
],
)),
)
);
}
}

View File

@ -0,0 +1,12 @@
import 'package:get/get.dart';
import '../messageList/messageList_entity.dart';
class MessageDetailState{
final itemData = MessageItemEntity().obs;
MessageDetailState() {
Map map = Get.arguments;
itemData.value = map["messageItemEntity"];
}
}

View File

@ -0,0 +1,81 @@
class MessageListEntity {
int? errorCode;
String? description;
String? errorMsg;
Data? data;
MessageListEntity(
{this.errorCode, this.description, this.errorMsg, this.data});
MessageListEntity.fromJson(Map<String, dynamic> json) {
errorCode = json['errorCode'];
description = json['description'];
errorMsg = json['errorMsg'];
data = json['data'] != null ? Data.fromJson(json['data']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['errorCode'] = errorCode;
data['description'] = description;
data['errorMsg'] = errorMsg;
if (this.data != null) {
data['data'] = this.data!.toJson();
}
return data;
}
}
class Data {
List<MessageItemEntity>? list;
int? pageNo;
int? pageSize;
Data({this.list, this.pageNo, this.pageSize});
Data.fromJson(Map<String, dynamic> json) {
if (json['list'] != null) {
list = <MessageItemEntity>[];
json['list'].forEach((v) {
list!.add(MessageItemEntity.fromJson(v));
});
}
pageNo = json['pageNo'];
pageSize = json['pageSize'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
if (list != null) {
data['list'] = list!.map((v) => v.toJson()).toList();
}
data['pageNo'] = pageNo;
data['pageSize'] = pageSize;
return data;
}
}
class MessageItemEntity {
String? id;
String? data;
int? createdAt;
int? readAt;
MessageItemEntity({this.id, this.data, this.createdAt, this.readAt});
MessageItemEntity.fromJson(Map<String, dynamic> json) {
id = json['id'];
data = json['data'];
createdAt = json['createdAt'];
readAt = json['readAt'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['data'] = this.data;
data['createdAt'] = createdAt;
data['readAt'] = readAt;
return data;
}
}

View File

@ -0,0 +1,54 @@
import 'dart:async';
import 'package:star_lock/tools/baseGetXController.dart';
import '../../../network/api_repository.dart';
import '../../../tools/eventBusEventManage.dart';
import 'messageList_entity.dart';
import 'messageList_state.dart';
class MessageListLogic extends BaseGetXController {
final MessageListState state = MessageListState();
//
void messageListDataRequest() async {
MessageListEntity entity = await ApiRepository.to.messageListLoadData(
pageNo:state.pageNum.toString(),
pageSize:state.pageSize.toString());
if (entity.errorCode!.codeIsSuccessful) {
state.itemDataList.value = entity.data!.list!;
}
}
///
StreamSubscription? _readMessageRefreshUIEvent;
void _readMessageRefreshUIAction() {
// eventBus
_readMessageRefreshUIEvent = eventBus.on<ReadMessageRefreshUI>().listen((event) {
messageListDataRequest();
});
}
@override
void onReady() {
// TODO: implement onReady
super.onReady();
messageListDataRequest();
_readMessageRefreshUIAction();
}
@override
void onInit() {
// TODO: implement onInit
super.onInit();
}
@override
void onClose() {
// TODO: implement onClose
super.onClose();
_readMessageRefreshUIEvent?.cancel();
}
}

View File

@ -3,10 +3,13 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/tools/noData.dart';
import '../../appRouters.dart';
import '../../app_settings/app_colors.dart';
import '../../tools/titleAppBar.dart';
import '../../translations/trans_lib.dart';
import '../../../appRouters.dart';
import '../../../app_settings/app_colors.dart';
import '../../../tools/dateTool.dart';
import '../../../tools/titleAppBar.dart';
import '../../../translations/trans_lib.dart';
import 'messageList_entity.dart';
import 'messageList_logic.dart';
class MessageListPage extends StatefulWidget {
const MessageListPage({Key? key}) : super(key: key);
@ -16,7 +19,9 @@ class MessageListPage extends StatefulWidget {
}
class _MessageListPageState extends State<MessageListPage> {
List dataList = [];
final logic = Get.put(MessageListLogic());
final state = Get.find<MessageListLogic>().state;
@override
Widget build(BuildContext context) {
return Scaffold(
@ -25,27 +30,25 @@ class _MessageListPageState extends State<MessageListPage> {
barTitle: TranslationLoader.lanKeys!.message!.tr,
haveBack: true,
backgroundColor: AppColors.mainColor),
body: dataList.isEmpty
body: Obx(() => state.itemDataList.isEmpty
? const NoData()
: ListView.builder(
itemCount: 10,
itemBuilder: (c, index) {
return _selectGatewayListListItem(
'images/controls_user.png', "您的钥匙已发送成功", "2023.6.21 11.15",
() {
// Navigator.pushNamed(context, Routers.gatewayConfigurationWifiPage);
});
}),
itemCount: 10,
itemBuilder: (c, index) {
MessageItemEntity messageItemEntity = state.itemDataList[index];
return _selectGatewayListListItem(messageItemEntity, () {
Get.toNamed(Routers.messageDetailPage, arguments: {"messageItemEntity": messageItemEntity});
});
})),
);
}
Widget _selectGatewayListListItem(String lockTypeIcon, String gateWayName,
String networkSignal, Function() action) {
Widget _selectGatewayListListItem(MessageItemEntity messageItemEntity, Function() action) {
return GestureDetector(
onTap: action,
child: Container(
height: 90.h,
margin: const EdgeInsets.only(bottom: 2),
margin: EdgeInsets.only(bottom: 2.h),
// padding:
// EdgeInsets.only(left: 10.w, right: 20.w, top: 20.h, bottom: 20.h),
decoration: BoxDecoration(
@ -54,14 +57,6 @@ class _MessageListPageState extends State<MessageListPage> {
),
child: Row(
children: [
SizedBox(
width: 10.w,
),
Image.asset(
lockTypeIcon,
width: 50.w,
height: 50.w,
),
SizedBox(
width: 20.w,
),
@ -73,24 +68,19 @@ class _MessageListPageState extends State<MessageListPage> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
gateWayName,
messageItemEntity.data!,
style: TextStyle(
fontSize: 22.sp, color: AppColors.blackColor),
fontSize: 22.sp, color: messageItemEntity.readAt! == 0 ? AppColors.blackColor : AppColors.placeholderTextColor),
),
],
),
SizedBox(height: 5.h),
SizedBox(height: 10.h),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
// Image.asset('images/mine/icon_mine_gatewaySignal_strong.png', width: 40.w, height: 40.w,),
// SizedBox(width: 10.w,),
Text(
networkSignal,
style: TextStyle(
fontSize: 18.sp,
color: AppColors.placeholderTextColor),
),
Text(DateTool().dateToYMDHNString(messageItemEntity.createdAt!.toString()), style: TextStyle(fontSize: 18.sp, color: messageItemEntity.readAt! == 0 ? AppColors.blackColor : AppColors.placeholderTextColor)),
],
),
SizedBox(width: 20.h),

View File

@ -0,0 +1,10 @@
import 'package:get/get.dart';
import 'messageList_entity.dart';
class MessageListState{
var pageNum = 1.obs; //
final pageSize = 20.obs; //
final itemDataList = <MessageItemEntity>[].obs;
}

View File

@ -1,6 +1,6 @@
abstract class Api {
static String baseAddress = "https://pre.lock.star-lock.cn"; //
// static String baseAddress = "https://dev.lock.star-lock.cn"; //
// static String baseAddress = "https://pre.lock.star-lock.cn"; //
static String baseAddress = "https://dev.lock.star-lock.cn"; //
// static String baseAddress = "http://192.168.1.15:8022"; //
// static String baseAddress = "https://ge.lock.star-lock.cn"; //
@ -168,4 +168,7 @@ abstract class Api {
final String unbindPhoneTokenURL = '/user/unbindPhoneToken'; //Token
final String unbindEmailTokenURL = '/user/unbindEmailToken'; //Token
final String pushBindAppIdURL = '/user/bindAppId'; //APP设备
final String messageListURL = '/notifications/list'; //
final String readMessageURL = '/notifications/markAsRead'; //
}

View File

@ -1458,6 +1458,22 @@ class ApiProvider extends BaseProvider {
Future<Response> pushBindAppId(String deviceId, int deviceType) => post(
pushBindAppIdURL.toUrl,
jsonEncode({"deviceId": deviceId, "deviceType": deviceType}));
//
Future<Response> messageListLoadData(String pageNo, String pageSize) =>
post(messageListURL.toUrl,
jsonEncode({
'pageNo': pageNo,
'pageSize': pageSize,
}));
//
Future<Response> readMessageLoadData(String messageId) =>
post(readMessageURL.toUrl,
jsonEncode({
'id': messageId,
}));
}
extension ExtensionString on String {

View File

@ -41,6 +41,7 @@ import '../main/lockDetail/lockDetail/lockNetToken_entity.dart';
import '../main/lockDetail/lockOperatingRecord/lockOperatingRecordGetLastRecordTime_entity.dart';
import '../main/lockMian/entity/lockListInfo_entity.dart';
import '../mine/addLock/saveLock/entity/SaveLockEntity.dart';
import '../mine/message/messageList/messageList_entity.dart';
import '../mine/minePersonInfo/minePersonInfoPage/minePersonGetUploadFileInfo_entity.dart';
import '../mine/mineSet/transferGateway/selectGetewayList_entity.dart';
import '../mine/mineSet/transferSmartLock/recipientInformation/recipientInformation_entity.dart';
@ -1466,4 +1467,22 @@ class ApiRepository {
final res = await apiProvider.pushBindAppId(deviceId, deviceType);
return MineUnbindPhoneOrEmailEntity.fromJson(res.body);
}
//
Future<MessageListEntity> messageListLoadData({
required String pageNo,
required String pageSize
}) async {
final res = await apiProvider.messageListLoadData(pageNo, pageSize);
return MessageListEntity.fromJson(res.body);
}
//
Future<MessageListEntity> readMessageLoadData({
required String messageId,
}) async {
final res = await apiProvider.readMessageLoadData(messageId);
return MessageListEntity.fromJson(res.body);
}
}

View File

@ -0,0 +1,18 @@
import 'package:flutter/services.dart';
///
class NativeInteractionConfig{
static String eventChannel = 'starLockFlutterReceive';
static String methodChannel = 'starLockFlutterSend';
}
///flutter向原生发送消息
class NativeInteractionTool{
static loadNativeShare({required String shareText}){
MethodChannel(NativeInteractionConfig.methodChannel).invokeMethod('loadNativeShare', {'shareText':shareText});
}
}

View File

@ -84,3 +84,8 @@ class GetPasswordTypeUpdateIndex {
class GetPasswordListRefreshUI {
GetPasswordListRefreshUI();
}
///
class ReadMessageRefreshUI {
ReadMessageRefreshUI();
}