Add presence indicator and wall sensor interface

This commit is contained in:
Mohammad Salameh
2024-04-19 17:47:49 +03:00
parent 822de1d9b5
commit d78394d259
4 changed files with 448 additions and 0 deletions

View File

@ -0,0 +1,349 @@
part of "wall_sensor_interface.dart";
class ParametersList extends StatelessWidget {
const ParametersList({
super.key,
required this.wallSensor,
});
final DeviceModel wallSensor;
@override
Widget build(BuildContext context) {
return Expanded(
flex: 7,
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
children: List.generate(
wallSensorButtons.length,
(index) {
if (index == 3) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
DefaultContainer(
padding: const EdgeInsets.symmetric(
vertical: 12, horizontal: 15),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
InkWell(
onTap: () {
showParameterDialog(
context,
'Motion Detection Sensitivity',
wallSensor,
5,
0,
10,
);
},
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.min,
children: [
const BodySmall(
text: 'Motion\nDetectionn\nSensitivity',
textAlign: TextAlign.center),
BodyLarge(
text: '5',
style: context.bodyLarge
.copyWith(fontWeight: FontsManager.bold),
),
],
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Container(
width: 1,
height: 45,
color: ColorsManager.greyColor,
),
),
Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const BodySmall(
text: 'Motionless\nDetection\nSensitivity',
textAlign: TextAlign.center),
BodyLarge(
text: '5',
style: context.bodyLarge.copyWith(
fontWeight: FontsManager.bold,
),
),
],
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Container(
width: 1,
height: 45,
color: ColorsManager.greyColor,
),
),
Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const BodySmall(
text: 'Far\nDetection',
textAlign: TextAlign.center),
BodyLarge(
text: '600cm',
style: context.bodyLarge.copyWith(
fontWeight: FontsManager.bold,
),
),
],
),
],
),
),
listItem(wallSensorButtons[index], context, wallSensor)
],
);
}
return listItem(wallSensorButtons[index], context, wallSensor);
},
),
),
),
);
}
final List<Map<String, Object?>> wallSensorButtons = const [
{
'icon': Assets.presenceSensorAssetsTime,
'title': 'Presence Time',
'value': 0,
'unit': 'min',
'page': null,
},
{
'icon': Assets.presenceSensorAssetsDistance,
'title': 'Current Distance',
'value': 279,
'unit': 'cm',
'dialog': null,
},
{
'icon': Assets.presenceSensorAssetsIlluminanceValue,
'title': 'Illuminance Value',
'value': 0,
'unit': 'Lux',
'page': null,
},
{
'icon': Assets.presenceSensorAssetsEmpty,
'title': 'Nobody Time',
'value': 10,
'unit': 'sec',
'dialog': null,
},
{
'icon': Assets.presenceSensorAssetsIndicator,
'title': 'Indicator',
'page': null,
},
{
'icon': Assets.presenceSensorAssetsRecord,
'title': 'Presence Record',
'page': null,
},
{
'icon': Assets.presenceSensorAssetsIlluminanceRecord,
'title': 'Illuminance Record',
'page': null,
},
];
}
Widget listItem(
Map<String, Object?> wallSensorButton,
BuildContext context,
DeviceModel wallSensor,
) {
return DefaultContainer(
margin: const EdgeInsets.only(bottom: 5),
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 20),
onTap: () {
if (wallSensorButton['page'] != null) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => wallSensorButton['page'] as Widget,
),
);
}
},
child: Row(
children: [
SvgPicture.asset(
wallSensorButton['icon'] as String,
),
const SizedBox(
width: 25,
),
BodyMedium(text: wallSensorButton['title'] as String),
if (wallSensorButton['value'] != null) const Spacer(),
if (wallSensorButton['value'] != null)
BodyMedium(
text: '${wallSensorButton['value']}${wallSensorButton['unit']}',
style: context.bodyMedium.copyWith(color: ColorsManager.greyColor),
),
if (wallSensorButton['value'] != null)
if (wallSensorButton['title'] == 'Indicator')
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Transform.scale(
scale: .8,
child: CupertinoSwitch(
value: false,
onChanged: (value) {},
applyTheme: true,
)),
],
),
),
// CustomSwitch(device: wallSensor),
if (wallSensorButton['title'] == 'Nobody Time')
const Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Icon(
Icons.arrow_forward_ios,
color: ColorsManager.greyColor,
size: 15,
),
],
),
],
),
);
}
showParameterDialog(
BuildContext context,
String title,
DeviceModel wallSensor,
int value,
int min,
int max,
) {
showDialog(
context: context,
builder: (context) => Dialog(
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20),
),
padding: const EdgeInsets.only(top: 20),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
BodyMedium(
text: title,
style: context.bodyMedium.copyWith(
color: ColorsManager.primaryColorWithOpacity,
fontWeight: FontsManager.extraBold,
),
),
Padding(
padding: const EdgeInsets.symmetric(
vertical: 15,
horizontal: 50,
),
child: Container(
height: 1,
width: double.infinity,
color: ColorsManager.greyColor,
),
),
Padding(
padding: const EdgeInsets.symmetric(
vertical: 10,
),
child: TitleMedium(
text: value.toString(),
style: context.titleMedium.copyWith(
color: Colors.black,
fontWeight: FontsManager.bold,
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// Icon(Icons.minus),
IconButton(
onPressed: () {
value--;
},
icon: const Icon(
Icons.remove,
color: Colors.grey,
),
),
Slider(
value: value.toDouble(),
onChanged: (value) {
// value = value;
},
min: 0,
max: 10,
label: value.toString(),
inactiveColor: ColorsManager.greyColor,
),
IconButton(
onPressed: () {
value++;
},
icon: const Icon(
Icons.add,
color: Colors.grey,
),
),
],
),
Container(
height: 1,
width: double.infinity,
color: ColorsManager.greyColor,
),
Row(
children: [
Expanded(
child: Center(
child: BodyMedium(
text: 'Cancel',
style: context.bodyMedium
.copyWith(color: ColorsManager.greyColor),
),
)),
Container(
height: 50,
width: 1,
color: ColorsManager.greyColor,
),
Expanded(
child: Center(
child: BodyMedium(
text: 'Confirm',
style: context.bodyMedium.copyWith(
color: ColorsManager.primaryColorWithOpacity),
),
)),
],
)
],
),
),
));
}

