完善添加锁流程,调试锁信息列表
This commit is contained in:
parent
239ea064f6
commit
2ec3ac16c7
@ -2,6 +2,7 @@ import 'package:get/get.dart';
|
|||||||
import 'package:star_lock/common/safetyVerification/safetyVerification_binding.dart';
|
import 'package:star_lock/common/safetyVerification/safetyVerification_binding.dart';
|
||||||
import 'package:star_lock/login/register/starLock_register_binding.dart';
|
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/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
|
||||||
|
import 'package:star_lock/main/lockDetail/lockDetail/lockDetail_main_page.dart';
|
||||||
import 'package:star_lock/mine/minePersonInfo/minePersonInfoEmail/minePersonInfoEmail_page.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/authorizedAdministrator/addAuthorizedAdministrator_page.dart';
|
||||||
import 'package:star_lock/mine/mineSet/lockGroup/lockGroupList_page.dart';
|
import 'package:star_lock/mine/mineSet/lockGroup/lockGroupList_page.dart';
|
||||||
@ -74,7 +75,7 @@ import 'main/lockDetail/otherTypeKey/otherTypeKeyManage/otherTypeKeyManage_page.
|
|||||||
import 'main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart';
|
import 'main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart';
|
||||||
import 'main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart';
|
import 'main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart';
|
||||||
import 'main/lockDetail/passwordKey/passwordKeyManage/passwordKeyManage_page.dart';
|
import 'main/lockDetail/passwordKey/passwordKeyManage/passwordKeyManage_page.dart';
|
||||||
import 'main/lockMian/lockMain_page.dart';
|
import 'main/lockMian/lockMain/lockMain_page.dart';
|
||||||
import 'mine/addLock/lockAddress/lockAddress_page.dart';
|
import 'mine/addLock/lockAddress/lockAddress_page.dart';
|
||||||
import 'mine/addLock/nearbyLock/nearbyLock_page.dart';
|
import 'mine/addLock/nearbyLock/nearbyLock_page.dart';
|
||||||
import 'mine/addLock/saveLock/saveLock_page.dart';
|
import 'mine/addLock/saveLock/saveLock_page.dart';
|
||||||
@ -127,7 +128,7 @@ abstract class Routers {
|
|||||||
static const nearbyLockPage = '/NearbyLockPage'; // 附近的锁
|
static const nearbyLockPage = '/NearbyLockPage'; // 附近的锁
|
||||||
static const lockAddressPage = '/LockAddressPage'; // 锁地址
|
static const lockAddressPage = '/LockAddressPage'; // 锁地址
|
||||||
static const saveLockPage = '/SaveLockPage'; // 保存锁
|
static const saveLockPage = '/SaveLockPage'; // 保存锁
|
||||||
static const lockDetailPage = '/LockDetailPage'; // 锁详情
|
static const lockDetailMainPage = '/LockDetailMainPage'; // 锁详情
|
||||||
static const electronicKeyListPage = '/ElectronicKeyListPage'; // 电子钥匙列表
|
static const electronicKeyListPage = '/ElectronicKeyListPage'; // 电子钥匙列表
|
||||||
static const electronicKeyDetailPage = '/ElectronicKeyDetailPage'; // 电子钥匙详情
|
static const electronicKeyDetailPage = '/ElectronicKeyDetailPage'; // 电子钥匙详情
|
||||||
static const electronicKeyDetailChangeDate =
|
static const electronicKeyDetailChangeDate =
|
||||||
@ -314,8 +315,8 @@ abstract class AppRouters {
|
|||||||
page: () => const SaveLockPage(),
|
page: () => const SaveLockPage(),
|
||||||
),
|
),
|
||||||
GetPage(
|
GetPage(
|
||||||
name: Routers.lockDetailPage,
|
name: Routers.lockDetailMainPage,
|
||||||
page: () => const LockDetailPage(),
|
page: () => const LockDetailMainPage(),
|
||||||
),
|
),
|
||||||
GetPage(
|
GetPage(
|
||||||
name: Routers.electronicKeyListPage,
|
name: Routers.electronicKeyListPage,
|
||||||
|
|||||||
@ -25,7 +25,7 @@ class BlueManage{
|
|||||||
Uuid serviceId = Uuid.parse('0000FFF0-0000-1000-8000-00805F9B34FB');
|
Uuid serviceId = Uuid.parse('0000FFF0-0000-1000-8000-00805F9B34FB');
|
||||||
Uuid characteristicIdSubscription = Uuid.parse("fff1");//用来订阅的特征id
|
Uuid characteristicIdSubscription = Uuid.parse("fff1");//用来订阅的特征id
|
||||||
Uuid characteristicIdWrite = Uuid.parse("fff2");// 用来写入的特征id
|
Uuid characteristicIdWrite = Uuid.parse("fff2");// 用来写入的特征id
|
||||||
String connectDeviceId = "";
|
String connectDeviceMacAddress = "";
|
||||||
String connectDeviceName = "";
|
String connectDeviceName = "";
|
||||||
|
|
||||||
final int _limitLen = 20;
|
final int _limitLen = 20;
|
||||||
@ -72,7 +72,7 @@ class BlueManage{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// print("startScanDevice:${device}");
|
// print("startScanDevice:${device}");
|
||||||
if (((device.serviceUuids.isNotEmpty ? device.serviceUuids[0] : "").toString().contains("758824")) && (device.rssi >= -100)) {
|
if (((device.serviceUuids.isNotEmpty ? device.serviceUuids[0] : "").toString().contains("758824")) && ((device.serviceUuids.isNotEmpty ? device.serviceUuids[0] : "").toString()[31] != "1") && (device.rssi >= -100)) {
|
||||||
final knownDeviceIndex = _scanDevices.indexWhere((d) => d.id == device.id);
|
final knownDeviceIndex = _scanDevices.indexWhere((d) => d.id == device.id);
|
||||||
|
|
||||||
if (knownDeviceIndex >= 0) {
|
if (knownDeviceIndex >= 0) {
|
||||||
@ -90,16 +90,18 @@ class BlueManage{
|
|||||||
|
|
||||||
/// 连接监听状态
|
/// 连接监听状态
|
||||||
Future<void> connect(String deviceMAC, String deviceName, {ConnectStateCallBack? connectStateCallBack, bool? isFrist = false}) async {
|
Future<void> connect(String deviceMAC, String deviceName, {ConnectStateCallBack? connectStateCallBack, bool? isFrist = false}) async {
|
||||||
connectDeviceId = deviceMAC;
|
connectDeviceMacAddress = deviceMAC;
|
||||||
connectDeviceName = deviceName;
|
connectDeviceName = deviceName;
|
||||||
print("connectDeviceId:$connectDeviceId connectDeviceName:$connectDeviceName");
|
print("connectDeviceId:$connectDeviceMacAddress connectDeviceName:$connectDeviceName");
|
||||||
|
|
||||||
EasyLoading.show();
|
EasyLoading.show();
|
||||||
Future.delayed(const Duration(seconds: 30), () { //asynchronous delay
|
Future.delayed(const Duration(seconds: 30), () { //asynchronous delay
|
||||||
print("30s之后 菊花没有隐藏的话,强制隐藏菊花");
|
print("30s之后 菊花没有隐藏的话,强制隐藏菊花");
|
||||||
EasyLoading.dismiss();
|
if(EasyLoading.isShow){
|
||||||
|
EasyLoading.dismiss();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
_flutterReactiveBle!.connectToDevice(id: connectDeviceId, connectionTimeout: const Duration(seconds: 15)).listen((connectionStateUpdate) async {
|
_flutterReactiveBle!.connectToDevice(id: connectDeviceMacAddress, connectionTimeout: const Duration(seconds: 15)).listen((connectionStateUpdate) async {
|
||||||
// 获取状态
|
// 获取状态
|
||||||
deviceConnectionState = connectionStateUpdate.connectionState;
|
deviceConnectionState = connectionStateUpdate.connectionState;
|
||||||
print('ConnectionState for device $deviceMAC : ${connectionStateUpdate.connectionState}');
|
print('ConnectionState for device $deviceMAC : ${connectionStateUpdate.connectionState}');
|
||||||
@ -180,7 +182,9 @@ class BlueManage{
|
|||||||
EasyLoading.show();
|
EasyLoading.show();
|
||||||
Future.delayed(const Duration(seconds: 30), () { //asynchronous delay
|
Future.delayed(const Duration(seconds: 30), () { //asynchronous delay
|
||||||
print("30s之后 菊花没有隐藏的话,强制隐藏菊花");
|
print("30s之后 菊花没有隐藏的话,强制隐藏菊花");
|
||||||
EasyLoading.dismiss();
|
if(EasyLoading.isShow){
|
||||||
|
EasyLoading.dismiss();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
connectStateCallBack!(deviceConnectionState!);
|
connectStateCallBack!(deviceConnectionState!);
|
||||||
}else{
|
}else{
|
||||||
@ -250,9 +254,10 @@ class BlueManage{
|
|||||||
|
|
||||||
// 写入
|
// 写入
|
||||||
Future<void> writeCharacteristicWithResponse(List<int> value) async {
|
Future<void> writeCharacteristicWithResponse(List<int> value) async {
|
||||||
QualifiedCharacteristic characteristic = QualifiedCharacteristic(characteristicId: characteristicIdWrite, serviceId: serviceId, deviceId: connectDeviceId);
|
QualifiedCharacteristic characteristic = QualifiedCharacteristic(characteristicId: characteristicIdWrite, serviceId: serviceId, deviceId: connectDeviceMacAddress);
|
||||||
print('Write with characteristicId:${characteristic.characteristicId} serviceId:${characteristic.serviceId} deviceId:${characteristic.deviceId} value : $value \nhexStr:${radixHex16String(value)}');
|
print('Write with characteristicId:${characteristic.characteristicId} serviceId:${characteristic.serviceId} deviceId:${characteristic.deviceId} value : $value \nhexStr:${radixHex16String(value)}');
|
||||||
|
int mtuLength = await _flutterReactiveBle!.requestMtu(deviceId: characteristic.deviceId, mtu: 30);
|
||||||
|
print("mtuLength:$mtuLength");
|
||||||
try {
|
try {
|
||||||
List<int> valueList = value;
|
List<int> valueList = value;
|
||||||
List subData = splitList(valueList, _limitLen);
|
List subData = splitList(valueList, _limitLen);
|
||||||
|
|||||||
@ -22,3 +22,9 @@ class EventBusManager {
|
|||||||
eventBus?.fire(event);
|
eventBus?.fire(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///刷新锁列表数据
|
||||||
|
class RefreshLockListInfoDataEvent{
|
||||||
|
RefreshLockListInfoDataEvent();
|
||||||
|
}
|
||||||
@ -52,7 +52,7 @@ class _SafetyVerificationPageState extends State<SafetyVerificationPage> with Ti
|
|||||||
});
|
});
|
||||||
print("countryCode:${state.getData["countryCode"]} getAccount:${state.getData["getAccount"]}");
|
print("countryCode:${state.getData["countryCode"]} getAccount:${state.getData["getAccount"]}");
|
||||||
|
|
||||||
var entity = await ApiRepository.to.getSliderVerifyImg(state.getData["countryCode"], state.getData["account"]);
|
var entity = await ApiRepository.to.getSliderVerifyImg(state.getData["countryCode"].toString(), state.getData["account"].toString());
|
||||||
if(entity.errorCode! == 0){
|
if(entity.errorCode! == 0){
|
||||||
state.sliderXMoved.value = 0;
|
state.sliderXMoved.value = 0;
|
||||||
sliderStartX = 0;
|
sliderStartX = 0;
|
||||||
@ -81,7 +81,7 @@ class _SafetyVerificationPageState extends State<SafetyVerificationPage> with Ti
|
|||||||
sliderMoveFinish = true;
|
sliderMoveFinish = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
var entity = await ApiRepository.to.checkSliderVerifyImg(state.getData["countryCode"], state.getData["account"], sliderMovedX.toString());
|
var entity = await ApiRepository.to.checkSliderVerifyImg(state.getData["countryCode"].toString(), state.getData["account"].toString(), sliderMovedX.toString());
|
||||||
if(entity.errorCode! == 0){
|
if(entity.errorCode! == 0){
|
||||||
checkSuccess("captchaVerification");
|
checkSuccess("captchaVerification");
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@ -74,4 +74,5 @@ class _CheckingInSetWorkTimePageState extends State<CheckingInSetWorkTimePage> {
|
|||||||
// print("组合 $year-$month-$day $hour:$minute:$millisecond");
|
// print("组合 $year-$month-$day $hour:$minute:$millisecond");
|
||||||
return dateSlug;
|
return dateSlug;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -412,7 +412,7 @@ class LockDetailLogic extends BaseGetXController{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 备用逻辑,进入管理钥匙界面默认连接
|
// 备用逻辑,进入管理钥匙界面获取锁状态
|
||||||
Future<void> connectBlue() async {
|
Future<void> connectBlue() async {
|
||||||
// 进来之后首先连接
|
// 进来之后首先连接
|
||||||
BlueManage().connect("AD01447A-30B5-A780-E778-DED3BDCB613E", "TMH_c3570480da8d", connectStateCallBack: (DeviceConnectionState state) async {
|
BlueManage().connect("AD01447A-30B5-A780-E778-DED3BDCB613E", "TMH_c3570480da8d", connectStateCallBack: (DeviceConnectionState state) async {
|
||||||
@ -435,21 +435,21 @@ class LockDetailLogic extends BaseGetXController{
|
|||||||
print("onReady()");
|
print("onReady()");
|
||||||
_initReplySubscription();
|
_initReplySubscription();
|
||||||
|
|
||||||
BlueManage().startScan((v){
|
// BlueManage().startScan((v){
|
||||||
|
//
|
||||||
});
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
// TODO: implement onInit
|
// TODO: implement onInit
|
||||||
super.onInit();
|
super.onInit();
|
||||||
print("onInit()");
|
print("lockDetail_onInit()");
|
||||||
|
|
||||||
BlueManage().connectDeviceName = "TMH_c3570480da8d";
|
BlueManage().connectDeviceName = "TMH_c3570480da8d";
|
||||||
BlueManage().connectDeviceId = "AD01447A-30B5-A780-E778-DED3BDCB613E";
|
BlueManage().connectDeviceMacAddress = "AD01447A-30B5-A780-E778-DED3BDCB613E";
|
||||||
|
|
||||||
// 进来第一步开始扫描
|
// 进来获取锁状态
|
||||||
// connectBlue();
|
// connectBlue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
import '../../../app_settings/app_colors.dart';
|
||||||
|
import '../../../tools/titleAppBar.dart';
|
||||||
|
import '../../../translations/trans_lib.dart';
|
||||||
|
import '../../lockMian/entity/lockInfoEntity.dart';
|
||||||
|
import 'lockDetail_page.dart';
|
||||||
|
|
||||||
|
class LockDetailMainPage extends StatefulWidget {
|
||||||
|
|
||||||
|
const LockDetailMainPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<LockDetailMainPage> createState() => _LockDetailMainPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LockDetailMainPageState extends State<LockDetailMainPage> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
appBar: TitleAppBar(
|
||||||
|
barTitle: TranslationLoader.lanKeys!.starLock!.tr,
|
||||||
|
haveBack: true,
|
||||||
|
backgroundColor: AppColors.mainColor),
|
||||||
|
// body: LockDetailPage(lockMainEntity: widget.lockMainEntity),
|
||||||
|
body: Container(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -4,14 +4,14 @@ import 'package:get/get.dart';
|
|||||||
|
|
||||||
import '../../../appRouters.dart';
|
import '../../../appRouters.dart';
|
||||||
import '../../../app_settings/app_colors.dart';
|
import '../../../app_settings/app_colors.dart';
|
||||||
import '../../../blue/io_tool/io_manager.dart';
|
|
||||||
import '../../../tools/storage.dart';
|
|
||||||
import '../../../tools/titleAppBar.dart';
|
|
||||||
import '../../../translations/trans_lib.dart';
|
import '../../../translations/trans_lib.dart';
|
||||||
|
import '../../lockMian/entity/lockInfoEntity.dart';
|
||||||
import 'lockDetail_logic.dart';
|
import 'lockDetail_logic.dart';
|
||||||
|
|
||||||
class LockDetailPage extends StatefulWidget {
|
class LockDetailPage extends StatefulWidget {
|
||||||
const LockDetailPage({Key? key}) : super(key: key);
|
final LockMainEntity lockMainEntity;
|
||||||
|
|
||||||
|
const LockDetailPage({Key? key, required this.lockMainEntity}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<LockDetailPage> createState() => _LockDetailPageState();
|
State<LockDetailPage> createState() => _LockDetailPageState();
|
||||||
@ -23,20 +23,21 @@ class _LockDetailPageState extends State<LockDetailPage> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
return Scaffold(
|
width: 1.sw,
|
||||||
backgroundColor: Colors.white,
|
height: 1.sh,
|
||||||
appBar: TitleAppBar(
|
color: Colors.white,
|
||||||
barTitle: TranslationLoader.lanKeys!.starLock!.tr,
|
child: Column(
|
||||||
haveBack: true,
|
children: [
|
||||||
backgroundColor: AppColors.mainColor),
|
topWidget(),
|
||||||
body: Column(
|
Expanded(child: bottomWidget())
|
||||||
children: [topWidget(), Expanded(child: bottomWidget())],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget topWidget() {
|
Widget topWidget() {
|
||||||
|
KeyInfos keyInfo = widget.lockMainEntity.data!.keyInfos![0];
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
SizedBox(height: 30.h),
|
SizedBox(height: 30.h),
|
||||||
@ -46,7 +47,7 @@ class _LockDetailPageState extends State<LockDetailPage> {
|
|||||||
Align(
|
Align(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: Text(
|
child: Text(
|
||||||
"MCBN01-ea9240",
|
keyInfo.lockAlias!,
|
||||||
style:
|
style:
|
||||||
TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w400),
|
TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w400),
|
||||||
)),
|
)),
|
||||||
@ -80,9 +81,9 @@ class _LockDetailPageState extends State<LockDetailPage> {
|
|||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: (){
|
onTap: (){
|
||||||
// logic.transferPermissionsAction();
|
// logic.transferPermissionsAction();
|
||||||
// logic.openDoorAction();
|
logic.openDoorAction();
|
||||||
// logic.editLockUserAction();
|
// logic.editLockUserAction();
|
||||||
logic.factoryDataResetAction();
|
// logic.factoryDataResetAction();
|
||||||
},
|
},
|
||||||
child: Image.asset('images/main/icon_main_openLockBtn.png',
|
child: Image.asset('images/main/icon_main_openLockBtn.png',
|
||||||
width: 268.w, height: 268.w),
|
width: 268.w, height: 268.w),
|
||||||
|
|||||||
@ -215,7 +215,7 @@ class KeyInfos {
|
|||||||
int? autoUnlock;
|
int? autoUnlock;
|
||||||
String? noKeyPwd;
|
String? noKeyPwd;
|
||||||
int? isAttendance;
|
int? isAttendance;
|
||||||
String? keyStatus;
|
int? keyStatus;
|
||||||
int? faceAuthentication;
|
int? faceAuthentication;
|
||||||
int? sensitivity;
|
int? sensitivity;
|
||||||
int? date;
|
int? date;
|
||||||
@ -253,7 +253,7 @@ class KeyInfos {
|
|||||||
String? adminPwd;
|
String? adminPwd;
|
||||||
String? deletePwd;
|
String? deletePwd;
|
||||||
int? timezoneRawOffSet;
|
int? timezoneRawOffSet;
|
||||||
String? userType;
|
int? userType;
|
||||||
int? validPwdNum;
|
int? validPwdNum;
|
||||||
String? featureValue;
|
String? featureValue;
|
||||||
int? adminUid;
|
int? adminUid;
|
||||||
|
|||||||
5
star_lock/lib/main/lockMian/lockList/lockList_logic.dart
Normal file
5
star_lock/lib/main/lockMian/lockList/lockList_logic.dart
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
|
|
||||||
|
class LockListLogic extends BaseGetXController{
|
||||||
|
|
||||||
|
}
|
||||||
105
star_lock/lib/main/lockMian/lockList/lockList_page.dart
Normal file
105
star_lock/lib/main/lockMian/lockList/lockList_page.dart
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
|
import 'package:star_lock/mine/mine/starLockMine_page.dart';
|
||||||
|
|
||||||
|
import '../../../appRouters.dart';
|
||||||
|
import '../../../app_settings/app_colors.dart';
|
||||||
|
import '../entity/lockInfoEntity.dart';
|
||||||
|
|
||||||
|
class LockListPage extends StatefulWidget {
|
||||||
|
final LockMainEntity lockMainEntity;
|
||||||
|
|
||||||
|
const LockListPage({Key? key, required this.lockMainEntity}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<LockListPage> createState() => _LockListPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LockListPageState extends State<LockListPage> {
|
||||||
|
var dataList = <KeyInfos>[];
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
if(widget.lockMainEntity.data!.pageNo == 1){
|
||||||
|
dataList = <KeyInfos>[];
|
||||||
|
}
|
||||||
|
dataList.addAll(widget.lockMainEntity.data!.keyInfos as Iterable<KeyInfos>);
|
||||||
|
|
||||||
|
return ListView.builder(
|
||||||
|
itemCount: dataList.length,
|
||||||
|
itemBuilder: (c, index) {
|
||||||
|
KeyInfos keyInfo = dataList[index];
|
||||||
|
return lockInfoListItem('images/icon_lock.png', keyInfo.lockAlias, () {
|
||||||
|
Navigator.pushNamed(context, Routers.lockDetailMainPage);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget lockInfoListItem(
|
||||||
|
String lockTypeIcon, String? lockTypeTitle, Function() action) {
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: action,
|
||||||
|
child: Container(
|
||||||
|
height: 122.h,
|
||||||
|
margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(20.w),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
height: 20.h,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
SizedBox(width: 30.w),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
lockTypeTitle!,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 24.sp, fontWeight: FontWeight.w500),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(width: 20.w),
|
||||||
|
Text(
|
||||||
|
"100%",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 18.sp, color: AppColors.darkGrayTextColor),
|
||||||
|
),
|
||||||
|
SizedBox(width: 2.w),
|
||||||
|
Image.asset(
|
||||||
|
'images/main/icon_main_cell.png',
|
||||||
|
width: 30.w,
|
||||||
|
height: 24.w,
|
||||||
|
),
|
||||||
|
SizedBox(width: 30.w),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 20.h,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
SizedBox(width: 30.w),
|
||||||
|
Text(
|
||||||
|
"永久/管理员",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 18.sp, color: AppColors.darkGrayTextColor),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
5
star_lock/lib/main/lockMian/lockList/lockList_state.dart
Normal file
5
star_lock/lib/main/lockMian/lockList/lockList_state.dart
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
|
class LockListState{
|
||||||
|
|
||||||
|
}
|
||||||
62
star_lock/lib/main/lockMian/lockMain/lockMain_logic.dart
Normal file
62
star_lock/lib/main/lockMian/lockMain/lockMain_logic.dart
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import '../../../blue/io_tool/manager_event_bus.dart';
|
||||||
|
import '../../../network/api_repository.dart';
|
||||||
|
import '../../../tools/baseGetXController.dart';
|
||||||
|
import 'lockMain_state.dart';
|
||||||
|
|
||||||
|
class LockMainLogic extends BaseGetXController {
|
||||||
|
final LockMainState state = LockMainState();
|
||||||
|
|
||||||
|
void getLockInfo() async{
|
||||||
|
var entity = await ApiRepository.to.getLockInfo(
|
||||||
|
lastUpdateDate:DateTime.now().millisecondsSinceEpoch.toString(),
|
||||||
|
pageNo:"1",
|
||||||
|
);
|
||||||
|
if(entity.errorCode!.codeIsSuccessful){
|
||||||
|
if(entity.data!.keyInfos!.isEmpty){
|
||||||
|
state.dataLength.value = 0;
|
||||||
|
}else if(entity.data!.keyInfos!.length == 1){
|
||||||
|
state.dataLength.value = 1;
|
||||||
|
}else{
|
||||||
|
state.dataLength.value = 2;
|
||||||
|
}
|
||||||
|
state.lockMainEntity.value = entity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 监听设备返回的数据
|
||||||
|
late StreamSubscription<RefreshLockListInfoDataEvent> _addLockSubscription;
|
||||||
|
void _initAddLockSubscription() {
|
||||||
|
_addLockSubscription = EventBusManager().eventBus!.on<RefreshLockListInfoDataEvent>().listen((event) async {
|
||||||
|
getLockInfo();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onReady() {
|
||||||
|
// TODO: implement onReady
|
||||||
|
super.onReady();
|
||||||
|
print("onReady()");
|
||||||
|
|
||||||
|
_initAddLockSubscription();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onInit() {
|
||||||
|
// TODO: implement onInit
|
||||||
|
super.onInit();
|
||||||
|
print("onInit()");
|
||||||
|
|
||||||
|
getLockInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onClose() {
|
||||||
|
// TODO: implement onClose
|
||||||
|
super.onClose();
|
||||||
|
_addLockSubscription.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
146
star_lock/lib/main/lockMian/lockMain/lockMain_page.dart
Normal file
146
star_lock/lib/main/lockMian/lockMain/lockMain_page.dart
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:star_lock/app_settings/app_colors.dart';
|
||||||
|
|
||||||
|
import '../../../appRouters.dart';
|
||||||
|
import '../../../baseWidget.dart';
|
||||||
|
import '../../../mine/mine/starLockMine_page.dart';
|
||||||
|
import '../../../tools/titleAppBar.dart';
|
||||||
|
import '../../../translations/trans_lib.dart';
|
||||||
|
import '../../lockDetail/lockDetail/lockDetail_page.dart';
|
||||||
|
import '../lockList/lockList_page.dart';
|
||||||
|
import 'lockMain_logic.dart';
|
||||||
|
|
||||||
|
class StarLockMainPage extends StatefulWidget {
|
||||||
|
const StarLockMainPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<StarLockMainPage> createState() => _StarLockMainPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
// GlobalKey<_StarLockMainPageState> starLockMainKey = GlobalKey();
|
||||||
|
class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget {
|
||||||
|
|
||||||
|
final logic = Get.put(LockMainLogic());
|
||||||
|
final state = Get.find<LockMainLogic>().state;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: const Color(0xFFF5F5F5),
|
||||||
|
appBar: TitleAppBar(
|
||||||
|
barTitle: TranslationLoader.lanKeys!.starLock!.tr,
|
||||||
|
haveBack: false,
|
||||||
|
haveOtherLeftWidget: true,
|
||||||
|
leftWidget: Builder(
|
||||||
|
builder: (context) => IconButton(
|
||||||
|
icon: Image.asset(
|
||||||
|
"images/main/mainLeft_menu_icon.png",
|
||||||
|
color: Colors.white,
|
||||||
|
width: 44.w,
|
||||||
|
height: 44.w,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
// _globalKey.currentState!.openDrawer();
|
||||||
|
Scaffold.of(context).openDrawer();
|
||||||
|
},
|
||||||
|
)),
|
||||||
|
backgroundColor: AppColors.mainColor,
|
||||||
|
// actionsList: [
|
||||||
|
// TextButton(
|
||||||
|
// child: const Text("", style: TextStyle(color: Colors.white)),
|
||||||
|
// onPressed: () {
|
||||||
|
// Navigator.pushNamed(context, Routers.starLockLoginPage);
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
),
|
||||||
|
drawer: Drawer(
|
||||||
|
width: 1.sw / 3 * 2,
|
||||||
|
child: const StarLockMinePage(),
|
||||||
|
),
|
||||||
|
body: Obx(() => getDataReturnUI(state.dataLength.value, )),
|
||||||
|
// body: getLockList(),
|
||||||
|
// body: unHaveData(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget getDataReturnUI(int type){
|
||||||
|
Widget returnWidget;
|
||||||
|
switch(type){
|
||||||
|
case 0:
|
||||||
|
returnWidget = unHaveData();
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
returnWidget = LockDetailPage(lockMainEntity: logic.state.lockMainEntity.value);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
returnWidget = LockListPage(lockMainEntity:logic.state.lockMainEntity.value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
returnWidget = unHaveData();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return returnWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget unHaveData() {
|
||||||
|
return Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: 220.w,
|
||||||
|
height: 220.w,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border.all(width: 4.w, color: AppColors.mainColor),
|
||||||
|
borderRadius: BorderRadius.circular(110.w),
|
||||||
|
),
|
||||||
|
child: InkWell(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(30.0),
|
||||||
|
child: Image.asset(
|
||||||
|
'images/main/icon_main_addLock.png',
|
||||||
|
width: 150.w,
|
||||||
|
height: 150.w,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
//实现回调函数
|
||||||
|
Navigator.pushNamed(
|
||||||
|
context, Routers.seletLockTypePage,
|
||||||
|
// arguments: {
|
||||||
|
// "url": ConstConfig.privacAgreementUrl,
|
||||||
|
// "title": '隐私政策'
|
||||||
|
// }
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: h(50.h),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.all(30.w),
|
||||||
|
child: Text(
|
||||||
|
TranslationLoader
|
||||||
|
.lanKeys!.whenAddingLockThePhoneMustBeNextToTheLock!.tr,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 26.sp,
|
||||||
|
fontWeight: FontWeight.w800,
|
||||||
|
color: AppColors.mainColor),
|
||||||
|
))
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void onShow() {}
|
||||||
|
|
||||||
|
void onHide() {}
|
||||||
|
}
|
||||||
11
star_lock/lib/main/lockMian/lockMain/lockMain_state.dart
Normal file
11
star_lock/lib/main/lockMian/lockMain/lockMain_state.dart
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
import '../entity/lockInfoEntity.dart';
|
||||||
|
|
||||||
|
class LockMainState {
|
||||||
|
|
||||||
|
// 0是无数据 1是有一条数据 2是有很多条数据
|
||||||
|
var dataLength = 0.obs;
|
||||||
|
Rx<LockMainEntity> lockMainEntity = LockMainEntity().obs;
|
||||||
|
}
|
||||||
@ -1,41 +0,0 @@
|
|||||||
import '../../network/api_repository.dart';
|
|
||||||
import '../../tools/baseGetXController.dart';
|
|
||||||
import 'lockMain_state.dart';
|
|
||||||
|
|
||||||
class LockMainLogic extends BaseGetXController {
|
|
||||||
final LockMainState state = LockMainState();
|
|
||||||
|
|
||||||
void getLockInfo() async{
|
|
||||||
var entity = await ApiRepository.to.getLockInfo(
|
|
||||||
lastUpdateDate:DateTime.now().millisecondsSinceEpoch.toString(),
|
|
||||||
pageNo:"1",
|
|
||||||
);
|
|
||||||
if(entity.errorCode!.codeIsSuccessful){
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void onReady() {
|
|
||||||
// TODO: implement onReady
|
|
||||||
super.onReady();
|
|
||||||
print("onReady()");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void onInit() {
|
|
||||||
// TODO: implement onInit
|
|
||||||
super.onInit();
|
|
||||||
print("onInit()");
|
|
||||||
|
|
||||||
getLockInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void onClose() {
|
|
||||||
// TODO: implement onClose
|
|
||||||
super.onClose();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,199 +0,0 @@
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
||||||
import 'package:get/get.dart';
|
|
||||||
import 'package:star_lock/app_settings/app_colors.dart';
|
|
||||||
|
|
||||||
import '../../appRouters.dart';
|
|
||||||
import '../../baseWidget.dart';
|
|
||||||
import '../../mine/mine/starLockMine_page.dart';
|
|
||||||
import '../../tools/titleAppBar.dart';
|
|
||||||
import '../../translations/trans_lib.dart';
|
|
||||||
import 'lockMain_logic.dart';
|
|
||||||
|
|
||||||
class StarLockMainPage extends StatefulWidget {
|
|
||||||
const StarLockMainPage({Key? key}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<StarLockMainPage> createState() => _StarLockMainPageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
// GlobalKey<_StarLockMainPageState> starLockMainKey = GlobalKey();
|
|
||||||
class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget {
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
|
|
||||||
final logic = Get.put(LockMainLogic());
|
|
||||||
// final state = Get.find<LockMainLogic>().state;
|
|
||||||
|
|
||||||
return Scaffold(
|
|
||||||
backgroundColor: const Color(0xFFF5F5F5),
|
|
||||||
appBar: TitleAppBar(
|
|
||||||
barTitle: TranslationLoader.lanKeys!.starLock!.tr,
|
|
||||||
haveBack: false,
|
|
||||||
haveOtherLeftWidget: true,
|
|
||||||
leftWidget: Builder(
|
|
||||||
builder: (context) => IconButton(
|
|
||||||
icon: Image.asset(
|
|
||||||
"images/main/mainLeft_menu_icon.png",
|
|
||||||
color: Colors.white,
|
|
||||||
width: 44.w,
|
|
||||||
height: 44.w,
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
// _globalKey.currentState!.openDrawer();
|
|
||||||
Scaffold.of(context).openDrawer();
|
|
||||||
},
|
|
||||||
)),
|
|
||||||
backgroundColor: AppColors.mainColor,
|
|
||||||
actionsList: [
|
|
||||||
TextButton(
|
|
||||||
child: const Text("", style: TextStyle(color: Colors.white)),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pushNamed(context, Routers.starLockLoginPage);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
drawer: Drawer(
|
|
||||||
width: 1.sw / 3 * 2,
|
|
||||||
child: const StarLockMinePage(),
|
|
||||||
),
|
|
||||||
body: getLockList(),
|
|
||||||
// body: unHaveData(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget getLockList() {
|
|
||||||
return ListView.builder(
|
|
||||||
itemCount: 5,
|
|
||||||
itemBuilder: (c, index) {
|
|
||||||
return nearbyLockItem('images/icon_lock.png', "MCBN01-ea9240", () {
|
|
||||||
Navigator.pushNamed(context, Routers.lockDetailPage);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget nearbyLockItem(
|
|
||||||
String lockTypeIcon, String lockTypeTitle, Function() action) {
|
|
||||||
return GestureDetector(
|
|
||||||
onTap: action,
|
|
||||||
child: Container(
|
|
||||||
height: 122.h,
|
|
||||||
margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.white,
|
|
||||||
borderRadius: BorderRadius.circular(20.w),
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
// mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
SizedBox(
|
|
||||||
height: 20.h,
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
SizedBox(width: 30.w),
|
|
||||||
Expanded(
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
lockTypeTitle,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 24.sp, fontWeight: FontWeight.w500),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(width: 20.w),
|
|
||||||
Text(
|
|
||||||
"100%",
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 18.sp, color: AppColors.darkGrayTextColor),
|
|
||||||
),
|
|
||||||
SizedBox(width: 2.w),
|
|
||||||
Image.asset(
|
|
||||||
'images/main/icon_main_cell.png',
|
|
||||||
width: 30.w,
|
|
||||||
height: 24.w,
|
|
||||||
),
|
|
||||||
SizedBox(width: 30.w),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: 20.h,
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
SizedBox(width: 30.w),
|
|
||||||
Text(
|
|
||||||
"永久/管理员",
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 18.sp, color: AppColors.darkGrayTextColor),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget unHaveData() {
|
|
||||||
return Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
border: Border.all(width: 4, color: AppColors.mainColor),
|
|
||||||
borderRadius: BorderRadius.circular(75),
|
|
||||||
),
|
|
||||||
child: InkWell(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(30.0),
|
|
||||||
child: Image.asset(
|
|
||||||
'images/main/icon_main_addLock.png',
|
|
||||||
width: 150.w,
|
|
||||||
height: 150.w,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
//实现回调函数
|
|
||||||
Navigator.pushNamed(
|
|
||||||
context, Routers.seletLockTypePage,
|
|
||||||
// arguments: {
|
|
||||||
// "url": ConstConfig.privacAgreementUrl,
|
|
||||||
// "title": '隐私政策'
|
|
||||||
// }
|
|
||||||
);
|
|
||||||
},
|
|
||||||
)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: h(50.h),
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
padding: EdgeInsets.all(30.w),
|
|
||||||
child: Text(
|
|
||||||
TranslationLoader
|
|
||||||
.lanKeys!.whenAddingLockThePhoneMustBeNextToTheLock!.tr,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 30.sp,
|
|
||||||
fontWeight: FontWeight.w800,
|
|
||||||
color: AppColors.mainColor),
|
|
||||||
))
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void onShow() {}
|
|
||||||
|
|
||||||
void onHide() {}
|
|
||||||
}
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
|
|
||||||
class LockMainState {
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,20 +1,23 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:amap_flutter_location/amap_flutter_location.dart';
|
import 'package:amap_flutter_location/amap_flutter_location.dart';
|
||||||
import 'package:amap_flutter_location/amap_location_option.dart';
|
import 'package:amap_flutter_location/amap_location_option.dart';
|
||||||
|
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
import 'package:amap_flutter_map/amap_flutter_map.dart';
|
import 'package:amap_flutter_map/amap_flutter_map.dart';
|
||||||
import 'package:amap_flutter_base/amap_flutter_base.dart';
|
import 'package:amap_flutter_base/amap_flutter_base.dart';
|
||||||
|
|
||||||
import '../../../app_settings/app_colors.dart';
|
import '../../../app_settings/app_colors.dart';
|
||||||
import '../../../main.dart';
|
|
||||||
|
typedef BlockAddressMapCallback = void Function(dynamic addressMap);
|
||||||
|
|
||||||
class LockAddressGaoDePage extends StatefulWidget {
|
class LockAddressGaoDePage extends StatefulWidget {
|
||||||
const LockAddressGaoDePage({Key? key}) : super(key: key);
|
BlockAddressMapCallback callback;
|
||||||
|
|
||||||
|
LockAddressGaoDePage({Key? key, required this.callback}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<LockAddressGaoDePage> createState() => _LockAddressGaoDePageState();
|
State<LockAddressGaoDePage> createState() => _LockAddressGaoDePageState();
|
||||||
@ -22,95 +25,109 @@ class LockAddressGaoDePage extends StatefulWidget {
|
|||||||
|
|
||||||
class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>{
|
class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>{
|
||||||
// 高德地图
|
// 高德地图
|
||||||
Map<String, Object>? _locationResult;
|
static const AMapApiKey amapApiKeys = AMapApiKey(iosKey: '883a3355d2d77c2fdc2667030dc97ffe', androidKey: '11d49b3f4fc09c04a02bbb7500925ba2');
|
||||||
StreamSubscription<Map<String, Object>>? _locationListener;
|
|
||||||
final AMapFlutterLocation _locationPlugin = AMapFlutterLocation();
|
|
||||||
late AMapController _mapController;
|
|
||||||
|
|
||||||
static const CameraPosition _kInitialPosition = CameraPosition(
|
AMapController? mapController;
|
||||||
target: LatLng(113.919112, 22.653728),
|
AMapFlutterLocation? location;
|
||||||
zoom: 10.0,
|
|
||||||
);
|
|
||||||
|
|
||||||
List<Widget> get _approvalNumberWidget => <Widget>[];
|
PermissionStatus? permissionStatus;
|
||||||
|
Map<String, Object>? addressInfo;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
/// 设置是否已经包含高德隐私政策并弹窗展示显示用户查看,如果未包含或者没有弹窗展示,高德定位SDK将不会工作
|
AMapFlutterLocation.setApiKey("11d49b3f4fc09c04a02bbb7500925ba2", "883a3355d2d77c2fdc2667030dc97ffe");
|
||||||
///
|
AMapFlutterLocation.updatePrivacyAgree(true);
|
||||||
/// 高德SDK合规使用方案请参考官网地址:https://lbs.amap.com/news/sdkhgsy
|
|
||||||
/// <b>必须保证在调用定位功能之前调用, 建议首次启动App时弹出《隐私政策》并取得用户同意</b>
|
|
||||||
///
|
|
||||||
/// 高德SDK合规使用方案请参考官网地址:https://lbs.amap.com/news/sdkhgsy
|
|
||||||
///
|
|
||||||
/// [hasContains] 隐私声明中是否包含高德隐私政策说明
|
|
||||||
///
|
|
||||||
/// [hasShow] 隐私权政策是否弹窗展示告知用户
|
|
||||||
AMapFlutterLocation.updatePrivacyShow(true, true);
|
AMapFlutterLocation.updatePrivacyShow(true, true);
|
||||||
|
|
||||||
/// 设置是否已经取得用户同意,如果未取得用户同意,高德定位SDK将不会工作
|
|
||||||
///
|
|
||||||
/// 高德SDK合规使用方案请参考官网地址:https://lbs.amap.com/news/sdkhgsy
|
|
||||||
///
|
|
||||||
/// <b>必须保证在调用定位功能之前调用, 建议首次启动App时弹出《隐私政策》并取得用户同意</b>
|
|
||||||
///
|
|
||||||
/// [hasAgree] 隐私权政策是否已经取得用户同意
|
|
||||||
AMapFlutterLocation.updatePrivacyAgree(true);
|
|
||||||
|
|
||||||
/// 动态申请定位权限
|
|
||||||
requestPermission();
|
requestPermission();
|
||||||
|
}
|
||||||
|
|
||||||
///设置Android和iOS的apiKey<br>
|
Future<void> requestPermission() async {
|
||||||
///key的申请请参考高德开放平台官网说明<br>
|
final status = await Permission.location.request();
|
||||||
///Android: https://lbs.amap.com/api/android-location-sdk/guide/create-project/get-key
|
permissionStatus = status;
|
||||||
///iOS: https://lbs.amap.com/api/ios-location-sdk/guide/create-project/get-key
|
switch (status) {
|
||||||
AMapFlutterLocation.setApiKey("1dbf56e2e8a4d0e4cdc2df9efd36bc71", "dfb64c0463cb53927914364b5c09aba0");
|
case PermissionStatus.denied:
|
||||||
|
print("拒绝");
|
||||||
///iOS 获取native精度类型
|
break;
|
||||||
if (Platform.isIOS) {
|
case PermissionStatus.granted:
|
||||||
requestAccuracyAuthorization();
|
requestLocation();
|
||||||
|
break;
|
||||||
|
case PermissionStatus.limited:
|
||||||
|
print("限制");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
print("其他状态");
|
||||||
|
requestLocation();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
///注册定位结果监听
|
void requestLocation() {
|
||||||
_locationListener = _locationPlugin.onLocationChanged().listen((Map<String, Object> result) {
|
location = AMapFlutterLocation()
|
||||||
setState(() {
|
..setLocationOption(AMapLocationOption())
|
||||||
_locationResult = result;
|
..onLocationChanged().listen((event) {
|
||||||
if (_locationResult != null) {
|
print("listenLocationChanged$event");
|
||||||
_locationResult?.forEach((key, value) {
|
double? latitude = double.parse(event['latitude'] as String);
|
||||||
print("key:$key value:$value");
|
double? longitude = double.parse(event['longitude'] as String);
|
||||||
|
if (latitude != 0 && longitude != 0) {
|
||||||
|
widget.callback(event);
|
||||||
|
setState(() {
|
||||||
|
addressInfo = event;
|
||||||
|
// currentLocation = CameraPosition(
|
||||||
|
// target: LatLng(latitude, longitude),
|
||||||
|
// zoom: 10,
|
||||||
|
// );
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
});
|
..startLocation();
|
||||||
|
|
||||||
_startLocation();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
///使用默认属性创建一个地图
|
if (addressInfo?['latitude'] == null ||
|
||||||
final AMapWidget map = AMapWidget(
|
addressInfo?['longitude'] == null ||
|
||||||
apiKey: const AMapApiKey(androidKey: '900f72eeee0f21e435cebb0ef155582a', iosKey: '4dfdec97b7bf0b8c13e94777103015a9'),
|
addressInfo?['errorCode'] == 0) {
|
||||||
onMapCreated: onMapCreated,
|
return const Text('Sorry');
|
||||||
// initialCameraPosition: _kInitialPosition
|
}
|
||||||
);
|
|
||||||
|
var latitude = 39.909187;
|
||||||
|
var longitude = 116.397451;
|
||||||
|
if(addressInfo!.containsKey('latitude')){
|
||||||
|
latitude = double.parse(addressInfo!['latitude'] as String);
|
||||||
|
longitude = double.parse(addressInfo!['longitude'] as String);
|
||||||
|
}
|
||||||
|
|
||||||
return Stack(
|
return Stack(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
height: MediaQuery.of(context).size.height,
|
height: MediaQuery.of(context).size.height,
|
||||||
width: MediaQuery.of(context).size.width,
|
width: MediaQuery.of(context).size.width,
|
||||||
child: map,
|
child: (addressInfo!["address"].toString().isNotEmpty) ? AMapWidget(
|
||||||
),
|
apiKey: amapApiKeys,
|
||||||
Positioned(
|
// 初始化地图中心
|
||||||
left: 10.w, bottom: 30.h,
|
initialCameraPosition: (
|
||||||
child: Container(
|
CameraPosition(
|
||||||
alignment: Alignment.centerLeft,
|
target: LatLng(latitude, longitude),
|
||||||
child: Column(
|
zoom: 10.0,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
)
|
||||||
children: _approvalNumberWidget),
|
),
|
||||||
)
|
//定位小蓝点
|
||||||
|
myLocationStyleOptions: MyLocationStyleOptions(
|
||||||
|
true,
|
||||||
|
),
|
||||||
|
// 普通地图normal,卫星地图satellite,夜间视图night,导航视图 navi,公交视图bus,
|
||||||
|
mapType: MapType.normal,
|
||||||
|
// 缩放级别范围
|
||||||
|
minMaxZoomPreference: const MinMaxZoomPreference(3, 20),
|
||||||
|
// 隐私政策包含高德 必须填写
|
||||||
|
privacyStatement: const AMapPrivacyStatement(hasAgree: true, hasContains: true, hasShow: true),
|
||||||
|
// 地图创建成功时返回AMapController
|
||||||
|
onMapCreated: (AMapController controller) {
|
||||||
|
mapController = controller;
|
||||||
|
},
|
||||||
|
): Container(),
|
||||||
),
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
left: 20.w, right: 20.w, bottom: 100.h,
|
left: 20.w, right: 20.w, bottom: 100.h,
|
||||||
@ -130,25 +147,25 @@ class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>{
|
|||||||
Image.asset('images/main/icon_addUserShowAddress.png', width: 30.w, height: 30.w),
|
Image.asset('images/main/icon_addUserShowAddress.png', width: 30.w, height: 30.w),
|
||||||
SizedBox(width: 10.w),
|
SizedBox(width: 10.w),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text("广东省深圳市宏发科技园", style: const TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500, overflow: TextOverflow.clip))
|
child: Text(addressInfo!["address"].toString() ?? "", style: const TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500, overflow: TextOverflow.clip))
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Container(height: 1.h, color: const Color(0xFF021732),),
|
|
||||||
Container(
|
|
||||||
// height: h(52),
|
|
||||||
padding: EdgeInsets.only(top: 15.h, bottom: 15, left:15.w, right: 15.w),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Image.asset('images/main/icon_addUserAddressShowTime.png', width: 30.w, height: 30.w),
|
|
||||||
SizedBox(width: 10.w,),
|
|
||||||
Expanded(
|
|
||||||
child: Text("2023.8.22 15.14", style: const TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),)
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
// Container(height: 1.h, color: const Color(0xFF021732),),
|
||||||
|
// Container(
|
||||||
|
// // height: h(52),
|
||||||
|
// padding: EdgeInsets.only(top: 15.h, bottom: 15, left:15.w, right: 15.w),
|
||||||
|
// child: Row(
|
||||||
|
// children: [
|
||||||
|
// Image.asset('images/main/icon_addUserAddressShowTime.png', width: 30.w, height: 30.w),
|
||||||
|
// SizedBox(width: 10.w,),
|
||||||
|
// Expanded(
|
||||||
|
// child: Text(DateTool().getNowDateYMDHM(), style: const TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),)
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
),),
|
),),
|
||||||
@ -156,164 +173,11 @@ class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>{
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void onMapCreated(AMapController controller) {
|
|
||||||
setState(() {
|
|
||||||
_mapController = controller;
|
|
||||||
getApprovalNumber();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 获取审图号
|
|
||||||
void getApprovalNumber() async {
|
|
||||||
//普通地图审图号
|
|
||||||
String? mapContentApprovalNumber =
|
|
||||||
await _mapController.getMapContentApprovalNumber();
|
|
||||||
//卫星地图审图号
|
|
||||||
String? satelliteImageApprovalNumber =
|
|
||||||
await _mapController.getSatelliteImageApprovalNumber();
|
|
||||||
setState(() {
|
|
||||||
if (null != mapContentApprovalNumber) {
|
|
||||||
_approvalNumberWidget.add(Text(mapContentApprovalNumber));
|
|
||||||
}
|
|
||||||
if (null != satelliteImageApprovalNumber) {
|
|
||||||
_approvalNumberWidget.add(Text(satelliteImageApprovalNumber));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
print('地图审图号(普通地图): $mapContentApprovalNumber');
|
|
||||||
print('地图审图号(卫星地图): $satelliteImageApprovalNumber');
|
|
||||||
}
|
|
||||||
|
|
||||||
///设置定位参数
|
|
||||||
void _setLocationOption() {
|
|
||||||
AMapLocationOption locationOption = new AMapLocationOption();
|
|
||||||
|
|
||||||
///是否单次定位
|
|
||||||
locationOption.onceLocation = false;
|
|
||||||
|
|
||||||
///是否需要返回逆地理信息
|
|
||||||
locationOption.needAddress = true;
|
|
||||||
|
|
||||||
///逆地理信息的语言类型
|
|
||||||
locationOption.geoLanguage = GeoLanguage.DEFAULT;
|
|
||||||
|
|
||||||
locationOption.desiredLocationAccuracyAuthorizationMode = AMapLocationAccuracyAuthorizationMode.ReduceAccuracy;
|
|
||||||
|
|
||||||
locationOption.fullAccuracyPurposeKey = "AMapLocationScene";
|
|
||||||
|
|
||||||
///设置Android端连续定位的定位间隔
|
|
||||||
locationOption.locationInterval = 2000;
|
|
||||||
|
|
||||||
///设置Android端的定位模式<br>
|
|
||||||
///可选值:<br>
|
|
||||||
///<li>[AMapLocationMode.Battery_Saving]</li>
|
|
||||||
///<li>[AMapLocationMode.Device_Sensors]</li>
|
|
||||||
///<li>[AMapLocationMode.Hight_Accuracy]</li>
|
|
||||||
locationOption.locationMode = AMapLocationMode.Hight_Accuracy;
|
|
||||||
|
|
||||||
///设置iOS端的定位最小更新距离<br>
|
|
||||||
locationOption.distanceFilter = -1;
|
|
||||||
|
|
||||||
///设置iOS端期望的定位精度
|
|
||||||
/// 可选值:<br>
|
|
||||||
/// <li>[DesiredAccuracy.Best] 最高精度</li>
|
|
||||||
/// <li>[DesiredAccuracy.BestForNavigation] 适用于导航场景的高精度 </li>
|
|
||||||
/// <li>[DesiredAccuracy.NearestTenMeters] 10米 </li>
|
|
||||||
/// <li>[DesiredAccuracy.Kilometer] 1000米</li>
|
|
||||||
/// <li>[DesiredAccuracy.ThreeKilometers] 3000米</li>
|
|
||||||
locationOption.desiredAccuracy = DesiredAccuracy.Best;
|
|
||||||
|
|
||||||
///设置iOS端是否允许系统暂停定位
|
|
||||||
locationOption.pausesLocationUpdatesAutomatically = false;
|
|
||||||
|
|
||||||
///将定位参数设置给定位插件
|
|
||||||
_locationPlugin.setLocationOption(locationOption);
|
|
||||||
}
|
|
||||||
|
|
||||||
///开始定位
|
|
||||||
void _startLocation() {
|
|
||||||
///开始定位之前设置定位参数
|
|
||||||
_setLocationOption();
|
|
||||||
_locationPlugin.startLocation();
|
|
||||||
}
|
|
||||||
|
|
||||||
///停止定位
|
|
||||||
void _stopLocation() {
|
|
||||||
_locationPlugin.stopLocation();
|
|
||||||
}
|
|
||||||
|
|
||||||
///获取iOS native的accuracyAuthorization类型
|
|
||||||
void requestAccuracyAuthorization() async {
|
|
||||||
AMapAccuracyAuthorization currentAccuracyAuthorization = await _locationPlugin.getSystemAccuracyAuthorization();
|
|
||||||
if (currentAccuracyAuthorization == AMapAccuracyAuthorization.AMapAccuracyAuthorizationFullAccuracy) {
|
|
||||||
print("精确定位类型");
|
|
||||||
} else if (currentAccuracyAuthorization == AMapAccuracyAuthorization.AMapAccuracyAuthorizationReducedAccuracy) {
|
|
||||||
print("模糊定位类型");
|
|
||||||
} else {
|
|
||||||
print("未知定位类型");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 动态申请定位权限
|
|
||||||
void requestPermission() async {
|
|
||||||
// 申请权限
|
|
||||||
bool hasLocationPermission = await requestLocationPermission();
|
|
||||||
if (hasLocationPermission) {
|
|
||||||
print("定位权限申请通过");
|
|
||||||
} else {
|
|
||||||
print("定位权限申请不通过");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 申请定位权限
|
|
||||||
/// 授予定位权限返回true, 否则返回false
|
|
||||||
Future<bool> requestLocationPermission() async {
|
|
||||||
//获取当前的权限
|
|
||||||
var status = await Permission.location.status;
|
|
||||||
if (status == PermissionStatus.granted) {
|
|
||||||
//已经授权
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
//未授权则发起一次申请
|
|
||||||
status = await Permission.location.request();
|
|
||||||
if (status == PermissionStatus.granted) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// @override
|
|
||||||
// void dispose() {
|
|
||||||
// super.dispose();
|
|
||||||
//
|
|
||||||
// _stopLocation();
|
|
||||||
//
|
|
||||||
// ///移除定位监听
|
|
||||||
// if (null != _locationListener) {
|
|
||||||
// _locationListener?.cancel();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// ///销毁定位
|
|
||||||
// _locationPlugin.destroy();
|
|
||||||
//
|
|
||||||
// print("高德地图定位销毁了");
|
|
||||||
// }
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
super.dispose();
|
super.dispose();
|
||||||
|
|
||||||
_stopLocation();
|
location?.destroy();
|
||||||
|
|
||||||
///移除定位监听
|
|
||||||
if (null != _locationListener) {
|
|
||||||
_locationListener?.cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
///销毁定位
|
|
||||||
_locationPlugin.destroy();
|
|
||||||
|
|
||||||
print("地图界面销毁了");
|
print("地图界面销毁了");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,7 @@ class LockAddressPage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _LockAddressPageState extends State<LockAddressPage> with RouteAware{
|
class _LockAddressPageState extends State<LockAddressPage> with RouteAware{
|
||||||
|
Map<String, Object>? addressInfo;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -37,15 +38,17 @@ class _LockAddressPageState extends State<LockAddressPage> with RouteAware{
|
|||||||
style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Get.toNamed(Routers.saveLockPage)!.then((value) {
|
Get.toNamed(Routers.saveLockPage, arguments: addressInfo);
|
||||||
dispose();
|
|
||||||
});
|
|
||||||
// Navigator.pushNamed(context, Routers.saveLockPage);
|
// Navigator.pushNamed(context, Routers.saveLockPage);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
body: LockAddressGaoDePage());
|
body: LockAddressGaoDePage(callback: (addressInfoMap){
|
||||||
|
addressInfo = addressInfoMap;
|
||||||
|
},)
|
||||||
|
// body: Container(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@ -25,7 +25,7 @@ class NearbyLockLogic extends BaseGetXController{
|
|||||||
|
|
||||||
final NearbyLockState state = NearbyLockState();
|
final NearbyLockState state = NearbyLockState();
|
||||||
|
|
||||||
// 点击复合要求的设备之后 连接
|
// 点击连接设备
|
||||||
void connect(String lockId, String deviceName){
|
void connect(String lockId, String deviceName){
|
||||||
BlueManage().connect(lockId, deviceName, isFrist: true);
|
BlueManage().connect(lockId, deviceName, isFrist: true);
|
||||||
}
|
}
|
||||||
@ -81,7 +81,7 @@ class NearbyLockLogic extends BaseGetXController{
|
|||||||
Future<void> _replyGetPrivateKeyKey(Reply reply) async {
|
Future<void> _replyGetPrivateKeyKey(Reply reply) async {
|
||||||
switch(reply.status){
|
switch(reply.status){
|
||||||
case 0x00:
|
case 0x00:
|
||||||
//成功
|
//成功
|
||||||
print('获取私钥成功');
|
print('获取私钥成功');
|
||||||
reply.data.removeAt(0);
|
reply.data.removeAt(0);
|
||||||
|
|
||||||
@ -90,6 +90,11 @@ class NearbyLockLogic extends BaseGetXController{
|
|||||||
var savePrivateKeyList = changeIntListToStringList(privateKey);
|
var savePrivateKeyList = changeIntListToStringList(privateKey);
|
||||||
Storage.setStringList(saveBluePrivateKey, savePrivateKeyList);
|
Storage.setStringList(saveBluePrivateKey, savePrivateKeyList);
|
||||||
|
|
||||||
|
// signKey
|
||||||
|
List<int> signKey = reply.data.sublist(16, 32);
|
||||||
|
var saveSignKeyList = changeIntListToStringList(signKey);
|
||||||
|
Storage.setStringList(saveBlueSignKey, saveSignKeyList);
|
||||||
|
|
||||||
Get.toNamed(Routers.lockAddressPage);
|
Get.toNamed(Routers.lockAddressPage);
|
||||||
break;
|
break;
|
||||||
case 0x07:
|
case 0x07:
|
||||||
|
|||||||
@ -26,22 +26,6 @@ class _NearbyLockPageState extends State<NearbyLockPage> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
// var uint8View1 = Uint8List(300);
|
|
||||||
// uint8View1[0] = 0xEF;
|
|
||||||
// uint8View1[1] = 0x01;
|
|
||||||
// uint8View1[2] = 0xEE;
|
|
||||||
// uint8View1[3] = 0x02;
|
|
||||||
// // String bar = utf8.decode(uint8View1);
|
|
||||||
// print("barrrrr:$uint8View1");
|
|
||||||
//
|
|
||||||
// for(int i = 0; i<uint8View1.length; i++){
|
|
||||||
// String hexString = uint8View1[i].toRadixString(16);
|
|
||||||
// print("666666666:$hexString");
|
|
||||||
// }
|
|
||||||
|
|
||||||
// String hexString = 4009881090.toRadixString(16);
|
|
||||||
// print("666666666:$hexString");
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: AppColors.mainBackgroundColor,
|
backgroundColor: AppColors.mainBackgroundColor,
|
||||||
appBar: TitleAppBar(
|
appBar: TitleAppBar(
|
||||||
@ -100,7 +84,8 @@ class _NearbyLockPageState extends State<NearbyLockPage> {
|
|||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(discoveredDevice.name, style: TextStyle(fontSize: 20.sp, color: AppColors.blackColor),),
|
// 第33、34两位00 表示休眠, 01表示唤醒
|
||||||
|
Text(discoveredDevice.name, style: TextStyle(fontSize: 20.sp, color: ((discoveredDevice.serviceUuids.isNotEmpty ? discoveredDevice.serviceUuids[0] : "").toString()[33] == "1") ? AppColors.blackColor : Colors.grey)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
|
|||||||
@ -30,9 +30,9 @@ class SaveLockEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class SaveLockEntityData {
|
class SaveLockEntityData {
|
||||||
String? lockId;
|
int? lockId;
|
||||||
String? nbRegisterSuccess;
|
String? nbRegisterSuccess;
|
||||||
String? keyId;
|
int? keyId;
|
||||||
|
|
||||||
SaveLockEntityData(
|
SaveLockEntityData(
|
||||||
{ this.lockId,
|
{ this.lockId,
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import 'dart:convert';
|
|||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
import '../../../appRouters.dart';
|
||||||
import '../../../blue/blue_manage.dart';
|
import '../../../blue/blue_manage.dart';
|
||||||
import '../../../blue/io_protocol/io_addUser.dart';
|
import '../../../blue/io_protocol/io_addUser.dart';
|
||||||
import '../../../blue/io_protocol/io_getLockStatu.dart';
|
import '../../../blue/io_protocol/io_getLockStatu.dart';
|
||||||
@ -174,14 +175,14 @@ class SaveLockLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 保存事件,先调用蓝牙,蓝牙调用成功后再调用后台接口
|
// 保存事件,先调用蓝牙,蓝牙调用成功后再调用后台接口
|
||||||
_saveLockAction(){
|
saveLockAction(){
|
||||||
addUserConnectBlue();
|
addUserConnectBlue();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加用户
|
// 添加用户
|
||||||
Future<void> addUserConnectBlue() async {
|
Future<void> addUserConnectBlue() async {
|
||||||
// 进来之后首先连接
|
// 进来之后首先连接
|
||||||
BlueManage().connect("AD01447A-30B5-A780-E778-DED3BDCB613E", "TMH_c3570480da8d", connectStateCallBack: (DeviceConnectionState state) async {
|
BlueManage().judgeReconnect("AD01447A-30B5-A780-E778-DED3BDCB613E", "TMH_c3570480da8d", (DeviceConnectionState state) async {
|
||||||
if (state == DeviceConnectionState.connected){
|
if (state == DeviceConnectionState.connected){
|
||||||
// 私钥
|
// 私钥
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
@ -197,7 +198,8 @@ class SaveLockLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IoSenderManage.senderAddUser(
|
IoSenderManage.senderAddUser(
|
||||||
lockID:BlueManage().connectDeviceName,
|
// lockID:BlueManage().connectDeviceName,
|
||||||
|
lockID: "TMH_c3570480da8d",
|
||||||
authUserID:"100001",
|
authUserID:"100001",
|
||||||
keyID:"1",
|
keyID:"1",
|
||||||
userID:"100001",
|
userID:"100001",
|
||||||
@ -218,8 +220,30 @@ class SaveLockLogic extends BaseGetXController {
|
|||||||
|
|
||||||
void bindBlueAdmin() async{
|
void bindBlueAdmin() async{
|
||||||
var lockDataMap = {};
|
var lockDataMap = {};
|
||||||
lockDataMap['lockId'] = BlueManage().connectDeviceName;
|
lockDataMap['lockName'] = BlueManage().connectDeviceName;
|
||||||
lockDataMap['lockMac'] = BlueManage().connectDeviceId;
|
lockDataMap['lockMac'] = BlueManage().connectDeviceMacAddress;
|
||||||
|
|
||||||
|
var positionMap = {};
|
||||||
|
positionMap['longitude'] = state.addressMap["longitude"];
|
||||||
|
positionMap['latitude'] = state.addressMap["latitude"];
|
||||||
|
positionMap['country'] = state.addressMap["country"];
|
||||||
|
positionMap['province'] = state.addressMap["province"];
|
||||||
|
positionMap['city'] = state.addressMap["city"];
|
||||||
|
positionMap['district'] = state.addressMap["district"];
|
||||||
|
positionMap['township'] = state.addressMap["street"];
|
||||||
|
positionMap['address'] = state.addressMap["address"];
|
||||||
|
|
||||||
|
var bluetooth = {};
|
||||||
|
bluetooth['bluetoothDeviceId'] = BlueManage().connectDeviceMacAddress;
|
||||||
|
bluetooth['bluetoothDeviceName'] = BlueManage().connectDeviceName;
|
||||||
|
|
||||||
|
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||||
|
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||||
|
bluetooth['publicKey'] = publicKeyDataList;
|
||||||
|
|
||||||
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
|
bluetooth['privateKey'] = getPrivateKeyList;
|
||||||
|
|
||||||
var entity = await ApiRepository.to.bindingBlueAdmin(
|
var entity = await ApiRepository.to.bindingBlueAdmin(
|
||||||
bindingDate:DateTime.now().millisecondsSinceEpoch.toString(),
|
bindingDate:DateTime.now().millisecondsSinceEpoch.toString(),
|
||||||
@ -227,11 +251,13 @@ class SaveLockLogic extends BaseGetXController {
|
|||||||
lockAlias:state.aliName.value,
|
lockAlias:state.aliName.value,
|
||||||
lockData:lockDataMap,
|
lockData:lockDataMap,
|
||||||
nbInitSuccess:"0",
|
nbInitSuccess:"0",
|
||||||
position:"113.918912, 22.653670",
|
position:positionMap,
|
||||||
|
bluetooth:bluetooth,
|
||||||
deviceNo:"123456"
|
deviceNo:"123456"
|
||||||
);
|
);
|
||||||
if(entity.errorCode!.codeIsSuccessful){
|
if(entity.errorCode!.codeIsSuccessful){
|
||||||
Get.close(3);
|
EventBusManager().eventBusFir(RefreshLockListInfoDataEvent);
|
||||||
|
Get.toNamed(Routers.starLockMain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -100,7 +100,8 @@ class _SaveLockPageState extends State<SaveLockPage> {
|
|||||||
bottom: 25.w
|
bottom: 25.w
|
||||||
),
|
),
|
||||||
onClick: (){
|
onClick: (){
|
||||||
Navigator.pop(context);
|
// Navigator.pop(context);
|
||||||
|
logic.saveLockAction();
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -8,11 +8,13 @@ import '../../../blue/blue_manage.dart';
|
|||||||
class SaveLockState {
|
class SaveLockState {
|
||||||
|
|
||||||
var aliName = ''.obs;
|
var aliName = ''.obs;
|
||||||
|
var addressMap = {}.obs;
|
||||||
TextEditingController aliNameController = TextEditingController();
|
TextEditingController aliNameController = TextEditingController();
|
||||||
|
|
||||||
SaveLockState() {
|
SaveLockState() {
|
||||||
aliName.value = BlueManage().connectDeviceName;
|
aliName.value = BlueManage().connectDeviceName;
|
||||||
aliNameController.text = aliName.value;
|
aliNameController.text = aliName.value;
|
||||||
|
addressMap.value = Get.arguments as Map;
|
||||||
}
|
}
|
||||||
|
|
||||||
void onClose() {
|
void onClose() {
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|||||||
import 'package:star_lock/mine/mine/starLockMine_page.dart';
|
import 'package:star_lock/mine/mine/starLockMine_page.dart';
|
||||||
|
|
||||||
import '../app_settings/app_colors.dart';
|
import '../app_settings/app_colors.dart';
|
||||||
import '../main/lockMian/lockMain_page.dart';
|
import '../main/lockMian/lockMain/lockMain_page.dart';
|
||||||
|
|
||||||
class NavPages extends StatefulWidget {
|
class NavPages extends StatefulWidget {
|
||||||
const NavPages({Key? key}) : super(key: key);
|
const NavPages({Key? key}) : super(key: key);
|
||||||
|
|||||||
@ -233,7 +233,8 @@ class ApiProvider extends BaseProvider {
|
|||||||
String lockAlias,
|
String lockAlias,
|
||||||
Map lockData,
|
Map lockData,
|
||||||
String nbInitSuccess,
|
String nbInitSuccess,
|
||||||
String position,
|
Map position,
|
||||||
|
Map bluetooth,
|
||||||
String deviceNo) =>
|
String deviceNo) =>
|
||||||
post(
|
post(
|
||||||
bindingBlueAdminURL.toUrl,
|
bindingBlueAdminURL.toUrl,
|
||||||
@ -244,6 +245,7 @@ class ApiProvider extends BaseProvider {
|
|||||||
'lockData': lockData,
|
'lockData': lockData,
|
||||||
"nbInitSuccess": nbInitSuccess,
|
"nbInitSuccess": nbInitSuccess,
|
||||||
'position': position,
|
'position': position,
|
||||||
|
'bluetooth': bluetooth,
|
||||||
'deviceNo': deviceNo
|
'deviceNo': deviceNo
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
@ -56,7 +56,7 @@ class BaseProvider extends GetConnect with Api {
|
|||||||
statusText: res.statusText,
|
statusText: res.statusText,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
print('得到的数据======>bodyString:${res.bodyString} body:${res.body} bodyBytes:${res.bodyBytes} status:${res.status} statusText:${res.statusText} statusCode:${res.statusCode}');
|
// print('得到的数据======>bodyString:${res.bodyString} body:${res.body} bodyBytes:${res.bodyBytes} status:${res.status} statusText:${res.statusText} statusCode:${res.statusCode}');
|
||||||
getDataResult(res.body);
|
getDataResult(res.body);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -182,7 +182,8 @@ class ApiRepository {
|
|||||||
required String lockAlias,
|
required String lockAlias,
|
||||||
required Map lockData,
|
required Map lockData,
|
||||||
required String nbInitSuccess,
|
required String nbInitSuccess,
|
||||||
required String position,
|
required Map position,
|
||||||
|
required Map bluetooth,
|
||||||
required String deviceNo}) async {
|
required String deviceNo}) async {
|
||||||
final res = await apiProvider.bindingBlueAdmin(
|
final res = await apiProvider.bindingBlueAdmin(
|
||||||
bindingDate,
|
bindingDate,
|
||||||
@ -191,6 +192,7 @@ class ApiRepository {
|
|||||||
lockData,
|
lockData,
|
||||||
nbInitSuccess,
|
nbInitSuccess,
|
||||||
position,
|
position,
|
||||||
|
bluetooth,
|
||||||
deviceNo);
|
deviceNo);
|
||||||
return SaveLockEntity.fromJson(res.body);
|
return SaveLockEntity.fromJson(res.body);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../main/lockMian/lockMain_page.dart';
|
import '../main/lockMian/lockMain/lockMain_page.dart';
|
||||||
|
|
||||||
|
|
||||||
class StarLockApplication extends StatefulWidget {
|
class StarLockApplication extends StatefulWidget {
|
||||||
|
|||||||
24
star_lock/lib/tools/dateTool.dart
Normal file
24
star_lock/lib/tools/dateTool.dart
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
|
||||||
|
class DateTool {
|
||||||
|
|
||||||
|
String getNowDateYMDHM(){
|
||||||
|
// 获取当前时间对象
|
||||||
|
DateTime now = DateTime.now();
|
||||||
|
|
||||||
|
//获取当前时间的年
|
||||||
|
int year = now.year;
|
||||||
|
//获取当前时间的月
|
||||||
|
int month = now.month;
|
||||||
|
//获取当前时间的日
|
||||||
|
int day = now.day;
|
||||||
|
//获取当前时间的时
|
||||||
|
int hour = now.hour;
|
||||||
|
//获取当前时间的分
|
||||||
|
int minute = now.minute;
|
||||||
|
//获取当前时间的秒
|
||||||
|
int millisecond = now.millisecond;
|
||||||
|
|
||||||
|
// print("组合 $year-$month-$day $hour:$minute:$millisecond");
|
||||||
|
return "$year.$month.$day $hour:$minute";
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user