Added latest changes and fixed issues and conflicts

This commit is contained in:
Abdullah Alassaf
2024-06-26 23:08:41 +03:00
8 changed files with 253 additions and 131 deletions
@@ -1,7 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
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';
@@ -9,6 +7,8 @@ import 'package:syncrow_app/features/devices/bloc/ceiling_bloc/ceiling_sensor_ev
import 'package:syncrow_app/features/devices/bloc/ceiling_bloc/ceiling_sensor_state.dart';
import 'package:syncrow_app/features/devices/model/ceiling_sensor_model.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/features/devices/view/widgets/device_appbar.dart';
import 'package:syncrow_app/features/devices/view/widgets/wall_sensor/wall_sensor_interface.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
@@ -20,8 +20,6 @@ import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
import 'package:syncrow_app/utils/resource_manager/constants.dart';
import 'package:syncrow_app/utils/resource_manager/font_manager.dart';
import '../device_appbar.dart';
class CeilingSensorInterface extends StatelessWidget {
const CeilingSensorInterface({super.key, required this.ceilingSensor});
final DeviceModel ceilingSensor;
@@ -51,12 +49,10 @@ class CeilingSensorInterface extends StatelessWidget {
backgroundColor: ColorsManager.backgroundColor,
extendBodyBehindAppBar: true,
extendBody: true,
appBar:DeviceAppbar(
appBar: DeviceAppbar(
deviceName: ceilingSensor.name!,
deviceUuid: ceilingSensor.uuid!,
),
body: Container(
width: MediaQuery.sizeOf(context).width,
height: MediaQuery.sizeOf(context).height,
@@ -77,85 +73,85 @@ class CeilingSensorInterface extends StatelessWidget {
: SafeArea(
child: Column(
children: [
const Spacer(),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// InkWell(
// onTap: () {
// if ((ceilingSensor.isOnline ?? false) == false) {
// ScaffoldMessenger.of(context).showSnackBar(
// const SnackBar(
// content: Text(
// 'Device is offline',
// ),
// backgroundColor: Colors.red,
// ),
// );
// return;
// }
// String controlCode = 'sensitivity';
// showDialog(
// context: context,
// builder: (context) => ParameterControlDialog(
// title: 'Sensitivity',
// sensor: ceilingSensor,
// controlCode: controlCode,
// value: ceilingSensor.status
// .firstWhere((element) => element.code == controlCode)
// .value as int,
// min: ceilingSensor.functions
// .firstWhere((element) => element.code == controlCode)
// .values
// ?.min ??
// 0,
// max: ceilingSensor.functions
// .firstWhere((element) => element.code == controlCode)
// .values
// ?.max ??
// 0,
// ),
// );
// },
// child:
// ),
SvgPicture.asset(
ceilingSensorModel.presenceState.toLowerCase() == 'motion'
? Assets.assetsIconsPresenceSensorAssetsPresenceSensorMotion
: Assets.assetsIconsPresenceSensorAssetsPresence,
width: 100,
height: 100,
// colorFilter: ColorFilter.mode(
// (ceilingSensor.isOnline ?? false)
// ? ColorsManager.primaryColor
// : Colors.grey.withOpacity(0.9),
// BlendMode.srcIn,
// ),
),
const SizedBox(
height: 10,
),
BodyMedium(
text: StringHelpers.toTitleCase(ceilingSensorModel.presenceState),
// (ceilingSensor.isOnline ?? false)
// ? StringHelpers.toTitleCase(ceilingSensor.status
// .firstWhere((element) =>
// element.code == 'presence_state')
// .value
// .toString())
// : "Offline",
style: context.bodyMedium.copyWith(
fontWeight: FontsManager.bold,
),
),
],
),
const Spacer(),
SingleChildScrollView(
Expanded(
flex: 1,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
// InkWell(
// onTap: () {
// if ((ceilingSensor.isOnline ?? false) == false) {
// ScaffoldMessenger.of(context).showSnackBar(
// const SnackBar(
// content: Text(
// 'Device is offline',
// ),
// backgroundColor: Colors.red,
// ),
// );
// return;
// }
// String controlCode = 'sensitivity';
// showDialog(
// context: context,
// builder: (context) => ParameterControlDialog(
// title: 'Sensitivity',
// sensor: ceilingSensor,
// controlCode: controlCode,
// value: ceilingSensor.status
// .firstWhere((element) => element.code == controlCode)
// .value as int,
// min: ceilingSensor.functions
// .firstWhere((element) => element.code == controlCode)
// .values
// ?.min ??
// 0,
// max: ceilingSensor.functions
// .firstWhere((element) => element.code == controlCode)
// .values
// ?.max ??
// 0,
// ),
// );
// },
// child:
// ),
SvgPicture.asset(
ceilingSensorModel.presenceState.toLowerCase() == 'motion'
? Assets.assetsIconsPresenceSensorAssetsPresenceSensorMotion
: Assets.assetsIconsPresenceSensorAssetsPresence,
width: 100,
height: 100,
// colorFilter: ColorFilter.mode(
// (ceilingSensor.isOnline ?? false)
// ? ColorsManager.primaryColor
// : Colors.grey.withOpacity(0.9),
// BlendMode.srcIn,
// ),
),
const SizedBox(
height: 10,
),
BodyMedium(
text:
StringHelpers.toTitleCase(ceilingSensorModel.presenceState),
// (ceilingSensor.isOnline ?? false)
// ? StringHelpers.toTitleCase(ceilingSensor.status
// .firstWhere((element) =>
// element.code == 'presence_state')
// .value
// .toString())
// : "Offline",
style: context.bodyMedium.copyWith(
fontWeight: FontsManager.bold,
),
),
],
),
),
Expanded(
flex: 2,
child: ListView(
children: [
DefaultContainer(
padding: const EdgeInsets.symmetric(
@@ -238,38 +234,82 @@ 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: [
SvgPicture.asset(
ceilingSensorButtons[index]['icon'] as String,
// width: 30,
// height: 50,
Row(
children: [
SvgPicture.asset(
ceilingSensorButtons()[index]['icon'] as String,
// width: 30,
// height: 50,
),
const SizedBox(
width: 25,
),
BodyMedium(
text: ceilingSensorButtons()[index]['title']
as String,
style: context.bodyMedium.copyWith(
fontWeight: FontsManager.bold,
),
),
],
),
const SizedBox(
width: 25,
),
BodyMedium(
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,
),
],
),
),
],
),
),
@@ -285,22 +325,53 @@ 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,
},
];
dynamic ceilingSensorButtons({
sensitivity_val = 0,
spaceType = 'Office',
maximumDistanceVal = '3.9m',
nobodyTimeVal = '1hr',
}) =>
[
{
'title': 'Space Type',
'icon': Assets.spaceTypeIcon,
'page': null,
'withArrow': true,
'val': spaceType
},
{
'title': 'Sensitivity',
'icon': Assets.sensitivityIcon,
'page': null,
'withArrow': true,
'val': sensitivity_val
},
{
'title': 'Maximum Distance',
'icon': Assets.maximumDistanceIcon,
'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,
},
];
}
@@ -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
@@ -12,7 +12,7 @@ class ParametersList extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Expanded(
flex: 7,
flex: 2,
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
@@ -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)
@@ -54,6 +53,7 @@ class ParametersList extends StatelessWidget {
0,
),
);
print('result=== $result');
if (result != null) {
BlocProvider.of<WallSensorBloc>(context)
.add(ChangeValueEvent(value: result, code: controlCode));
@@ -92,7 +92,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 +140,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)
@@ -10,7 +10,7 @@ class PresenceIndicator extends StatelessWidget {
// .value
// .toString();
return Expanded(
flex: 6,
flex: 1,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [