修复首页多条数据显示bug

This commit is contained in:
魏少阳 2023-08-30 14:55:42 +08:00
parent f95eebc74e
commit f26bb166c2
9 changed files with 76 additions and 11 deletions

View File

@ -3,6 +3,7 @@ import 'package:star_lock/common/safetyVerification/safetyVerification_binding.d
import 'package:star_lock/login/register/starLock_register_binding.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
import 'package:star_lock/main/lockDetail/lockDetail/lockDetail_main_page.dart';
import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart';
import 'package:star_lock/mine/minePersonInfo/minePersonInfoEmail/minePersonInfoEmail_page.dart';
import 'package:star_lock/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator_page.dart';
import 'package:star_lock/mine/mineSet/lockGroup/lockGroupList_page.dart';

View File

@ -17,6 +17,7 @@ import '../../../blue/io_tool/manager_event_bus.dart';
import '../../../blue/sender_manage.dart';
import '../../../login/login/entity/LoginData.dart';
import '../../../login/login/entity/LoginEntity.dart';
import '../../../network/api_repository.dart';
import '../../../tools/baseGetXController.dart';
import '../../../tools/storage.dart';
import 'lockDetail_state.dart';
@ -351,7 +352,7 @@ class LockDetailLogic extends BaseGetXController{
List<int> getTokenList = changeStringListToIntList(token!);
print("openDoorTokenPubToken:$getTokenList");
print("privateKey:$privateKey token:$token");
print("publicKey:$publicKey publicKeyDataList:$publicKeyDataList privateKey:$privateKey getPrivateKeyList:$getPrivateKeyList token:$token getTokenList:$getTokenList");
IoSenderManage.senderEditUser(
lockID:BlueManage().connectDeviceName,
authUserID:await Storage.getUserId(),
@ -430,7 +431,7 @@ class LockDetailLogic extends BaseGetXController{
//
Future<void> connectBlue() async {
//
BlueManage().connect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, connectStateCallBack: (DeviceConnectionState state) async {
BlueManage().connect(state.keyInfos.value.bluetooth!.bluetoothDeviceId!, state.keyInfos.value.bluetooth!.bluetoothDeviceName!, connectStateCallBack: (DeviceConnectionState state) async {
if (state == DeviceConnectionState.connected){
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);

View File

@ -1,8 +1,10 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import '../../../app_settings/app_colors.dart';
import '../../../network/api_repository.dart';
import '../../../tools/titleAppBar.dart';
import '../../../translations/trans_lib.dart';
import '../../lockMian/entity/lockInfoEntity.dart';
@ -17,16 +19,47 @@ class LockDetailMainPage extends StatefulWidget {
}
class _LockDetailMainPageState extends State<LockDetailMainPage> {
void getLockInfo() async{
var entity = await ApiRepository.to.getLockInfo(
lastUpdateDate:DateTime.now().millisecondsSinceEpoch.toString(),
pageNo:"1",
);
if(entity.errorCode!.codeIsSuccessful){
}else{
}
}
@override
void initState() {
// TODO: implement initState
super.initState();
}
@override
Widget build(BuildContext context) {
final isFrist;
KeyInfos keyInfos = KeyInfos();
LockMainEntity lockEntity = LockMainEntity();
dynamic obj = ModalRoute.of(context)?.settings.arguments;
if (obj != null && (obj["lockMainEntity"] != null)) {
lockEntity = obj["lockMainEntity"];
}
if (obj != null && (obj["keyInfo"] != null)) {
keyInfos = obj["keyInfo"];
}
return Scaffold(
backgroundColor: Colors.white,
appBar: TitleAppBar(
barTitle: TranslationLoader.lanKeys!.starLock!.tr,
haveBack: true,
backgroundColor: AppColors.mainColor),
// body: LockDetailPage(lockMainEntity: widget.lockMainEntity),
body: Container(),
body: LockDetailPage(isFrist:true ,lockMainEntity:lockEntity, keyInfo: keyInfos),
// body: Container(),
);
}
}

View File

@ -5,6 +5,9 @@ import 'package:get/get.dart';
import '../../../appRouters.dart';
import '../../../app_settings/app_colors.dart';
import '../../../blue/blue_manage.dart';
import '../../../blue/io_tool/io_manager.dart';
import '../../../blue/io_tool/io_tool.dart';
import '../../../tools/storage.dart';
import '../../../translations/trans_lib.dart';
import '../../lockMian/entity/lockInfoEntity.dart';
import 'lockDetail_logic.dart';
@ -33,6 +36,18 @@ class _LockDetailPageState extends State<LockDetailPage> {
state.keyInfos.value = widget.keyInfo;
BlueManage().connectDeviceName = state.keyInfos.value.bluetooth!.bluetoothDeviceName!;
BlueManage().connectDeviceMacAddress = state.keyInfos.value.bluetooth!.bluetoothDeviceId!;
List<int> publicKeyData = state.keyInfos.value.bluetooth!.publicKey!.cast<int>();
var saveStrList = changeIntListToStringList(publicKeyData);
Storage.setStringList(saveBluePublicKey, saveStrList);
//
List<int> privateKeyData = state.keyInfos.value.bluetooth!.privateKey!.cast<int>();
var savePrivateKeyList = changeIntListToStringList(privateKeyData);
Storage.setStringList(saveBluePrivateKey, savePrivateKeyList);
// print("publicKeyData:$publicKeyData saveStrList:$saveStrList privateKeyData:$privateKeyData savePrivateKeyList:$savePrivateKeyList");
// logic.connectBlue();
}
@override
@ -62,7 +77,7 @@ class _LockDetailPageState extends State<LockDetailPage> {
Align(
alignment: Alignment.center,
child: Text(
widget.keyInfo.lockAlias!,
widget.keyInfo!.lockAlias!,
style:
TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w400),
)),

View File

@ -490,18 +490,21 @@ class Bluetooth {
String? bluetoothDeviceName;
List<dynamic>? publicKey;
List<dynamic>? privateKey;
List<dynamic>? signKey;
Bluetooth(
{this.bluetoothDeviceId,
this.bluetoothDeviceName,
this.publicKey,
this.privateKey});
this.privateKey,
this.signKey});
Bluetooth.fromJson(Map<String, dynamic> json) {
bluetoothDeviceId = json['bluetoothDeviceId'];
bluetoothDeviceName = json['bluetoothDeviceName'];
publicKey = json['publicKey'];
privateKey = json['publicKey'];
privateKey = json['privateKey'];
signKey = json['signKey'];
}
Map<String, dynamic> toJson() {
@ -510,6 +513,7 @@ class Bluetooth {
data['bluetoothDeviceName'] = bluetoothDeviceName;
data['publicKey'] = publicKey;
data['privateKey'] = privateKey;
data['signKey'] = signKey;
return data;
}
}

View File

@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/mine/mine/starLockMine_page.dart';
import '../../../appRouters.dart';
@ -31,7 +32,10 @@ class _LockListPageState extends State<LockListPage> {
itemBuilder: (c, index) {
KeyInfos keyInfo = dataList[index];
return lockInfoListItem('images/icon_lock.png', keyInfo.lockAlias, () {
Navigator.pushNamed(context, Routers.lockDetailMainPage);
Get.toNamed(Routers.lockDetailMainPage, arguments: {
"lockMainEntity": widget.lockMainEntity,
"keyInfo": keyInfo
});
});
});
}

View File

@ -45,7 +45,7 @@ class _NearbyLockPageState extends State<NearbyLockPage> {
// Navigator.pushNamed(context, Routers.lockAddressPage);
// logic.getPublicKey(state.devices[index].serviceUuids[0].toString());
state.seletLockName.value = state.devices[index].name;
print("connect-lockId:${state.devices[index].id} deviceName:${state.devices[index].name}");
// print("connect-lockId:${state.devices[index].id} deviceName:${state.devices[index].name}");
logic.connect(state.devices[index].id, state.devices[index].name);
});
},
@ -64,7 +64,7 @@ class _NearbyLockPageState extends State<NearbyLockPage> {
Widget nearbyLockItem(String lockTypeIcon, DiscoveredDevice discoveredDevice, Function() action ) {
return GestureDetector(
onTap: action,
onTap: ((discoveredDevice.serviceUuids.isNotEmpty ? discoveredDevice.serviceUuids[0] : "").toString()[33] == "1") ? action : null,
child: Column(
// mainAxisAlignment: MainAxisAlignment.center,
children: [

View File

@ -204,7 +204,7 @@ class SaveLockLogic extends BaseGetXController {
userID:await Storage.getUserId(),
openMode:1,
keyType:1,
startDate:0x11223344,
startDate:DateTime.now().millisecondsSinceEpoch,
expireDate:0x11223344,
role:255,
password:"123456",
@ -244,6 +244,12 @@ class SaveLockLogic extends BaseGetXController {
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
bluetooth['privateKey'] = getPrivateKeyList;
var signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!);
bluetooth['signKey'] = signKeyDataList;
print("addUser:publicKeyDataList$publicKeyDataList getPrivateKeyList:$getPrivateKeyList signKeyDataList:$signKeyDataList");
var entity = await ApiRepository.to.bindingBlueAdmin(
bindingDate:DateTime.now().millisecondsSinceEpoch.toString(),
hotelMode:"2",

View File

@ -124,6 +124,7 @@ class Storage {
if (data != null && data.isNotEmpty) {
userId = LoginEntity.fromJson(jsonDecode(data)).data!.userid.toString();
}
print("pubUserId:$userId");
return userId;
}