feat: xhj 设备列表 添加搜索功能
This commit is contained in:
parent
f9fdb1b6ce
commit
4f75d1a43a
@ -97,6 +97,14 @@ class GroupList {
|
|||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GroupList copy(){
|
||||||
|
return GroupList(
|
||||||
|
groupName: groupName,
|
||||||
|
groupId: groupId,
|
||||||
|
lockList: lockList?.map((e) => e.copy()).toList(),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class LockListInfoItemEntity {
|
class LockListInfoItemEntity {
|
||||||
@ -268,6 +276,10 @@ class LockListInfoItemEntity {
|
|||||||
bool isLockOwnerBool() {
|
bool isLockOwnerBool() {
|
||||||
return isLockOwner == 1;
|
return isLockOwner == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LockListInfoItemEntity copy(){
|
||||||
|
return LockListInfoItemEntity.fromJson(toJson());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Bluetooth {
|
class Bluetooth {
|
||||||
|
|||||||
@ -23,20 +23,30 @@ import '../entity/lockListInfo_entity.dart';
|
|||||||
import 'lockList_state.dart';
|
import 'lockList_state.dart';
|
||||||
|
|
||||||
class LockListLogic extends BaseGetXController {
|
class LockListLogic extends BaseGetXController {
|
||||||
LockListLogic(this.entity){
|
LockListLogic(this.entity) {}
|
||||||
}
|
|
||||||
|
|
||||||
LockListState state = LockListState();
|
LockListState state = LockListState();
|
||||||
List<GroupList> groupDataList = <GroupList>[];
|
List<GroupList> _groupDataList = <GroupList>[];
|
||||||
LockListInfoGroupEntity? entity;
|
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) {
|
void setLockListInfoGroupEntity(LockListInfoGroupEntity entity) {
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
if (entity.pageNo == 1) {
|
if (entity.pageNo == 1) {
|
||||||
groupDataList = <GroupList>[];
|
_groupDataList = <GroupList>[];
|
||||||
}
|
}
|
||||||
groupDataList.addAll(entity.groupList!);
|
_groupDataList.addAll(entity.groupList!);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,10 +6,12 @@ import '../entity/lockListInfo_entity.dart';
|
|||||||
|
|
||||||
class LockListState{
|
class LockListState{
|
||||||
|
|
||||||
var itemStatusIsEable = false.obs; // 列表里面item是否能点击
|
RxBool itemStatusIsEable = false.obs; // 列表里面item是否能点击
|
||||||
LockListInfoItemEntity lockListInfoItemEntity = LockListInfoItemEntity(); // 当前选中要删除的item
|
LockListInfoItemEntity lockListInfoItemEntity = LockListInfoItemEntity(); // 当前选中要删除的item
|
||||||
var passwordTF = TextEditingController();
|
TextEditingController passwordTF = TextEditingController();
|
||||||
var deleteAdministratorIsHaveAllData = false.obs; // 删除管理员是否有所有数据
|
RxBool deleteAdministratorIsHaveAllData = false.obs; // 删除管理员是否有所有数据
|
||||||
var ifCurrentScreen = true.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>[
|
children: <Widget>[
|
||||||
Align(
|
Align(
|
||||||
alignment: Alignment.topRight,
|
alignment: Alignment.topRight,
|
||||||
child: IconButton(
|
child: Row(
|
||||||
onPressed: () {
|
mainAxisSize: MainAxisSize.min,
|
||||||
Get.toNamed(Routers.selectLockTypePage);
|
children: <Widget>[
|
||||||
},
|
IconButton(
|
||||||
icon: Icon(
|
onPressed: () {
|
||||||
Icons.add_circle,
|
state.showSearch.value = !state.showSearch.value;
|
||||||
size: 48.w,
|
},
|
||||||
color: AppColors.mainColor,
|
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(
|
||||||
padding: EdgeInsets.only(left: 45.w),
|
padding: EdgeInsets.only(left: 45.w),
|
||||||
child: Text(
|
child: Text(
|
||||||
@ -65,15 +124,17 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ListView.builder(
|
child: Obx(() {
|
||||||
itemCount: logic.groupDataList.length,
|
return ListView.builder(
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemCount: logic.groupDataList.length,
|
||||||
final GroupList itemData = logic.groupDataList[index];
|
itemBuilder: (BuildContext context, int index) {
|
||||||
return _buildLockExpandedList(context, index, itemData);
|
final GroupList itemData = logic.groupDataList[index];
|
||||||
},
|
return _buildLockExpandedList(context, index, itemData);
|
||||||
shrinkWrap: true,
|
},
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
shrinkWrap: true,
|
||||||
),
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
|
);
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user