154 lines
4.8 KiB
Dart
Executable File
154 lines
4.8 KiB
Dart
Executable File
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:star_lock/main/lockDetail/messageWarn/lockUser/lockUser_entity.dart';
|
|
import 'package:star_lock/main/lockDetail/messageWarn/lockUser/lockUser_logic.dart';
|
|
import 'package:star_lock/main/lockDetail/messageWarn/lockUser/lockUser_state.dart';
|
|
import 'package:star_lock/tools/keySearchWidget.dart';
|
|
import '../../../../app_settings/app_colors.dart';
|
|
import '../../../../tools/submitBtn.dart';
|
|
import '../../../../tools/titleAppBar.dart';
|
|
|
|
class LockUserPage extends StatefulWidget {
|
|
const LockUserPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<LockUserPage> createState() => _LockUserPageState();
|
|
}
|
|
|
|
class _LockUserPageState extends State<LockUserPage> {
|
|
final LockUserLogic logic = Get.put(LockUserLogic());
|
|
final LockUserState state = Get.find<LockUserLogic>().state;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: AppColors.mainBackgroundColor,
|
|
appBar: TitleAppBar(
|
|
barTitle: '锁用户'.tr,
|
|
haveBack: true,
|
|
backgroundColor: AppColors.mainColor,
|
|
),
|
|
body: Column(
|
|
children: <Widget>[
|
|
KeySearchWidget(
|
|
editingController: state.searchController,
|
|
onSubmittedAction: () {
|
|
logic.pageNo = 1;
|
|
logic.getLockKeysList();
|
|
},
|
|
),
|
|
SizedBox(
|
|
height: 20.h,
|
|
),
|
|
Expanded(child: _buildMainUI()),
|
|
SubmitBtn(
|
|
btnName: '确定'.tr,
|
|
onClick: () {
|
|
Get.back(result: state.lockUserList[state.isSelectIndex.value]);
|
|
},
|
|
),
|
|
SizedBox(
|
|
height: 64.h,
|
|
)
|
|
],
|
|
));
|
|
}
|
|
|
|
Widget _buildMainUI() {
|
|
return Obx(() => ListView.separated(
|
|
shrinkWrap: true,
|
|
itemCount: state.lockUserList.length,
|
|
itemBuilder: (BuildContext c, int index) {
|
|
return _electronicKeyItem(state.lockUserList[index], index);
|
|
},
|
|
separatorBuilder: (BuildContext context, int index) {
|
|
return const Divider(
|
|
height: 1,
|
|
color: AppColors.greyLineColor,
|
|
);
|
|
},
|
|
));
|
|
}
|
|
|
|
Widget _electronicKeyItem(LockUserListKeys lockUserKeys, int selectIndex) {
|
|
return GestureDetector(
|
|
onTap: () {
|
|
for (int i = 0; i < state.lockUserList.length; i++) {
|
|
final LockUserListKeys item = state.lockUserList[i];
|
|
if (selectIndex == i) {
|
|
item.isCurrentSelect = true;
|
|
} else {
|
|
item.isCurrentSelect = false;
|
|
}
|
|
}
|
|
setState(() {
|
|
state.isSelectIndex.value = selectIndex;
|
|
});
|
|
},
|
|
child: Container(
|
|
color: Colors.white,
|
|
width: 1.sw,
|
|
height: 90.h,
|
|
child: Row(
|
|
children: <Widget>[
|
|
SizedBox(
|
|
width: 30.w,
|
|
),
|
|
Image.asset(
|
|
lockUserKeys.currentTypeImg ?? 'images/controls_user.png',
|
|
width: 60.w,
|
|
height: 60.w,
|
|
),
|
|
SizedBox(
|
|
width: 20.w,
|
|
),
|
|
Expanded(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: <Widget>[
|
|
Row(
|
|
children: <Widget>[
|
|
Text(
|
|
lockUserKeys.currentKeyName ?? '',
|
|
style: TextStyle(
|
|
fontSize: 24.sp, color: AppColors.blackColor),
|
|
),
|
|
SizedBox(width: 10.w),
|
|
Expanded(
|
|
child: SizedBox(
|
|
width: 20.w,
|
|
)),
|
|
],
|
|
),
|
|
SizedBox(height: 10.h),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: <Widget>[
|
|
Text(
|
|
logic.getKeyUseDateStr(lockUserKeys),
|
|
style: TextStyle(
|
|
fontSize: 18.sp,
|
|
color: AppColors.placeholderTextColor),
|
|
),
|
|
],
|
|
),
|
|
SizedBox(width: 20.h),
|
|
],
|
|
),
|
|
),
|
|
Obx(() => Image.asset(
|
|
state.isSelectIndex.value == selectIndex
|
|
? 'images/icon_round_select.png'
|
|
: 'images/icon_round_unSelect.png',
|
|
width: 30.w,
|
|
height: 30.w,
|
|
)),
|
|
SizedBox(width: 20.h),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|