diff --git a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_page.dart b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_page.dart new file mode 100644 index 00000000..ff690b08 --- /dev/null +++ b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_page.dart @@ -0,0 +1,163 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/utils.dart'; +import 'package:star_lock/app_settings/app_colors.dart'; +import 'package:star_lock/tools/ExpandedListView.dart'; +import 'package:star_lock/translations/trans_lib.dart'; + +class MassSendLockGroupListPage extends StatefulWidget { + const MassSendLockGroupListPage({Key? key}) : super(key: key); + + @override + State createState() { + return _MassSendLockGroupListPageState(); + } +} + +class _MassSendLockGroupListPageState extends State { + @override + void initState() { + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: AppColors.mainColor, + title: Text( + TranslationLoader.lanKeys!.authorityManagement!.tr, + style: TextStyle( + color: Colors.white, + fontSize: 28.sp, + fontWeight: FontWeight.w600), + ), + elevation: 0, + leading: IconButton( + icon: const Icon(Icons.arrow_back_ios, color: Colors.white), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Column( + children: [ + Text( + '请选择要发送的锁', + style: TextStyle( + color: AppColors.darkGrayTextColor, fontSize: 22.sp), + ), + _keyGroupList() + ], + )); + } + +//设备列表 + Widget _keyGroupList() { + return Column( + children: [ + SizedBox( + height: 10.h, + ), + Expanded( + child: ListView.separated( + itemBuilder: (context, index) { + if (index == 0) { + return _buildLockExpandedList(context, index, "大门锁"); + } else if (index == 1) { + return _buildLockExpandedList(context, index, "办公室锁"); + } else if (index == 2) { + return _buildLockExpandedList(context, index, "会议室锁"); + } else { + return _buildLockExpandedList(context, index, "宴会厅锁"); + } + }, + separatorBuilder: (context, index) { + return const Divider( + height: 1, + color: AppColors.greyLineColor, + ); + }, + itemCount: 5)), + ], + ); + } + +//设备多层级列表 + Widget _buildLockExpandedList(context, index, deviceName) { + return ExpandedListTile( + onTap: () => print("onTap."), + title: deviceName, + imgName: 'images/icon_lock.png', + typeImgList: const [], + child: ListView.separated( + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemCount: 10, + itemBuilder: (_, index) { + if (index == 0) { + return _buildNameWidget( + context, index, 'images/icon_password.png', '张三'); + } else if (index == 1) { + return _buildNameWidget( + context, index, 'images/icon_card.png', '李四'); + } else if (index == 2) { + return _buildNameWidget( + context, index, 'images/icon_fingerprint.png', '王二'); + } else if (index == 3) { + return _buildNameWidget( + context, index, 'images/icon_card.png', '麻子'); + } else { + return null; + } + }, + separatorBuilder: (BuildContext context, int index) { + return const Divider( + height: 1, + color: AppColors.greyLineColor, + ); + }, + ), + ); + } + + //单个姓名行 + Widget _buildNameWidget(context, index, imageName, getName) { + return GestureDetector( + child: Container( + height: 60.h, + color: Colors.white, + width: ScreenUtil().screenWidth, + child: Row( + children: [ + SizedBox( + width: 30.w, + ), + Image.asset( + 'images/controls_user.png', + width: 36.w, + height: 36.w, + ), + SizedBox( + width: 10.w, + ), + Text( + getName, + style: TextStyle( + fontSize: 20.sp, color: AppColors.darkGrayTextColor), + ), + SizedBox( + width: 30.w, + ) + ], + ), + ), + onTap: () { + // selectNameIndex = index; + // setState(() { + // if (selectNameIndex == index) { + // isNameSelect = !isNameSelect; + // } + // }); + }, + ); + } +} diff --git a/star_lock/lib/network/api.dart b/star_lock/lib/network/api.dart index f3e9c1fa..dbeeb595 100644 --- a/star_lock/lib/network/api.dart +++ b/star_lock/lib/network/api.dart @@ -35,4 +35,6 @@ abstract class Api { final String addlockGroupURL = '/keyGroup/add'; //创建锁分组 final String lockGroupListURL = '/authorizedAdmin/listGroup'; //锁分组列表 final String updateSettingURL = '/room/updateSetting'; //标记房态 + final String keyGroupListURL = '/keyGroup/list'; //分组列表 + final String lockListByGroupURL = '/room/listByGroup'; //分组下的锁 } diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index 17724f64..72b22227 100644 --- a/star_lock/lib/network/api_provider.dart +++ b/star_lock/lib/network/api_provider.dart @@ -342,6 +342,13 @@ class ApiProvider extends BaseProvider { Future updateSetting(String lockId, String isOn, String type) => post(updateSettingURL.toUrl, jsonEncode({'lockId': lockId, 'isOn': isOn, 'type': type})); + + Future keyGroupList(String type) => + post(keyGroupListURL.toUrl, jsonEncode({'type': type})); + + Future lockListByGroup(String type, String keyGroupId) => post( + lockListByGroupURL.toUrl, + jsonEncode({'type': type, 'keyGroupId': keyGroupId})); } extension ExtensionString on String { diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index deceb636..3786c781 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -325,4 +325,17 @@ class ApiRepository { final res = await apiProvider.deleteKeyboardPwd(lockId, isOn, type); return PasswordKeyEntity.fromJson(res.body); } + + //分组列表 + Future keyGroupList(String type) async { + final res = await apiProvider.keyGroupList(type); + return PasswordKeyEntity.fromJson(res.body); + } + + //分组下的锁 + Future lockListByGroup( + String type, String keyGroupId) async { + final res = await apiProvider.lockListByGroup(type, keyGroupId); + return PasswordKeyEntity.fromJson(res.body); + } }