Add scheduling category parameter to BuildScheduleView and update device control dialogs

This commit is contained in:
mohammad
2025-06-19 16:20:46 +03:00
parent 2267d95795
commit 0b774a6dfc
8 changed files with 368 additions and 116 deletions

View File

@ -83,12 +83,13 @@ class OneGangGlassSwitchControlView extends StatelessWidget with HelperResponsiv
),
GestureDetector(
onTap: () {
showDialog(
showDialog<void>(
context: context,
builder: (ctx) => BlocProvider.value(
value: BlocProvider.of<OneGangGlassSwitchBloc>(context),
child: BuildScheduleView(
deviceUuid: deviceId,
category: 'switch_1',
),
));
},

View File

@ -76,12 +76,13 @@ class WallLightDeviceControl extends StatelessWidget
),
GestureDetector(
onTap: () {
showDialog(
showDialog<void>(
context: context,
builder: (ctx) => BlocProvider.value(
value: BlocProvider.of<WallLightSwitchBloc>(context),
child: BuildScheduleView(
deviceUuid: deviceId,
category: 'switch_1',
),
));
},

View File

@ -12,8 +12,10 @@ import 'package:syncrow_web/pages/device_managment/water_heater/helper/add_sched
import 'package:syncrow_web/pages/device_managment/water_heater/models/water_heater_status_model.dart';
class BuildScheduleView extends StatelessWidget {
const BuildScheduleView({super.key, required this.deviceUuid});
const BuildScheduleView(
{super.key, required this.deviceUuid, required this.category});
final String deviceUuid;
final String category;
@override
Widget build(BuildContext context) {
@ -21,7 +23,7 @@ class BuildScheduleView extends StatelessWidget {
create: (_) => ScheduleBloc(
deviceId: deviceUuid,
)
..add(const ScheduleGetEvent(category: "switch_1"))
..add(ScheduleGetEvent(category: category))
..add(ScheduleFetchStatusEvent(deviceUuid)),
child: Dialog(
backgroundColor: Colors.white,

View File

@ -115,14 +115,14 @@ class ThreeGangGlassSwitchControlView extends StatelessWidget
onChange: (value) {},
showToggle: false,
),
GestureDetector(
onTap: () {
showDialog(
showDialog<void>(
context: context,
builder: (ctx) => BlocProvider.value(
value: BlocProvider.of<ThreeGangGlassSwitchBloc>(context),
child: BuildScheduleView(
category: 'switch_1',
deviceUuid: deviceId,
),
));
@ -160,26 +160,6 @@ class ThreeGangGlassSwitchControlView extends StatelessWidget
),
),
)
// ToggleWidget(
// value: true,
// code: '',
// deviceId: deviceId,
// label: 'Scheduling',
// icon: Assets.scheduling,
// onChange: (value) {
// print('Scheduling clicked');
// showDialog(
// context: context,
// builder: (ctx) => BlocProvider.value(
// value: BlocProvider.of<ThreeGangGlassSwitchBloc>(context),
// child: BuildScheduleView(
// deviceUuid: deviceId,
// ),
// ),
// );
// },
// showToggle: false,
// ),
],
);
}

View File

@ -98,12 +98,13 @@ class LivingRoomDeviceControlsView extends StatelessWidget
),
GestureDetector(
onTap: () {
showDialog(
showDialog<void>(
context: context,
builder: (ctx) => BlocProvider.value(
value: BlocProvider.of<LivingRoomBloc>(context),
child: BuildScheduleView(
deviceUuid: deviceId,
category: 'switch_1',
),
));
},
@ -128,13 +129,141 @@ class LivingRoomDeviceControlsView extends StatelessWidget
),
),
const Spacer(),
Text(
'Scheduling',
textAlign: TextAlign.center,
style: context.textTheme.titleMedium!.copyWith(
fontWeight: FontWeight.w400,
color: ColorsManager.blackColor,
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Wall Light',
style: context.textTheme.titleMedium!.copyWith(
fontWeight: FontWeight.w200,
fontSize: 12,
color: ColorsManager.blackColor,
),
),
Text(
'Scheduling',
style: context.textTheme.titleMedium!.copyWith(
fontWeight: FontWeight.w400,
color: ColorsManager.blackColor,
),
),
],
),
],
),
),
),
GestureDetector(
onTap: () {
showDialog<void>(
context: context,
builder: (ctx) => BlocProvider.value(
value: BlocProvider.of<LivingRoomBloc>(context),
child: BuildScheduleView(
deviceUuid: deviceId,
category: 'switch_2',
),
));
},
child: DeviceControlsContainer(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: 60,
height: 60,
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: ColorsManager.whiteColors,
),
margin: const EdgeInsets.symmetric(horizontal: 4),
padding: const EdgeInsets.all(12),
child: ClipOval(
child: SvgPicture.asset(
Assets.scheduling,
fit: BoxFit.fill,
),
),
),
const Spacer(),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Ceiling Light',
style: context.textTheme.titleMedium!.copyWith(
fontWeight: FontWeight.w200,
fontSize: 12,
color: ColorsManager.blackColor,
),
),
Text(
'Scheduling',
textAlign: TextAlign.center,
style: context.textTheme.titleMedium!.copyWith(
fontWeight: FontWeight.w400,
color: ColorsManager.blackColor,
),
),
],
),
],
),
),
),
GestureDetector(
onTap: () {
showDialog<void>(
context: context,
builder: (ctx) => BlocProvider.value(
value: BlocProvider.of<LivingRoomBloc>(context),
child: BuildScheduleView(
deviceUuid: deviceId,
category: 'switch_3',
),
));
},
child: DeviceControlsContainer(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: 60,
height: 60,
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: ColorsManager.whiteColors,
),
margin: const EdgeInsets.symmetric(horizontal: 4),
padding: const EdgeInsets.all(12),
child: ClipOval(
child: SvgPicture.asset(
Assets.scheduling,
fit: BoxFit.fill,
),
),
),
const Spacer(),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Spotlight',
style: context.textTheme.titleMedium!.copyWith(
fontWeight: FontWeight.w200,
fontSize: 12,
color: ColorsManager.blackColor,
),
),
Text(
'Scheduling',
textAlign: TextAlign.center,
style: context.textTheme.titleMedium!.copyWith(
fontWeight: FontWeight.w400,
color: ColorsManager.blackColor,
),
),
],
),
],
),

