a,领锁,点击+号时,如果获取网络时间失败,不进入下一页,提示必须联网 b. 开锁时:有网络时间则同步,无网络则不同步时间 c. 同步时间功能:必须有网才同步时间,确定和通通锁不一致 2、修改登录、注册、修改密码选择跟当前ip不是用一个国家的时候,弹窗提示
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/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart';
|
||
import 'package:star_lock/mine/mineSet/lockGroup/lockGroupList/lockGroupList_state.dart';
|
||
import 'package:star_lock/tools/showTipView.dart';
|
||
|
||
import '../../../../../../appRouters.dart';
|
||
import '../../../../../../app_settings/app_colors.dart';
|
||
import '../../../../../../tools/commonItem.dart';
|
||
import '../../../../../../tools/titleAppBar.dart';
|
||
import '../../../../../../translations/trans_lib.dart';
|
||
import '../../../../tools/left_slide_actions.dart';
|
||
import '../../../../tools/noData.dart';
|
||
import 'lockGroupList_logic.dart';
|
||
|
||
class LockGroupListPage extends StatefulWidget {
|
||
const LockGroupListPage({Key? key}) : super(key: key);
|
||
|
||
@override
|
||
State<LockGroupListPage> createState() => _LockGroupListPageState();
|
||
}
|
||
|
||
class _LockGroupListPageState extends State<LockGroupListPage> {
|
||
final LockGroupListLogic logic = Get.put(LockGroupListLogic());
|
||
final LockGroupListState state = Get.find<LockGroupListLogic>().state;
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return Scaffold(
|
||
backgroundColor: AppColors.mainBackgroundColor,
|
||
appBar: TitleAppBar(
|
||
barTitle: TranslationLoader.lanKeys!.lockGroup!.tr,
|
||
haveBack: true,
|
||
actionsList: <Widget>[
|
||
IconButton(
|
||
icon: Image.asset(
|
||
'images/icon_add_white.png',
|
||
width: 36.w,
|
||
height: 36.w,
|
||
),
|
||
onPressed: () {
|
||
// 处理操作按钮的点击事件-添加锁分组
|
||
state.changeNameController.text = '';
|
||
// showCupertinoAlertDialog(context, true, 0);
|
||
ShowTipView().showTFViewAlertDialog(
|
||
state.changeNameController,
|
||
TranslationLoader.lanKeys!.createNewGroup!.tr,
|
||
TranslationLoader.lanKeys!.pleaseEnter!.tr, () {
|
||
//发送编辑钥匙名称请求
|
||
if (state.changeNameController.text.isNotEmpty) {
|
||
Navigator.of(context).pop();
|
||
logic.addLockGroupRequest();
|
||
} else {
|
||
logic.showToast(
|
||
TranslationLoader.lanKeys!.pleaseEnterAGroupName!.tr);
|
||
}
|
||
});
|
||
},
|
||
),
|
||
],
|
||
backgroundColor: AppColors.mainColor),
|
||
body: Column(
|
||
children: <Widget>[
|
||
Expanded(
|
||
child: Obx(() => state.itemDataList.value.isEmpty
|
||
? NoData()
|
||
: _buildMainUI())),
|
||
],
|
||
),
|
||
);
|
||
}
|
||
|
||
Widget _buildMainUI() {
|
||
for (int i = 0; i < state.itemDataList.value.length; i++) {
|
||
final GroupListItem itemData = state.itemDataList.value[i];
|
||
state.lockNum += itemData.lockList!.length;
|
||
}
|
||
return ListView.separated(
|
||
itemCount: state.itemDataList.value.length + 1,
|
||
itemBuilder: (BuildContext c, int index) {
|
||
if (index == state.itemDataList.value.length) {
|
||
return Center(
|
||
child: Column(
|
||
children: <Widget>[
|
||
SizedBox(
|
||
height: 20.h,
|
||
),
|
||
SizedBox(
|
||
height: 40.h,
|
||
child: Text(
|
||
'${TranslationLoader.lanKeys!.lockTrCount!.tr}:${state.lockNum.toString()}',
|
||
style: TextStyle(
|
||
color: AppColors.darkGrayTextColor, fontSize: 20.sp),
|
||
),
|
||
)
|
||
],
|
||
),
|
||
);
|
||
} else {
|
||
final GroupListItem itemData = state.itemDataList.value[index];
|
||
if (itemData.groupType == 0) {
|
||
state.ungrouped = itemData;
|
||
}
|
||
if (index < state.itemDataList.value.length) {
|
||
return LeftSlideActions(
|
||
key: Key(itemData.keyGroupId!.toString()),
|
||
actionsWidth: itemData.groupType != 0 ? 200.w : 0,
|
||
actions: itemData.groupType != 0
|
||
? <Widget>[
|
||
_buildEditBtn(itemData),
|
||
_buildDeleteBtn(itemData),
|
||
]
|
||
: <Widget>[],
|
||
decoration: const BoxDecoration(
|
||
borderRadius: BorderRadius.all(Radius.circular(1)),
|
||
),
|
||
child: CommonItem(
|
||
leftTitel: '${itemData.keyGroupName}(${itemData.lockList?.length})',
|
||
rightTitle: '',
|
||
allHeight: 70.h,
|
||
action: () {
|
||
Get.toNamed(Routers.lockItemListPage, arguments: <String, GroupListItem>{
|
||
'groupListItem': itemData,
|
||
'ungrouped': state.ungrouped
|
||
});
|
||
}),
|
||
);
|
||
}
|
||
return const SizedBox.shrink();
|
||
}
|
||
},
|
||
separatorBuilder: (BuildContext context, int index) {
|
||
return const Divider(
|
||
height: 1,
|
||
color: AppColors.greyLineColor,
|
||
);
|
||
});
|
||
}
|
||
|
||
Widget _buildDeleteBtn(GroupListItem groupListItem) {
|
||
return GestureDetector(
|
||
onTap: () {
|
||
// 省略: 弹出是否删除的确认对话框。
|
||
// showIosTipViewDialog(context, groupListItem);
|
||
ShowTipView().showIosTipWithContentDialog('分组下的锁将被移到未分组里'.tr, () {
|
||
logic.deleteLockGroupRequest(groupListItem.keyGroupId!);
|
||
});
|
||
},
|
||
child: Container(
|
||
width: 100.w,
|
||
color: const Color(0xFFF20101),
|
||
alignment: Alignment.center,
|
||
child: Text(
|
||
TranslationLoader.lanKeys!.delete!.tr,
|
||
style: const TextStyle(
|
||
fontSize: 16,
|
||
fontWeight: FontWeight.w500,
|
||
color: Colors.white,
|
||
height: 1,
|
||
),
|
||
),
|
||
),
|
||
);
|
||
}
|
||
|
||
Widget _buildEditBtn(GroupListItem groupListItem) {
|
||
return GestureDetector(
|
||
onTap: () {
|
||
// 编辑
|
||
state.changeNameController.text = groupListItem.keyGroupName!;
|
||
// showCupertinoAlertDialog(context, false, groupListItem.keyGroupId!);
|
||
|
||
ShowTipView().showTFViewAlertDialog(
|
||
state.changeNameController,
|
||
'修改名称'.tr,
|
||
TranslationLoader.lanKeys!.pleaseEnter!.tr, () {
|
||
if (state.changeNameController.text.isNotEmpty) {
|
||
Get.back();
|
||
logic.editLockGroupRequest(groupListItem.keyGroupId!);
|
||
} else {
|
||
logic.showToast(
|
||
TranslationLoader.lanKeys!.pleaseEnterAGroupName!.tr);
|
||
}
|
||
}, isShowSuffixIcon: true);
|
||
},
|
||
child: Container(
|
||
width: 100.w,
|
||
color: AppColors.mainColor,
|
||
alignment: Alignment.center,
|
||
child: Text(
|
||
'重命名'.tr,
|
||
style: const TextStyle(
|
||
fontSize: 16,
|
||
fontWeight: FontWeight.w500,
|
||
color: Colors.white,
|
||
height: 1,
|
||
),
|
||
),
|
||
),
|
||
);
|
||
}
|
||
}
|