354 lines
11 KiB
Dart
Executable File
354 lines
11 KiB
Dart
Executable File
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get_utils/get_utils.dart';
|
|
import 'package:star_lock/appRouters.dart';
|
|
import 'package:star_lock/app_settings/app_colors.dart';
|
|
import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart';
|
|
import 'package:star_lock/tools/ExpandedListView.dart';
|
|
import 'package:star_lock/tools/noData.dart';
|
|
import 'package:star_lock/tools/submitBtn.dart';
|
|
|
|
class AuthorityManagementPage extends StatefulWidget {
|
|
const AuthorityManagementPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<StatefulWidget> createState() {
|
|
return _AuthorityManagementPageState();
|
|
}
|
|
}
|
|
|
|
class _AuthorityManagementPageState extends State<AuthorityManagementPage>
|
|
with SingleTickerProviderStateMixin {
|
|
TabController? _tabController;
|
|
final FlutterContactPicker _contactPicker = FlutterContactPicker();
|
|
late Contact _contact;
|
|
final TextEditingController _templateNameTf = TextEditingController();
|
|
bool isNameSelect = false;
|
|
bool isDeviceSelect = false;
|
|
int selectDeviceIndex = 0;
|
|
int selectNameIndex = 0;
|
|
List dataList = [];
|
|
|
|
List tabs = [
|
|
'姓名'.tr,
|
|
'设备'.tr
|
|
];
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
|
|
_tabController = TabController(length: 2, vsync: this);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return DefaultTabController(
|
|
length: 2,
|
|
child: Scaffold(
|
|
appBar: AppBar(
|
|
backgroundColor: AppColors.mainColor,
|
|
title: Text(
|
|
'批量授权'.tr,
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 28.sp,
|
|
fontWeight: FontWeight.w600),
|
|
),
|
|
elevation: 0,
|
|
leading: IconButton(
|
|
icon: const Icon(Icons.arrow_back_ios, color: Colors.white),
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
),
|
|
bottom: PreferredSize(
|
|
preferredSize: const Size.fromHeight(45),
|
|
child: Material(
|
|
color: Colors.white,
|
|
child: Theme(
|
|
data: ThemeData(
|
|
///点击的背景高亮颜色,处理阴影
|
|
highlightColor: Colors.transparent,
|
|
|
|
///点击水波纹颜色
|
|
splashColor: Colors.transparent,
|
|
),
|
|
child: TabBar(
|
|
controller: _tabController,
|
|
indicatorSize: TabBarIndicatorSize.label,
|
|
indicatorColor: AppColors.mainColor,
|
|
unselectedLabelColor: AppColors.blackColor,
|
|
labelColor: AppColors.mainColor,
|
|
// isScrollable: true,
|
|
tabs: tabs.map((e) => Tab(text: e)).toList()),
|
|
)),
|
|
),
|
|
),
|
|
body: TabBarView(controller: _tabController, children: <Widget>[
|
|
if (dataList.isEmpty) NoData() else _permissionNameList(),
|
|
if (dataList.isEmpty) NoData() else _permissionDeviceList()
|
|
])));
|
|
}
|
|
|
|
//姓名列表
|
|
Widget _permissionNameList() {
|
|
return Column(
|
|
children: <Widget>[
|
|
SizedBox(
|
|
height: 10.h,
|
|
),
|
|
Expanded(
|
|
child: ListView.separated(
|
|
itemBuilder: (BuildContext context, int index) {
|
|
if (index == 0) {
|
|
return _buildNameExpandedList(context, index, '张三');
|
|
} else if (index == 1) {
|
|
return _buildNameExpandedList(context, index, '李四');
|
|
} else if (index == 2) {
|
|
return _buildNameExpandedList(context, index, '王二');
|
|
} else {
|
|
return _buildNameExpandedList(context, index, '麻子');
|
|
}
|
|
},
|
|
separatorBuilder: (BuildContext context, int index) {
|
|
return const Divider(
|
|
height: 1,
|
|
color: AppColors.greyLineColor,
|
|
);
|
|
},
|
|
itemCount: 5)),
|
|
SizedBox(
|
|
height: 20.h,
|
|
),
|
|
_buildDeauthorizationBtn1(),
|
|
SizedBox(
|
|
height: 40.h,
|
|
)
|
|
],
|
|
);
|
|
}
|
|
|
|
//设备列表
|
|
Widget _permissionDeviceList() {
|
|
return Column(
|
|
children: <Widget>[
|
|
SizedBox(
|
|
height: 10.h,
|
|
),
|
|
Expanded(
|
|
child: ListView.separated(
|
|
itemBuilder: (BuildContext context, int index) {
|
|
if (index == 0) {
|
|
return _buildDeviceExpandedList(context, index, '大门锁');
|
|
} else if (index == 1) {
|
|
return _buildDeviceExpandedList(context, index, '办公室锁');
|
|
} else if (index == 2) {
|
|
return _buildDeviceExpandedList(context, index, '会议室锁');
|
|
} else {
|
|
return _buildDeviceExpandedList(context, index, '宴会厅锁');
|
|
}
|
|
},
|
|
separatorBuilder: (BuildContext context, int index) {
|
|
return const Divider(
|
|
height: 1,
|
|
color: AppColors.greyLineColor,
|
|
);
|
|
},
|
|
itemCount: 5)),
|
|
SizedBox(
|
|
height: 20.h,
|
|
),
|
|
_buildDeauthorizationBtn2(),
|
|
SizedBox(
|
|
height: 40.h,
|
|
)
|
|
],
|
|
);
|
|
}
|
|
|
|
//设备多层级列表
|
|
Widget _buildDeviceExpandedList(context, index, deviceName) {
|
|
return ExpandedListTile(
|
|
onTap: () {
|
|
},
|
|
// title: deviceName,
|
|
// imgName: 'images/icon_lock.png',
|
|
isShowBtn: true,
|
|
typeImgList: const [],
|
|
groupItem: GroupListItem(),
|
|
child: ListView.separated(
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
shrinkWrap: true,
|
|
itemCount: 10,
|
|
itemBuilder: (_, int index) {
|
|
if (index == 0) {
|
|
return _buildNameWidget(
|
|
context, index, 'images/icon_password.png', '张三');
|
|
} else if (index == 1) {
|
|
return _buildNameWidget(
|
|
context, index, 'images/icon_card.png', '李四');
|
|
} else if (index == 2) {
|
|
return _buildNameWidget(
|
|
context, index, 'images/icon_fingerprint.png', '王二');
|
|
} else if (index == 3) {
|
|
return _buildNameWidget(
|
|
context, index, 'images/icon_card.png', '麻子');
|
|
} else {
|
|
return null;
|
|
}
|
|
},
|
|
separatorBuilder: (BuildContext context, int index) {
|
|
return const Divider(
|
|
height: 1,
|
|
color: AppColors.greyLineColor,
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
//姓名多层级列表
|
|
Widget _buildNameExpandedList(context, index, deviceName) {
|
|
return ExpandedListTile(
|
|
onTap: () {
|
|
},
|
|
// title: deviceName,
|
|
// imgName: 'images/controls_user.png',
|
|
isShowBtn: true,
|
|
typeImgList: const ['images/icon_password.png', 'images/icon_card.png'],
|
|
groupItem: GroupListItem(),
|
|
child: ListView.separated(
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
shrinkWrap: true,
|
|
itemCount: 5,
|
|
itemBuilder: (_, 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,
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
//单个姓名行
|
|
Widget _buildNameWidget(context, index, imageName, getName) {
|
|
return GestureDetector(
|
|
child: Container(
|
|
height: 60.h,
|
|
color: Colors.white,
|
|
width: ScreenUtil().screenWidth,
|
|
child: Row(
|
|
children: <Widget>[
|
|
SizedBox(
|
|
width: 30.w,
|
|
),
|
|
Image.asset(
|
|
'images/controls_user.png',
|
|
width: 36.w,
|
|
height: 36.w,
|
|
),
|
|
SizedBox(
|
|
width: 10.w,
|
|
),
|
|
Text(
|
|
getName,
|
|
style: TextStyle(
|
|
fontSize: 20.sp, color: AppColors.darkGrayTextColor),
|
|
),
|
|
SizedBox(
|
|
width: 30.w,
|
|
)
|
|
],
|
|
),
|
|
),
|
|
onTap: () {
|
|
selectNameIndex = index;
|
|
setState(() {
|
|
if (selectNameIndex == index) {
|
|
isNameSelect = !isNameSelect;
|
|
}
|
|
});
|
|
},
|
|
);
|
|
}
|
|
|
|
//单个设备行
|
|
Widget _buildDeviceWidget(context, index, imageName, deviceName) {
|
|
return GestureDetector(
|
|
child: Container(
|
|
height: 60.h,
|
|
color: Colors.white,
|
|
width: ScreenUtil().screenWidth,
|
|
child: Row(
|
|
children: <Widget>[
|
|
SizedBox(
|
|
width: 30.w,
|
|
),
|
|
Image.asset(
|
|
imageName,
|
|
width: 36.w,
|
|
height: 36.w,
|
|
),
|
|
SizedBox(
|
|
width: 10.w,
|
|
),
|
|
Text(
|
|
deviceName,
|
|
style: TextStyle(
|
|
fontSize: 20.sp, color: AppColors.darkGrayTextColor),
|
|
),
|
|
SizedBox(
|
|
width: 30.w,
|
|
)
|
|
],
|
|
),
|
|
),
|
|
onTap: () {
|
|
selectDeviceIndex = index;
|
|
setState(() {
|
|
if (selectDeviceIndex == index) {
|
|
isDeviceSelect = !isDeviceSelect;
|
|
}
|
|
});
|
|
},
|
|
);
|
|
}
|
|
|
|
//去授权按钮-姓名
|
|
Widget _buildDeauthorizationBtn1() {
|
|
return SubmitBtn(
|
|
btnName: '去授权'.tr,
|
|
onClick: () {
|
|
Navigator.pushNamed(context, Routers.getDeviceListPage);
|
|
},
|
|
);
|
|
}
|
|
|
|
//去授权按钮-关联设备
|
|
Widget _buildDeauthorizationBtn2() {
|
|
return SubmitBtn(
|
|
btnName: '去授权'.tr,
|
|
onClick: () {
|
|
Navigator.pushNamed(context, Routers.getNameListPage);
|
|
},
|
|
);
|
|
}
|
|
}
|