feat: xhj 设备列表 添加搜索功能
This commit is contained in:
parent
f9fdb1b6ce
commit
4f75d1a43a
@ -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 {
|
||||
|
||||
@ -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<GroupList> groupDataList = <GroupList>[];
|
||||
List<GroupList> _groupDataList = <GroupList>[];
|
||||
LockListInfoGroupEntity? entity;
|
||||
|
||||
List<GroupList> get groupDataList {
|
||||
final List<GroupList> 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 = <GroupList>[];
|
||||
_groupDataList = <GroupList>[];
|
||||
}
|
||||
groupDataList.addAll(entity.groupList!);
|
||||
_groupDataList.addAll(entity.groupList!);
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
@ -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; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
|
||||
}
|
||||
@ -43,16 +43,75 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
|
||||
children: <Widget>[
|
||||
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: <Widget>[
|
||||
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: <Widget>[
|
||||
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<LockListXHJPage> 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(),
|
||||
);
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user