From 9b0e6ff89841a1f45a7f50ea2c1a0a3898f4a648 Mon Sep 17 00:00:00 2001 From: mohammad Date: Sun, 20 Oct 2024 16:36:45 +0300 Subject: [PATCH] power_clamp --- .../helper/route_controls_based_code.dart | 12 ++ .../power_clamp/bloc/smart_power_bloc.dart | 171 +++++++++++++++++ .../power_clamp/bloc/smart_power_event.dart | 59 ++++++ .../power_clamp/bloc/smart_power_state.dart | 56 ++++++ .../models/wall_light_status_model.dart | 47 +++++ .../power_clamp/view/power_chart.dart | 177 ++++++++++++++++++ .../power_clamp/view/power_info_card.dart | 84 +++++++++ .../view/smart_power_device_control.dart | 67 +++++++ .../view/wall_light_batch_control.dart | 92 +++++++++ .../shared/device_batch_control_dialog.dart | 3 +- pubspec.lock | 32 ++-- pubspec.yaml | 1 + 12 files changed, 788 insertions(+), 13 deletions(-) create mode 100644 lib/pages/device_managment/power_clamp/bloc/smart_power_bloc.dart create mode 100644 lib/pages/device_managment/power_clamp/bloc/smart_power_event.dart create mode 100644 lib/pages/device_managment/power_clamp/bloc/smart_power_state.dart create mode 100644 lib/pages/device_managment/power_clamp/models/wall_light_status_model.dart create mode 100644 lib/pages/device_managment/power_clamp/view/power_chart.dart create mode 100644 lib/pages/device_managment/power_clamp/view/power_info_card.dart create mode 100644 lib/pages/device_managment/power_clamp/view/smart_power_device_control.dart create mode 100644 lib/pages/device_managment/power_clamp/view/wall_light_batch_control.dart diff --git a/lib/pages/device_managment/all_devices/helper/route_controls_based_code.dart b/lib/pages/device_managment/all_devices/helper/route_controls_based_code.dart index d4b5b21a..6e506a8e 100644 --- a/lib/pages/device_managment/all_devices/helper/route_controls_based_code.dart +++ b/lib/pages/device_managment/all_devices/helper/route_controls_based_code.dart @@ -18,6 +18,7 @@ import 'package:syncrow_web/pages/device_managment/main_door_sensor/view/main_do import 'package:syncrow_web/pages/device_managment/one_g_glass_switch/view/one_gang_glass_batch_control_view.dart'; import 'package:syncrow_web/pages/device_managment/one_gang_switch/view/wall_light_batch_control.dart'; import 'package:syncrow_web/pages/device_managment/one_gang_switch/view/wall_light_device_control.dart'; +import 'package:syncrow_web/pages/device_managment/power_clamp/view/smart_power_device_control.dart'; import 'package:syncrow_web/pages/device_managment/three_g_glass_switch/view/three_gang_glass_switch_batch_control_view.dart'; import 'package:syncrow_web/pages/device_managment/three_g_glass_switch/view/three_gang_glass_switch_control_view.dart'; import 'package:syncrow_web/pages/device_managment/three_gang_switch/view/living_room_batch_controls.dart'; @@ -94,6 +95,10 @@ mixin RouteControlsBasedCode { return WaterLeakView( deviceId: device.uuid!, ); + case 'PC': + return SmartPowerDeviceControl( + deviceId: device.uuid!, + ); default: return const SizedBox(); } @@ -224,6 +229,13 @@ mixin RouteControlsBasedCode { .map((e) => e.uuid!) .toList(), ); + case 'PC': + return WaterLeakBatchControlView( + deviceIds: devices + .where((e) => (e.productType == 'PC')) + .map((e) => e.uuid!) + .toList(), + ); default: return const SizedBox(); } diff --git a/lib/pages/device_managment/power_clamp/bloc/smart_power_bloc.dart b/lib/pages/device_managment/power_clamp/bloc/smart_power_bloc.dart new file mode 100644 index 00000000..d3eb7120 --- /dev/null +++ b/lib/pages/device_managment/power_clamp/bloc/smart_power_bloc.dart @@ -0,0 +1,171 @@ +import 'dart:async'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart'; +import 'package:syncrow_web/pages/device_managment/power_clamp/bloc/smart_power_event.dart'; +import 'package:syncrow_web/pages/device_managment/power_clamp/bloc/smart_power_state.dart'; +import 'package:syncrow_web/pages/device_managment/power_clamp/models/wall_light_status_model.dart'; +import 'package:syncrow_web/services/devices_mang_api.dart'; + +class SmartPowerBloc extends Bloc { + SmartPowerBloc({required this.deviceId}) : super(SmartPowerInitial()) { + on(_onFetchDeviceStatus); + on(_onControl); + on(_onFetchBatchStatus); + on(_onBatchControl); + on(_onFactoryReset); + } + + late SmartPowerStatusModel deviceStatus; + final String deviceId; + Timer? _timer; + + FutureOr _onFetchDeviceStatus( + SmartPowerFetchDeviceEvent event, Emitter emit) async { + emit(SmartPowerLoading()); + try { + // final status = + // await DevicesManagementApi().getDeviceStatus(event.deviceId); + // deviceStatus = + // SmartPowerStatusModel.fromJson(event.deviceId, status.status); + emit(SmartPowerStatusLoaded(deviceStatus)); + } catch (e) { + emit(SmartPowerError(e.toString())); + } + } + + FutureOr _onControl( + SmartPowerControl event, Emitter emit) async { + final oldValue = _getValueByCode(event.code); + + _updateLocalValue(event.code, event.value); + + emit(SmartPowerStatusLoaded(deviceStatus)); + + await _runDebounce( + deviceId: event.deviceId, + code: event.code, + value: event.value, + oldValue: oldValue, + emit: emit, + isBatch: false, + ); + } + + Future _runDebounce({ + required dynamic deviceId, + required String code, + required bool value, + required bool oldValue, + required Emitter emit, + required bool isBatch, + }) async { + late String id; + + if (deviceId is List) { + id = deviceId.first; + } else { + id = deviceId; + } + + if (_timer != null) { + _timer!.cancel(); + } + + _timer = Timer(const Duration(milliseconds: 500), () async { + try { + late bool response; + + if (isBatch) { + response = await DevicesManagementApi() + .deviceBatchControl(deviceId, code, value); + } else { + response = await DevicesManagementApi() + .deviceControl(deviceId, Status(code: code, value: value)); + } + + if (!response) { + _revertValueAndEmit(id, code, oldValue, emit); + } + } catch (e) { + _revertValueAndEmit(id, code, oldValue, emit); + } + }); + } + + void _revertValueAndEmit(String deviceId, String code, bool oldValue, + Emitter emit) { + _updateLocalValue(code, oldValue); + emit(SmartPowerStatusLoaded(deviceStatus)); + } + + void _updateLocalValue(String code, bool value) { + if (code == 'switch_1') { + deviceStatus = deviceStatus.copyWith(switch1: value); + } + } + + bool _getValueByCode(String code) { + switch (code) { + case 'switch_1': + return deviceStatus.switch1; + default: + return false; + } + } + + Future _onFetchBatchStatus( + SmartPowerFetchBatchEvent event, Emitter emit) async { + emit(SmartPowerLoading()); + try { + final status = + await DevicesManagementApi().getBatchStatus(event.devicesIds); + deviceStatus = + SmartPowerStatusModel.fromJson(event.devicesIds.first, status.status); + emit(SmartPowerStatusLoaded(deviceStatus)); + } catch (e) { + emit(SmartPowerError(e.toString())); + } + } + + @override + Future close() { + _timer?.cancel(); + return super.close(); + } + + FutureOr _onBatchControl( + SmartPowerBatchControl event, Emitter emit) async { + final oldValue = _getValueByCode(event.code); + + _updateLocalValue(event.code, event.value); + + emit(SmartPowerStatusLoaded(deviceStatus)); + + await _runDebounce( + deviceId: event.devicesIds, + code: event.code, + value: event.value, + oldValue: oldValue, + emit: emit, + isBatch: true, + ); + } + + FutureOr _onFactoryReset( + WallLightFactoryReset event, Emitter emit) async { + emit(SmartPowerLoading()); + try { + final response = await DevicesManagementApi().factoryReset( + event.factoryReset, + event.deviceId, + ); + if (!response) { + emit(SmartPowerError('Failed')); + } else { + emit(SmartPowerStatusLoaded(deviceStatus)); + } + } catch (e) { + emit(SmartPowerError(e.toString())); + } + } +} diff --git a/lib/pages/device_managment/power_clamp/bloc/smart_power_event.dart b/lib/pages/device_managment/power_clamp/bloc/smart_power_event.dart new file mode 100644 index 00000000..15a034fc --- /dev/null +++ b/lib/pages/device_managment/power_clamp/bloc/smart_power_event.dart @@ -0,0 +1,59 @@ +import 'package:equatable/equatable.dart'; +import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart'; + +class SmartPowerEvent extends Equatable { + @override + List get props => []; +} + +class SmartPowerFetchDeviceEvent extends SmartPowerEvent { + final String deviceId; + + SmartPowerFetchDeviceEvent(this.deviceId); + + @override + List get props => [deviceId]; +} + +class SmartPowerControl extends SmartPowerEvent { + final String deviceId; + final String code; + final bool value; + + SmartPowerControl( + {required this.deviceId, required this.code, required this.value}); + + @override + List get props => [deviceId, code, value]; +} + +class SmartPowerFetchBatchEvent extends SmartPowerEvent { + final List devicesIds; + + SmartPowerFetchBatchEvent(this.devicesIds); + + @override + List get props => [devicesIds]; +} + +class SmartPowerBatchControl extends SmartPowerEvent { + final List devicesIds; + final String code; + final bool value; + + SmartPowerBatchControl( + {required this.devicesIds, required this.code, required this.value}); + + @override + List get props => [devicesIds, code, value]; +} + +class WallLightFactoryReset extends SmartPowerEvent { + final String deviceId; + final FactoryResetModel factoryReset; + + WallLightFactoryReset({required this.deviceId, required this.factoryReset}); + + @override + List get props => [deviceId, factoryReset]; +} diff --git a/lib/pages/device_managment/power_clamp/bloc/smart_power_state.dart b/lib/pages/device_managment/power_clamp/bloc/smart_power_state.dart new file mode 100644 index 00000000..005f5c70 --- /dev/null +++ b/lib/pages/device_managment/power_clamp/bloc/smart_power_state.dart @@ -0,0 +1,56 @@ +import 'package:equatable/equatable.dart'; +import 'package:syncrow_web/pages/device_managment/power_clamp/models/wall_light_status_model.dart'; + +class SmartPowerState extends Equatable { + @override + List get props => []; +} + +class SmartPowerInitial extends SmartPowerState {} + +class SmartPowerLoading extends SmartPowerState {} + +class SmartPowerStatusLoaded extends SmartPowerState { + final SmartPowerStatusModel status; + + SmartPowerStatusLoaded(this.status); + + @override + List get props => [status]; +} + +class SmartPowerError extends SmartPowerState { + final String message; + + SmartPowerError(this.message); + + @override + List get props => [message]; +} + +class SmartPowerControlError extends SmartPowerState { + final String message; + + SmartPowerControlError(this.message); + + @override + List get props => [message]; +} + +class SmartPowerBatchControlError extends SmartPowerState { + final String message; + + SmartPowerBatchControlError(this.message); + + @override + List get props => [message]; +} + +class SmartPowerBatchStatusLoaded extends SmartPowerState { + final List status; + + SmartPowerBatchStatusLoaded(this.status); + + @override + List get props => [status]; +} diff --git a/lib/pages/device_managment/power_clamp/models/wall_light_status_model.dart b/lib/pages/device_managment/power_clamp/models/wall_light_status_model.dart new file mode 100644 index 00000000..15060492 --- /dev/null +++ b/lib/pages/device_managment/power_clamp/models/wall_light_status_model.dart @@ -0,0 +1,47 @@ +import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart'; + +class SmartPowerStatusModel { + final String uuid; + final bool switch1; + final int countDown; + + SmartPowerStatusModel({ + required this.uuid, + required this.switch1, + required this.countDown, + }); + + factory SmartPowerStatusModel.fromJson(String id, List jsonList) { + late bool switch1; + late int countDown; + + for (var status in jsonList) { + switch (status.code) { + case 'switch_1': + switch1 = status.value ?? false; + break; + case 'countdown_1': + countDown = status.value ?? 0; + break; + } + } + + return SmartPowerStatusModel( + uuid: id, + switch1: switch1, + countDown: countDown, + ); + } + + SmartPowerStatusModel copyWith({ + String? uuid, + bool? switch1, + int? countDown, + }) { + return SmartPowerStatusModel( + uuid: uuid ?? this.uuid, + switch1: switch1 ?? this.switch1, + countDown: countDown ?? this.countDown, + ); + } +} diff --git a/lib/pages/device_managment/power_clamp/view/power_chart.dart b/lib/pages/device_managment/power_clamp/view/power_chart.dart new file mode 100644 index 00000000..2cd4ce5b --- /dev/null +++ b/lib/pages/device_managment/power_clamp/view/power_chart.dart @@ -0,0 +1,177 @@ +import 'package:flutter/material.dart'; +import 'package:fl_chart/fl_chart.dart'; +import 'package:syncrow_web/utils/color_manager.dart'; + +class EnergyConsumptionPage extends StatefulWidget { + final List chartData; + final double totalConsumption; + final String date; + + EnergyConsumptionPage({ + required this.chartData, + required this.totalConsumption, + required this.date, + }); + + @override + _EnergyConsumptionPageState createState() => _EnergyConsumptionPageState(); +} + +class _EnergyConsumptionPageState extends State { + late List _chartData; + + @override + void initState() { + _chartData = widget.chartData; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Column( + children: [ + Expanded( + child: Padding( + padding: const EdgeInsets.only(top: 15), + child: LineChart( + LineChartData( + lineTouchData: LineTouchData( + handleBuiltInTouches: true, + touchSpotThreshold: 2, + getTouchLineEnd: (barData, spotIndex) { + return 10.0; + }, + touchTooltipData: LineTouchTooltipData( + getTooltipColor: (touchTooltipItem) => Colors.white, + tooltipRoundedRadius: 10.0, + tooltipPadding: const EdgeInsets.all(8.0), + tooltipBorder: BorderSide(color: Colors.grey, width: 1), + getTooltipItems: (List touchedSpots) { + return touchedSpots.map((spot) { + return LineTooltipItem( + '${spot.x},\n ${spot.y.toStringAsFixed(2)} kWh', + const TextStyle( + color: Colors.blue, + fontWeight: FontWeight.bold, + fontSize: 12, + ), + ); + }).toList(); + }, + )), + titlesData: FlTitlesData( + bottomTitles: AxisTitles( + sideTitles: SideTitles( + showTitles: false, + ), + ), + leftTitles: const AxisTitles( + sideTitles: SideTitles( + showTitles: false, + ), + ), + rightTitles: AxisTitles( + sideTitles: SideTitles( + showTitles: false, + ), + ), + topTitles: AxisTitles( + sideTitles: SideTitles( + showTitles: true, + reservedSize: 70, + getTitlesWidget: (value, meta) { + int index = value.toInt(); + if (index >= 0 && index < _chartData.length) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: RotatedBox( + quarterTurns: -1, + child: Text(_chartData[index].time, + style: TextStyle(fontSize: 10)), + ), + ); + } + return const SizedBox.shrink(); + }, + ), + ), + ), + gridData: FlGridData( + show: true, + drawVerticalLine: true, + horizontalInterval: 1, + verticalInterval: 1, + getDrawingVerticalLine: (value) { + return FlLine( + color: Colors.grey.withOpacity(0.2), + dashArray: [8, 8], + strokeWidth: 1, + ); + }, + getDrawingHorizontalLine: (value) { + return FlLine( + color: Colors.grey.withOpacity(0.2), + dashArray: [5, 5], + strokeWidth: 1, + ); + }, + drawHorizontalLine: false, + ), + lineBarsData: [ + LineChartBarData( + preventCurveOvershootingThreshold: 0.1, + curveSmoothness: 0.5, + preventCurveOverShooting: true, + aboveBarData: BarAreaData(), + spots: _chartData + .asMap() + .entries + .map((entry) => FlSpot( + entry.key.toDouble(), entry.value.consumption)) + .toList(), + isCurved: true, + color: ColorsManager.primaryColor.withOpacity(0.6), + show: true, + shadow: Shadow(color: Colors.black12), + belowBarData: BarAreaData( + show: true, + gradient: LinearGradient( + colors: [ + ColorsManager.primaryColor.withOpacity(0.5), + Colors.blue.withOpacity(0.1), + ], + begin: Alignment.center, + end: Alignment.bottomCenter, + ), + ), + dotData: FlDotData( + show: false, + ), + isStrokeCapRound: true, + barWidth: 2, + ), + ], + borderData: FlBorderData( + show: false, + border: Border.all( + color: Color(0xff023DFE).withOpacity(0.7), + width: 10, + ), + ), + ), + ), + ), + ), + ], + ), + ); + } +} + +class EnergyData { + EnergyData(this.time, this.consumption); + final String time; + final double consumption; +} +// \ No newline at end of file diff --git a/lib/pages/device_managment/power_clamp/view/power_info_card.dart b/lib/pages/device_managment/power_clamp/view/power_info_card.dart new file mode 100644 index 00000000..de90da4f --- /dev/null +++ b/lib/pages/device_managment/power_clamp/view/power_info_card.dart @@ -0,0 +1,84 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/painting.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:syncrow_web/utils/color_manager.dart'; + +class PowerClampInfoCard extends StatelessWidget { + final String iconPath; + final String title; + final String value; + final String unit; + + const PowerClampInfoCard({ + Key? key, + required this.iconPath, + required this.title, + required this.value, + required this.unit, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Expanded( + child: Padding( + padding: const EdgeInsets.all(5.0), + child: Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(20), + ), + height: 55, + color: ColorsManager.graysColor, + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Expanded( + child: SvgPicture.asset( + iconPath, + fit: BoxFit.fill, + ), + ), + Expanded( + flex: 3, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + value, + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.w700, + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + value, + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.w700, + ), + ), + Text( + unit, + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.w700, + ), + ), + ], + ), + ], + ), + ) + ], + ), + ), + ), + ); + } +} diff --git a/lib/pages/device_managment/power_clamp/view/smart_power_device_control.dart b/lib/pages/device_managment/power_clamp/view/smart_power_device_control.dart new file mode 100644 index 00000000..2e6ee338 --- /dev/null +++ b/lib/pages/device_managment/power_clamp/view/smart_power_device_control.dart @@ -0,0 +1,67 @@ +import 'package:flutter/material.dart'; +import 'package:syncrow_web/pages/device_managment/power_clamp/view/power_chart.dart'; +import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart'; + +//Smart Power Clamp +class SmartPowerDeviceControl extends StatelessWidget + with HelperResponsiveLayout { + final String deviceId; + + const SmartPowerDeviceControl({super.key, required this.deviceId}); + @override + Widget build(BuildContext context) { + return _buildStatusControls( + context, + ); + + // BlocProvider( + // create: (context) => SmartPowerBloc(deviceId: deviceId) + // ..add(SmartPowerFetchDeviceEvent(deviceId)), + // child: BlocBuilder( + // builder: (context, state) { + // if (state is SmartPowerLoading) { + // return const Center(child: CircularProgressIndicator()); + // } else if (state is SmartPowerStatusLoaded) { + // return _buildStatusControls(context, state.status); + // } + + // // else if (state is WallLightSwitchError || + // // state is WallLightSwitchControlError) { + // // return const Center(child: Text('Error fetching status')); + // // } else { + // return const Center(child: CircularProgressIndicator()); + // // } + // }, + // ), + // ); + } + + Widget _buildStatusControls( + BuildContext context, + ) { + final isExtraLarge = isExtraLargeScreenSize(context); + final isLarge = isLargeScreenSize(context); + final isMedium = isMediumScreenSize(context); + return Container( + height: 150, + child: EnergyConsumptionPage( + chartData: [ + EnergyData('12:00 AM', 4.0), + EnergyData('01:00 AM', 3.5), + EnergyData('02:00 AM', 3.8), + EnergyData('03:00 AM', 3.2), + EnergyData('04:00 AM', 4.0), + EnergyData('05:00 AM', 3.4), + EnergyData('06:00 AM', 3.2), + EnergyData('07:00 AM', 3.5), + EnergyData('08:00 AM', 3.8), + EnergyData('09:00 AM', 3.6), + EnergyData('10:00 AM', 3.9), + EnergyData('11:00 AM', 4.0), + ], + totalConsumption: 10000, + date: '10/08/2024', + ), + ); + } +} diff --git a/lib/pages/device_managment/power_clamp/view/wall_light_batch_control.dart b/lib/pages/device_managment/power_clamp/view/wall_light_batch_control.dart new file mode 100644 index 00000000..e1dabb61 --- /dev/null +++ b/lib/pages/device_managment/power_clamp/view/wall_light_batch_control.dart @@ -0,0 +1,92 @@ +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/one_gang_switch/bloc/wall_light_switch_bloc.dart'; +import 'package:syncrow_web/pages/device_managment/one_gang_switch/bloc/wall_light_switch_event.dart'; +import 'package:syncrow_web/pages/device_managment/one_gang_switch/bloc/wall_light_switch_state.dart'; +import 'package:syncrow_web/pages/device_managment/one_gang_switch/models/wall_light_status_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/toggle_widget.dart'; +import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart'; + +class WallLightBatchControlView extends StatelessWidget + with HelperResponsiveLayout { + const WallLightBatchControlView({super.key, required this.deviceIds}); + + final List deviceIds; + + @override + Widget build(BuildContext context) { + return BlocProvider( + create: (context) => WallLightSwitchBloc(deviceId: deviceIds.first) + ..add(WallLightSwitchFetchBatchEvent(deviceIds)), + child: BlocBuilder( + builder: (context, state) { + if (state is WallLightSwitchLoading) { + return const Center(child: CircularProgressIndicator()); + } else if (state is WallLightSwitchStatusLoaded) { + return _buildStatusControls(context, state.status); + } else if (state is WallLightSwitchError || + state is WallLightSwitchControlError) { + return const Center(child: Text('Error fetching status')); + } else { + return const Center(child: CircularProgressIndicator()); + } + }, + ), + ); + } + + Widget _buildStatusControls( + BuildContext context, WallLightStatusModel status) { + final isExtraLarge = isExtraLargeScreenSize(context); + final isLarge = isLargeScreenSize(context); + final isMedium = isMediumScreenSize(context); + return SizedBox( + child: 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: [ + ToggleWidget( + value: status.switch1, + code: 'switch_1', + deviceId: deviceIds.first, + label: 'Wall Light', + onChange: (value) { + context.read().add( + WallLightSwitchBatchControl( + devicesIds: deviceIds, + code: 'switch_1', + value: value, + ), + ); + }, + ), + FirmwareUpdateWidget( + deviceId: deviceIds.first, + version: 12, + ), + FactoryResetWidget( + callFactoryReset: () { + context.read().add(WallLightFactoryReset( + deviceId: status.uuid, + factoryReset: FactoryResetModel(devicesUuid: deviceIds))); + }, + ), + ], + ), + ); + } +} diff --git a/lib/pages/device_managment/shared/device_batch_control_dialog.dart b/lib/pages/device_managment/shared/device_batch_control_dialog.dart index 5076ef76..d11b1701 100644 --- a/lib/pages/device_managment/shared/device_batch_control_dialog.dart +++ b/lib/pages/device_managment/shared/device_batch_control_dialog.dart @@ -7,7 +7,8 @@ import 'package:syncrow_web/pages/device_managment/all_devices/helper/route_cont import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart'; import 'package:syncrow_web/utils/color_manager.dart'; -class DeviceBatchControlDialog extends StatelessWidget with RouteControlsBasedCode { +class DeviceBatchControlDialog extends StatelessWidget + with RouteControlsBasedCode { final List devices; const DeviceBatchControlDialog({super.key, required this.devices}); diff --git a/pubspec.lock b/pubspec.lock index 2c9cb88c..fa61b407 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -137,6 +137,14 @@ packages: url: "https://pub.dev" source: hosted version: "7.0.0" + fl_chart: + dependency: "direct main" + description: + name: fl_chart + sha256: "94307bef3a324a0d329d3ab77b2f0c6e5ed739185ffc029ed28c0f9b019ea7ef" + url: "https://pub.dev" + source: hosted + version: "0.69.0" flutter: dependency: "direct main" description: flutter @@ -292,18 +300,18 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" + sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" url: "https://pub.dev" source: hosted - version: "10.0.5" + version: "10.0.4" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" + sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" url: "https://pub.dev" source: hosted - version: "3.0.5" + version: "3.0.3" leak_tracker_testing: dependency: transitive description: @@ -340,18 +348,18 @@ packages: dependency: transitive description: name: material_color_utilities - sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" url: "https://pub.dev" source: hosted - version: "0.11.1" + version: "0.8.0" meta: dependency: transitive description: name: meta - sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.12.0" nested: dependency: transitive description: @@ -561,10 +569,10 @@ packages: dependency: transitive description: name: test_api - sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" url: "https://pub.dev" source: hosted - version: "0.7.2" + version: "0.7.0" typed_data: dependency: transitive description: @@ -609,10 +617,10 @@ packages: dependency: transitive description: name: vm_service - sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" + sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" url: "https://pub.dev" source: hosted - version: "14.2.5" + version: "14.2.1" web: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index dfeb1ff9..7742e4da 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -49,6 +49,7 @@ dependencies: intl: ^0.19.0 dropdown_search: ^5.0.6 flutter_dotenv: ^5.1.0 + fl_chart: ^0.69.0 dev_dependencies: flutter_test: