import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/mine/mineSet/appUnlockNeedMobileNetworkingLock/selectLockListEntity.dart'; import '../../../app_settings/app_colors.dart'; import '../../../tools/commonItem.dart'; import '../../../tools/noData.dart'; import '../../../tools/submitBtn.dart'; import '../../../tools/titleAppBar.dart'; import '../../../translations/trans_lib.dart'; import 'appUnlockNeedMobileNetworkingLock_logic.dart'; class APPUnlockNeedMobileNetworkingLockPage extends StatefulWidget { const APPUnlockNeedMobileNetworkingLockPage({Key? key}) : super(key: key); @override State createState() => _APPUnlockNeedMobileNetworkingLockPageState(); } class _APPUnlockNeedMobileNetworkingLockPageState extends State { final logic = Get.put(AppUnlockNeedMobileNetworkingLockLogic()); final state = Get.find().state; @override void initState() { super.initState(); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( barTitle: TranslationLoader .lanKeys!.appUnlockRequiresMobilePhoneAccessToTheLock!.tr, haveBack: true, // actionsList: [ // IconButton( // onPressed: () {}, // icon: Image.asset( // "images/icon_bar_search.png", // width: 30.w, // height: 30.w, // )) // ], backgroundColor: AppColors.mainColor), body: Obx(() => state.lockItemList.value.isEmpty ? NoData() :Column( children: [ Container( padding: EdgeInsets.all(30.w), child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Expanded( child: Text( TranslationLoader.lanKeys! .appUnlockRequiresMobilePhoneAccessToTheLockTip!.tr, style: TextStyle(fontSize: 22.sp), )), ], ), ), CommonItem( leftTitel: TranslationLoader.lanKeys!.checkAll!.tr, rightTitle: "", allHeight: 70.h, isHaveLine: false, isHaveRightWidget: true, rightWidget: GestureDetector( onTap: () { state.isCheckAll.value = !state.isCheckAll.value; for(LockItemData lockItemData in state.lockItemList.value){ if(state.isCheckAll.value == true){ lockItemData.appUnlockOnline = 1; state.selectLockIdList.add(lockItemData.lockId); }else{ lockItemData.appUnlockOnline = 0; state.selectLockIdList = []; } } setState(() {}); }, child: Obx(() => Row( children: [ Image.asset( state.isCheckAll.value ? 'images/icon_round_select.png' : 'images/icon_round_unSelect.png', width: 30.w, height: 30.w, ), ]), ), )), SizedBox(height: 15.h), Expanded( child: ListView.builder( itemCount: state.lockItemList.value.length, itemBuilder: (c, index) { LockItemData itemData = state.lockItemList.value[index]; // if(state.isCheckAll.value == true){ // itemData.isCheck = true; // }else{ // itemData.isCheck = false; // } return _gatewatListItem(itemData); }), ), SubmitBtn( btnName: TranslationLoader.lanKeys!.sure!.tr, onClick: () { if (state.selectLockIdList.isNotEmpty) { logic.setAppUnlockMustOnlineRequest(); } else { logic.showToast("请选择需设置的锁"); } }), SizedBox( height: 40.h, ) ], ))); } Widget _gatewatListItem(LockItemData itemData) { return GestureDetector( onTap: () { setState(() { if (itemData.appUnlockOnline == 0) { itemData.appUnlockOnline = 1; state.selectLockIdList.add(itemData.lockId); } else { itemData.appUnlockOnline = 0; state.selectLockIdList.remove(itemData.lockId); } if(state.selectLockIdList.length == state.lockItemList.length){ state.isCheckAll.value = true; }else{ state.isCheckAll.value = false; } }); }, child: Container( height: 80.h, margin: const EdgeInsets.only(bottom: 2), padding: EdgeInsets.only(left: 10.w, right: 20.w, top: 20.h, bottom: 20.h), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10.w), ), child: Row( children: [ SizedBox( width: 15.w, ), Image.asset( itemData.appUnlockOnline == 1 ? 'images/icon_round_select.png' : 'images/icon_round_unSelect.png', width: 30.w, height: 30.w, ), SizedBox( width: 10.w, ), Text( itemData.lockAlias ?? "", style: TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w600), ) ], ), ), ); } }