mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
push wall sensor
This commit is contained in:
@ -29,7 +29,7 @@ class AcDeviceBatchControl extends StatelessWidget with HelperResponsiveLayout {
|
||||
builder: (context, state) {
|
||||
if (state is ACStatusLoaded) {
|
||||
return GridView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 50),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 50, vertical: 20),
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
|
@ -8,9 +8,11 @@ import 'package:syncrow_web/pages/device_managment/curtain/view/curtain_batch_st
|
||||
import 'package:syncrow_web/pages/device_managment/curtain/view/curtain_status_view.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/door_lock/view/door_lock_batch_control_view.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/door_lock/view/door_lock_control_view.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/gateway/view/gateway_batch_control.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/gateway/view/gateway_view.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/three_gang_switch/view/living_room_batch_controls.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/three_gang_switch/view/living_room_device_control.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/wall_sensor/view/wall_sensor_batch_control.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/wall_sensor/view/wall_sensor_conrtols.dart';
|
||||
|
||||
mixin RouteControlsBasedCode {
|
||||
@ -70,18 +72,25 @@ mixin RouteControlsBasedCode {
|
||||
.map((e) => e.uuid!)
|
||||
.toList(),
|
||||
);
|
||||
// case 'GW':
|
||||
// return GateWayControls(
|
||||
// gatewayId: device.first.uuid!,
|
||||
// );
|
||||
case 'GW':
|
||||
return GatewayBatchControl(
|
||||
gatewayIds: devices
|
||||
.where((e) => (e.productType == 'GW'))
|
||||
.map((e) => e.uuid!)
|
||||
.toList(),
|
||||
);
|
||||
case 'DL':
|
||||
return DoorLockBatchControlView(
|
||||
devicesIds: devices
|
||||
.where((e) => (e.productType == 'DL'))
|
||||
.map((e) => e.uuid!)
|
||||
.toList());
|
||||
// case 'WPS':
|
||||
// return WallSensorControls(device: device.first);
|
||||
case 'WPS':
|
||||
return WallSensorBatchControl(
|
||||
devicesIds: devices
|
||||
.where((e) => (e.productType == 'WPS'))
|
||||
.map((e) => e.uuid!)
|
||||
.toList());
|
||||
// case 'CPS':
|
||||
// return CeilingSensorControls(
|
||||
// device: device.first,
|
||||
@ -94,10 +103,11 @@ mixin RouteControlsBasedCode {
|
||||
.toList(),
|
||||
);
|
||||
case 'AC':
|
||||
return AcDeviceBatchControl(devicesIds: devices
|
||||
.where((e) => (e.productType == 'AC'))
|
||||
.map((e) => e.uuid!)
|
||||
.toList());
|
||||
return AcDeviceBatchControl(
|
||||
devicesIds: devices
|
||||
.where((e) => (e.productType == 'AC'))
|
||||
.map((e) => e.uuid!)
|
||||
.toList());
|
||||
default:
|
||||
return const SizedBox();
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ class CurtainBatchStatusView extends StatelessWidget
|
||||
final isLarge = isLargeScreenSize(context);
|
||||
final isMedium = isMediumScreenSize(context);
|
||||
return GridView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 50),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 50, vertical: 20),
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
|
@ -16,7 +16,7 @@ class DoorLockBatchControlView extends StatelessWidget
|
||||
final isMedium = isMediumScreenSize(context);
|
||||
return SizedBox(
|
||||
child: GridView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 50),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 50, vertical: 20),
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
|
@ -0,0 +1,48 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/gateway/bloc/gate_way_bloc.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/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
||||
|
||||
class GatewayBatchControl extends StatelessWidget with HelperResponsiveLayout {
|
||||
const GatewayBatchControl({super.key, required this.gatewayIds});
|
||||
|
||||
final List<String> gatewayIds;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final isExtraLarge = isExtraLargeScreenSize(context);
|
||||
final isLarge = isLargeScreenSize(context);
|
||||
final isMedium = isMediumScreenSize(context);
|
||||
|
||||
return BlocProvider(
|
||||
create: (context) => GateWayBloc()..add(GatWayById(gatewayIds.first)),
|
||||
child: BlocBuilder<GateWayBloc, GateWayState>(
|
||||
builder: (context, state) {
|
||||
if (state is GatewayLoadingState) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
} else if (state is UpdateGatewayState) {
|
||||
return GridView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 50, vertical: 20),
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: isLarge || isExtraLarge || isMedium ? 2 : 1,
|
||||
mainAxisExtent: 140,
|
||||
crossAxisSpacing: 12,
|
||||
mainAxisSpacing: 12,
|
||||
),
|
||||
children: [
|
||||
FirmwareUpdateWidget(deviceId: gatewayIds.first, version: 2),
|
||||
FactoryResetWidget(deviceId: gatewayIds.first),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return const Center(child: Text('Error fetching status'));
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -22,7 +22,7 @@ class DeviceBatchControlDialog extends StatelessWidget
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: SizedBox(
|
||||
width: devices.length < 3 ? 500 : 798,
|
||||
width: devices.length < 2 ? 500 : 800,
|
||||
// height: context.screenHeight * 0.7,
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
|
@ -13,6 +13,7 @@ class WallSensorBloc extends Bloc<WallSensorEvent, WallSensorState> {
|
||||
|
||||
WallSensorBloc({required this.deviceId}) : super(WallSensorInitialState()) {
|
||||
on<WallSensorInitialEvent>(_fetchWallSensorStatus);
|
||||
on<WallSensorBatchControlEvent>(_fetchWallSensorBatchControl);
|
||||
on<WallSensorChangeValueEvent>(_changeValue);
|
||||
on<GetDeviceReportsEvent>(_getDeviceReports);
|
||||
on<ShowDescriptionEvent>(_showDescription);
|
||||
@ -99,7 +100,7 @@ class WallSensorBloc extends Bloc<WallSensorEvent, WallSensorState> {
|
||||
try {
|
||||
await DevicesManagementApi.getDeviceReports(deviceId, event.code)
|
||||
.then((value) {
|
||||
emit(DeviceReportsState(deviceReport: value, code:event.code));
|
||||
emit(DeviceReportsState(deviceReport: value, code: event.code));
|
||||
});
|
||||
} catch (e) {
|
||||
emit(DeviceReportsFailedState(error: e.toString()));
|
||||
@ -116,4 +117,17 @@ class WallSensorBloc extends Bloc<WallSensorEvent, WallSensorState> {
|
||||
BackToGridViewEvent event, Emitter<WallSensorState> emit) {
|
||||
emit(WallSensorUpdateState(wallSensorModel: deviceStatus));
|
||||
}
|
||||
|
||||
FutureOr<void> _fetchWallSensorBatchControl(
|
||||
WallSensorBatchControlEvent event, Emitter<WallSensorState> emit) async {
|
||||
emit(WallSensorLoadingInitialState());
|
||||
try {
|
||||
var response = await DevicesManagementApi().getDeviceStatus(deviceId);
|
||||
deviceStatus = WallSensorModel.fromJson(response.status);
|
||||
emit(WallSensorUpdateState(wallSensorModel: deviceStatus));
|
||||
} catch (e) {
|
||||
emit(WallSensorFailedState(error: e.toString()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,10 @@ class WallSensorChangeValueEvent extends WallSensorEvent {
|
||||
List<Object> get props => [value, code];
|
||||
}
|
||||
|
||||
class WallSensorBatchControlEvent extends WallSensorEvent {
|
||||
const WallSensorBatchControlEvent();
|
||||
}
|
||||
|
||||
class GetDeviceReportsEvent extends WallSensorEvent {
|
||||
final String deviceUuid;
|
||||
final String code;
|
||||
|
@ -0,0 +1,121 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.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/shared/sensors_widgets/presence_update_data.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/wall_sensor/bloc/bloc.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/wall_sensor/bloc/event.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/wall_sensor/bloc/state.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/wall_sensor/model/wall_sensor_model.dart';
|
||||
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
||||
|
||||
class WallSensorBatchControl extends StatelessWidget
|
||||
with HelperResponsiveLayout {
|
||||
const WallSensorBatchControl({super.key, required this.devicesIds});
|
||||
|
||||
final List<String> devicesIds;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final isExtraLarge = isExtraLargeScreenSize(context);
|
||||
final isLarge = isLargeScreenSize(context);
|
||||
final isMedium = isMediumScreenSize(context);
|
||||
return BlocProvider(
|
||||
create: (context) => WallSensorBloc(deviceId: devicesIds.first)
|
||||
..add(const WallSensorBatchControlEvent()),
|
||||
child: BlocBuilder<WallSensorBloc, WallSensorState>(
|
||||
builder: (context, state) {
|
||||
if (state is WallSensorLoadingInitialState ||
|
||||
state is DeviceReportsLoadingState) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
} else if (state is WallSensorUpdateState) {
|
||||
return _buildGridView(context, state.wallSensorModel, isExtraLarge,
|
||||
isLarge, isMedium);
|
||||
} else if (state is DeviceReportsFailedState) {
|
||||
final model = context.read<WallSensorBloc>().deviceStatus;
|
||||
return _buildGridView(
|
||||
context, model, isExtraLarge, isLarge, isMedium);
|
||||
}
|
||||
return const Center(child: Text('Error fetching status'));
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildGridView(BuildContext context, WallSensorModel model,
|
||||
bool isExtraLarge, bool isLarge, bool isMedium) {
|
||||
return GridView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 50, vertical: 20),
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: isLarge || isExtraLarge
|
||||
? 3
|
||||
: isMedium
|
||||
? 2
|
||||
: 1,
|
||||
mainAxisExtent: 140,
|
||||
crossAxisSpacing: 12,
|
||||
mainAxisSpacing: 12,
|
||||
),
|
||||
children: [
|
||||
PresenceUpdateData(
|
||||
value: model.motionSensitivity.toDouble(),
|
||||
title: 'Motion Detection Sensitivity:',
|
||||
minValue: 1,
|
||||
maxValue: 5,
|
||||
steps: 1,
|
||||
action: (int value) {
|
||||
context.read<WallSensorBloc>().add(
|
||||
WallSensorChangeValueEvent(
|
||||
code: 'motion_sensitivity_value',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
PresenceUpdateData(
|
||||
value: model.motionlessSensitivity.toDouble(),
|
||||
title: 'Motionless Detection Sensitivity:',
|
||||
minValue: 1,
|
||||
maxValue: 5,
|
||||
steps: 1,
|
||||
action: (int value) => context.read<WallSensorBloc>().add(
|
||||
WallSensorChangeValueEvent(
|
||||
code: 'motionless_sensitivity',
|
||||
value: value,
|
||||
),
|
||||
),
|
||||
),
|
||||
PresenceUpdateData(
|
||||
value: model.noBodyTime.toDouble(),
|
||||
title: 'Nobody Time:',
|
||||
minValue: 10,
|
||||
maxValue: 10000,
|
||||
steps: 1,
|
||||
description: 'hr',
|
||||
action: (int value) =>
|
||||
context.read<WallSensorBloc>().add(WallSensorChangeValueEvent(
|
||||
code: 'no_one_time',
|
||||
value: value,
|
||||
))),
|
||||
PresenceUpdateData(
|
||||
value: model.farDetection.toDouble(),
|
||||
title: 'Far Detection:',
|
||||
minValue: 75,
|
||||
maxValue: 600,
|
||||
steps: 75,
|
||||
description: 'cm',
|
||||
action: (int value) => context.read<WallSensorBloc>().add(
|
||||
WallSensorChangeValueEvent(
|
||||
code: 'far_detection',
|
||||
value: value,
|
||||
),
|
||||
),
|
||||
),
|
||||
FirmwareUpdateWidget(deviceId: devicesIds.first, version: 2),
|
||||
FactoryResetWidget(deviceId: devicesIds.first),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user