This commit is contained in:
魏少阳 2024-01-06 16:26:19 +08:00
commit 396c750e47
15 changed files with 170 additions and 128 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

View File

@ -9,6 +9,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_sound/flutter_sound.dart'; import 'package:flutter_sound/flutter_sound.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
import 'package:star_lock/talk/udp/udp_talkClass.dart';
import 'package:star_lock/tools/app_manager.dart'; import 'package:star_lock/tools/app_manager.dart';
import 'package:star_lock/tools/bindings/app_binding.dart'; import 'package:star_lock/tools/bindings/app_binding.dart';
import 'package:star_lock/tools/device_info_service.dart'; import 'package:star_lock/tools/device_info_service.dart';
@ -175,6 +176,9 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver, BaseWidget {
} else if (state == AppLifecycleState.paused) { } else if (state == AppLifecycleState.paused) {
// //
print("应用进入后台"); print("应用进入后台");
if (UDPTalkClass().isBeCall == true) {
UDPTalkClass().playLocalAudio();
}
} }
} }
} }
@ -233,4 +237,3 @@ Future<bool> getMicrophonePermission() async {
} }
return false; return false;
} }

View File

@ -24,7 +24,8 @@ class _AddICCardPageState extends State<AddICCardPage> {
return Scaffold( return Scaffold(
backgroundColor: AppColors.mainBackgroundColor, backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar( appBar: TitleAppBar(
barTitle: "${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.card!.tr}", barTitle:
"${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.card!.tr}",
haveBack: true, haveBack: true,
backgroundColor: AppColors.mainColor, backgroundColor: AppColors.mainColor,
), ),
@ -32,22 +33,35 @@ class _AddICCardPageState extends State<AddICCardPage> {
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
// mainAxisAlignment: MainAxisAlignment.center, // mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
SizedBox(height: 420.h), SizedBox(height: 200.h),
CupertinoActivityIndicator(radius: 25.h,), Image.asset(
'images/main/icon_addCard.png',
width: 234.w,
height: 211.h,
fit: BoxFit.cover,
),
SizedBox(height: 90.h),
CupertinoActivityIndicator(
radius: 25.h,
),
SizedBox(height: 120.h), SizedBox(height: 120.h),
Container( Container(
width: 1.sw, width: 1.sw,
height: 50.h, height: 50.h,
// padding: EdgeInsets.only(left: 30.w, right: 30.w, top: 10.h, bottom: 10.h), // padding: EdgeInsets.only(left: 30.w, right: 30.w, top: 10.h, bottom: 10.h),
margin: EdgeInsets.only(left: 15.w, right: 15.w, top: 10.h, bottom: 10.h), margin: EdgeInsets.only(
left: 15.w, right: 15.w, top: 10.h, bottom: 10.h),
// color: AppColors.blackColor, // color: AppColors.blackColor,
decoration: BoxDecoration( decoration: BoxDecoration(
color: AppColors.blackColor, color: AppColors.blackColor,
borderRadius: BorderRadius.circular(10.w), borderRadius: BorderRadius.circular(10.w),
), ),
child: Center( child: Center(
child: Obx(() => Text(state.ifConnectScuess.value ? "已连接到锁,请将卡靠近锁的读卡区" : "尝试连接设备...", style:TextStyle(color: Colors.white, fontSize: 24.sp))) child: Obx(() => Text(
), state.ifConnectScuess.value
? "已连接到锁,请将卡靠近锁的读卡区"
: "尝试连接设备...",
style: TextStyle(color: Colors.white, fontSize: 24.sp)))),
), ),
], ],
), ),

View File

@ -6,6 +6,7 @@ import 'package:flutter_voice_processor/flutter_voice_processor.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
import 'package:star_lock/main/lockDetail/lockDetail/realTimePicture/realTimePicture_state.dart'; import 'package:star_lock/main/lockDetail/lockDetail/realTimePicture/realTimePicture_state.dart';
import 'package:star_lock/talk/call/callTalk.dart';
import '../../../../talk/call/g711.dart'; import '../../../../talk/call/g711.dart';
import '../../../../talk/udp/udp_manage.dart'; import '../../../../talk/udp/udp_manage.dart';
@ -62,6 +63,7 @@ class RealTimePictureLogic extends BaseGetXController {
userMobile: await state.userMobile, userMobile: await state.userMobile,
userMobileIP: await state.userMobileIP, userMobileIP: await state.userMobileIP,
endData: []); endData: []);
CallTalk().stopPcmSound();
// //
Get.back(); Get.back();

