mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 18:16:21 +00:00
Sensitivity & Ceiling Sensor ui
This commit is contained in:
@ -0,0 +1,60 @@
|
||||
|
||||
|
||||
|
||||
import 'package:syncrow_app/generated/assets.dart';
|
||||
|
||||
dynamic ceilingSensorButtons({
|
||||
sensitivity_val = 0,
|
||||
spaceType='Office',
|
||||
maximumDistanceVal='3.9m',
|
||||
nobodyTimeVal='1hr',
|
||||
}) => [
|
||||
{
|
||||
'title': 'Space Type',
|
||||
'icon': Assets.space_type_icon,
|
||||
'page': null,
|
||||
'withArrow':true,
|
||||
'val':spaceType
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
'title': 'Sensitivity',
|
||||
'icon': Assets.sensitivity,
|
||||
'page': null,
|
||||
'withArrow':true,
|
||||
'val':sensitivity_val
|
||||
|
||||
},
|
||||
{
|
||||
'title': 'Maximum Distance',
|
||||
'icon': Assets.maximum_distance,
|
||||
'page': null,
|
||||
'withArrow':true,
|
||||
'val':maximumDistanceVal,
|
||||
|
||||
},
|
||||
{
|
||||
'title': 'Nobody Time',
|
||||
'icon': Assets.assetsIconsPresenceSensorAssetsEmpty,
|
||||
'page': null,
|
||||
'withArrow':true,
|
||||
'val':nobodyTimeVal,
|
||||
},
|
||||
{
|
||||
'title': 'Induction History',
|
||||
'icon': Assets.assetsIconsPresenceSensorAssetsInductionRecording,
|
||||
'page': null,
|
||||
'withArrow':false,
|
||||
|
||||
|
||||
},
|
||||
{
|
||||
'title': 'Help Description',
|
||||
'icon': Assets.assetsIconsPresenceSensorAssetsHelpDescription,
|
||||
'page': null,
|
||||
'withArrow':false,
|
||||
|
||||
|
||||
},
|
||||
];
|
@ -1,3 +1,4 @@
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@ -5,9 +6,13 @@ import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/ceiling_bloc/ceiling_sensor_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/ceiling_bloc/ceiling_sensor_buttons.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/ceiling_bloc/ceiling_sensor_event.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/ceiling_bloc/ceiling_sensor_state.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/wall_sensor_bloc/wall_sensor_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/model/ceiling_sensor_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
||||
@ -21,6 +26,7 @@ import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/font_manager.dart';
|
||||
|
||||
import '../device_appbar.dart';
|
||||
import '../wall_sensor/wall_sensor_interface.dart';
|
||||
|
||||
class CeilingSensorInterface extends StatelessWidget {
|
||||
const CeilingSensorInterface({super.key, required this.ceilingSensor});
|
||||
@ -35,8 +41,8 @@ class CeilingSensorInterface extends StatelessWidget {
|
||||
create: (context) =>
|
||||
CeilingSensorBloc(deviceId: ceilingSensor.uuid ?? '')..add(InitialEvent()),
|
||||
child: BlocBuilder<CeilingSensorBloc, CeilingSensorState>(builder: (context, state) {
|
||||
CeilingSensorModel ceilingSensorModel =
|
||||
CeilingSensorModel(presenceState: 'none', sensitivity: 1, checkingResult: '');
|
||||
|
||||
CeilingSensorModel ceilingSensorModel = CeilingSensorModel(presenceState: 'none', sensitivity: 1, checkingResult: '');
|
||||
if (state is UpdateState) {
|
||||
ceilingSensorModel = state.ceilingSensorModel;
|
||||
} else if (state is LoadingNewSate) {
|
||||
@ -55,8 +61,6 @@ class CeilingSensorInterface extends StatelessWidget {
|
||||
deviceName: ceilingSensor.name!,
|
||||
deviceUuid: ceilingSensor.uuid!,
|
||||
),
|
||||
|
||||
|
||||
body: Container(
|
||||
width: MediaQuery.sizeOf(context).width,
|
||||
height: MediaQuery.sizeOf(context).height,
|
||||
@ -119,7 +123,6 @@ class CeilingSensorInterface extends StatelessWidget {
|
||||
// },
|
||||
// child:
|
||||
// ),
|
||||
|
||||
SvgPicture.asset(
|
||||
ceilingSensorModel.presenceState.toLowerCase() == 'motion'
|
||||
? Assets.assetsIconsPresenceSensorAssetsPresenceSensorMotion
|
||||
@ -238,26 +241,46 @@ class CeilingSensorInterface extends StatelessWidget {
|
||||
height: 15,
|
||||
),
|
||||
...List.generate(
|
||||
ceilingSensorButtons.length,
|
||||
ceilingSensorButtons().length,
|
||||
(index) => DefaultContainer(
|
||||
margin: const EdgeInsets.only(bottom: 5),
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 12, horizontal: 20),
|
||||
onTap: () {
|
||||
if (ceilingSensorButtons[index]['page'] != null) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
ceilingSensorButtons[index]['page'] as Widget,
|
||||
),
|
||||
);
|
||||
onTap: () async {
|
||||
if( ceilingSensorButtons()[index]['title']=='Sensitivity'){
|
||||
final result =
|
||||
await showDialog(context: context, builder: (context) {
|
||||
return ParameterControlDialog(
|
||||
title: ceilingSensorButtons()[index]['title'].toString(),
|
||||
sensor: ceilingSensor,
|
||||
value: ceilingSensorModel.sensitivity,
|
||||
min: 0,
|
||||
max: 10,
|
||||
);
|
||||
},);
|
||||
if (result != null) {
|
||||
|
||||
BlocProvider.of<CeilingSensorBloc>(context)
|
||||
.add(ChangeValueEvent(value: result, code: 'sensitivity'));
|
||||
}
|
||||
}
|
||||
|
||||
// if (ceilingSensorButtons[index]['page'] != null) {
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// MaterialPageRoute(
|
||||
// builder: (context) =>
|
||||
// ceilingSensorButtons[index]['page'] as Widget,
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(children: [
|
||||
SvgPicture.asset(
|
||||
ceilingSensorButtons[index]['icon'] as String,
|
||||
ceilingSensorButtons()[index]['icon'] as String,
|
||||
// width: 30,
|
||||
// height: 50,
|
||||
),
|
||||
@ -265,11 +288,25 @@ class CeilingSensorInterface extends StatelessWidget {
|
||||
width: 25,
|
||||
),
|
||||
BodyMedium(
|
||||
text: ceilingSensorButtons[index]['title'] as String,
|
||||
text: ceilingSensorButtons()[index]['title'] as String,
|
||||
style: context.bodyMedium.copyWith(
|
||||
fontWeight: FontsManager.bold,
|
||||
),
|
||||
),
|
||||
],),
|
||||
|
||||
if(ceilingSensorButtons()[index]['withArrow']==true)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Text(ceilingSensorButtons(sensitivity_val:ceilingSensorModel.sensitivity.toString() )[index]['val'].toString()),
|
||||
const Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
color: ColorsManager.greyColor,
|
||||
size: 15,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -286,21 +323,3 @@ class CeilingSensorInterface extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
var ceilingSensorButtons = [
|
||||
{
|
||||
'title': 'Parameter Settings',
|
||||
'icon': Assets.assetsIconsPresenceSensorAssetsParameterSettings,
|
||||
'page': null,
|
||||
},
|
||||
{
|
||||
'title': 'Induction History',
|
||||
'icon': Assets.assetsIconsPresenceSensorAssetsInductionRecording,
|
||||
'page': null,
|
||||
},
|
||||
{
|
||||
'title': 'Help Description',
|
||||
'icon': Assets.assetsIconsPresenceSensorAssetsHelpDescription,
|
||||
'page': null,
|
||||
},
|
||||
];
|
||||
|
@ -6,7 +6,6 @@ class ParameterControlDialog extends StatefulWidget {
|
||||
final int value;
|
||||
final int min;
|
||||
final int max;
|
||||
final String controlCode;
|
||||
|
||||
const ParameterControlDialog({
|
||||
super.key,
|
||||
@ -15,7 +14,6 @@ class ParameterControlDialog extends StatefulWidget {
|
||||
required this.value,
|
||||
required this.min,
|
||||
required this.max,
|
||||
required this.controlCode,
|
||||
});
|
||||
|
||||
@override
|
||||
|
@ -40,7 +40,6 @@ class ParametersList extends StatelessWidget {
|
||||
builder: (context) => ParameterControlDialog(
|
||||
title: 'Motion Detection Sensitivity',
|
||||
sensor: wallSensor,
|
||||
controlCode: controlCode,
|
||||
value: presenceSensorsModel.motionSensitivity,
|
||||
min: wallSensor.functions
|
||||
.firstWhere((element) => element.code == controlCode)
|
||||
@ -52,8 +51,10 @@ class ParametersList extends StatelessWidget {
|
||||
.values
|
||||
?.max ??
|
||||
0,
|
||||
|
||||
),
|
||||
);
|
||||
print('result=== $result');
|
||||
if (result != null) {
|
||||
BlocProvider.of<WallSensorBloc>(context)
|
||||
.add(ChangeValueEvent(value: result, code: controlCode));
|
||||
@ -92,7 +93,6 @@ class ParametersList extends StatelessWidget {
|
||||
builder: (context) => ParameterControlDialog(
|
||||
title: 'Motionless Detection Sensitivity',
|
||||
sensor: wallSensor,
|
||||
controlCode: controlCode,
|
||||
value: presenceSensorsModel.motionlessSensitivity,
|
||||
min: wallSensor.functions
|
||||
.firstWhere((element) => element.code == controlCode)
|
||||
@ -141,13 +141,13 @@ class ParametersList extends StatelessWidget {
|
||||
if ((wallSensor.isOnline ?? false) == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
String controlCode = 'far_detection';
|
||||
final result = await showDialog(
|
||||
context: context,
|
||||
builder: (context) => ParameterControlDialog(
|
||||
title: 'Far Detection',
|
||||
sensor: wallSensor,
|
||||
controlCode: controlCode,
|
||||
value: presenceSensorsModel.farDetection,
|
||||
min: wallSensor.functions
|
||||
.firstWhere((element) => element.code == controlCode)
|
||||
|
Reference in New Issue
Block a user