diff --git a/lib/main/lockMian/entity/lockListInfo_entity.dart b/lib/main/lockMian/entity/lockListInfo_entity.dart index b3c62d17..ecb49bbd 100755 --- a/lib/main/lockMian/entity/lockListInfo_entity.dart +++ b/lib/main/lockMian/entity/lockListInfo_entity.dart @@ -97,6 +97,14 @@ class GroupList { } return data; } + + GroupList copy(){ + return GroupList( + groupName: groupName, + groupId: groupId, + lockList: lockList?.map((e) => e.copy()).toList(), + ); + } } class LockListInfoItemEntity { @@ -268,6 +276,10 @@ class LockListInfoItemEntity { bool isLockOwnerBool() { return isLockOwner == 1; } + + LockListInfoItemEntity copy(){ + return LockListInfoItemEntity.fromJson(toJson()); + } } class Bluetooth { diff --git a/lib/main/lockMian/lockList/lockList_logic.dart b/lib/main/lockMian/lockList/lockList_logic.dart index 14b08463..b06b7f1f 100755 --- a/lib/main/lockMian/lockList/lockList_logic.dart +++ b/lib/main/lockMian/lockList/lockList_logic.dart @@ -23,20 +23,30 @@ import '../entity/lockListInfo_entity.dart'; import 'lockList_state.dart'; class LockListLogic extends BaseGetXController { - LockListLogic(this.entity){ - } + LockListLogic(this.entity) {} LockListState state = LockListState(); - List groupDataList = []; + List _groupDataList = []; LockListInfoGroupEntity? entity; + List get groupDataList { + final List list = _groupDataList.map((e)=>e.copy()).toList(); + if (state.searchStr.value != '' && state.showSearch.value) { + list.forEach((GroupList element) { + element.lockList?.removeWhere((LockListInfoItemEntity element) => + !(element.lockAlias?.contains(state.searchStr.value) ?? true)); + }); + } + return list; + } + //设置数据 void setLockListInfoGroupEntity(LockListInfoGroupEntity entity) { this.entity = entity; if (entity.pageNo == 1) { - groupDataList = []; + _groupDataList = []; } - groupDataList.addAll(entity.groupList!); + _groupDataList.addAll(entity.groupList!); update(); } diff --git a/lib/main/lockMian/lockList/lockList_state.dart b/lib/main/lockMian/lockList/lockList_state.dart index 58c174ef..1b072405 100755 --- a/lib/main/lockMian/lockList/lockList_state.dart +++ b/lib/main/lockMian/lockList/lockList_state.dart @@ -6,10 +6,12 @@ import '../entity/lockListInfo_entity.dart'; class LockListState{ - var itemStatusIsEable = false.obs; // 列表里面item是否能点击 + RxBool itemStatusIsEable = false.obs; // 列表里面item是否能点击 LockListInfoItemEntity lockListInfoItemEntity = LockListInfoItemEntity(); // 当前选中要删除的item - var passwordTF = TextEditingController(); - var deleteAdministratorIsHaveAllData = false.obs; // 删除管理员是否有所有数据 - var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 + TextEditingController passwordTF = TextEditingController(); + RxBool deleteAdministratorIsHaveAllData = false.obs; // 删除管理员是否有所有数据 + RxBool ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 + RxBool showSearch = false.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 + RxString searchStr = ''.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 } \ No newline at end of file diff --git a/lib/main/lockMian/lockList/lockList_xhj_page.dart b/lib/main/lockMian/lockList/lockList_xhj_page.dart index 8292364d..f76baa68 100755 --- a/lib/main/lockMian/lockList/lockList_xhj_page.dart +++ b/lib/main/lockMian/lockList/lockList_xhj_page.dart @@ -43,16 +43,75 @@ class _LockListXHJPageState extends State with RouteAware { children: [ Align( alignment: Alignment.topRight, - child: IconButton( - onPressed: () { - Get.toNamed(Routers.selectLockTypePage); - }, - icon: Icon( - Icons.add_circle, - size: 48.w, - color: AppColors.mainColor, - )), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + IconButton( + onPressed: () { + state.showSearch.value = !state.showSearch.value; + }, + icon: Icon( + Icons.search, + size: 32.w, + color: AppColors.blackColor, + )), + IconButton( + onPressed: () { + Get.toNamed(Routers.selectLockTypePage); + }, + icon: Icon( + Icons.add_circle, + size: 48.w, + color: AppColors.mainColor, + )), + ], + ), ), + //椭圆形 输入框 + Obx(() { + return state.showSearch.value + ? Container( + height: 50.w, + decoration: BoxDecoration( + color: Colors.white.withOpacity(0.8), + borderRadius: BorderRadius.circular(40.w), + ), + margin: EdgeInsets.only( + left: 25.w, right: 25.w, bottom: 20.h), + child: Stack( + children: [ + Padding( + padding: EdgeInsets.only(top: 14.h, left: 20.w), + child: Icon( + Icons.search, + size: 28.w, + color: AppColors.blackColor, + ), + ), + TextField( + decoration: InputDecoration( + hintText: '搜索'.tr, + hintStyle: TextStyle( + fontSize: 24.sp, + color: AppColors.blackColor, + ), + border: InputBorder.none, + contentPadding: EdgeInsets.only( + top: 6.h, + left: 50.w, + ), + isCollapsed: true, + ), + onChanged: (String value) { + state.searchStr.value = value; + }, + autofocus: true, + ), + ], + ), + ) + : const SizedBox.shrink(); + }), Padding( padding: EdgeInsets.only(left: 45.w), child: Text( @@ -65,15 +124,17 @@ class _LockListXHJPageState extends State with RouteAware { ), ), Expanded( - child: ListView.builder( - itemCount: logic.groupDataList.length, - itemBuilder: (BuildContext context, int index) { - final GroupList itemData = logic.groupDataList[index]; - return _buildLockExpandedList(context, index, itemData); - }, - shrinkWrap: true, - physics: const AlwaysScrollableScrollPhysics(), - ), + child: Obx(() { + return ListView.builder( + itemCount: logic.groupDataList.length, + itemBuilder: (BuildContext context, int index) { + final GroupList itemData = logic.groupDataList[index]; + return _buildLockExpandedList(context, index, itemData); + }, + shrinkWrap: true, + physics: const AlwaysScrollableScrollPhysics(), + ); + }), ), ], ),