mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-11 07:38:05 +00:00
push ceiling sensor batch
This commit is contained in:
@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:syncrow_web/pages/device_managment/ac/view/ac_device_batch_control.dart';
|
import 'package:syncrow_web/pages/device_managment/ac/view/ac_device_batch_control.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/ac/view/ac_device_control.dart';
|
import 'package:syncrow_web/pages/device_managment/ac/view/ac_device_control.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/ceiling_sensor/view/ceiling_sensor_batch_control.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/ceiling_sensor/view/ceiling_sensor_controls.dart';
|
import 'package:syncrow_web/pages/device_managment/ceiling_sensor/view/ceiling_sensor_controls.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/curtain/view/curtain_batch_status_view.dart';
|
import 'package:syncrow_web/pages/device_managment/curtain/view/curtain_batch_status_view.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/curtain/view/curtain_status_view.dart';
|
import 'package:syncrow_web/pages/device_managment/curtain/view/curtain_status_view.dart';
|
||||||
@ -91,10 +92,13 @@ mixin RouteControlsBasedCode {
|
|||||||
.where((e) => (e.productType == 'WPS'))
|
.where((e) => (e.productType == 'WPS'))
|
||||||
.map((e) => e.uuid!)
|
.map((e) => e.uuid!)
|
||||||
.toList());
|
.toList());
|
||||||
// case 'CPS':
|
case 'CPS':
|
||||||
// return CeilingSensorControls(
|
return CeilingSensorBatchControl(
|
||||||
// device: device.first,
|
devicesIds: devices
|
||||||
// );
|
.where((e) => (e.productType == 'CPS'))
|
||||||
|
.map((e) => e.uuid!)
|
||||||
|
.toList(),
|
||||||
|
);
|
||||||
case 'CUR':
|
case 'CUR':
|
||||||
return CurtainBatchStatusView(
|
return CurtainBatchStatusView(
|
||||||
devicesIds: devices
|
devicesIds: devices
|
||||||
|
@ -14,6 +14,7 @@ class CeilingSensorBloc extends Bloc<CeilingSensorEvent, CeilingSensorState> {
|
|||||||
|
|
||||||
CeilingSensorBloc({required this.deviceId}) : super(CeilingInitialState()) {
|
CeilingSensorBloc({required this.deviceId}) : super(CeilingInitialState()) {
|
||||||
on<CeilingInitialEvent>(_fetchCeilingSensorStatus);
|
on<CeilingInitialEvent>(_fetchCeilingSensorStatus);
|
||||||
|
on<CeilingBatchControlEvent>(_fetchCeilingSensorBatchControl);
|
||||||
on<CeilingChangeValueEvent>(_changeValue);
|
on<CeilingChangeValueEvent>(_changeValue);
|
||||||
on<GetCeilingDeviceReportsEvent>(_getDeviceReports);
|
on<GetCeilingDeviceReportsEvent>(_getDeviceReports);
|
||||||
on<ShowCeilingDescriptionEvent>(_showDescription);
|
on<ShowCeilingDescriptionEvent>(_showDescription);
|
||||||
@ -128,4 +129,17 @@ class CeilingSensorBloc extends Bloc<CeilingSensorEvent, CeilingSensorState> {
|
|||||||
BackToCeilingGridViewEvent event, Emitter<CeilingSensorState> emit) {
|
BackToCeilingGridViewEvent event, Emitter<CeilingSensorState> emit) {
|
||||||
emit(CeilingUpdateState(ceilingSensorModel: deviceStatus));
|
emit(CeilingUpdateState(ceilingSensorModel: deviceStatus));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FutureOr<void> _fetchCeilingSensorBatchControl(
|
||||||
|
CeilingBatchControlEvent event, Emitter<CeilingSensorState> emit) async {
|
||||||
|
emit(CeilingLoadingInitialState());
|
||||||
|
try {
|
||||||
|
var response = await DevicesManagementApi().getDeviceStatus(deviceId);
|
||||||
|
deviceStatus = CeilingSensorModel.fromJson(response.status);
|
||||||
|
emit(CeilingUpdateState(ceilingSensorModel: deviceStatus));
|
||||||
|
} catch (e) {
|
||||||
|
emit(CeilingFailedState(error: e.toString()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,8 @@ abstract class CeilingSensorEvent extends Equatable {
|
|||||||
|
|
||||||
class CeilingInitialEvent extends CeilingSensorEvent {}
|
class CeilingInitialEvent extends CeilingSensorEvent {}
|
||||||
|
|
||||||
|
class CeilingBatchControlEvent extends CeilingSensorEvent {}
|
||||||
|
|
||||||
class CeilingChangeValueEvent extends CeilingSensorEvent {
|
class CeilingChangeValueEvent extends CeilingSensorEvent {
|
||||||
final dynamic value;
|
final dynamic value;
|
||||||
final String code;
|
final String code;
|
||||||
|
@ -0,0 +1,119 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/device_managment/ceiling_sensor/bloc/bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/device_managment/ceiling_sensor/bloc/event.dart';
|
||||||
|
import 'package:syncrow_web/pages/device_managment/ceiling_sensor/bloc/state.dart';
|
||||||
|
import 'package:syncrow_web/pages/device_managment/ceiling_sensor/model/ceiling_sensor_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/shared/sensors_widgets/presence_space_type.dart';
|
||||||
|
import 'package:syncrow_web/pages/device_managment/shared/sensors_widgets/presence_update_data.dart';
|
||||||
|
import 'package:syncrow_web/pages/device_managment/shared/sensors_widgets/presense_nobody_time.dart';
|
||||||
|
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
||||||
|
|
||||||
|
class CeilingSensorBatchControl extends StatelessWidget
|
||||||
|
with HelperResponsiveLayout {
|
||||||
|
const CeilingSensorBatchControl({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) => CeilingSensorBloc(deviceId: devicesIds.first)
|
||||||
|
..add(CeilingBatchControlEvent()),
|
||||||
|
child: BlocBuilder<CeilingSensorBloc, CeilingSensorState>(
|
||||||
|
builder: (context, state) {
|
||||||
|
if (state is CeilingLoadingInitialState ||
|
||||||
|
state is CeilingReportsLoadingState) {
|
||||||
|
return const Center(child: CircularProgressIndicator());
|
||||||
|
} else if (state is CeilingUpdateState) {
|
||||||
|
return _buildGridView(context, state.ceilingSensorModel,
|
||||||
|
isExtraLarge, isLarge, isMedium);
|
||||||
|
} else if (state is CeilingReportsFailedState) {
|
||||||
|
final model = context.read<CeilingSensorBloc>().deviceStatus;
|
||||||
|
return _buildGridView(
|
||||||
|
context, model, isExtraLarge, isLarge, isMedium);
|
||||||
|
}
|
||||||
|
return const Center(child: Text('Error fetching status'));
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildGridView(BuildContext context, CeilingSensorModel model,
|
||||||
|
bool isExtraLarge, bool isLarge, bool isMedium) {
|
||||||
|
return GridView(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 50),
|
||||||
|
shrinkWrap: true,
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
|
crossAxisCount: isLarge || isExtraLarge
|
||||||
|
? 3
|
||||||
|
: isMedium
|
||||||
|
? 2
|
||||||
|
: 1,
|
||||||
|
mainAxisExtent: 140,
|
||||||
|
crossAxisSpacing: 12,
|
||||||
|
mainAxisSpacing: 12,
|
||||||
|
),
|
||||||
|
children: [
|
||||||
|
PresenceSpaceType(
|
||||||
|
description: 'Space Type',
|
||||||
|
value: model.spaceType,
|
||||||
|
action: (String value) => context.read<CeilingSensorBloc>().add(
|
||||||
|
CeilingChangeValueEvent(
|
||||||
|
code: 'scene',
|
||||||
|
value: value,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
PresenceUpdateData(
|
||||||
|
value: model.sensitivity.toDouble(),
|
||||||
|
title: 'Sensitivity:',
|
||||||
|
minValue: 1,
|
||||||
|
maxValue: 5,
|
||||||
|
steps: 1,
|
||||||
|
action: (int value) {
|
||||||
|
context.read<CeilingSensorBloc>().add(
|
||||||
|
CeilingChangeValueEvent(
|
||||||
|
code: 'sensitivity',
|
||||||
|
value: value,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
PresenceUpdateData(
|
||||||
|
value: model.maxDistance.toDouble(),
|
||||||
|
title: 'Maximum Distance:',
|
||||||
|
minValue: 0,
|
||||||
|
maxValue: 500,
|
||||||
|
steps: 50,
|
||||||
|
description: 'm',
|
||||||
|
action: (int value) => context.read<CeilingSensorBloc>().add(
|
||||||
|
CeilingChangeValueEvent(
|
||||||
|
code: 'moving_max_dis',
|
||||||
|
value: value,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
PresenceNoBodyTime(
|
||||||
|
value: model.noBodyTime,
|
||||||
|
title: 'Nobody Time:',
|
||||||
|
description: '',
|
||||||
|
action: (String value) => context.read<CeilingSensorBloc>().add(
|
||||||
|
CeilingChangeValueEvent(
|
||||||
|
code: 'nobody_time',
|
||||||
|
value: value,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
FirmwareUpdateWidget(deviceId: devicesIds.first, version: 4),
|
||||||
|
FactoryResetWidget(deviceId: devicesIds.first),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user