View File

@ -3,6 +3,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/lockDetail/realTimePicture/realTimePicture_logic.dart'; import 'package:star_lock/main/lockDetail/lockDetail/realTimePicture/realTimePicture_logic.dart';
import 'package:star_lock/talk/call/callTalk.dart';
import '../../../../app_settings/app_colors.dart'; import '../../../../app_settings/app_colors.dart';
import '../../../../tools/showTFView.dart'; import '../../../../tools/showTFView.dart';
@ -39,6 +40,11 @@ class _RealTimePicturePageState extends State<RealTimePicturePage>
} }
}); });
// 10
Future.delayed(const Duration(seconds: 10), () {
state.animationController.stop();
});
logic.udpMonitorAction(); logic.udpMonitorAction();
} }
@ -188,7 +194,7 @@ class _RealTimePicturePageState extends State<RealTimePicturePage>
bottomBtnItemWidget( bottomBtnItemWidget(
"images/main/icon_lockDetail_hangUp.png", "挂断", Colors.red, () async { "images/main/icon_lockDetail_hangUp.png", "挂断", Colors.red, () async {
logic.stopProcessing(); logic.stopProcessing();
CallTalk().stopPcmSound();
// //
logic.udpHangUpAction(); logic.udpHangUpAction();
}), }),
@ -307,7 +313,7 @@ class _RealTimePicturePageState extends State<RealTimePicturePage>
), ),
), ),
onTap: () { onTap: () {
print('点击重新连接'); state.animationController.forward();
}, },
), ),
); );

View File

@ -1,4 +1,3 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:math'; import 'dart:math';
@ -7,6 +6,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_voice_processor/flutter_voice_processor.dart'; import 'package:flutter_voice_processor/flutter_voice_processor.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
import 'package:star_lock/talk/call/callTalk.dart';
import '../../../../talk/call/g711.dart'; import '../../../../talk/call/g711.dart';
import '../../../../talk/udp/udp_manage.dart'; import '../../../../talk/udp/udp_manage.dart';
@ -41,14 +41,16 @@ class LockMonitoringLogic extends BaseGetXController {
/// UDP发送的状态 /// UDP发送的状态
StreamSubscription? _getUDPStatusRefreshUIEvent; StreamSubscription? _getUDPStatusRefreshUIEvent;
void _getUDPStatusRefreshUIAction() { void _getUDPStatusRefreshUIAction() {
_getUDPStatusRefreshUIEvent = eventBus.on<GetUDPStatusRefreshUI>().listen((event) { _getUDPStatusRefreshUIEvent =
eventBus.on<GetUDPStatusRefreshUI>().listen((event) {
state.udpStatus.value = event.udpStatus; state.udpStatus.value = event.udpStatus;
if(state.udpStatus.value == 8){ if (state.udpStatus.value == 8) {
// 60 // 60
state.oneMinuteTimeTimer = Timer.periodic(const Duration(seconds:1), (Timer t) async { state.oneMinuteTimeTimer =
Timer.periodic(const Duration(seconds: 1), (Timer t) async {
state.oneMinuteTime.value++; state.oneMinuteTime.value++;
// Get.log('state.oneMinuteTime.value:${state.oneMinuteTime.value}'); // Get.log('state.oneMinuteTime.value:${state.oneMinuteTime.value}');
if(state.oneMinuteTime.value >= 60){ if (state.oneMinuteTime.value >= 60) {
// 60 // 60
state.oneMinuteTimeTimer.cancel(); state.oneMinuteTimeTimer.cancel();
state.oneMinuteTime.value = 0; state.oneMinuteTime.value = 0;
@ -63,6 +65,7 @@ class LockMonitoringLogic extends BaseGetXController {
userMobileIP: await state.userMobileIP, userMobileIP: await state.userMobileIP,
endData: []); endData: []);
CallTalk().stopPcmSound();
// //
Get.back(); Get.back();
} }
@ -81,8 +84,7 @@ class LockMonitoringLogic extends BaseGetXController {
lockIP: UDPManage().host, lockIP: UDPManage().host,
userMobile: await state.userMobile, userMobile: await state.userMobile,
userMobileIP: await state.userMobileIP, userMobileIP: await state.userMobileIP,
endData: [] endData: []);
);
} }
/// ///
@ -128,7 +130,9 @@ class LockMonitoringLogic extends BaseGetXController {
while (start < audioData.length) { while (start < audioData.length) {
// await Future.delayed(const Duration(milliseconds: 50)); // await Future.delayed(const Duration(milliseconds: 50));
int end = (start + length > audioData.length) ? audioData.length : start + length; int end = (start + length > audioData.length)
? audioData.length
: start + length;
List<int> sublist = audioData.sublist(start, end); List<int> sublist = audioData.sublist(start, end);
sendRecordData({ sendRecordData({
"bytes": sublist, "bytes": sublist,
@ -165,7 +169,9 @@ class LockMonitoringLogic extends BaseGetXController {
errorListener(VoiceProcessorException error) { errorListener(VoiceProcessorException error) {
print("VoiceProcessorException: $error"); print("VoiceProcessorException: $error");
}; }
;
state.voiceProcessor?.addFrameListener(frameListener); state.voiceProcessor?.addFrameListener(frameListener);
state.voiceProcessor?.addErrorListener(errorListener); state.voiceProcessor?.addErrorListener(errorListener);
@ -173,15 +179,10 @@ class LockMonitoringLogic extends BaseGetXController {
if (await state.voiceProcessor?.hasRecordAudioPermission() ?? false) { if (await state.voiceProcessor?.hasRecordAudioPermission() ?? false) {
await state.voiceProcessor?.start(320, 8000); await state.voiceProcessor?.start(320, 8000);
bool? isRecording = await state.voiceProcessor?.isRecording(); bool? isRecording = await state.voiceProcessor?.isRecording();
} else {}
} else {
}
} on PlatformException catch (ex) { } on PlatformException catch (ex) {
Get.log("PlatformException: $ex"); Get.log("PlatformException: $ex");
} finally { } finally {}
}
} }
Future<void> stopProcessing() async { Future<void> stopProcessing() async {
@ -189,9 +190,7 @@ class LockMonitoringLogic extends BaseGetXController {
await state.voiceProcessor?.stop(); await state.voiceProcessor?.stop();
} on PlatformException catch (ex) { } on PlatformException catch (ex) {
Get.log("PlatformException: $ex"); Get.log("PlatformException: $ex");
} finally { } finally {}
}
} }
void onError(Object e) { void onError(Object e) {
@ -199,7 +198,6 @@ class LockMonitoringLogic extends BaseGetXController {
} }
sendRecordData(Map<String, dynamic> args) async { sendRecordData(Map<String, dynamic> args) async {
List<int> bytes = args["bytes"]; List<int> bytes = args["bytes"];
// int udpSendDataFrameNumber = args["udpSendDataFrameNumber"]; // int udpSendDataFrameNumber = args["udpSendDataFrameNumber"];
String? lockID = args["lockID"]; String? lockID = args["lockID"];
@ -218,7 +216,7 @@ class LockMonitoringLogic extends BaseGetXController {
// while(list.isNotEmpty) { // while(list.isNotEmpty) {
state.udpSendDataFrameNumber++; state.udpSendDataFrameNumber++;
if (state.udpSendDataFrameNumber >= 65536) state.udpSendDataFrameNumber=1; if (state.udpSendDataFrameNumber >= 65536) state.udpSendDataFrameNumber = 1;
// 57 // 57
List<int> topBytes = []; List<int> topBytes = [];
@ -281,7 +279,8 @@ class LockMonitoringLogic extends BaseGetXController {
topBytes[6] = (state.udpSendDataFrameNumber & 0x000000FF); topBytes[6] = (state.udpSendDataFrameNumber & 0x000000FF);
topBytes[7] = ((state.udpSendDataFrameNumber & 0x0000FF00) >> 8); topBytes[7] = ((state.udpSendDataFrameNumber & 0x0000FF00) >> 8);
print("udpSendDataFrameNumber:${state.udpSendDataFrameNumber} topBytes[63]:${topBytes[6]} topBytes[64]:${topBytes[7]}"); print(
"udpSendDataFrameNumber:${state.udpSendDataFrameNumber} topBytes[63]:${topBytes[6]} topBytes[64]:${topBytes[7]}");
topBytes.addAll(bytes); topBytes.addAll(bytes);
Get.log("setVoiceBytes:$topBytes"); Get.log("setVoiceBytes:$topBytes");
@ -293,8 +292,7 @@ class LockMonitoringLogic extends BaseGetXController {
lockIP: lockIP, lockIP: lockIP,
userMobile: userMobile, userMobile: userMobile,
userMobileIP: userMobileIP, userMobileIP: userMobileIP,
endData: topBytes endData: topBytes);
);
// UDPManage().sendData(topBytes); // UDPManage().sendData(topBytes);
} }
@ -324,7 +322,16 @@ class LockMonitoringLogic extends BaseGetXController {
} }
int search(int val) { int search(int val) {
List<int> table = [0xFF, 0x1FF, 0x3FF, 0x7FF, 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF]; List<int> table = [
0xFF,
0x1FF,
0x3FF,
0x7FF,
0xFFF,
0x1FFF,
0x3FFF,
0x7FFF
];
int size = 8; int size = 8;
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
if (val <= table[i]) { if (val <= table[i]) {
@ -392,9 +399,10 @@ class LockMonitoringLogic extends BaseGetXController {
void onClose() { void onClose() {
// TODO: implement onClose // TODO: implement onClose
print("锁详情界面销毁了"); print("锁详情界面销毁了");
CallTalk().stopPcmSound();
_getTVDataRefreshUIEvent!.cancel(); _getTVDataRefreshUIEvent!.cancel();
_getUDPStatusRefreshUIEvent!.cancel(); _getUDPStatusRefreshUIEvent!.cancel();
if(state.oneMinuteTimeTimer != null){ if (state.oneMinuteTimeTimer != null) {
state.oneMinuteTimeTimer.cancel(); state.oneMinuteTimeTimer.cancel();
} }
stopProcessing(); stopProcessing();

View File

@ -1,8 +1,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/talk/call/callTalk.dart';
import '../../../../app_settings/app_colors.dart'; import '../../../../app_settings/app_colors.dart';
import '../../../../talk/udp/udp_manage.dart'; import '../../../../talk/udp/udp_manage.dart';
@ -43,12 +43,15 @@ class _LockMonitoringPageState extends State<LockMonitoringPage> {
top: ScreenUtil().statusBarHeight + 30.h, top: ScreenUtil().statusBarHeight + 30.h,
width: 1.sw, width: 1.sw,
child: Obx(() { child: Obx(() {
var sec = (state.oneMinuteTime.value % 60).toString().padLeft(2,'0'); var sec =
var min = (state.oneMinuteTime.value ~/ 60).toString().padLeft(2,'0'); (state.oneMinuteTime.value % 60).toString().padLeft(2, '0');
var min =
(state.oneMinuteTime.value ~/ 60).toString().padLeft(2, '0');
return Row( return Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Text("$min:$sec", style: TextStyle(fontSize: 26.sp, color: Colors.white)), Text("$min:$sec",
style: TextStyle(fontSize: 26.sp, color: Colors.white)),
// SizedBox(width: 30.w), // SizedBox(width: 30.w),
// GestureDetector( // GestureDetector(
// onTap: () { // onTap: () {
@ -66,8 +69,7 @@ class _LockMonitoringPageState extends State<LockMonitoringPage> {
// ), // ),
// ), // ),
// ), // ),
] ]);
);
}), }),
), ),
Positioned( Positioned(
@ -155,45 +157,44 @@ class _LockMonitoringPageState extends State<LockMonitoringPage> {
Widget bottomBottomBtnWidget() { Widget bottomBottomBtnWidget() {
return Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ return Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [
// //
Obx(() => bottomBtnItemWidget(getAnswerBtnImg(), getAnswerBtnName(), Colors.white, () async { Obx(() => bottomBtnItemWidget(
// getAnswerBtnImg(), getAnswerBtnName(), Colors.white, () async {
await logic.getPermissionStatus().then((value) async { //
if (!value) { await logic.getPermissionStatus().then((value) async {
return; if (!value) {
} return;
}
// state.isSenderAudioData.value = false; // state.isSenderAudioData.value = false;
print("发送接听了"); print("发送接听了");
// //
logic.udpAnswerAction(); logic.udpAnswerAction();
}); });
}, }, longPress: () {
longPress: (){ //
// print("onLongPress");
print("onLongPress"); state.listAudioData.value = <int>[];
state.listAudioData.value = <int>[]; if (state.udpStatus.value == 8) {
if (state.udpStatus.value == 8) { state.udpStatus.value = 9;
state.udpStatus.value = 9;
}
// logic.readG711Data();
logic.startProcessing();
},
longPressUp: () async {
//
print("onLongPressUp");
if (state.udpStatus.value == 9) {
state.udpStatus.value = 8;
}
} }
) // logic.readG711Data();
), logic.startProcessing();
bottomBtnItemWidget("images/main/icon_lockDetail_hangUp.png", "挂断", Colors.red, () async { }, longPressUp: () async {
//
print("onLongPressUp");
if (state.udpStatus.value == 9) {
state.udpStatus.value = 8;
}
})),
bottomBtnItemWidget(
"images/main/icon_lockDetail_hangUp.png", "挂断", Colors.red, () async {
logic.stopProcessing(); logic.stopProcessing();
CallTalk().stopPcmSound();
// //
logic.udpHangUpAction(); logic.udpHangUpAction();
}), }),
bottomBtnItemWidget("images/main/icon_lockDetail_monitoringUnlock.png", "开锁", AppColors.mainColor, () { bottomBtnItemWidget("images/main/icon_lockDetail_monitoringUnlock.png",
"开锁", AppColors.mainColor, () {
showDeletPasswordAlertDialog(context); showDeletPasswordAlertDialog(context);
}) })
]); ]);
@ -202,26 +203,28 @@ class _LockMonitoringPageState extends State<LockMonitoringPage> {
String getAnswerBtnImg() { String getAnswerBtnImg() {
switch (state.udpStatus.value) { switch (state.udpStatus.value) {
case 8: case 8:
return "images/main/icon_lockDetail_monitoringUnTalkback.png"; return "images/main/icon_lockDetail_monitoringUnTalkback.png";
case 9: case 9:
return "images/main/icon_lockDetail_monitoringTalkback.png"; return "images/main/icon_lockDetail_monitoringTalkback.png";
default: default:
return "images/main/icon_lockDetail_monitoringAnswerCalls.png"; return "images/main/icon_lockDetail_monitoringAnswerCalls.png";
} }
} }
String getAnswerBtnName() { String getAnswerBtnName() {
switch (state.udpStatus.value) { switch (state.udpStatus.value) {
case 8: case 8:
return "长按说话"; return "长按说话";
case 9: case 9:
return "松开发送"; return "松开发送";
default: default:
return "接听"; return "接听";
} }
} }
Widget bottomBtnItemWidget(String iconUrl, String name, Color backgroundColor, Function() onClick, {Function()? longPress, Function()? longPressUp}) { Widget bottomBtnItemWidget(
String iconUrl, String name, Color backgroundColor, Function() onClick,
{Function()? longPress, Function()? longPressUp}) {
var wh = 80.w; var wh = 80.w;
return GestureDetector( return GestureDetector(
onTap: onClick, onTap: onClick,
@ -285,6 +288,5 @@ class _LockMonitoringPageState extends State<LockMonitoringPage> {
@override @override
void dispose() { void dispose() {
super.dispose(); super.dispose();
} }
} }

View File

@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/tools/eventBusEventManage.dart';
import '../../../../app_settings/app_colors.dart'; import '../../../../app_settings/app_colors.dart';
import '../../../../tools/CustomUnderlineTabIndicator.dart'; import '../../../../tools/CustomUnderlineTabIndicator.dart';
@ -13,9 +14,7 @@ class PasswordKeyManageTabbarPage extends StatefulWidget {
final LockListInfoItemEntity keyInfo; final LockListInfoItemEntity keyInfo;
PasswordKeyManageTabbarPage( PasswordKeyManageTabbarPage(
{Key? key, {Key? key, required this.initialIndex, required this.keyInfo})
required this.initialIndex,
required this.keyInfo})
: super(key: key); : super(key: key);
@override @override
State<PasswordKeyManageTabbarPage> createState() => State<PasswordKeyManageTabbarPage> createState() =>
@ -44,6 +43,15 @@ class _PasswordKeyManageTabbarPageState
vsync: this, vsync: this,
length: _itemTabs.length, length: _itemTabs.length,
initialIndex: widget.initialIndex); initialIndex: widget.initialIndex);
_tabController.addListener(handleTabIndex);
}
int handleTabIndex() {
//
int currentIndex = _tabController.index;
// item
eventBus.fire(GetPasswordTypeUpdateIndex(currentIndex));
return currentIndex;
} }
@override @override
@ -102,7 +110,7 @@ class _PasswordKeyManageTabbarPageState
controller: _tabController, controller: _tabController,
children: _itemTabs children: _itemTabs
.map((ItemView item) => PasswordKeyPerpetualPage( .map((ItemView item) => PasswordKeyPerpetualPage(
type: item.type, type: _tabController.index.toString(),
getKeyInfo: widget.keyInfo, getKeyInfo: widget.keyInfo,
)) ))
.toList(), .toList(),

View File

@ -4,6 +4,7 @@ import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
import 'package:star_lock/blue/io_type.dart'; import 'package:star_lock/blue/io_type.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_state.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_state.dart';
import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/eventBusEventManage.dart';
import 'package:star_lock/tools/toast.dart'; import 'package:star_lock/tools/toast.dart';
import '../../../../blue/blue_manage.dart'; import '../../../../blue/blue_manage.dart';
@ -18,6 +19,15 @@ import '../../../../tools/storage.dart';
class PasswordKeyPerpetualLogic extends BaseGetXController { class PasswordKeyPerpetualLogic extends BaseGetXController {
final PasswordKeyPerpetualState state = PasswordKeyPerpetualState(); final PasswordKeyPerpetualState state = PasswordKeyPerpetualState();
///
StreamSubscription? getPasswordTypeUpdateIndexEvent;
void getPasswordTypeUpdateIndexAction() {
getPasswordTypeUpdateIndexEvent =
eventBus.on<GetPasswordTypeUpdateIndex>().listen((event) {
state.widgetType.value = event.passwordType;
});
}
/** /**
1 6使 1 6使
2 24使 2 24使
@ -39,20 +49,19 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
String getFailureDateTime = '0'; String getFailureDateTime = '0';
String getEffectiveDateTime = '0'; String getEffectiveDateTime = '0';
String lockId = state.keyInfo.value.lockId.toString(); String lockId = state.keyInfo.value.lockId.toString();
int passwordType = int.parse(state.widgetType.value); String getKeyType = state.widgetType.value.toString();
String getKeyType = passwordType.toString(); if (state.widgetType.value == 0) {
if (passwordType == 0) {
// //
getKeyType = '2'; getKeyType = '2';
} else if (passwordType == 1) { } else if (state.widgetType.value == 1) {
// //
getKeyType = '3'; getKeyType = '3';
} else if (passwordType == 2) { } else if (state.widgetType.value == 2) {
// //
getKeyType = '1'; getKeyType = '1';
} else if (passwordType == 3) { } else if (state.widgetType.value == 3) {
// //
} else if (passwordType == 4) { } else if (state.widgetType.value == 4) {
// //
if (state.loopModeStr.value == '周末') { if (state.loopModeStr.value == '周末') {
getKeyType = '5'; getKeyType = '5';
@ -75,15 +84,14 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
} else if (state.loopModeStr.value == '星期日') { } else if (state.loopModeStr.value == '星期日') {
getKeyType = '14'; getKeyType = '14';
} }
} else if (passwordType == 5) { } else if (state.widgetType.value == 5) {
// //
getKeyType = '4'; getKeyType = '4';
} }
print('得到的类型为getKeyType$getKeyType');
if (state.widgetType.value != '0' && if (state.widgetType.value != 0 &&
state.widgetType.value != '2' && state.widgetType.value != 2 &&
state.widgetType.value != '5') { state.widgetType.value != 5) {
getFailureDateTime = getFailureDateTime =
state.failureDateTime.value.millisecondsSinceEpoch.toString(); state.failureDateTime.value.millisecondsSinceEpoch.toString();
getEffectiveDateTime = getEffectiveDateTime =
@ -223,7 +231,8 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
// //
Future<void> senderCustomPasswords() async { Future<void> senderCustomPasswords() async {
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState state) async { BlueManage().bludSendData(BlueManage().connectDeviceName,
(DeviceConnectionState state) async {
if (state == DeviceConnectionState.connected) { if (state == DeviceConnectionState.connected) {
var publicKey = await Storage.getStringList(saveBluePublicKey); var publicKey = await Storage.getStringList(saveBluePublicKey);
List<int> publicKeyDataList = changeStringListToIntList(publicKey!); List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
@ -257,6 +266,7 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
super.onReady(); super.onReady();
_initReplySubscription(); _initReplySubscription();
getPasswordTypeUpdateIndexAction();
} }
@override @override

View File

@ -5,6 +5,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/app_settings/app_colors.dart'; import 'package:star_lock/app_settings/app_colors.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyManage/passwordKeyManage_tabbar.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart';
import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/pickers.dart';
import 'package:star_lock/tools/pickers/style/default_style.dart'; import 'package:star_lock/tools/pickers/style/default_style.dart';
@ -54,8 +55,6 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
state.widgetType.value = widget.type;
return SingleChildScrollView( return SingleChildScrollView(
child: Obx(() => indexChangeWidget()), child: Obx(() => indexChangeWidget()),
); );
@ -65,7 +64,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
if (state.isSendSuccess.value == true) { if (state.isSendSuccess.value == true) {
return sendElectronicKeySucceed(); return sendElectronicKeySucceed();
} else { } else {
switch (int.parse(widget.type)) { switch (state.widgetType.value) {
case 0: case 0:
{ {
// //
@ -186,7 +185,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDH, Pickers.showDatePicker(context, mode: DateMode.YMDH,
onConfirm: (p) { onConfirm: (p) {
if (int.parse(widget.type) == 3) { if (state.widgetType.value == 3) {
// //
state.effectiveDateTime.value = DateTime.parse( state.effectiveDateTime.value = DateTime.parse(
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'); '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}');
@ -216,7 +215,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDH, Pickers.showDatePicker(context, mode: DateMode.YMDH,
onConfirm: (p) { onConfirm: (p) {
if (int.parse(widget.type) == 3) { if (state.widgetType.value == 3) {
// //
state.failureDateTime.value = DateTime.parse( state.failureDateTime.value = DateTime.parse(
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'); '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}');
@ -400,7 +399,6 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
onClick: () async { onClick: () async {
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
if (isDemoMode == false) { if (isDemoMode == false) {
int getWidgetNumber = int.parse(widget.type);
DateTime startDateTime = DateTime( DateTime startDateTime = DateTime(
state.effectiveDateTime.value.year, state.effectiveDateTime.value.year,
state.effectiveDateTime.value.month, state.effectiveDateTime.value.month,
@ -413,7 +411,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
state.failureDateTime.value.hour); state.failureDateTime.value.hour);
// //
if (getWidgetNumber == 3) { if (state.widgetType.value == 3) {
logic.getStartDate(state.effectiveDateTime.value); logic.getStartDate(state.effectiveDateTime.value);
if (state.nameController.text.isEmpty) { if (state.nameController.text.isEmpty) {
Toast.show(msg: '请输入姓名'); Toast.show(msg: '请输入姓名');
@ -440,7 +438,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
} }
// //
if (getWidgetNumber == 1) { if (state.widgetType.value == 1) {
if (!startDateTime.isBefore(endDateTime) || if (!startDateTime.isBefore(endDateTime) ||
startDateTime.isAtSameMomentAs(endDateTime)) { startDateTime.isAtSameMomentAs(endDateTime)) {
Toast.show(msg: '失效时间需大于生效时间'); Toast.show(msg: '失效时间需大于生效时间');
@ -448,7 +446,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
} }
} }
// //
if (getWidgetNumber == 4) { if (state.widgetType.value == 4) {
if (!startDateTime.isBefore(endDateTime) || if (!startDateTime.isBefore(endDateTime) ||
startDateTime.isAtSameMomentAs(endDateTime)) { startDateTime.isAtSameMomentAs(endDateTime)) {
Toast.show(msg: '结束时间需大于当前时间'); Toast.show(msg: '结束时间需大于当前时间');

View File

@ -43,6 +43,6 @@ class PasswordKeyPerpetualState {
var loopEndHours = DateTime.now().hour.obs; var loopEndHours = DateTime.now().hour.obs;
var loopModeStr = '周末'.obs; // var loopModeStr = '周末'.obs; //
final widgetType = ''.obs; final widgetType = 0.obs;
final keyInfo = LockListInfoItemEntity().obs; final keyInfo = LockListInfoItemEntity().obs;
} }

View File

@ -153,6 +153,9 @@ class CallTalk {
// //
void stopPcmSound() { void stopPcmSound() {
FlutterPcmSound.setup(sampleRate: 8000, channelCount: 1);
FlutterPcmSound.pause();
FlutterPcmSound.clear();
FlutterPcmSound.stop(); FlutterPcmSound.stop();
} }
} }

View File

@ -1,5 +1,4 @@
import 'dart:async'; import 'dart:async';
import 'package:audioplayers/audioplayers.dart'; import 'package:audioplayers/audioplayers.dart';
import 'package:fast_gbk/fast_gbk.dart'; import 'package:fast_gbk/fast_gbk.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -71,11 +70,7 @@ class UDPTalkClass {
UDPManage().sendData(data); UDPManage().sendData(data);
}); });
// _getFirstFrameGoPushAction(); Get.toNamed(Routers.lockMonitoringPage, arguments: {"lockId": "111"});
// Future.delayed(const Duration(seconds: 1), () {
//
Get.toNamed(Routers.lockMonitoringPage, arguments: {"lockId": "111"});
// });
} }
playLocalAudio(); playLocalAudio();
@ -84,19 +79,6 @@ class UDPTalkClass {
} }
} }
void _getFirstFrameGoPushAction() {
// eventBus
StreamSubscription _GetFirstFrameGoPushEvent =
eventBus.on<GetFirstFrameGoPush>().listen((event) {
if (event.isFirstFrame == true) {
Future.delayed(const Duration(seconds: 1), () {
//
Get.toNamed(Routers.lockMonitoringPage, arguments: {"lockId": "111"});
});
}
});
}
// call的本人 // call的本人
Future<bool> isCallMe(List<int>? data) async { Future<bool> isCallMe(List<int>? data) async {
final loginData = await Storage.getLoginData(); final loginData = await Storage.getLoginData();

View File

@ -67,3 +67,9 @@ class GetFirstFrameGoPush {
bool isFirstFrame; bool isFirstFrame;
GetFirstFrameGoPush(this.isFirstFrame); GetFirstFrameGoPush(this.isFirstFrame);
} }
/// typeIndex
class GetPasswordTypeUpdateIndex {
int passwordType;
GetPasswordTypeUpdateIndex(this.passwordType);
}