mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
push SOS device
This commit is contained in:
@ -192,7 +192,7 @@ mixin RouteControlsBasedCode {
|
|||||||
);
|
);
|
||||||
case 'SOS':
|
case 'SOS':
|
||||||
return SOSBatchControlView(
|
return SOSBatchControlView(
|
||||||
deviceIds: devices.where((e) => (e.productType == 'sos')).map((e) => e.uuid!).toList(),
|
deviceIds: devices.where((e) => (e.productType == 'SOS')).map((e) => e.uuid!).toList(),
|
||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
return const SizedBox();
|
return const SizedBox();
|
||||||
|
@ -6,6 +6,7 @@ import 'package:syncrow_web/pages/device_managment/garage_door/bloc/garage_door_
|
|||||||
import 'package:syncrow_web/pages/device_managment/garage_door/helper/garage_door_helper.dart';
|
import 'package:syncrow_web/pages/device_managment/garage_door/helper/garage_door_helper.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/garage_door/models/garage_door_model.dart';
|
import 'package:syncrow_web/pages/device_managment/garage_door/models/garage_door_model.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/garage_door/widgets/schedule_garage_view.dart';
|
import 'package:syncrow_web/pages/device_managment/garage_door/widgets/schedule_garage_view.dart';
|
||||||
|
import 'package:syncrow_web/pages/device_managment/shared/icon_name_status_container.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/shared/table/report_table.dart';
|
import 'package:syncrow_web/pages/device_managment/shared/table/report_table.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/shared/toggle_widget.dart';
|
import 'package:syncrow_web/pages/device_managment/shared/toggle_widget.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
@ -13,10 +14,7 @@ import 'package:syncrow_web/utils/constants/assets.dart';
|
|||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
||||||
|
|
||||||
import '../../main_door_sensor/view/main_door_control_view.dart';
|
class GarageDoorControlView extends StatelessWidget with HelperResponsiveLayout {
|
||||||
|
|
||||||
class GarageDoorControlView extends StatelessWidget
|
|
||||||
with HelperResponsiveLayout {
|
|
||||||
final String deviceId;
|
final String deviceId;
|
||||||
|
|
||||||
const GarageDoorControlView({required this.deviceId, super.key});
|
const GarageDoorControlView({required this.deviceId, super.key});
|
||||||
@ -24,8 +22,7 @@ class GarageDoorControlView extends StatelessWidget
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (context) => GarageDoorBloc(deviceId: deviceId)
|
create: (context) => GarageDoorBloc(deviceId: deviceId)..add(GarageDoorInitialEvent(deviceId)),
|
||||||
..add(GarageDoorInitialEvent(deviceId)),
|
|
||||||
child: BlocBuilder<GarageDoorBloc, GarageDoorState>(
|
child: BlocBuilder<GarageDoorBloc, GarageDoorState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
if (state is GarageDoorLoadingState) {
|
if (state is GarageDoorLoadingState) {
|
||||||
@ -37,9 +34,7 @@ class GarageDoorControlView extends StatelessWidget
|
|||||||
garageDoorSensor: true,
|
garageDoorSensor: true,
|
||||||
onRowTap: (index) {},
|
onRowTap: (index) {},
|
||||||
onClose: () {
|
onClose: () {
|
||||||
context
|
context.read<GarageDoorBloc>().add(BackToGarageDoorGridViewEvent());
|
||||||
.read<GarageDoorBloc>()
|
|
||||||
.add(BackToGarageDoorGridViewEvent());
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else if (state is GarageDoorLoadedState) {
|
} else if (state is GarageDoorLoadedState) {
|
||||||
@ -80,10 +75,7 @@ class GarageDoorControlView extends StatelessWidget
|
|||||||
icon: status.switch1 ? Assets.openedDoor : Assets.closedDoor,
|
icon: status.switch1 ? Assets.openedDoor : Assets.closedDoor,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.read<GarageDoorBloc>().add(
|
context.read<GarageDoorBloc>().add(
|
||||||
GarageDoorControlEvent(
|
GarageDoorControlEvent(deviceId: status.uuid, value: !status.switch1, code: 'switch_1'),
|
||||||
deviceId: status.uuid,
|
|
||||||
value: !status.switch1,
|
|
||||||
code: 'switch_1'),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
status: status.switch1,
|
status: status.switch1,
|
||||||
@ -92,8 +84,7 @@ class GarageDoorControlView extends StatelessWidget
|
|||||||
IconNameStatusContainer(
|
IconNameStatusContainer(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.read<GarageDoorBloc>().add(
|
context.read<GarageDoorBloc>().add(
|
||||||
FetchGarageDoorSchedulesEvent(
|
FetchGarageDoorSchedulesEvent(deviceId: deviceId, category: 'switch_1'),
|
||||||
deviceId: deviceId, category: 'switch_1'),
|
|
||||||
);
|
);
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
@ -116,9 +107,7 @@ class GarageDoorControlView extends StatelessWidget
|
|||||||
children: [
|
children: [
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
context
|
context.read<GarageDoorBloc>().add(DecreaseGarageDoorDelayEvent(deviceId: status.uuid));
|
||||||
.read<GarageDoorBloc>()
|
|
||||||
.add(DecreaseGarageDoorDelayEvent(deviceId: status.uuid));
|
|
||||||
},
|
},
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
Icons.remove,
|
Icons.remove,
|
||||||
@ -136,8 +125,7 @@ class GarageDoorControlView extends StatelessWidget
|
|||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'h',
|
'h',
|
||||||
style: context.textTheme.bodySmall!
|
style: context.textTheme.bodySmall!.copyWith(color: ColorsManager.blackColor),
|
||||||
.copyWith(color: ColorsManager.blackColor),
|
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
(status.delay.inMinutes % 60).toString().padLeft(2, '0'),
|
(status.delay.inMinutes % 60).toString().padLeft(2, '0'),
|
||||||
@ -148,14 +136,11 @@ class GarageDoorControlView extends StatelessWidget
|
|||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'm',
|
'm',
|
||||||
style: context.textTheme.bodySmall!
|
style: context.textTheme.bodySmall!.copyWith(color: ColorsManager.blackColor),
|
||||||
.copyWith(color: ColorsManager.blackColor),
|
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
context
|
context.read<GarageDoorBloc>().add(IncreaseGarageDoorDelayEvent(deviceId: status.uuid));
|
||||||
.read<GarageDoorBloc>()
|
|
||||||
.add(IncreaseGarageDoorDelayEvent(deviceId: status.uuid));
|
|
||||||
},
|
},
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
Icons.add,
|
Icons.add,
|
||||||
@ -173,9 +158,7 @@ class GarageDoorControlView extends StatelessWidget
|
|||||||
onChange: (value) {
|
onChange: (value) {
|
||||||
context.read<GarageDoorBloc>().add(
|
context.read<GarageDoorBloc>().add(
|
||||||
GarageDoorControlEvent(
|
GarageDoorControlEvent(
|
||||||
deviceId: status.uuid,
|
deviceId: status.uuid, value: value ? status.delay.inSeconds : 0, code: 'countdown_1'),
|
||||||
value: value ? status.delay.inSeconds : 0,
|
|
||||||
code: 'countdown_1'),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -184,8 +167,7 @@ class GarageDoorControlView extends StatelessWidget
|
|||||||
name: 'Records',
|
name: 'Records',
|
||||||
icon: Assets.records,
|
icon: Assets.records,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.read<GarageDoorBloc>().add(FetchGarageDoorRecordsEvent(
|
context.read<GarageDoorBloc>().add(FetchGarageDoorRecordsEvent(code: 'switch_1', deviceId: status.uuid));
|
||||||
code: 'switch_1', deviceId: status.uuid));
|
|
||||||
},
|
},
|
||||||
status: false,
|
status: false,
|
||||||
textColor: ColorsManager.blackColor,
|
textColor: ColorsManager.blackColor,
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
|
||||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/main_door_sensor/bloc/main_door_sensor_bloc.dart';
|
import 'package:syncrow_web/pages/device_managment/main_door_sensor/bloc/main_door_sensor_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/main_door_sensor/bloc/main_door_sensor_event.dart';
|
import 'package:syncrow_web/pages/device_managment/main_door_sensor/bloc/main_door_sensor_event.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/main_door_sensor/bloc/main_door_sensor_state.dart';
|
import 'package:syncrow_web/pages/device_managment/main_door_sensor/bloc/main_door_sensor_state.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/main_door_sensor/models/main_door_status_model.dart';
|
import 'package:syncrow_web/pages/device_managment/main_door_sensor/models/main_door_status_model.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/main_door_sensor/widgets/notification_dialog.dart';
|
import 'package:syncrow_web/pages/device_managment/main_door_sensor/widgets/notification_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/shared/device_controls_container.dart';
|
import 'package:syncrow_web/pages/device_managment/shared/icon_name_status_container.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/shared/table/report_table.dart';
|
import 'package:syncrow_web/pages/device_managment/shared/table/report_table.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
|
||||||
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
||||||
|
|
||||||
class MainDoorSensorControlView extends StatelessWidget with HelperResponsiveLayout {
|
class MainDoorSensorControlView extends StatelessWidget with HelperResponsiveLayout {
|
||||||
@ -113,71 +111,3 @@ class MainDoorSensorControlView extends StatelessWidget with HelperResponsiveLay
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class IconNameStatusContainer extends StatelessWidget {
|
|
||||||
const IconNameStatusContainer({
|
|
||||||
super.key,
|
|
||||||
required this.name,
|
|
||||||
required this.icon,
|
|
||||||
required this.onTap,
|
|
||||||
required this.status,
|
|
||||||
required this.textColor,
|
|
||||||
this.paddingAmount = 12,
|
|
||||||
required this.isFullIcon,
|
|
||||||
});
|
|
||||||
|
|
||||||
final String name;
|
|
||||||
final String icon;
|
|
||||||
final GestureTapCallback onTap;
|
|
||||||
final bool status;
|
|
||||||
final Color textColor;
|
|
||||||
final double? paddingAmount;
|
|
||||||
final bool isFullIcon;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return GestureDetector(
|
|
||||||
onTap: onTap,
|
|
||||||
child: DeviceControlsContainer(
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
if (isFullIcon)
|
|
||||||
ClipOval(
|
|
||||||
child: SvgPicture.asset(
|
|
||||||
icon,
|
|
||||||
fit: BoxFit.contain,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
else
|
|
||||||
ClipOval(
|
|
||||||
child: Container(
|
|
||||||
height: 60,
|
|
||||||
width: 60,
|
|
||||||
padding: EdgeInsets.all(paddingAmount ?? 8),
|
|
||||||
color: ColorsManager.whiteColors,
|
|
||||||
child: SvgPicture.asset(
|
|
||||||
icon,
|
|
||||||
width: 35,
|
|
||||||
height: 35,
|
|
||||||
fit: BoxFit.contain,
|
|
||||||
),
|
|
||||||
)),
|
|
||||||
const Spacer(),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 6),
|
|
||||||
child: Text(
|
|
||||||
name,
|
|
||||||
textAlign: TextAlign.start,
|
|
||||||
style: context.textTheme.titleMedium!.copyWith(
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
color: textColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
|
||||||
import 'package:syncrow_web/pages/device_managment/all_devices/helper/route_controls_based_code.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/helper/route_controls_based_code.dart';
|
||||||
|
|
||||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
|
|
||||||
class DeviceBatchControlDialog extends StatelessWidget
|
class DeviceBatchControlDialog extends StatelessWidget with RouteControlsBasedCode {
|
||||||
with RouteControlsBasedCode {
|
|
||||||
final List<AllDevicesModel> devices;
|
final List<AllDevicesModel> devices;
|
||||||
|
|
||||||
const DeviceBatchControlDialog({super.key, required this.devices});
|
const DeviceBatchControlDialog({super.key, required this.devices});
|
||||||
@ -139,6 +135,8 @@ String getBatchDialogName(AllDevicesModel device) {
|
|||||||
return "Garage Door Opener";
|
return "Garage Door Opener";
|
||||||
case 'WL':
|
case 'WL':
|
||||||
return "Water Leak Sensor";
|
return "Water Leak Sensor";
|
||||||
|
case 'SOS':
|
||||||
|
return "SOS";
|
||||||
default:
|
default:
|
||||||
return device.categoryName ?? 'Device Control';
|
return device.categoryName ?? 'Device Control';
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,73 @@
|
|||||||
|
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/extension/build_context_x.dart';
|
||||||
|
|
||||||
|
class IconNameStatusContainer extends StatelessWidget {
|
||||||
|
const IconNameStatusContainer({
|
||||||
|
super.key,
|
||||||
|
required this.name,
|
||||||
|
required this.icon,
|
||||||
|
required this.onTap,
|
||||||
|
required this.status,
|
||||||
|
required this.textColor,
|
||||||
|
this.paddingAmount = 12,
|
||||||
|
required this.isFullIcon,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String name;
|
||||||
|
final String icon;
|
||||||
|
final GestureTapCallback onTap;
|
||||||
|
final bool status;
|
||||||
|
final Color textColor;
|
||||||
|
final double? paddingAmount;
|
||||||
|
final bool isFullIcon;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: onTap,
|
||||||
|
child: DeviceControlsContainer(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
if (isFullIcon)
|
||||||
|
ClipOval(
|
||||||
|
child: SvgPicture.asset(
|
||||||
|
icon,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
else
|
||||||
|
ClipOval(
|
||||||
|
child: Container(
|
||||||
|
height: 60,
|
||||||
|
width: 60,
|
||||||
|
padding: EdgeInsets.all(paddingAmount ?? 8),
|
||||||
|
color: ColorsManager.whiteColors,
|
||||||
|
child: SvgPicture.asset(
|
||||||
|
icon,
|
||||||
|
width: 35,
|
||||||
|
height: 35,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
const Spacer(),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 6),
|
||||||
|
child: Text(
|
||||||
|
name,
|
||||||
|
textAlign: TextAlign.start,
|
||||||
|
style: context.textTheme.titleMedium!.copyWith(
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
color: textColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@ import 'dart:async';
|
|||||||
import 'package:bloc/bloc.dart';
|
import 'package:bloc/bloc.dart';
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_reports.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_reports.dart';
|
||||||
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/sos/models/sos_status_model.dart';
|
import 'package:syncrow_web/pages/device_managment/sos/models/sos_status_model.dart';
|
||||||
import 'package:syncrow_web/services/devices_mang_api.dart';
|
import 'package:syncrow_web/services/devices_mang_api.dart';
|
||||||
|
|
||||||
@ -16,6 +17,7 @@ class SosDeviceBloc extends Bloc<SosDeviceEvent, SosDeviceState> {
|
|||||||
on<GetDeviceRecords>(_getDeviceRecords);
|
on<GetDeviceRecords>(_getDeviceRecords);
|
||||||
on<GetDeviceAutomationRecords>(_getDeviceAutomationRecords);
|
on<GetDeviceAutomationRecords>(_getDeviceAutomationRecords);
|
||||||
on<BackToSosStatusView>(_backToSosStatusView);
|
on<BackToSosStatusView>(_backToSosStatusView);
|
||||||
|
on<SosFactoryReset>(_sosFactoryReset);
|
||||||
}
|
}
|
||||||
|
|
||||||
late SosStatusModel deviceStatus;
|
late SosStatusModel deviceStatus;
|
||||||
@ -71,4 +73,18 @@ class SosDeviceBloc extends Bloc<SosDeviceEvent, SosDeviceState> {
|
|||||||
FutureOr<void> _backToSosStatusView(BackToSosStatusView event, Emitter<SosDeviceState> emit) {
|
FutureOr<void> _backToSosStatusView(BackToSosStatusView event, Emitter<SosDeviceState> emit) {
|
||||||
emit(SosDeviceLoadedState(deviceStatus));
|
emit(SosDeviceLoadedState(deviceStatus));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FutureOr<void> _sosFactoryReset(SosFactoryReset event, Emitter<SosDeviceState> emit) async {
|
||||||
|
emit(SosDeviceLoadingState());
|
||||||
|
try {
|
||||||
|
final response = await DevicesManagementApi().factoryReset(event.factoryReset, event.deviceId);
|
||||||
|
if (response) {
|
||||||
|
emit(SosDeviceLoadedState(deviceStatus));
|
||||||
|
} else {
|
||||||
|
emit(const SosDeviceErrorState('Factory reset failed'));
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
emit(SosDeviceErrorState(e.toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,3 +37,13 @@ class BackToSosStatusView extends SosDeviceEvent {
|
|||||||
@override
|
@override
|
||||||
List<Object?> get props => [];
|
List<Object?> get props => [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class SosFactoryReset extends SosDeviceEvent {
|
||||||
|
final String deviceId;
|
||||||
|
final FactoryResetModel factoryReset;
|
||||||
|
|
||||||
|
const SosFactoryReset({required this.deviceId, required this.factoryReset});
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [deviceId, factoryReset];
|
||||||
|
}
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart';
|
||||||
|
import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart';
|
||||||
|
import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart';
|
||||||
|
import 'package:syncrow_web/pages/device_managment/sos/bloc/sos_device_bloc.dart';
|
||||||
|
|
||||||
class SOSBatchControlView extends StatelessWidget {
|
class SOSBatchControlView extends StatelessWidget {
|
||||||
const SOSBatchControlView({
|
const SOSBatchControlView({
|
||||||
@ -10,6 +15,52 @@ class SOSBatchControlView extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return const Placeholder();
|
return Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
width: 170,
|
||||||
|
// height: 140,
|
||||||
|
child: FirmwareUpdateWidget(deviceId: deviceIds.first, version: 2)),
|
||||||
|
const SizedBox(
|
||||||
|
width: 12,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: 170,
|
||||||
|
height: 140,
|
||||||
|
child: FactoryResetWidget(
|
||||||
|
callFactoryReset: () {
|
||||||
|
context.read<SosDeviceBloc>().add(
|
||||||
|
SosFactoryReset(deviceId: deviceIds.first, factoryReset: FactoryResetModel(devicesUuid: deviceIds)));
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
// Widget _buildStatusControls(BuildContext context, SosStatusModel status) {
|
||||||
|
// return Row(
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
// children: [
|
||||||
|
// SizedBox(
|
||||||
|
// width: 170,
|
||||||
|
// // height: 140,
|
||||||
|
// child: FirmwareUpdateWidget(deviceId: deviceIds.first, version: 2)),
|
||||||
|
// const SizedBox(
|
||||||
|
// width: 12,
|
||||||
|
// ),
|
||||||
|
// SizedBox(
|
||||||
|
// width: 170,
|
||||||
|
// height: 140,
|
||||||
|
// child: FactoryResetWidget(
|
||||||
|
// callFactoryReset: () {
|
||||||
|
// context.read<SosDeviceBloc>().add(
|
||||||
|
// SosFactoryReset(deviceId: deviceIds.first, factoryReset: FactoryResetModel(devicesUuid: deviceIds)));
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// );
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,10 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/main_door_sensor/view/main_door_control_view.dart';
|
import 'package:syncrow_web/pages/device_managment/shared/icon_name_status_container.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/shared/table/report_table.dart';
|
import 'package:syncrow_web/pages/device_managment/shared/table/report_table.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/sos/bloc/sos_device_bloc.dart';
|
import 'package:syncrow_web/pages/device_managment/sos/bloc/sos_device_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/device_managment/sos/widgets/sos_notification_dialog.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
||||||
@ -83,7 +84,7 @@ class SosDeviceControlsView extends StatelessWidget with HelperResponsiveLayout
|
|||||||
children: [
|
children: [
|
||||||
IconNameStatusContainer(
|
IconNameStatusContainer(
|
||||||
isFullIcon: false,
|
isFullIcon: false,
|
||||||
name: deviceStatus.sosStatus == 'sos' ? 'SOS' : 'normal',
|
name: deviceStatus.sosStatus == 'sos' ? 'SOS' : 'Normal',
|
||||||
icon: deviceStatus.sosStatus == 'sos' ? Assets.sos : Assets.sosNormal,
|
icon: deviceStatus.sosStatus == 'sos' ? Assets.sos : Assets.sosNormal,
|
||||||
onTap: () {},
|
onTap: () {},
|
||||||
status: false,
|
status: false,
|
||||||
@ -108,11 +109,11 @@ class SosDeviceControlsView extends StatelessWidget with HelperResponsiveLayout
|
|||||||
name: 'Automation Record',
|
name: 'Automation Record',
|
||||||
icon: Assets.automationRecords,
|
icon: Assets.automationRecords,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.read<SosDeviceBloc>().add(
|
// context.read<SosDeviceBloc>().add(
|
||||||
GetDeviceAutomationRecords(
|
// GetDeviceAutomationRecords(
|
||||||
device.uuid!,
|
// device.uuid!,
|
||||||
),
|
// ),
|
||||||
);
|
// );
|
||||||
},
|
},
|
||||||
status: false,
|
status: false,
|
||||||
textColor: ColorsManager.blackColor,
|
textColor: ColorsManager.blackColor,
|
||||||
@ -122,10 +123,10 @@ class SosDeviceControlsView extends StatelessWidget with HelperResponsiveLayout
|
|||||||
name: 'Alarm Settings',
|
name: 'Alarm Settings',
|
||||||
icon: Assets.mainDoorNotifi,
|
icon: Assets.mainDoorNotifi,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
// showDialog(
|
showDialog(
|
||||||
// context: context,
|
context: context,
|
||||||
// builder: (context) => const NotificationDialog(),
|
builder: (context) => const SosNotificationDialog(),
|
||||||
// );
|
);
|
||||||
},
|
},
|
||||||
status: false,
|
status: false,
|
||||||
textColor: ColorsManager.blackColor,
|
textColor: ColorsManager.blackColor,
|
||||||
|
@ -0,0 +1,116 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:syncrow_web/pages/device_managment/shared/toggle_widget.dart';
|
||||||
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
|
||||||
|
class SosNotificationDialog extends StatefulWidget {
|
||||||
|
const SosNotificationDialog({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<SosNotificationDialog> createState() => _NotificationDialogState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _NotificationDialogState extends State<SosNotificationDialog> {
|
||||||
|
bool isLowBatteryNotificationEnabled = true;
|
||||||
|
bool isSosAlarmEnabled = true;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Dialog(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
insetPadding: const EdgeInsets.all(20),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
),
|
||||||
|
child: SizedBox(
|
||||||
|
width: 550,
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(20.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
const SizedBox(),
|
||||||
|
Text(
|
||||||
|
'Notification Settings',
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 22,
|
||||||
|
color: ColorsManager.dialogBlueTitle,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
width: 25,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.transparent,
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
border: Border.all(
|
||||||
|
color: Colors.grey,
|
||||||
|
width: 1.0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: IconButton(
|
||||||
|
padding: EdgeInsets.all(1),
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.close,
|
||||||
|
color: Colors.grey,
|
||||||
|
size: 18,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
width: 170,
|
||||||
|
height: 135,
|
||||||
|
child: ToggleWidget(
|
||||||
|
value: isSosAlarmEnabled,
|
||||||
|
code: 'notification',
|
||||||
|
deviceId: '',
|
||||||
|
label: 'SOS Alarm',
|
||||||
|
onChange: (v) {
|
||||||
|
setState(() {
|
||||||
|
isSosAlarmEnabled = v;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
icon: '-1',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 16,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: 170,
|
||||||
|
height: 135,
|
||||||
|
child: ToggleWidget(
|
||||||
|
value: isLowBatteryNotificationEnabled,
|
||||||
|
code: 'notification',
|
||||||
|
deviceId: '',
|
||||||
|
label: 'Low Battery',
|
||||||
|
onChange: (v) {
|
||||||
|
setState(() {
|
||||||
|
isLowBatteryNotificationEnabled = v;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
icon: '-1',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,13 +1,13 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/main_door_sensor/view/main_door_control_view.dart';
|
import 'package:syncrow_web/pages/device_managment/shared/icon_name_status_container.dart';
|
||||||
|
import 'package:syncrow_web/pages/device_managment/shared/table/report_table.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/water_leak/bloc/water_leak_bloc.dart';
|
import 'package:syncrow_web/pages/device_managment/water_leak/bloc/water_leak_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/water_leak/bloc/water_leak_event.dart';
|
import 'package:syncrow_web/pages/device_managment/water_leak/bloc/water_leak_event.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/water_leak/bloc/water_leak_state.dart';
|
import 'package:syncrow_web/pages/device_managment/water_leak/bloc/water_leak_state.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/water_leak/widgets/water_leak_notifi_dialog.dart';
|
import 'package:syncrow_web/pages/device_managment/water_leak/widgets/water_leak_notifi_dialog.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/shared/table/report_table.dart';
|
|
||||||
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
||||||
|
|
||||||
class WaterLeakView extends StatelessWidget with HelperResponsiveLayout {
|
class WaterLeakView extends StatelessWidget with HelperResponsiveLayout {
|
||||||
@ -21,8 +21,7 @@ class WaterLeakView extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
final isLarge = isLargeScreenSize(context);
|
final isLarge = isLargeScreenSize(context);
|
||||||
final isMedium = isMediumScreenSize(context);
|
final isMedium = isMediumScreenSize(context);
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (context) =>
|
create: (context) => WaterLeakBloc(deviceId)..add(FetchWaterLeakStatusEvent(deviceId)),
|
||||||
WaterLeakBloc(deviceId)..add(FetchWaterLeakStatusEvent(deviceId)),
|
|
||||||
child: BlocBuilder<WaterLeakBloc, WaterLeakState>(
|
child: BlocBuilder<WaterLeakBloc, WaterLeakState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
if (state is WaterLeakLoadingState) {
|
if (state is WaterLeakLoadingState) {
|
||||||
@ -45,31 +44,21 @@ class WaterLeakView extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
children: [
|
children: [
|
||||||
IconNameStatusContainer(
|
IconNameStatusContainer(
|
||||||
isFullIcon: false,
|
isFullIcon: false,
|
||||||
name: state.status.watersensorState == 'normal'
|
name: state.status.watersensorState == 'normal' ? 'Normal' : 'Leak Detection',
|
||||||
? 'Normal'
|
icon: state.status.watersensorState == 'normal' ? Assets.waterLeakNormal : Assets.waterLeakDetected,
|
||||||
: 'Leak Detection',
|
|
||||||
icon: state.status.watersensorState == 'normal'
|
|
||||||
? Assets.waterLeakNormal
|
|
||||||
: Assets.waterLeakDetected,
|
|
||||||
onTap: () {},
|
onTap: () {},
|
||||||
status: state.status.watersensorState == 'normal',
|
status: state.status.watersensorState == 'normal',
|
||||||
textColor: state.status.watersensorState == 'normal'
|
textColor: state.status.watersensorState == 'normal' ? ColorsManager.blackColor : ColorsManager.red,
|
||||||
? ColorsManager.blackColor
|
|
||||||
: ColorsManager.red,
|
|
||||||
),
|
),
|
||||||
IconNameStatusContainer(
|
IconNameStatusContainer(
|
||||||
isFullIcon: false,
|
isFullIcon: false,
|
||||||
name: 'Records',
|
name: 'Records',
|
||||||
icon: Assets.records,
|
icon: Assets.records,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context
|
context.read<WaterLeakBloc>().add(FetchWaterLeakReportsEvent(
|
||||||
.read<WaterLeakBloc>()
|
|
||||||
.add(FetchWaterLeakReportsEvent(
|
|
||||||
deviceId: deviceId,
|
deviceId: deviceId,
|
||||||
code: 'watersensor_state',
|
code: 'watersensor_state',
|
||||||
from: DateTime.now()
|
from: DateTime.now().subtract(const Duration(days: 30)).millisecondsSinceEpoch,
|
||||||
.subtract(const Duration(days: 30))
|
|
||||||
.millisecondsSinceEpoch,
|
|
||||||
to: DateTime.now().millisecondsSinceEpoch,
|
to: DateTime.now().millisecondsSinceEpoch,
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
@ -109,9 +98,7 @@ class WaterLeakView extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
waterLeak: true,
|
waterLeak: true,
|
||||||
onRowTap: (index) {},
|
onRowTap: (index) {},
|
||||||
onClose: () {
|
onClose: () {
|
||||||
context
|
context.read<WaterLeakBloc>().add(FetchWaterLeakStatusEvent(deviceId));
|
||||||
.read<WaterLeakBloc>()
|
|
||||||
.add(FetchWaterLeakStatusEvent(deviceId));
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else if (state is WaterLeakReportsFailedState) {
|
} else if (state is WaterLeakReportsFailedState) {
|
||||||
|
Reference in New Issue
Block a user