View File

@ -0,0 +1,29 @@
part of "wall_sensor_interface.dart";
class PresenceIndicator extends StatelessWidget {
const PresenceIndicator({super.key});
@override
Widget build(BuildContext context) {
return Expanded(
flex: 6,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SvgPicture.asset(
Assets.presenceSensorAssetsPresence,
width: 100,
height: 100,
),
const SizedBox(
height: 10,
),
BodyMedium(
text: 'Presence',
style: context.bodyMedium.copyWith(fontWeight: FontsManager.bold),
),
],
),
);
}
}

View File

@ -0,0 +1,68 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_svg/flutter_svg.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';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/title_medium.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/context_extension.dart';
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';
part "parameters_list.dart";
part "presence_indicator.dart";
class WallMountedInterface extends StatelessWidget {
const WallMountedInterface({super.key, required this.wallSensor});
final DeviceModel wallSensor;
@override
Widget build(BuildContext context) {
return AnnotatedRegion(
value: SystemUiOverlayStyle(
statusBarColor: ColorsManager.primaryColor.withOpacity(0.5),
statusBarIconBrightness: Brightness.light,
),
child: SafeArea(
child: Scaffold(
backgroundColor: ColorsManager.backgroundColor,
extendBodyBehindAppBar: true,
extendBody: true,
appBar: AppBar(
backgroundColor: Colors.transparent,
centerTitle: true,
title: BodyLarge(
text: wallSensor.name ?? "",
fontColor: ColorsManager.primaryColor,
fontWeight: FontsManager.bold,
),
),
body: Container(
width: MediaQuery.sizeOf(context).width,
height: MediaQuery.sizeOf(context).height,
padding: const EdgeInsets.all(Constants.defaultPadding),
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage(
Assets.imagesBackground,
),
fit: BoxFit.cover,
opacity: 0.4,
),
),
child: Column(
children: [
const PresenceIndicator(),
ParametersList(wallSensor: wallSensor),
],
),
),
),
),
);
}
}

View File

@ -11,6 +11,7 @@ import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_interface.dart';
import 'package:syncrow_app/features/devices/view/widgets/lights/light_interface.dart';
import 'package:syncrow_app/features/devices/view/widgets/presence_sensor/wall_sensor_interface.dart';
import 'package:syncrow_app/features/devices/view/widgets/smart_door/door_interface.dart';
import 'package:syncrow_app/features/devices/view/widgets/three_gang/three_gang_interface.dart';
import 'package:syncrow_app/features/shared_widgets/custom_switch.dart';
@ -85,6 +86,7 @@ void showDeviceInterface(DeviceModel device, BuildContext context) {
navigateToInterface(AcInterface(ac: device), context);
break;
case DeviceType.WallSensor:
navigateToInterface(WallMountedInterface(wallSensor: device), context);
break;
case DeviceType.CeilingSensor:
break;