app-starlock/lib/mine/mineSet/authorityManagement/getDeviceList_page.dart

136 lines
3.9 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/tools/submitBtn.dart';
import '../../../../app_settings/app_colors.dart';
import '../../../../tools/titleAppBar.dart';
class GetDeviceListPage extends StatefulWidget {
const GetDeviceListPage({Key? key}) : super(key: key);
@override
State<GetDeviceListPage> createState() => _GetDeviceListPageState();
}
class _GetDeviceListPageState extends State<GetDeviceListPage> {
bool isNameSelect = false;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(
2024-08-01 18:54:32 +08:00
barTitle: '关联设备'.tr,
haveBack: true,
backgroundColor: AppColors.mainColor,
),
body: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: EdgeInsets.only(
left: 30.w, top: 16.w, right: 30.w, bottom: 16.w),
child: Text(
'请选择姓名要关联哪些设备'.tr,
style: TextStyle(
color: AppColors.darkGrayTextColor, fontSize: 20.sp),
textAlign: TextAlign.start,
),
),
Expanded(child: _permissionDeviceList()),
],
),
);
}
//设备列表
Widget _permissionDeviceList() {
return Column(
children: <Widget>[
Expanded(
child: ListView.separated(
itemBuilder: (BuildContext context, int index) {
if (index == 0) {
return _buildDeviceWidget(
context, index, 'images/icon_lock.png', '大门锁');
} else if (index == 1) {
return _buildDeviceWidget(
context, index, 'images/icon_lock.png', '办公室锁');
} else if (index == 2) {
return _buildDeviceWidget(
context, index, 'images/icon_lock.png', '会议室锁');
} else {
return _buildDeviceWidget(
context, index, 'images/icon_lock.png', '宴会厅锁');
}
},
separatorBuilder: (BuildContext context, int index) {
return const Divider(
height: 1,
color: AppColors.greyLineColor,
);
},
itemCount: 5)),
SizedBox(
height: 20.h,
),
SubmitBtn(
btnName: '确定'.tr,
onClick: () {},
),
SizedBox(
height: 40.h,
)
],
);
}
Widget _buildDeviceWidget(context, index, imageName, deviceName) {
return GestureDetector(
child: Container(
height: 90.h,
color: Colors.white,
width: ScreenUtil().screenWidth,
child: Row(
children: <Widget>[
SizedBox(
width: 30.w,
),
Image.asset(
isNameSelect == false
2024-01-23 17:29:18 +08:00
? 'images/icon_round_unSelect.png'
2024-01-23 17:48:06 +08:00
: 'images/icon_round_select.png',
width: 30.sp,
height: 30.sp,
),
SizedBox(
width: 20.w,
),
Image.asset(
imageName,
width: 36.w,
height: 36.w,
),
SizedBox(
width: 10.w,
),
Text(
deviceName,
style: TextStyle(fontSize: 22.sp, color: AppColors.blackColor),
),
SizedBox(
width: 30.w,
)
],
),
),
onTap: () {
setState(() {
isNameSelect = !isNameSelect;
});
},
);
}
}