implemented ceiling and wall sensors, and bug fixes

This commit is contained in:
Abdullah Alassaf
2024-08-26 15:35:18 +03:00
parent 929b72d11a
commit afee0eb5b1
98 changed files with 920 additions and 671 deletions

View File

@ -0,0 +1,20 @@
import 'package:flutter/material.dart';
import 'package:syncrow_web/utils/color_manager.dart';
class DeviceControlsContainer extends StatelessWidget {
const DeviceControlsContainer({required this.child, super.key});
final Widget child;
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: ColorsManager.greyColor.withOpacity(0.2),
border: Border.all(color: ColorsManager.boxDivider),
),
padding: const EdgeInsets.all(16),
child: child,
);
}
}

View File

@ -43,27 +43,32 @@ class IncrementDecrementWidget extends StatelessWidget {
),
),
),
RichText(
text: TextSpan(
text: '',
children: [
TextSpan(
text: value,
style: TextStyle(
fontSize: 38,
color: ColorsManager.dialogBlueTitle,
fontWeight: FontWeight.bold,
),
Expanded(
child: FittedBox(
fit: BoxFit.scaleDown,
child: RichText(
text: TextSpan(
text: '',
children: [
TextSpan(
text: value,
style: TextStyle(
fontSize: 40,
color: ColorsManager.dialogBlueTitle,
fontWeight: FontWeight.bold,
),
),
TextSpan(
text: description,
style: TextStyle(
fontSize: 16,
color: descriptionColor ?? ColorsManager.blackColor,
fontWeight: FontWeight.bold,
),
),
],
),
TextSpan(
text: description,
style: TextStyle(
fontSize: 12,
color: descriptionColor ?? ColorsManager.blackColor,
fontWeight: FontWeight.bold,
),
),
],
),
),
),
Material(

View File

@ -0,0 +1,51 @@
import 'package:flutter/material.dart';
import 'package:syncrow_web/pages/device_managment/shared/device_controls_container.dart';
import 'package:syncrow_web/utils/color_manager.dart';
class PresenceDisplayValue extends StatelessWidget {
const PresenceDisplayValue(
{super.key, required this.value, required this.postfix, required this.description});
final String value;
final String postfix;
final String description;
@override
Widget build(BuildContext context) {
return DeviceControlsContainer(
child: Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
value,
style: Theme.of(context).textTheme.bodyLarge!.copyWith(
color: ColorsManager.dialogBlueTitle,
fontSize: 40,
fontWeight: FontWeight.w700),
),
Padding(
padding: const EdgeInsets.only(bottom: 10),
child: Text(
postfix,
style: Theme.of(context).textTheme.bodySmall!.copyWith(
color: ColorsManager.blackColor, fontSize: 16, fontWeight: FontWeight.w700),
),
),
],
),
Text(
description,
style: Theme.of(context).textTheme.bodySmall!.copyWith(
color: ColorsManager.blackColor, fontWeight: FontWeight.w400, fontSize: 16),
),
],
),
),
);
}
}

View File

@ -0,0 +1,34 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:syncrow_web/pages/device_managment/shared/device_controls_container.dart';
import 'package:syncrow_web/utils/color_manager.dart';
class PresenceStaticWidget extends StatelessWidget {
const PresenceStaticWidget({required this.icon, required this.description, super.key});
final String icon;
final String description;
@override
Widget build(BuildContext context) {
return DeviceControlsContainer(
child: Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SvgPicture.asset(
icon,
width: 60,
height: 60,
),
Text(
description,
style: Theme.of(context).textTheme.bodySmall!.copyWith(
color: ColorsManager.blackColor, fontWeight: FontWeight.w400, fontSize: 16),
),
],
),
),
);
}
}

View File

@ -0,0 +1,52 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_web/pages/device_managment/shared/device_controls_container.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
class PresenceState extends StatelessWidget {
const PresenceState({
super.key,
required this.value,
});
final String value;
@override
Widget build(BuildContext context) {
return DeviceControlsContainer(
child: Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
'Status:',
style: Theme.of(context).textTheme.bodySmall!.copyWith(
color: ColorsManager.blackColor, fontWeight: FontWeight.w400, fontSize: 10),
),
],
),
SvgPicture.asset(
value.toLowerCase() == 'motion'
? Assets.sensorMotionIcon
: value.toLowerCase() == 'presence'
? Assets.sensorPresenceIcon
: Assets.sensorVacantIcon,
width: 60,
height: 60,
),
Text(
value,
style: Theme.of(context).textTheme.bodySmall!.copyWith(
color: ColorsManager.blackColor, fontWeight: FontWeight.w400, fontSize: 16),
),
],
),
),
);
}
}

View File

@ -0,0 +1,94 @@
import 'package:flutter/material.dart';
import 'package:syncrow_web/pages/device_managment/shared/device_controls_container.dart';
import 'package:syncrow_web/pages/device_managment/shared/increament_decreament.dart';
import 'package:syncrow_web/utils/color_manager.dart';
class PresenceUpdateData extends StatefulWidget {
const PresenceUpdateData({
super.key,
required this.title,
required this.value,
required this.action,
required this.minValue,
required this.maxValue,
required this.steps,
this.description,
});
final String title;
final double value;
final double minValue;
final double maxValue;
final double steps;
final Function action;
final String? description;
@override
State<PresenceUpdateData> createState() => _CurrentTempState();
}
class _CurrentTempState extends State<PresenceUpdateData> {
late double _adjustedValue;
@override
void initState() {
super.initState();
_adjustedValue = _initialAdjustedValue(widget.value);
}
double _initialAdjustedValue(dynamic value) {
if (value is int || value is double) {
return value;
} else {
throw ArgumentError('Invalid value type: Expected int or double');
}
}
void _onValueChanged(double newValue) {
widget.action(newValue.toInt());
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
return DeviceControlsContainer(
child: Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.title,
style: Theme.of(context).textTheme.bodySmall!.copyWith(
color: ColorsManager.blackColor, fontWeight: FontWeight.w400, fontSize: 10),
),
IncrementDecrementWidget(
value: widget.value.toString(),
description: widget.description ?? '',
descriptionColor: ColorsManager.blackColor,
onIncrement: () {
if (_adjustedValue < widget.maxValue) {
setState(() {
_adjustedValue = _adjustedValue + widget.steps;
});
_onValueChanged(_adjustedValue);
}
},
onDecrement: () {
if (_adjustedValue > widget.minValue) {
setState(() {
_adjustedValue = _adjustedValue - widget.steps;
});
_onValueChanged(_adjustedValue);
}
}),
],
),
),
);
}
}