View File

@ -115,6 +115,52 @@ class TwoGangGlassSwitchControlView extends StatelessWidget
value: BlocProvider.of<TwoGangGlassSwitchBloc>(context),
child: BuildScheduleView(
deviceUuid: deviceId,
category: 'switch_1',
),
));
},
child: DeviceControlsContainer(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: 60,
height: 60,
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: ColorsManager.whiteColors,
),
margin: const EdgeInsets.symmetric(horizontal: 4),
padding: const EdgeInsets.all(12),
child: ClipOval(
child: SvgPicture.asset(
Assets.scheduling,
fit: BoxFit.fill,
),
),
),
const Spacer(),
Text(
'Scheduling',
textAlign: TextAlign.center,
style: context.textTheme.titleMedium!.copyWith(
fontWeight: FontWeight.w400,
color: ColorsManager.blackColor,
),
),
],
),
),
),
GestureDetector(
onTap: () {
showDialog(
context: context,
builder: (ctx) => BlocProvider.value(
value: BlocProvider.of<TwoGangGlassSwitchBloc>(context),
child: BuildScheduleView(
deviceUuid: deviceId,
category: 'switch_2',
),
));
},

View File

@ -43,92 +43,184 @@ class TwoGangDeviceControlView extends StatelessWidget
Widget _buildStatusControls(BuildContext context, TwoGangStatusModel status) {
return Center(
child: Wrap(
alignment: WrapAlignment.center,
spacing: 12,
runSpacing: 12,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: 200,
height: 120,
child: ToggleWidget(
value: status.switch1,
code: 'switch_1',
deviceId: deviceId,
label: 'Wall Light',
onChange: (value) {
context.read<TwoGangSwitchBloc>().add(TwoGangSwitchControl(
deviceId: deviceId,
code: 'switch_1',
value: value,
));
},
),
),
SizedBox(
width: 200,
height: 120,
child: ToggleWidget(
value: status.switch2,
code: 'switch_2',
deviceId: deviceId,
label: 'Ceiling Light',
onChange: (value) {
context.read<TwoGangSwitchBloc>().add(TwoGangSwitchControl(
deviceId: deviceId,
code: 'switch_2',
value: value,
));
},
),
),
SizedBox(
width: 200,
height: 120,
child: GestureDetector(
onTap: () {
showDialog(
context: context,
builder: (ctx) => BlocProvider.value(
value: BlocProvider.of<TwoGangSwitchBloc>(context),
child: BuildScheduleView(
deviceUuid: deviceId,
),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: 200,
height: 150,
child: ToggleWidget(
value: status.switch1,
code: 'switch_1',
deviceId: deviceId,
label: 'Wall Light',
onChange: (value) {
context.read<TwoGangSwitchBloc>().add(TwoGangSwitchControl(
deviceId: deviceId,
code: 'switch_1',
value: value,
));
},
child: DeviceControlsContainer(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: 60,
height: 60,
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: ColorsManager.whiteColors,
),
margin: const EdgeInsets.symmetric(horizontal: 4),
padding: const EdgeInsets.all(12),
child: ClipOval(
child: SvgPicture.asset(
Assets.scheduling,
fit: BoxFit.fill,
),
),
),
const Spacer(),
Text(
'Scheduling',
textAlign: TextAlign.center,
style: context.textTheme.titleMedium!.copyWith(
fontWeight: FontWeight.w400,
color: ColorsManager.blackColor,
),
),
],
},
),
),
),
const SizedBox(width: 10),
SizedBox(
width: 200,
height: 150,
child: ToggleWidget(
value: status.switch2,
code: 'switch_2',
deviceId: deviceId,
label: 'Ceiling Light',
onChange: (value) {
context.read<TwoGangSwitchBloc>().add(TwoGangSwitchControl(
deviceId: deviceId,
code: 'switch_2',
value: value,
));
},
),
),
],
),
const SizedBox(height: 20),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: 200,
height: 150,
child: GestureDetector(
onTap: () {
showDialog<void>(
context: context,
builder: (ctx) => BlocProvider.value(
value:
BlocProvider.of<TwoGangSwitchBloc>(context),
child: BuildScheduleView(
deviceUuid: deviceId,
category: 'switch_1',
),
));
},
child: DeviceControlsContainer(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: 60,
height: 60,
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: ColorsManager.whiteColors,
),
margin: const EdgeInsets.symmetric(horizontal: 4),
padding: const EdgeInsets.all(12),
child: ClipOval(
child: SvgPicture.asset(
Assets.scheduling,
fit: BoxFit.fill,
),
),
),
const Spacer(),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Wall Light',
textAlign: TextAlign.center,
style: context.textTheme.titleMedium!.copyWith(
fontWeight: FontWeight.w200,
color: ColorsManager.blackColor,
fontSize: 12),
),
Text(
'Scheduling',
textAlign: TextAlign.center,
style: context.textTheme.titleMedium!.copyWith(
fontWeight: FontWeight.w400,
color: ColorsManager.blackColor,
),
),
],
),
],
),
),
),
),
const SizedBox(width: 10),
SizedBox(
width: 200,
height: 150,
child: GestureDetector(
onTap: () {
showDialog<void>(
context: context,
builder: (ctx) => BlocProvider.value(
value:
BlocProvider.of<TwoGangSwitchBloc>(context),
child: BuildScheduleView(
deviceUuid: deviceId,
category: 'switch_2',
),
));
},
child: DeviceControlsContainer(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: 60,
height: 60,
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: ColorsManager.whiteColors,
),
margin: const EdgeInsets.symmetric(horizontal: 4),
padding: const EdgeInsets.all(12),
child: ClipOval(
child: SvgPicture.asset(
Assets.scheduling,
fit: BoxFit.fill,
),
),
),
const Spacer(),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Ceiling Light',
textAlign: TextAlign.center,
style: context.textTheme.titleMedium!.copyWith(
fontWeight: FontWeight.w200,
color: ColorsManager.blackColor,
fontSize: 12),
),
Text(
'Scheduling',
textAlign: TextAlign.center,
style: context.textTheme.titleMedium!.copyWith(
fontWeight: FontWeight.w400,
color: ColorsManager.blackColor,
),
),
],
),
],
),
),
),
),
],
)
],
),

View File

@ -76,12 +76,13 @@ class WaterHeaterDeviceControlView extends StatelessWidget
),
GestureDetector(
onTap: () {
showDialog(
showDialog<void>(
context: context,
builder: (ctx) => BlocProvider.value(
value: BlocProvider.of<WaterHeaterBloc>(context),
child: BuildScheduleView(
deviceUuid: device.uuid ?? '',
category: 'switch_1',
),
));
},