138 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 GetNameListPage extends StatefulWidget {
const GetNameListPage({Key? key}) : super(key: key);
@override
State<GetNameListPage> createState() => _GetNameListPageState();
}
class _GetNameListPageState extends State<GetNameListPage> {
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: [
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: _permissionNameList()),
],
),
);
}
//姓名列表
Widget _permissionNameList() {
return Column(
children: [
Expanded(
child: ListView.separated(
itemBuilder: (context, index) {
if (index == 0) {
return _buildNameWidget(
context, index, 'images/controls_user.png', '张三');
} else if (index == 1) {
return _buildNameWidget(
context, index, 'images/controls_user.png', '李四');
} else if (index == 2) {
return _buildNameWidget(
context, index, 'images/controls_user.png', '王二');
} else if (index == 3) {
return _buildNameWidget(
context, index, 'images/controls_user.png', '麻子');
}
return null;
},
separatorBuilder: (context, index) {
return const Divider(
height: 1,
color: AppColors.greyLineColor,
);
},
itemCount: 5)),
SizedBox(
height: 20.h,
),
SubmitBtn(
btnName: '确定'.tr,
onClick: () {},
),
SizedBox(
height: 40.h,
)
],
);
}
Widget _buildNameWidget(context, index, imageName, getName) {
return GestureDetector(
child: Container(
height: 90.h,
color: Colors.white,
width: ScreenUtil().screenWidth,
child: Row(
children: [
SizedBox(
width: 30.w,
),
Image.asset(
imageName,
width: 36.w,
height: 36.w,
),
SizedBox(
width: 10.w,
),
Text(
getName,
style: TextStyle(fontSize: 22.sp, color: AppColors.blackColor),
),
Expanded(
child: SizedBox(
width: 20.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: 30.w,
)
],
),
),
onTap: () {
setState(() {
isNameSelect = !isNameSelect;
});
},
);
}
}