1,门锁日志页面完善新增(未完成)

2,完善监视部分逻辑
This commit is contained in:
Daisy 2024-01-11 09:41:19 +08:00
parent c2fd318087
commit 5ef4f42b39
6 changed files with 297 additions and 86 deletions

View File

@ -2,6 +2,7 @@ import 'dart:async';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_page.dart';
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_state.dart';
import 'package:star_lock/main/lockDetail/lockOperatingRecord/lockOperatingRecordGetLastRecordTime_entity.dart';
import 'package:star_lock/tools/toast.dart';

View File

@ -1,13 +1,13 @@
import 'package:cupertino_stepper/cupertino_stepper.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_advanced_calendar/flutter_advanced_calendar.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:gzx_dropdown_menu/gzx_dropdown_menu.dart';
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_logic.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart';
import '../../../app_settings/app_colors.dart';
import '../../../tools/custom_bottom_sheet.dart';
import '../../../tools/noData.dart';
import '../../../tools/storage.dart';
import '../../../tools/titleAppBar.dart';
import '../../../tools/toast.dart';
@ -24,8 +24,15 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> {
final logic = Get.put(DoorLockLogLogic());
final state = Get.find<DoorLockLogLogic>().state;
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(
@ -42,21 +49,6 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> {
onPressed: () async {
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
if (isDemoMode == false) {
// JhPopMenus.showLinePop(context, clickCallback: (index, selText) {
// print('选中index: $index');
// print('选中text: $selText');
// if (index == 0) {
// logic.mockNetworkDataRequest();
// } else if (index == 1) {
// logic.clearOperationRecordRequest();
// }
// }, listData: [
// {'text': '读取记录'},
// {'text': '清空记录'},
// {'text': '导出记录'},
// ]);
_openModalBottomSheet();
} else {
// Get.toNamed(Routers.seletLockTypePage);
Toast.show(msg: "演示模式");
@ -67,76 +59,268 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> {
),
body: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AdvancedCalendar(
controller: state.calendarControllerCustom,
events: state.events,
weekLineHeight: 50.0.h,
startWeekDay: 1,
innerDot: true,
keepLineSize: true,
calendarTextStyle: TextStyle(
fontSize: 22.sp,
fontWeight: FontWeight.w500,
height: 1.3125,
letterSpacing: 0,
Theme(
data: theme.copyWith(
textTheme: theme.textTheme.copyWith(
titleMedium: theme.textTheme.titleMedium!.copyWith(
fontSize: 16,
color: theme.colorScheme.secondary,
),
bodyLarge: theme.textTheme.bodyLarge!.copyWith(
fontSize: 14,
color: Colors.black54,
),
bodyMedium: theme.textTheme.bodyMedium!.copyWith(
fontSize: 12,
color: Colors.black87,
),
),
primaryColor: AppColors.mainColor,
highlightColor: Colors.yellow,
disabledColor: Colors.green,
),
headerStyle: TextStyle(
fontSize: 22.sp,
fontWeight: FontWeight.w500,
height: 1.3125,
letterSpacing: 0,
child: AdvancedCalendar(
controller: state.calendarControllerCustom,
events: state.events,
weekLineHeight: 48.0,
startWeekDay: 1,
innerDot: true,
keepLineSize: true,
calendarTextStyle: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.w400,
height: 1.3125,
letterSpacing: 0,
),
),
),
Stack(
key: state.stackKey,
children: <Widget>[
Column(
children: <Widget>[
_buildHeaderView(),
],
),
// GZXDropDownMenu目前只能在Stack内CustomScrollView和NestedScrollView
_buildDropDownMenu()
],
),
OrientationBuilder(
builder: (BuildContext context, Orientation orientation) {
switch (orientation) {
case Orientation.portrait:
return _buildStepper(StepperType.vertical);
case Orientation.landscape:
return _buildStepper(StepperType.horizontal);
default:
throw UnimplementedError(orientation.toString());
}
},
),
],
),
),
);
}
String getTypeIcon(int type) {
String title = 'images/controls_user.png';
switch (type) {
case 1:
//
title = 'images/controls_user.png';
break;
case 4:
//
title = 'images/icon_password.png';
break;
case 7:
// ic卡
title = 'images/icon_card.png';
break;
case 8:
//
title = 'images/icon_fingerprint.png';
break;
default:
break;
}
return title;
//GZXDropDownHeader
Widget _buildHeaderView() {
return GZXDropDownHeader(
//
items: [
GZXDropDownHeaderItem(state.dropDownDoorLockItem[0], iconSize: 36),
],
// GZXDropDownHeader对应第一父级Stack的key
stackKey: state.stackKey,
// controller用于控制menu的显示或隐藏
controller: state.dropdownMenuController,
// openEndDrawer
onItemTap: (index) {},
//
height: 46,
//
color: Colors.white,
//
style: TextStyle(
color: AppColors.darkGrayTextColor, fontSize: ScreenUtil().setSp(24)),
//
dropDownStyle: TextStyle(
fontSize: ScreenUtil().setSp(24),
color: AppColors.darkGrayTextColor,
),
//
iconSize: 20,
//
iconColor: AppColors.greyBackgroundColor,
//
iconDropDownColor: AppColors.mainColor,
);
}
Future _openModalBottomSheet() async {
showModalBottomSheet(
context: context,
shape: RoundedRectangleBorder(
borderRadius: BorderRadiusDirectional.circular(10)),
builder: (BuildContext context) {
return AlertBottomWidget(
topTitle: '',
items: const ['读取记录', '清空记录', '导出记录'],
chooseCallback: (value) {
int getSelectIndex = value;
if (getSelectIndex == 0) {
logic.mockNetworkDataRequest();
} else if (getSelectIndex == 1) {
logic.clearOperationRecordRequest();
}
},
);
});
//
Widget _buildDropDownMenu() {
return Obx(() => GZXDropDownMenu(
// controller用于控制menu的显示或隐藏
controller: state.dropdownMenuController,
//
animationMilliseconds: 300,
//
// maskColor: Theme.of(context).primaryColor.withOpacity(0.5),
// maskColor: Colors.red.withOpacity(0.5),
dropdownMenuChanging: (isShow, index) {},
dropdownMenuChanged: (isShow, index) {},
// _dropdownMenuController.hide();
menus: [
GZXDropdownMenuBuilder(
dropDownHeight: 44.0.h * state.eventSortConditions.value.length,
dropDownWidget: _buildConditionListWidget(
state.eventSortConditions.value, (value) {
state.selectGroupSortCondition = value;
state.dropDownDoorLockItem[0] =
state.selectGroupSortCondition.name;
})),
],
));
}
_buildConditionListWidget(
items, void Function(SortCondition sortCondition) itemOnTap) {
return Container(
color: Colors.white,
child: ListView.separated(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
scrollDirection: Axis.vertical,
itemCount: items.length,
// item
separatorBuilder: (BuildContext context, int index) =>
const Divider(height: 1.0),
// 线
itemBuilder: (BuildContext context, int index) {
return gestureDetector(items, index, itemOnTap, context);
},
),
);
}
GestureDetector gestureDetector(
items,
int index,
void Function(SortCondition sortCondition) itemOnTap,
BuildContext context) {
SortCondition goodsSortCondition = items[index];
return GestureDetector(
onTap: () {
for (var value in items) {
value.isSelected = false;
}
goodsSortCondition.isSelected = true;
itemOnTap(goodsSortCondition);
},
child: SizedBox(
height: 44.h,
child: Center(
child: Obx(() => Text(
goodsSortCondition.name,
style: TextStyle(
color: goodsSortCondition.isSelected
? AppColors.mainColor
: Colors.black,
),
)),
),
));
}
CupertinoStepper _buildStepper(StepperType type) {
final canCancel = state.currentStep.value > 0;
final canContinue = state.currentStep.value < 3;
return CupertinoStepper(
type: type,
currentStep: state.currentStep.value,
onStepTapped: (step) => setState(() => state.currentStep.value = step),
onStepCancel:
canCancel ? () => setState(() => --state.currentStep.value) : null,
onStepContinue:
canContinue ? () => setState(() => ++state.currentStep.value) : null,
steps: [
for (var i = 0; i < 3; ++i)
_buildStep(
title: const Text(''),
isActive: i == state.currentStep.value,
state: i == state.currentStep.value
? StepState.editing
: i < state.currentStep.value
? StepState.complete
: StepState.indexed,
),
// _buildStep(
// title: Text('Error'),
// state: StepState.error,
// ),
// _buildStep(
// title: Text('Disabled'),
// state: StepState.disabled,
// )
],
);
}
Step _buildStep({
required Widget title,
StepState state = StepState.indexed,
bool isActive = false,
}) {
return Step(
title: title,
subtitle: const Text('10:45 有人出现在门口'),
state: state,
isActive: isActive,
content: LimitedBox(
maxWidth: 300,
maxHeight: 300,
child: Container(color: CupertinoColors.systemGrey),
),
);
}
}
String getTypeIcon(int type) {
String title = 'images/controls_user.png';
switch (type) {
case 1:
//
title = 'images/controls_user.png';
break;
case 4:
//
title = 'images/icon_password.png';
break;
case 7:
// ic卡
title = 'images/icon_card.png';
break;
case 8:
//
title = 'images/icon_fingerprint.png';
break;
default:
break;
}
return title;
}
class SortCondition {
String name;
bool isSelected;
SortCondition({
required this.name,
required this.isSelected,
});
}

View File

@ -1,5 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_advanced_calendar/flutter_advanced_calendar.dart';
import 'package:get/get.dart';
import 'package:gzx_dropdown_menu/gzx_dropdown_menu.dart';
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_page.dart';
import '../../lockMian/entity/lockListInfo_entity.dart';
import '../electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart';
@ -9,11 +12,25 @@ class DoorLockLogState {
final lockOperatingRecordListData = <KeyRecordDataItem>[].obs;
final calendarControllerToday = AdvancedCalendarController.today();
final calendarControllerCustom =
AdvancedCalendarController(DateTime(2024, 01, 09));
AdvancedCalendarController(DateTime(2024, 01, 10));
final events = <DateTime>[
DateTime.now(),
DateTime(2024, 10, 10),
];
final eventSortConditions = [
SortCondition(name: '全部事件', isSelected: true),
SortCondition(name: '门锁异常', isSelected: false),
SortCondition(name: '有人出现', isSelected: false),
SortCondition(name: '有人按门铃', isSelected: false),
SortCondition(name: '一次性密码开门', isSelected: false)
].obs;
final List dropDownDoorLockItem = ['全部事件'];
final GZXDropdownMenuController dropdownMenuController =
GZXDropdownMenuController();
final scaffoldKey = GlobalKey<ScaffoldState>();
final GlobalKey stackKey = GlobalKey();
late SortCondition selectGroupSortCondition = eventSortConditions.value[0];
var currentStep = 0.obs;
DoorLockLogState() {
keyInfos.value = Get.arguments["keyInfo"];

View File

@ -27,6 +27,11 @@ class _RealTimePicturePageState extends State<RealTimePicturePage>
void initState() {
super.initState();
//
Timer(const Duration(seconds: 30), () {
Get.back();
});
state.animationController =
AnimationController(duration: const Duration(seconds: 1), vsync: this);
state.animationController.repeat();
@ -373,6 +378,7 @@ class _RealTimePicturePageState extends State<RealTimePicturePage>
void _handleFailure() {
//
state.animationController.stop();
state.realTimePicTimer.cancel();
}
@override

View File

@ -197,16 +197,16 @@ class CommandUDPReciverManager {
//
print("对方结束监视");
} else {
//
//
print("结束监视反馈");
}
Toast.show(msg: "对方已结束监视");
UDPTalkClass().status = 0;
UDPTalkClass().isBeCall = false;
UDPTalkClass().stopLocalAudio();
CallTalk().stopPcmSound();
eventBus.fire(GetUDPStatusRefreshUI(UDPTalkClass().status));
Get.back();
// Toast.show(msg: "对方已结束监视");
// UDPTalkClass().status = 0;
// UDPTalkClass().isBeCall = false;
// UDPTalkClass().stopLocalAudio();
// CallTalk().stopPcmSound();
// eventBus.fire(GetUDPStatusRefreshUI(UDPTalkClass().status));
// Get.back();
}
break;
default:

View File

@ -135,6 +135,9 @@ dependencies:
#监听网络连接状态
connectivity_plus: ^5.0.2
flutter_advanced_calendar: ^1.4.1
#下拉选择菜单框
gzx_dropdown_menu: ^3.1.0
cupertino_stepper: ^0.2.1
dev_dependencies:
flutter_test: