169 lines
5.1 KiB
Dart
Executable File
169 lines
5.1 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/mine/mineSet/transferGateway/selectGetewayList_state.dart';
|
|
|
|
import '../../../../appRouters.dart';
|
|
import '../../../../app_settings/app_colors.dart';
|
|
import '../../../../tools/titleAppBar.dart';
|
|
import '../../../tools/noData.dart';
|
|
import 'selectGetewayList_entity.dart';
|
|
import 'selectGetewayList_logic.dart';
|
|
|
|
class SelectGetewayListPage extends StatefulWidget {
|
|
const SelectGetewayListPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<SelectGetewayListPage> createState() => _SelectGetewayListPageState();
|
|
}
|
|
|
|
class _SelectGetewayListPageState extends State<SelectGetewayListPage> {
|
|
final SelectGetewayListLogic logic = Get.put(SelectGetewayListLogic());
|
|
final SelectGetewayListState state = Get.find<SelectGetewayListLogic>().state;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: AppColors.mainBackgroundColor,
|
|
appBar: TitleAppBar(
|
|
barTitle: '选择网关'.tr,
|
|
haveBack: true,
|
|
backgroundColor: AppColors.mainColor,
|
|
actionsList: <Widget>[
|
|
TextButton(
|
|
onPressed: () {
|
|
setState(() {
|
|
for (GetewayItemData element in state.getewayListData.value) {
|
|
if(state.isSelectAll == true){
|
|
state.isSelectAll = false;
|
|
element.select = 0;
|
|
}else{
|
|
state.isSelectAll = true;
|
|
element.select = 1;
|
|
}
|
|
}
|
|
});
|
|
},
|
|
child: Text(
|
|
'全选'.tr,
|
|
style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
|
))
|
|
],
|
|
),
|
|
body: Column(
|
|
children: <Widget>[
|
|
Expanded(child: _buildMainUI()),
|
|
SizedBox(
|
|
height: 20.h,
|
|
),
|
|
_buildNextBtn(),
|
|
SizedBox(
|
|
height: 64.h,
|
|
)
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildMainUI() {
|
|
return Obx(() => state.getewayListData.value.isNotEmpty ? ListView.separated(
|
|
itemCount: state.getewayListData.value.length,
|
|
separatorBuilder: (BuildContext context, int index) {
|
|
return Divider(
|
|
height: 1,
|
|
indent: 20.w,
|
|
endIndent: 20.w,
|
|
color: AppColors.greyLineColor,
|
|
);
|
|
},
|
|
itemBuilder: (BuildContext c, int index) {
|
|
GetewayItemData getewayItemData = state.getewayListData.value[index];
|
|
return _electronicKeyItem(getewayItemData, () {
|
|
setState(() {
|
|
if(getewayItemData.select == 1){
|
|
getewayItemData.select = 0;
|
|
}else{
|
|
getewayItemData.select = 1;
|
|
}
|
|
});
|
|
});
|
|
}): NoData());
|
|
}
|
|
|
|
Widget _electronicKeyItem(GetewayItemData getewayItemData, Function() action) {
|
|
return GestureDetector(
|
|
onTap: action,
|
|
child: Container(
|
|
color: Colors.white,
|
|
height: 80.h,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: <Widget>[
|
|
SizedBox(
|
|
width: 20.w,
|
|
),
|
|
GestureDetector(
|
|
child: Image.asset(
|
|
(getewayItemData.select == 1) ? 'images/icon_round_select.png' : 'images/icon_round_unSelect.png',
|
|
width: 30.w,
|
|
height: 30.w,
|
|
),
|
|
),
|
|
SizedBox(
|
|
width: 16.w,
|
|
),
|
|
Image.asset(
|
|
'images/getewayType_G2.png',
|
|
width: 50.w,
|
|
height: 50.w,
|
|
fit: BoxFit.fill,
|
|
),
|
|
SizedBox(
|
|
width: 16.w,
|
|
),
|
|
Text(getewayItemData.gatewayName!, style: TextStyle(fontSize: 24.sp),)
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildNextBtn() {
|
|
return GestureDetector(
|
|
child: Container(
|
|
color: AppColors.mainColor,
|
|
width: ScreenUtil().screenWidth,
|
|
height: 64.h,
|
|
child: TextButton(
|
|
onPressed: () async {
|
|
bool isCanNext = false;
|
|
List idList = [];
|
|
for (final GetewayItemData element in state.getewayListData.value) {
|
|
if(element.select == 1){
|
|
isCanNext = true;
|
|
idList.add(element.gatewayId);
|
|
}
|
|
}
|
|
if(isCanNext == false){
|
|
logic.showToast('请选择锁'.tr);
|
|
return;
|
|
}
|
|
final data = await Get.toNamed(Routers.recipientInformationPage, arguments: <String, Object>{
|
|
'idList':idList,
|
|
'isFromType':2,
|
|
});
|
|
if(data != null) {
|
|
logic.getGetewayListData();
|
|
}
|
|
},
|
|
child: Text(
|
|
'下一步'.tr,
|
|
style: TextStyle(fontSize: 24.sp, color: Colors.white),
|
|
)),
|
|
),
|
|
);
|
|
}
|
|
}
|