204 lines
7.2 KiB
Dart
Executable File
204 lines
7.2 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/appUnlockNeedMobileNetworkingLock/appUnlockNeedMobileNetworkingLock_state.dart';
|
|
import 'package:star_lock/mine/mineSet/appUnlockNeedMobileNetworkingLock/selectLockListEntity.dart';
|
|
|
|
import '../../../app_settings/app_colors.dart';
|
|
import '../../../tools/commonItem.dart';
|
|
import '../../../tools/keySearchWidget.dart';
|
|
import '../../../tools/noData.dart';
|
|
import '../../../tools/storage.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<APPUnlockNeedMobileNetworkingLockPage> createState() =>
|
|
_APPUnlockNeedMobileNetworkingLockPageState();
|
|
}
|
|
|
|
class _APPUnlockNeedMobileNetworkingLockPageState extends State<APPUnlockNeedMobileNetworkingLockPage> {
|
|
final AppUnlockNeedMobileNetworkingLockLogic logic = Get.put(AppUnlockNeedMobileNetworkingLockLogic());
|
|
final AppUnlockNeedMobileNetworkingLockState state = Get.find<AppUnlockNeedMobileNetworkingLockLogic>().state;
|
|
|
|
Future<void> getHttpData() async {
|
|
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
|
if (isDemoMode == false) {
|
|
logic.mockNetworkDataRequest().then((SelectLockListEntity value) {
|
|
setState(() {});
|
|
});
|
|
}
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
|
|
getHttpData();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: AppColors.mainBackgroundColor,
|
|
resizeToAvoidBottomInset: false,
|
|
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: <Widget>[
|
|
KeySearchWidget(
|
|
editingController: state.searchController,
|
|
onSubmittedAction: () {
|
|
state.lockItemList.value = [];
|
|
logic.mockNetworkDataRequest();
|
|
},
|
|
),
|
|
Container(
|
|
padding: EdgeInsets.all(15.w),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: <Widget>[
|
|
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(final 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: <Widget>[
|
|
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: (BuildContext c, int index) {
|
|
final 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: <Widget>[
|
|
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,
|
|
),
|
|
Expanded(child: Text(
|
|
itemData.lockAlias ?? '',
|
|
style: TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w600),
|
|
)),
|
|
// Text(
|
|
// itemData.lockAlias ?? '',
|
|
// style: TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w600),
|
|
// )
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|