feat:修改鑫泓佳设备匹配样式

This commit is contained in:
anfe 2024-04-30 11:33:44 +08:00
parent aa4e741674
commit 17bea0f9fa
3 changed files with 217 additions and 121 deletions

View File

@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:star_lock/flavors.dart';
import 'package:star_lock/mine/addLock/addLock/addLock_logic.dart';
import 'package:star_lock/tools/appFirstEnterHandle.dart';
import 'package:star_lock/tools/storage.dart';
@ -30,10 +31,20 @@ class _AddLockPageState extends State<AddLockPage> with BaseWidget {
builder: (AddLockLogic logic) {
return Scaffold(
backgroundColor: Colors.white,
appBar: TitleAppBar(
appBar: F.sw(
defaultCall: () => TitleAppBar(
barTitle: TranslationLoader.lanKeys!.addLock!.tr,
haveBack: true,
backgroundColor: AppColors.mainColor),
backgroundColor: AppColors.mainColor,
),
xhjCall: () => TitleAppBar(
barTitle: TranslationLoader.lanKeys!.addLock!.tr,
haveBack: true,
backgroundColor: Colors.white,
iconColor: AppColors.blackColor,
titleColor: AppColors.blackColor,
),
),
body: ListView(
// mainAxisAlignment: MainAxisAlignment.center,
// crossAxisAlignment: CrossAxisAlignment.center,

View File

@ -1,10 +1,10 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/flavors.dart';
import '../../../app_settings/app_colors.dart';
import '../../../blue/blue_manage.dart';
import '../../../tools/appRouteObserver.dart';
@ -27,30 +27,48 @@ class _NearbyLockPageState extends State<NearbyLockPage> with RouteAware {
void initState() {
// TODO: implement initState
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(
barTitle: TranslationLoader.lanKeys!.nearbyLock!.tr,
haveBack: true,
backgroundColor: AppColors.mainColor,
actionsList: [
CupertinoActivityIndicator(radius: 18.w, color: Colors.white,),
SizedBox(width: 30.w)
],
appBar: F.sw(
defaultCall: () => TitleAppBar(
barTitle: TranslationLoader.lanKeys!.nearbyLock!.tr,
haveBack: true,
backgroundColor: AppColors.mainColor,
actionsList: [
CupertinoActivityIndicator(
radius: 18.w,
color: Colors.white,
),
SizedBox(width: 30.w)
]),
xhjCall: () => TitleAppBar(
barTitle: TranslationLoader.lanKeys!.nearbyLock!.tr,
haveBack: true,
backgroundColor: Colors.white,
iconColor: AppColors.blackColor,
titleColor: AppColors.blackColor,
actionsList: [
CupertinoActivityIndicator(
radius: 18.w,
color: AppColors.blackColor,
),
SizedBox(width: 30.w)
]),
),
body: Obx(() {
return ListView.separated(
itemCount: state.devices.length,
itemBuilder: (c, index) {
return nearbyLockItem('images/icon_lockGroup_item.png', state.devices[index], () {
return nearbyLockItem(
'images/icon_lockGroup_item.png', state.devices[index], () {
// Navigator.pushNamed(context, Routers.lockAddressPage);
// logic.getPublicKey(state.devices[index].serviceUuids[0].toString());
state.selectLockName.value = state.devices[index].advertisementData.advName;
state.selectLockName.value =
state.devices[index].advertisementData.advName;
logic.connect(state.devices[index].advertisementData.advName);
// Get.toNamed(Routers.lockAddressGaoDePage);
});
@ -68,9 +86,16 @@ class _NearbyLockPageState extends State<NearbyLockPage> with RouteAware {
);
}
Widget nearbyLockItem(String lockTypeIcon, ScanResult scanResult, Function() action ) {
Widget nearbyLockItem(
String lockTypeIcon, ScanResult scanResult, Function() action) {
return GestureDetector(
onTap: ((scanResult.advertisementData.serviceUuids.isNotEmpty ? scanResult.advertisementData.serviceUuids[0] : "").toString()[33] == "1") ? action : null,
onTap: ((scanResult.advertisementData.serviceUuids.isNotEmpty
? scanResult.advertisementData.serviceUuids[0]
: "")
.toString()[33] ==
"1")
? action
: null,
child: Column(
// mainAxisAlignment: MainAxisAlignment.center,
children: [
@ -92,7 +117,18 @@ class _NearbyLockPageState extends State<NearbyLockPage> with RouteAware {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 323300 01
Text(scanResult.advertisementData.advName, style: TextStyle(fontSize: 20.sp, color: ((scanResult.advertisementData.serviceUuids.isNotEmpty ? scanResult.advertisementData.serviceUuids[0] : "").toString()[33] == "1") ? AppColors.blackColor : Colors.grey)),
Text(scanResult.advertisementData.advName,
style: TextStyle(
fontSize: 20.sp,
color: ((scanResult.advertisementData.serviceUuids
.isNotEmpty
? scanResult.advertisementData
.serviceUuids[0]
: "")
.toString()[33] ==
"1")
? AppColors.blackColor
: Colors.grey)),
],
),
SizedBox(
@ -173,5 +209,4 @@ class _NearbyLockPageState extends State<NearbyLockPage> with RouteAware {
logic.stopScanBlueList();
BlueManage().disconnect();
}
}

View File

@ -1,4 +1,3 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
@ -18,7 +17,8 @@ class SelectLockTypePage extends StatefulWidget {
State<SelectLockTypePage> createState() => _SelectLockTypePageState();
}
class _SelectLockTypePageState extends State<SelectLockTypePage> with BaseWidget {
class _SelectLockTypePageState extends State<SelectLockTypePage>
with BaseWidget {
final logic = Get.put(SelectLockTypeLogic());
final state = Get.find<SelectLockTypeLogic>().state;
@ -26,121 +26,165 @@ class _SelectLockTypePageState extends State<SelectLockTypePage> with BaseWidget
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(
appBar: F.sw(
defaultCall: () => TitleAppBar(
barTitle: TranslationLoader.lanKeys!.selectLockType!.tr,
haveBack: true,
backgroundColor: AppColors.mainColor),
backgroundColor: AppColors.mainColor,
),
xhjCall: () => TitleAppBar(
barTitle: TranslationLoader.lanKeys!.selectLockType!.tr,
haveBack: true,
backgroundColor: Colors.white,
iconColor: AppColors.blackColor,
titleColor: AppColors.blackColor,
),
),
body: Column(
children: [
allLock(),
Expanded(
child: Container(
padding: const EdgeInsets.only(left: 10, right: 10, bottom: 10),
child: GridView.count(
crossAxisCount: 2,
childAspectRatio: 2.83,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
children: [
lockTypeItem('images/lockType/lockType_doorLock.png',
TranslationLoader.lanKeys!.doorLock!.tr, () {
Navigator.pushNamed(context, Routers.addLockPage,
arguments: {'getLockType': 1});
}),
if (!F.isLite)
lockTypeItem('images/lockType/lockType_NFCLock.png',
TranslationLoader.lanKeys!.NFCPassiveLock!.tr, () {
// Navigator.pushNamed(context, Routers.addLockPage);
}),
if (!F.isLite)
lockTypeItem('images/lockType/lockType_padlock.png',
TranslationLoader.lanKeys!.padlock!.tr, () {
// Navigator.pushNamed(context, Routers.addLockPage);
}),
lockTypeItem('images/lockType/lockType_safeLock.png',
TranslationLoader.lanKeys!.safeLock!.tr, () {
Navigator.pushNamed(context, Routers.addLockPage,
arguments: {'getLockType': 4});
}),
lockTypeItem('images/lockType/lockType_parkingLock.png',
TranslationLoader.lanKeys!.parkingLock!.tr, () {
Navigator.pushNamed(context, Routers.addLockPage,
arguments: {'getLockType': 5});
}),
lockTypeItem('images/lockType/lockType_entranceGuardLock.png',
TranslationLoader.lanKeys!.itelligentAccessControl!.tr,
() {
Navigator.pushNamed(context, Routers.addLockPage,
arguments: {'getLockType': 6});
}),
// lockTypeItem('images/lockType/lockType_bicycleLock.png',
// TranslationLoader.lanKeys!.bicycleLock!.tr, () {
// Navigator.pushNamed(context, Routers.addLockPage);
// }),
if (!F.isLite)
lockTypeItem('images/lockType/lockType_gatewayLock.png',
TranslationLoader.lanKeys!.gateway!.tr, () {
// Navigator.pushNamed(context, Routers.gatewayListPage);
}),
if (!F.isLite)
lockTypeItem('images/lockType/lockType_camera.png', '网络摄像头'.tr,
() {
// Navigator.pushNamed(context, Routers.gatewayListPage);
}),
],
),
),
)
lockTypeList(),
],
),
);
}
//
Widget lockTypeList() {
Widget view = F.sw(
defaultCall: () => GridView.count(
crossAxisCount: 2,
childAspectRatio: 2.83,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
children: getLockTypeList(),
),
xhjCall: () => GridView.count(
crossAxisCount: 1,
childAspectRatio: 6,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
children: getLockTypeList(),
));
return Expanded(
child: Container(
padding: const EdgeInsets.only(left: 10, right: 10, bottom: 10),
child: view,
),
);
}
//
List<Widget> getLockTypeList() {
return [
lockTypeItem('images/lockType/lockType_doorLock.png',
TranslationLoader.lanKeys!.doorLock!.tr, () {
Navigator.pushNamed(context, Routers.addLockPage,
arguments: {'getLockType': 1});
}),
if (!F.isLite)
lockTypeItem('images/lockType/lockType_NFCLock.png',
TranslationLoader.lanKeys!.NFCPassiveLock!.tr, () {
// Navigator.pushNamed(context, Routers.addLockPage);
}),
if (!F.isLite)
lockTypeItem('images/lockType/lockType_padlock.png',
TranslationLoader.lanKeys!.padlock!.tr, () {
// Navigator.pushNamed(context, Routers.addLockPage);
}),
lockTypeItem('images/lockType/lockType_safeLock.png',
TranslationLoader.lanKeys!.safeLock!.tr, () {
Navigator.pushNamed(context, Routers.addLockPage,
arguments: {'getLockType': 4});
}),
lockTypeItem('images/lockType/lockType_parkingLock.png',
TranslationLoader.lanKeys!.parkingLock!.tr, () {
Navigator.pushNamed(context, Routers.addLockPage,
arguments: {'getLockType': 5});
}),
lockTypeItem('images/lockType/lockType_entranceGuardLock.png',
TranslationLoader.lanKeys!.itelligentAccessControl!.tr, () {
Navigator.pushNamed(context, Routers.addLockPage,
arguments: {'getLockType': 6});
}),
// lockTypeItem('images/lockType/lockType_bicycleLock.png',
// TranslationLoader.lanKeys!.bicycleLock!.tr, () {
// Navigator.pushNamed(context, Routers.addLockPage);
// }),
if (!F.isLite)
lockTypeItem('images/lockType/lockType_gatewayLock.png',
TranslationLoader.lanKeys!.gateway!.tr, () {
// Navigator.pushNamed(context, Routers.gatewayListPage);
}),
if (!F.isLite)
lockTypeItem('images/lockType/lockType_camera.png', '网络摄像头'.tr, () {
// Navigator.pushNamed(context, Routers.gatewayListPage);
}),
];
}
//
Widget allLock() {
Widget view = Row(
children: [
SizedBox(width: 30.w),
Image.asset(
'images/lockType/lockType_allLocks.png',
width: 88.w,
height: 80.w,
),
SizedBox(width: 40.w),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(TranslationLoader.lanKeys!.allLock!.tr,
style: TextStyle(
fontSize: 24.sp,
)),
Text(TranslationLoader.lanKeys!.searchAllLockType!.tr,
style: TextStyle(
fontSize: 20.sp, color: AppColors.darkGrayTextColor)),
],
),
),
SizedBox(width: 40.w),
Image.asset(
'images/icon_right_grey.png',
width: 12.w,
height: 21.w,
),
SizedBox(width: 40.w),
],
);
//
view = F.sw(
defaultCall: () => Container(
height: 150.h,
color: Colors.white,
margin: const EdgeInsets.all(10),
child: view,
),
xhjCall: () => Container(
height: 150.h,
margin: const EdgeInsets.all(10),
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(color: AppColors.mainColor, width: 1),
borderRadius: BorderRadius.circular(20.r),
),
child: view,
));
return GestureDetector(
onTap: () {
Navigator.pushNamed(context, Routers.addLockPage,
arguments: {'getLockType': 0});
},
child: Container(
height: 150.h,
color: Colors.white,
margin: const EdgeInsets.all(10),
child: Row(
children: [
SizedBox(width: 30.w),
Image.asset(
'images/lockType/lockType_allLocks.png',
width: 88.w,
height: 80.w,
),
SizedBox(width: 40.w),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(TranslationLoader.lanKeys!.allLock!.tr,
style: TextStyle(
fontSize: 24.sp,
)),
Text(TranslationLoader.lanKeys!.searchAllLockType!.tr,
style: TextStyle(
fontSize: 20.sp, color: AppColors.darkGrayTextColor)),
],
),
),
SizedBox(width: 40.w),
Image.asset(
'images/icon_right_grey.png',
width: 12.w,
height: 21.w,
),
SizedBox(width: 40.w),
],
),
),
child: view,
);
}
@ -150,8 +194,14 @@ class _SelectLockTypePageState extends State<SelectLockTypePage> with BaseWidget
onTap: action,
child: Container(
height: 120.h,
color: Colors.white,
// margin: EdgeInsets.all(10),
decoration: F.sw(
defaultCall: () => const BoxDecoration(
color: Colors.white,
),
xhjCall: () => BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20.r),
)),
child: Row(
children: [
SizedBox(width: 30.w),