Compare commits

..

1 Commits

77 changed files with 541 additions and 2452 deletions

View File

@ -1,8 +0,0 @@
<svg width="175" height="134" viewBox="0 0 175 134" fill="none" xmlns="http://www.w3.org/2000/svg">
<line x1="0.5" y1="2.18557e-08" x2="0.499994" y2="132.759" stroke="#B9C0C5"/>
<line x1="175" y1="133.259" x2="-4.37114e-08" y2="133.259" stroke="#B9C0C5"/>
<rect x="16.0922" y="66.3794" width="28.1609" height="66.3793" fill="#C7CDD1"/>
<rect x="54.3105" y="24.1379" width="28.1609" height="108.621" fill="#ABB4BA"/>
<rect x="92.5288" y="78.4484" width="28.1609" height="54.3103" fill="#C7CDD1"/>
<rect x="130.747" y="48.2759" width="28.1609" height="84.4828" fill="#ABB4BA"/>
</svg>

Before

Width:  |  Height:  |  Size: 583 B

View File

@ -1,5 +0,0 @@
<svg width="175" height="134" viewBox="0 0 175 134" fill="none" xmlns="http://www.w3.org/2000/svg">
<line x1="0.5" y1="3.05394e-05" x2="0.499994" y2="132.759" stroke="#B9C0C5"/>
<line x1="175" y1="133.259" x2="-4.37114e-08" y2="133.259" stroke="#B9C0C5"/>
<path d="M1.5 132.5C13 132.5 6.58852 66.5 29.5 66.5C46.5 66.5 46.1214 24.9349 68.5 24.5C94.2816 23.999 80.7136 78.5065 106.5 78.5C125.715 78.4952 131.5 48.5 145.5 48.5C159.5 48.5 156.5 96 171.5 96" stroke="#ABB4BA" stroke-width="2" stroke-linecap="round"/>
</svg>

Before

Width:  |  Height:  |  Size: 520 B

View File

@ -1,7 +0,0 @@
<svg width="175" height="134" viewBox="0 0 175 134" fill="none" xmlns="http://www.w3.org/2000/svg">
<line x1="0.5" y1="2.18557e-08" x2="0.499994" y2="132.759" stroke="#B9C0C5"/>
<line x1="175" y1="133.259" x2="-4.37114e-08" y2="133.259" stroke="#B9C0C5"/>
<path d="M1.5 132.5C13 132.5 6.58852 66.5 29.5 66.5C46.5 66.5 46.1214 24.9348 68.5 24.5C94.2816 23.999 80.7136 78.5064 106.5 78.5C125.715 78.4951 131.5 48.5 145.5 48.5C159.5 48.5 156.5 95.9999 171.5 95.9999" stroke="#ABB4BA" stroke-width="1.5" stroke-linecap="round" stroke-dasharray="4 4"/>
<path d="M1.5 132.5C13 132.5 6.58852 78.4999 29.5 78.4999C46.5 78.4999 45.6214 44.9349 68 44.5C93.7816 43.999 80.7136 27.0065 106.5 27C125.715 26.9952 131.5 63.5 145.5 63.5C159.5 63.5 156.5 113.5 171.5 113.5" stroke="#C7CDD1" stroke-width="1.5" stroke-linecap="round" stroke-dasharray="4 4"/>
<path d="M1.5 132.5C13 132.5 6.58852 85.9999 29.5 85.9999C46.5 85.9999 45.6214 11.9348 68 11.4999C93.7816 10.9989 80.7136 43.5064 106.5 43.4999C125.715 43.4951 131.5 35.4999 145.5 35.4999C159.5 35.4999 156.5 105.5 171.5 105.5" stroke="#D5D5D5" stroke-width="1.5" stroke-linecap="round" stroke-dasharray="4 4"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,99 +0,0 @@
<svg width="181" height="121" viewBox="0 0 181 121" fill="none" xmlns="http://www.w3.org/2000/svg">
<line x1="15.5" y1="-2.52181e-08" x2="15.5" y2="120" stroke="#B9B9B9"/>
<line x1="45.5" y1="-2.52181e-08" x2="45.5" y2="120" stroke="#B9B9B9"/>
<line x1="75.5" y1="-2.52181e-08" x2="75.5" y2="120" stroke="#B9B9B9"/>
<line x1="105.5" y1="-2.52181e-08" x2="105.5" y2="120" stroke="#B9B9B9"/>
<line x1="135.5" y1="-2.52181e-08" x2="135.5" y2="120" stroke="#B9B9B9"/>
<line x1="165.5" y1="-2.52181e-08" x2="165.5" y2="120" stroke="#B9B9B9"/>
<line x1="30.5" y1="-2.52181e-08" x2="30.5" y2="120" stroke="#B9B9B9"/>
<line x1="60.5" y1="-2.52181e-08" x2="60.5" y2="120" stroke="#B9B9B9"/>
<line x1="90.5" y1="-2.52181e-08" x2="90.5" y2="120" stroke="#B9B9B9"/>
<line x1="120.5" y1="-2.52181e-08" x2="120.5" y2="120" stroke="#B9B9B9"/>
<line x1="150.5" y1="-2.52181e-08" x2="150.5" y2="120" stroke="#B9B9B9"/>
<line x1="180.5" y1="-2.52181e-08" x2="180.5" y2="120" stroke="#B9B9B9"/>
<line x1="181" y1="120.5" x2="-4.52101e-08" y2="120.5" stroke="#B9B9B9"/>
<line x1="181" y1="60.5" x2="-4.52101e-08" y2="60.5" stroke="#B9B9B9"/>
<line x1="181" y1="90.5" x2="-4.52101e-08" y2="90.5" stroke="#B9B9B9"/>
<line x1="181" y1="30.5" x2="-4.52101e-08" y2="30.5" stroke="#B9B9B9"/>
<line x1="181" y1="105.5" x2="-4.52101e-08" y2="105.5" stroke="#B9B9B9"/>
<line x1="181" y1="45.5" x2="-4.52101e-08" y2="45.5" stroke="#B9B9B9"/>
<line x1="181" y1="75.5" x2="-4.52101e-08" y2="75.5" stroke="#B9B9B9"/>
<line x1="181" y1="15.5" x2="-4.52101e-08" y2="15.5" stroke="#B9B9B9"/>
<rect x="16" y="16" width="14" height="14" fill="#F2F2F2"/>
<rect x="31" y="16" width="14" height="14" fill="#F2F2F2"/>
<rect x="46" y="16" width="14" height="14" fill="#F2F2F2"/>
<rect x="61" y="16" width="14" height="14" fill="#F2F2F2"/>
<rect x="76" y="16" width="14" height="14" fill="#F2F2F2"/>
<rect x="91" y="16" width="14" height="14" fill="#F2F2F2"/>
<rect x="106" y="16" width="14" height="14" fill="#F2F2F2"/>
<rect x="121" y="16" width="14" height="14" fill="#F2F2F2"/>
<rect x="136" y="16" width="14" height="14" fill="#F2F2F2"/>
<rect x="151" y="16" width="14" height="14" fill="#F2F2F2"/>
<rect x="166" y="16" width="14" height="14" fill="#F2F2F2"/>
<rect x="16" y="31" width="14" height="14" fill="#F2F2F2"/>
<rect x="31" y="31" width="14" height="14" fill="#D5D5D5"/>
<rect x="46" y="31" width="14" height="14" fill="#D5D5D5"/>
<rect x="61" y="31" width="14" height="14" fill="#D5D5D5"/>
<rect x="76" y="31" width="14" height="14" fill="#D5D5D5"/>
<rect x="91" y="31" width="14" height="14" fill="#D5D5D5"/>
<rect x="106" y="31" width="14" height="14" fill="#D5D5D5"/>
<rect x="121" y="31" width="14" height="14" fill="#D5D5D5"/>
<rect x="136" y="31" width="14" height="14" fill="#D5D5D5"/>
<rect x="151" y="31" width="14" height="14" fill="#D5D5D5"/>
<rect x="166" y="31" width="14" height="14" fill="#F2F2F2"/>
<rect x="16" y="46" width="14" height="14" fill="#F2F2F2"/>
<rect x="31" y="46" width="14" height="14" fill="#D5D5D5"/>
<rect x="46" y="46" width="14" height="14" fill="#D5D5D5"/>
<rect x="61" y="46" width="14" height="14" fill="#D5D5D5"/>
<rect x="76" y="46" width="14" height="14" fill="#D5D5D5"/>
<rect x="91" y="46" width="14" height="14" fill="#D5D5D5"/>
<rect x="106" y="46" width="14" height="14" fill="#D5D5D5"/>
<rect x="121" y="46" width="14" height="14" fill="#D5D5D5"/>
<rect x="136" y="46" width="14" height="14" fill="#D5D5D5"/>
<rect x="151" y="46" width="14" height="14" fill="#D5D5D5"/>
<rect x="166" y="46" width="14" height="14" fill="#F2F2F2"/>
<rect x="16" y="61" width="14" height="14" fill="#F2F2F2"/>
<rect x="31" y="61" width="14" height="14" fill="#D5D5D5"/>
<rect x="46" y="61" width="14" height="14" fill="#D5D5D5"/>
<rect x="61" y="61" width="14" height="14" fill="#B1B1B1"/>
<rect x="76" y="61" width="14" height="14" fill="#B1B1B1"/>
<rect x="91" y="61" width="14" height="14" fill="#B1B1B1"/>
<rect x="106" y="61" width="14" height="14" fill="#B1B1B1"/>
<rect x="121" y="61" width="14" height="14" fill="#B1B1B1"/>
<rect x="136" y="61" width="14" height="14" fill="#D5D5D5"/>
<rect x="151" y="61" width="14" height="14" fill="#D5D5D5"/>
<rect x="166" y="61" width="14" height="14" fill="#F2F2F2"/>
<rect x="16" y="76" width="14" height="14" fill="#F2F2F2"/>
<rect x="31" y="76" width="14" height="14" fill="#D5D5D5"/>
<rect x="46" y="76" width="14" height="14" fill="#D5D5D5"/>
<rect x="61" y="76" width="14" height="14" fill="#D5D5D5"/>
<rect x="76" y="76" width="14" height="14" fill="#D5D5D5"/>
<rect x="91" y="76" width="14" height="14" fill="#D5D5D5"/>
<rect x="106" y="76" width="14" height="14" fill="#D5D5D5"/>
<rect x="121" y="76" width="14" height="14" fill="#D5D5D5"/>
<rect x="136" y="76" width="14" height="14" fill="#D5D5D5"/>
<rect x="151" y="76" width="14" height="14" fill="#D5D5D5"/>
<rect x="166" y="76" width="14" height="14" fill="#F2F2F2"/>
<rect x="16" y="91" width="14" height="14" fill="#F2F2F2"/>
<rect x="31" y="91" width="14" height="14" fill="#D5D5D5"/>
<rect x="46" y="91" width="14" height="14" fill="#D5D5D5"/>
<rect x="61" y="91" width="14" height="14" fill="#D5D5D5"/>
<rect x="76" y="91" width="14" height="14" fill="#D5D5D5"/>
<rect x="91" y="91" width="14" height="14" fill="#D5D5D5"/>
<rect x="106" y="91" width="14" height="14" fill="#D5D5D5"/>
<rect x="121" y="91" width="14" height="14" fill="#D5D5D5"/>
<rect x="136" y="91" width="14" height="14" fill="#D5D5D5"/>
<rect x="151" y="91" width="14" height="14" fill="#D5D5D5"/>
<rect x="166" y="91" width="14" height="14" fill="#F2F2F2"/>
<rect x="16" y="106" width="14" height="14" fill="#F2F2F2"/>
<rect x="31" y="106" width="14" height="14" fill="#F2F2F2"/>
<rect x="46" y="106" width="14" height="14" fill="#F2F2F2"/>
<rect x="61" y="106" width="14" height="14" fill="#F2F2F2"/>
<rect x="76" y="106" width="14" height="14" fill="#F2F2F2"/>
<rect x="91" y="106" width="14" height="14" fill="#F2F2F2"/>
<rect x="106" y="106" width="14" height="14" fill="#F2F2F2"/>
<rect x="121" y="106" width="14" height="14" fill="#F2F2F2"/>
<rect x="136" y="106" width="14" height="14" fill="#F2F2F2"/>
<rect x="151" y="106" width="14" height="14" fill="#F2F2F2"/>
<rect x="166" y="106" width="14" height="14" fill="#F2F2F2"/>
</svg>

Before

Width:  |  Height:  |  Size: 6.1 KiB

View File

@ -1,7 +0,0 @@
<svg width="175" height="134" viewBox="0 0 175 134" fill="none" xmlns="http://www.w3.org/2000/svg">
<line x1="0.5" y1="2.18557e-08" x2="0.499994" y2="132.759" stroke="#B9C0C5"/>
<line x1="175" y1="133.259" x2="-4.37114e-08" y2="133.259" stroke="#B9C0C5"/>
<path d="M1.5 95.9999C13 95.9999 6.58853 66.4999 29.5 66.4999C46.5 66.4999 46.1214 34.9348 68.5 34.4999C94.2816 33.9989 80.7136 65.0065 106.5 65C125.715 64.9952 131.5 50.5 145.5 50.5C159.5 50.5 156.5 70.5 171.5 70.5" stroke="#C7CDD1" stroke-width="2" stroke-linecap="round"/>
<path d="M1.5 106C13 106 6.58853 76.4999 29.5 76.4999C46.5 76.4999 46.1214 44.9348 68.5 44.4999C94.2816 43.9989 80.7136 75.0065 106.5 75C125.715 74.9952 131.5 60.5 145.5 60.5C159.5 60.5 156.5 80.5 171.5 80.5" stroke="#F2F2F2" stroke-width="2" stroke-linecap="round"/>
<path d="M1.5 116C13 116 6.58853 86.4999 29.5 86.4999C46.5 86.4999 46.1214 54.9348 68.5 54.4999C94.2816 53.9989 80.7136 85.0065 106.5 85C125.715 84.9952 131.5 70.5 145.5 70.5C159.5 70.5 156.5 90.5 171.5 90.5" stroke="#ABB4BA" stroke-width="2" stroke-linecap="round"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -20,7 +20,6 @@ class AqiDistributionChart extends StatelessWidget {
return BarChart( return BarChart(
BarChartData( BarChartData(
maxY: 100.1, maxY: 100.1,
alignment: BarChartAlignment.start,
gridData: EnergyManagementChartsHelper.gridData( gridData: EnergyManagementChartsHelper.gridData(
horizontalInterval: 20, horizontalInterval: 20,
), ),

View File

@ -3,9 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/analytics/modules/air_quality/blocs/air_quality_distribution/air_quality_distribution_bloc.dart'; import 'package:syncrow_web/pages/analytics/modules/air_quality/blocs/air_quality_distribution/air_quality_distribution_bloc.dart';
import 'package:syncrow_web/pages/analytics/modules/air_quality/widgets/aqi_distribution_chart.dart'; import 'package:syncrow_web/pages/analytics/modules/air_quality/widgets/aqi_distribution_chart.dart';
import 'package:syncrow_web/pages/analytics/modules/air_quality/widgets/aqi_distribution_chart_title.dart'; import 'package:syncrow_web/pages/analytics/modules/air_quality/widgets/aqi_distribution_chart_title.dart';
import 'package:syncrow_web/pages/analytics/widgets/analytics_chart_empty_state_widget.dart';
import 'package:syncrow_web/pages/analytics/widgets/analytics_error_widget.dart'; import 'package:syncrow_web/pages/analytics/widgets/analytics_error_widget.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
import 'package:syncrow_web/utils/style.dart'; import 'package:syncrow_web/utils/style.dart';
class AqiDistributionChartBox extends StatelessWidget { class AqiDistributionChartBox extends StatelessWidget {
@ -34,20 +32,8 @@ class AqiDistributionChartBox extends StatelessWidget {
const SizedBox(height: 10), const SizedBox(height: 10),
const Divider(), const Divider(),
const SizedBox(height: 20), const SizedBox(height: 20),
Visibility( Expanded(
visible: state.chartData.isNotEmpty, child: AqiDistributionChart(chartData: state.chartData),
replacement: AnalyticsChartEmptyStateWidget(
isLoading: state.status == AirQualityDistributionStatus.loading,
isError: state.status == AirQualityDistributionStatus.failure,
isInitial: state.status == AirQualityDistributionStatus.initial,
errorMessage: state.errorMessage,
iconPath: Assets.emptyBarredChart,
),
child: Expanded(
child: AqiDistributionChart(
chartData: state.chartData,
),
),
), ),
], ],
), ),

View File

@ -3,9 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/analytics/modules/air_quality/blocs/range_of_aqi/range_of_aqi_bloc.dart'; import 'package:syncrow_web/pages/analytics/modules/air_quality/blocs/range_of_aqi/range_of_aqi_bloc.dart';
import 'package:syncrow_web/pages/analytics/modules/air_quality/widgets/range_of_aqi_chart.dart'; import 'package:syncrow_web/pages/analytics/modules/air_quality/widgets/range_of_aqi_chart.dart';
import 'package:syncrow_web/pages/analytics/modules/air_quality/widgets/range_of_aqi_chart_title.dart'; import 'package:syncrow_web/pages/analytics/modules/air_quality/widgets/range_of_aqi_chart_title.dart';
import 'package:syncrow_web/pages/analytics/widgets/analytics_chart_empty_state_widget.dart';
import 'package:syncrow_web/pages/analytics/widgets/analytics_error_widget.dart'; import 'package:syncrow_web/pages/analytics/widgets/analytics_error_widget.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
import 'package:syncrow_web/utils/style.dart'; import 'package:syncrow_web/utils/style.dart';
class RangeOfAqiChartBox extends StatelessWidget { class RangeOfAqiChartBox extends StatelessWidget {
@ -34,20 +32,10 @@ class RangeOfAqiChartBox extends StatelessWidget {
const SizedBox(height: 10), const SizedBox(height: 10),
const Divider(), const Divider(),
const SizedBox(height: 20), const SizedBox(height: 20),
Visibility( Expanded(
visible: state.filteredRangeOfAqi.isNotEmpty, child: RangeOfAqiChart(
replacement: AnalyticsChartEmptyStateWidget( chartData: state.filteredRangeOfAqi,
isLoading: state.status == RangeOfAqiStatus.loading, selectedAqiType: state.selectedAqiType,
isError: state.status == RangeOfAqiStatus.failure,
isInitial: state.status == RangeOfAqiStatus.initial,
errorMessage: state.errorMessage,
iconPath: Assets.emptyRangeOfAqi,
),
child: Expanded(
child: RangeOfAqiChart(
chartData: state.filteredRangeOfAqi,
selectedAqiType: state.selectedAqiType,
),
), ),
), ),
], ],

View File

@ -38,7 +38,7 @@ class AnalyticsEnergyManagementView extends StatelessWidget {
return SingleChildScrollView( return SingleChildScrollView(
child: Container( child: Container(
padding: _padding, padding: _padding,
height: MediaQuery.sizeOf(context).height * 1.05, height: MediaQuery.sizeOf(context).height * 1,
child: const Column( child: const Column(
children: [ children: [
Expanded( Expanded(

View File

@ -5,10 +5,8 @@ import 'package:syncrow_web/pages/analytics/modules/energy_management/blocs/ener
import 'package:syncrow_web/pages/analytics/modules/energy_management/widgets/chart_title.dart'; import 'package:syncrow_web/pages/analytics/modules/energy_management/widgets/chart_title.dart';
import 'package:syncrow_web/pages/analytics/modules/energy_management/widgets/energy_consumption_per_device_chart.dart'; import 'package:syncrow_web/pages/analytics/modules/energy_management/widgets/energy_consumption_per_device_chart.dart';
import 'package:syncrow_web/pages/analytics/modules/energy_management/widgets/energy_consumption_per_device_devices_list.dart'; import 'package:syncrow_web/pages/analytics/modules/energy_management/widgets/energy_consumption_per_device_devices_list.dart';
import 'package:syncrow_web/pages/analytics/widgets/analytics_chart_empty_state_widget.dart';
import 'package:syncrow_web/pages/analytics/widgets/analytics_error_widget.dart'; import 'package:syncrow_web/pages/analytics/widgets/analytics_error_widget.dart';
import 'package:syncrow_web/pages/analytics/widgets/charts_loading_widget.dart'; import 'package:syncrow_web/pages/analytics/widgets/charts_loading_widget.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
import 'package:syncrow_web/utils/style.dart'; import 'package:syncrow_web/utils/style.dart';
class EnergyConsumptionPerDeviceChartBox extends StatelessWidget { class EnergyConsumptionPerDeviceChartBox extends StatelessWidget {
@ -56,24 +54,8 @@ class EnergyConsumptionPerDeviceChartBox extends StatelessWidget {
const SizedBox(height: 20), const SizedBox(height: 20),
const Divider(height: 0), const Divider(height: 0),
const SizedBox(height: 20), const SizedBox(height: 20),
Visibility( Expanded(
visible: state.chartData.isNotEmpty && child: EnergyConsumptionPerDeviceChart(chartData: state.chartData),
state.chartData
.every((e) => e.energy.every((e) => e.value != 0)),
replacement: AnalyticsChartEmptyStateWidget(
isLoading:
state.status == EnergyConsumptionPerDeviceStatus.loading,
isError: state.status == EnergyConsumptionPerDeviceStatus.failure,
isInitial:
state.status == EnergyConsumptionPerDeviceStatus.initial,
errorMessage: state.errorMessage,
iconPath: Assets.emptyEnergyManagementPerDevice,
),
child: Expanded(
child: EnergyConsumptionPerDeviceChart(
chartData: state.chartData,
),
),
), ),
], ],
), ),

View File

@ -3,10 +3,8 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/analytics/modules/energy_management/blocs/total_energy_consumption/total_energy_consumption_bloc.dart'; import 'package:syncrow_web/pages/analytics/modules/energy_management/blocs/total_energy_consumption/total_energy_consumption_bloc.dart';
import 'package:syncrow_web/pages/analytics/modules/energy_management/widgets/chart_title.dart'; import 'package:syncrow_web/pages/analytics/modules/energy_management/widgets/chart_title.dart';
import 'package:syncrow_web/pages/analytics/modules/energy_management/widgets/total_energy_consumption_chart.dart'; import 'package:syncrow_web/pages/analytics/modules/energy_management/widgets/total_energy_consumption_chart.dart';
import 'package:syncrow_web/pages/analytics/widgets/analytics_chart_empty_state_widget.dart';
import 'package:syncrow_web/pages/analytics/widgets/analytics_error_widget.dart'; import 'package:syncrow_web/pages/analytics/widgets/analytics_error_widget.dart';
import 'package:syncrow_web/pages/analytics/widgets/charts_loading_widget.dart'; import 'package:syncrow_web/pages/analytics/widgets/charts_loading_widget.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
import 'package:syncrow_web/utils/style.dart'; import 'package:syncrow_web/utils/style.dart';
class TotalEnergyConsumptionChartBox extends StatelessWidget { class TotalEnergyConsumptionChartBox extends StatelessWidget {
@ -43,18 +41,7 @@ class TotalEnergyConsumptionChartBox extends StatelessWidget {
const SizedBox(height: 20), const SizedBox(height: 20),
const Divider(), const Divider(),
const SizedBox(height: 20), const SizedBox(height: 20),
Visibility( TotalEnergyConsumptionChart(chartData: state.chartData),
visible: state.chartData.isNotEmpty &&
state.chartData.every((e) => e.value != 0),
replacement: AnalyticsChartEmptyStateWidget(
isLoading: state.status == TotalEnergyConsumptionStatus.loading,
isError: state.status == TotalEnergyConsumptionStatus.failure,
isInitial: state.status == TotalEnergyConsumptionStatus.initial,
errorMessage: state.errorMessage,
iconPath: Assets.emptyEnergyManagementChart,
),
child: TotalEnergyConsumptionChart(chartData: state.chartData),
),
], ],
), ),
), ),

View File

@ -18,7 +18,6 @@ class OccupancyChart extends StatelessWidget {
return BarChart( return BarChart(
BarChartData( BarChartData(
maxY: 100.001, maxY: 100.001,
alignment: BarChartAlignment.start,
gridData: EnergyManagementChartsHelper.gridData().copyWith( gridData: EnergyManagementChartsHelper.gridData().copyWith(
checkToShowHorizontalLine: (value) => true, checkToShowHorizontalLine: (value) => true,
horizontalInterval: 20, horizontalInterval: 20,

View File

@ -6,10 +6,8 @@ import 'package:syncrow_web/pages/analytics/modules/energy_management/widgets/ch
import 'package:syncrow_web/pages/analytics/modules/occupancy/blocs/occupancy/occupancy_bloc.dart'; import 'package:syncrow_web/pages/analytics/modules/occupancy/blocs/occupancy/occupancy_bloc.dart';
import 'package:syncrow_web/pages/analytics/modules/occupancy/helpers/fetch_occupancy_data_helper.dart'; import 'package:syncrow_web/pages/analytics/modules/occupancy/helpers/fetch_occupancy_data_helper.dart';
import 'package:syncrow_web/pages/analytics/modules/occupancy/widgets/occupancy_chart.dart'; import 'package:syncrow_web/pages/analytics/modules/occupancy/widgets/occupancy_chart.dart';
import 'package:syncrow_web/pages/analytics/widgets/analytics_chart_empty_state_widget.dart';
import 'package:syncrow_web/pages/analytics/widgets/analytics_error_widget.dart'; import 'package:syncrow_web/pages/analytics/widgets/analytics_error_widget.dart';
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart'; import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
import 'package:syncrow_web/utils/style.dart'; import 'package:syncrow_web/utils/style.dart';
class OccupancyChartBox extends StatelessWidget { class OccupancyChartBox extends StatelessWidget {
@ -69,24 +67,7 @@ class OccupancyChartBox extends StatelessWidget {
const SizedBox(height: 20), const SizedBox(height: 20),
const Divider(), const Divider(),
const SizedBox(height: 20), const SizedBox(height: 20),
Visibility( Expanded(child: OccupancyChart(chartData: state.chartData)),
visible: state.chartData.isNotEmpty &&
state.chartData.every(
(e) => e.occupancy.isNotEmpty,
),
replacement: AnalyticsChartEmptyStateWidget(
isLoading: state.status == OccupancyStatus.loading,
isError: state.status == OccupancyStatus.failure,
isInitial: state.status == OccupancyStatus.initial,
errorMessage: state.errorMessage,
iconPath: Assets.emptyBarredChart,
),
child: Expanded(
child: OccupancyChart(
chartData: state.chartData,
),
),
),
], ],
), ),
); );

View File

@ -6,10 +6,8 @@ import 'package:syncrow_web/pages/analytics/modules/energy_management/widgets/ch
import 'package:syncrow_web/pages/analytics/modules/occupancy/blocs/occupancy_heat_map/occupancy_heat_map_bloc.dart'; import 'package:syncrow_web/pages/analytics/modules/occupancy/blocs/occupancy_heat_map/occupancy_heat_map_bloc.dart';
import 'package:syncrow_web/pages/analytics/modules/occupancy/helpers/fetch_occupancy_data_helper.dart'; import 'package:syncrow_web/pages/analytics/modules/occupancy/helpers/fetch_occupancy_data_helper.dart';
import 'package:syncrow_web/pages/analytics/modules/occupancy/widgets/occupancy_heat_map.dart'; import 'package:syncrow_web/pages/analytics/modules/occupancy/widgets/occupancy_heat_map.dart';
import 'package:syncrow_web/pages/analytics/widgets/analytics_chart_empty_state_widget.dart';
import 'package:syncrow_web/pages/analytics/widgets/analytics_error_widget.dart'; import 'package:syncrow_web/pages/analytics/widgets/analytics_error_widget.dart';
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart'; import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
import 'package:syncrow_web/utils/style.dart'; import 'package:syncrow_web/utils/style.dart';
class OccupancyHeatMapBox extends StatelessWidget { class OccupancyHeatMapBox extends StatelessWidget {
@ -70,29 +68,16 @@ class OccupancyHeatMapBox extends StatelessWidget {
const SizedBox(height: 20), const SizedBox(height: 20),
const Divider(), const Divider(),
const SizedBox(height: 20), const SizedBox(height: 20),
Visibility( Expanded(
visible: state.heatMapData.isNotEmpty && child: OccupancyHeatMap(
state.heatMapData.every( selectedDate:
(e) => e.countTotalPresenceDetected != 0, context.watch<AnalyticsDatePickerBloc>().state.yearlyDate,
), heatMapData: state.heatMapData.asMap().map(
replacement: AnalyticsChartEmptyStateWidget( (_, value) => MapEntry(
isLoading: state.status == OccupancyHeatMapStatus.loading, value.eventDate,
isError: state.status == OccupancyHeatMapStatus.failure, value.countTotalPresenceDetected,
isInitial: state.status == OccupancyHeatMapStatus.initial,
errorMessage: state.errorMessage,
iconPath: Assets.emptyHeatmap,
),
child: Expanded(
child: OccupancyHeatMap(
selectedDate:
context.watch<AnalyticsDatePickerBloc>().state.yearlyDate,
heatMapData: state.heatMapData.asMap().map(
(_, value) => MapEntry(
value.eventDate,
value.countTotalPresenceDetected,
),
), ),
), ),
), ),
), ),
], ],

View File

@ -17,8 +17,8 @@ class DeviceLocationDetailsServiceDecorator implements DeviceLocationService {
'reverse', 'reverse',
queryParameters: { queryParameters: {
'format': 'json', 'format': 'json',
'lat': 25.1880567, 'lat': param.latitude,
'lon': 55.266608, 'lon': param.longitude,
}, },
); );

View File

@ -1,68 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:syncrow_web/common/widgets/app_loading_indicator.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/extension/build_context_x.dart';
class AnalyticsChartEmptyStateWidget extends StatelessWidget {
const AnalyticsChartEmptyStateWidget({
required this.iconPath,
this.isLoading = false,
this.isError = false,
this.isInitial = false,
this.errorMessage,
this.noDataMessage = 'No data to display',
this.initialMessage = 'Please select a space to see data',
super.key,
});
final bool isLoading;
final bool isError;
final bool isInitial;
final String? errorMessage;
final String noDataMessage;
final String initialMessage;
final String iconPath;
@override
Widget build(BuildContext context) {
return Expanded(
child: _buildWidgetBasedOnState(context),
);
}
Widget _buildWidgetBasedOnState(BuildContext context) {
final widgetsMap = {
isLoading: const AppLoadingIndicator(),
isInitial: _buildState(context, initialMessage),
isError: _buildState(context, errorMessage ?? 'Something went wrong'),
};
return widgetsMap[true] ?? _buildState(context, noDataMessage);
}
Widget _buildState(BuildContext context, String message) {
return Center(
child: Column(
spacing: 16,
mainAxisAlignment: MainAxisAlignment.center,
children: [
const SizedBox(height: 16),
Expanded(child: SvgPicture.asset(iconPath, fit: BoxFit.contain)),
SelectableText(
message,
style: isError
? context.textTheme.bodyMedium?.copyWith(
color: ColorsManager.red,
fontSize: 16,
fontWeight: FontWeight.w700,
)
: null,
textAlign: TextAlign.center,
),
const SizedBox(height: 16),
],
),
);
}
}

View File

@ -57,9 +57,6 @@ class Status {
}; };
} }
factory Status.fromJson(String source) => Status.fromMap(json.decode(source));
String toJson() => json.encode(toMap());
Status copyWith({ Status copyWith({
String? code, String? code,
dynamic value, dynamic value,
@ -69,4 +66,8 @@ class Status {
value: value ?? this.value, value: value ?? this.value,
); );
} }
factory Status.fromJson(String source) => Status.fromMap(json.decode(source));
String toJson() => json.encode(toMap());
} }

View File

@ -68,6 +68,7 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
children: [ children: [
Expanded(child: SpaceTreeView( Expanded(child: SpaceTreeView(
onSelect: () { onSelect: () {
context.read<DeviceManagementBloc>().add(ResetFilters());
context.read<DeviceManagementBloc>().add(FetchDevices(context)); context.read<DeviceManagementBloc>().add(FetchDevices(context));
}, },
)), )),

View File

@ -62,10 +62,9 @@ class CurtainModuleItems extends StatelessWidget with HelperResponsiveLayout {
BlocProvider.of<CurtainModuleBloc>(context), BlocProvider.of<CurtainModuleBloc>(context),
child: BuildScheduleView( child: BuildScheduleView(
deviceUuid: deviceId, deviceUuid: deviceId,
category: 'Timer', category: 'CUR_2',
code: 'control', code: 'control',
countdownCode: 'Timer',
deviceType: 'CUR_2',
), ),
)); ));
}, },

View File

@ -40,7 +40,7 @@ class OneGangGlassSwitchBloc
emit(OneGangGlassSwitchLoading()); emit(OneGangGlassSwitchLoading());
try { try {
final status = await DevicesManagementApi().getDeviceStatus(event.deviceId); final status = await DevicesManagementApi().getDeviceStatus(event.deviceId);
_listenToChanges(event.deviceId); _listenToChanges(event.deviceId, emit);
deviceStatus = OneGangGlassStatusModel.fromJson(event.deviceId, status.status); deviceStatus = OneGangGlassStatusModel.fromJson(event.deviceId, status.status);
emit(OneGangGlassSwitchStatusLoaded(deviceStatus)); emit(OneGangGlassSwitchStatusLoaded(deviceStatus));
} catch (e) { } catch (e) {
@ -48,28 +48,42 @@ class OneGangGlassSwitchBloc
} }
} }
StreamSubscription<DatabaseEvent>? _deviceStatusSubscription; void _listenToChanges(
String deviceId,
void _listenToChanges(String deviceId) { Emitter<OneGangGlassSwitchState> emit,
) {
try { try {
final ref = FirebaseDatabase.instance.ref('device-status/$deviceId'); final ref = FirebaseDatabase.instance.ref('device-status/$deviceId');
_deviceStatusSubscription = ref.onValue.listen((DatabaseEvent event) async { final stream = ref.onValue;
if (event.snapshot.value == null) return;
final usersMap = event.snapshot.value! as Map<dynamic, dynamic>; stream.listen((DatabaseEvent event) {
final data = event.snapshot.value as Map<dynamic, dynamic>?;
if (data == null) return;
final statusList = <Status>[]; final statusList = <Status>[];
if (data['status'] != null) {
usersMap['status'].forEach((element) { for (var element in data['status']) {
statusList.add(Status(code: element['code'], value: element['value'])); statusList.add(
}); Status(
code: element['code'].toString(),
deviceStatus = value: element['value'].toString(),
OneGangGlassStatusModel.fromJson(usersMap['productUuid'], statusList); ),
);
add(StatusUpdated(deviceStatus)); }
}
if (statusList.isNotEmpty) {
final newStatus = OneGangGlassStatusModel.fromJson(deviceId, statusList);
if (newStatus != deviceStatus) {
deviceStatus = newStatus;
if (!isClosed) {
add(StatusUpdated(deviceStatus));
}
}
}
}); });
} catch (_) {} } catch (e) {
emit(OneGangGlassSwitchError('Failed to listen to changes: $e'));
}
} }
void _onStatusUpdated( void _onStatusUpdated(
@ -160,10 +174,4 @@ class OneGangGlassSwitchBloc
deviceStatus = deviceStatus.copyWith(switch1: value); deviceStatus = deviceStatus.copyWith(switch1: value);
} }
} }
@override
Future<void> close() {
_deviceStatusSubscription?.cancel();
return super.close();
}
} }

View File

@ -90,8 +90,6 @@ class OneGangGlassSwitchControlView extends StatelessWidget
child: BuildScheduleView( child: BuildScheduleView(
category: 'switch_1', category: 'switch_1',
deviceUuid: deviceId, deviceUuid: deviceId,
countdownCode: 'countdown_1',
deviceType: '1GT',
), ),
)); ));
}, },

View File

@ -80,8 +80,6 @@ class WallLightDeviceControl extends StatelessWidget
child: BuildScheduleView( child: BuildScheduleView(
category: 'switch_1', category: 'switch_1',
deviceUuid: deviceId, deviceUuid: deviceId,
countdownCode: 'countdown_1',
deviceType: '1G',
), ),
)); ));
}, },

View File

@ -47,7 +47,7 @@ class ScheduleBloc extends Bloc<ScheduleEvent, ScheduleState> {
final success = await RemoteControlDeviceService().controlDevice( final success = await RemoteControlDeviceService().controlDevice(
deviceUuid: deviceId, deviceUuid: deviceId,
status: Status( status: Status(
code: event.countdownCode, code: 'countdown_1',
value: 0, value: 0,
), ),
); );
@ -80,18 +80,15 @@ class ScheduleBloc extends Bloc<ScheduleEvent, ScheduleState> {
) { ) {
if (state is ScheduleLoaded) { if (state is ScheduleLoaded) {
final currentState = state as ScheduleLoaded; final currentState = state as ScheduleLoaded;
emit(currentState.copyWith( emit(currentState.copyWith(
countdownSeconds: currentState.countdownSeconds,
selectedTime: currentState.selectedTime,
deviceId: deviceId,
scheduleMode: event.scheduleMode, scheduleMode: event.scheduleMode,
countdownHours: currentState.countdownHours, countdownRemaining: Duration.zero,
countdownMinutes: currentState.countdownMinutes, countdownHours: 0,
inchingHours: currentState.inchingHours, countdownMinutes: 0,
inchingMinutes: currentState.inchingMinutes, inchingHours: 0,
inchingMinutes: 0,
isCountdownActive: false,
isInchingActive: false, isInchingActive: false,
isCountdownActive: currentState.countdownRemaining > Duration.zero,
)); ));
} }
} }
@ -224,6 +221,7 @@ class ScheduleBloc extends Bloc<ScheduleEvent, ScheduleState> {
deviceId, deviceId,
event.category, event.category,
); );
if (state is ScheduleLoaded) { if (state is ScheduleLoaded) {
final currentState = state as ScheduleLoaded; final currentState = state as ScheduleLoaded;
emit(currentState.copyWith( emit(currentState.copyWith(
@ -287,8 +285,9 @@ class ScheduleBloc extends Bloc<ScheduleEvent, ScheduleState> {
) async { ) async {
try { try {
if (state is ScheduleLoaded) { if (state is ScheduleLoaded) {
final dateTime = DateTime.parse(event.time);
Status status = Status(code: '', value: ''); Status status = Status(code: '', value: '');
if (event.deviceType == 'CUR_2') { if (event.category == 'CUR_2') {
status = status.copyWith( status = status.copyWith(
code: 'control', code: 'control',
value: event.functionOn == true ? 'open' : 'close'); value: event.functionOn == true ? 'open' : 'close');
@ -296,8 +295,6 @@ class ScheduleBloc extends Bloc<ScheduleEvent, ScheduleState> {
status = status =
status.copyWith(code: event.category, value: event.functionOn); status.copyWith(code: event.category, value: event.functionOn);
} }
final dateTime = DateTime.parse(event.time);
final updatedSchedule = ScheduleEntry( final updatedSchedule = ScheduleEntry(
scheduleId: event.scheduleId, scheduleId: event.scheduleId,
category: event.category, category: event.category,
@ -408,7 +405,7 @@ class ScheduleBloc extends Bloc<ScheduleEvent, ScheduleState> {
final totalSeconds = final totalSeconds =
Duration(hours: event.hours, minutes: event.minutes).inSeconds; Duration(hours: event.hours, minutes: event.minutes).inSeconds;
final code = event.mode == ScheduleModes.countdown final code = event.mode == ScheduleModes.countdown
? event.countDownCode ? 'countdown_1'
: 'switch_inching'; : 'switch_inching';
final currentState = state as ScheduleLoaded; final currentState = state as ScheduleLoaded;
final duration = Duration(seconds: totalSeconds); final duration = Duration(seconds: totalSeconds);
@ -435,7 +432,7 @@ class ScheduleBloc extends Bloc<ScheduleEvent, ScheduleState> {
); );
if (success) { if (success) {
if (code == event.countDownCode) { if (code == 'countdown_1') {
final countdownDuration = Duration(seconds: totalSeconds); final countdownDuration = Duration(seconds: totalSeconds);
emit( emit(
@ -449,7 +446,7 @@ class ScheduleBloc extends Bloc<ScheduleEvent, ScheduleState> {
); );
if (countdownDuration.inSeconds > 0) { if (countdownDuration.inSeconds > 0) {
_startCountdownTimer(emit, countdownDuration, event.countDownCode); _startCountdownTimer(emit, countdownDuration);
} else { } else {
_countdownTimer?.cancel(); _countdownTimer?.cancel();
emit( emit(
@ -479,7 +476,9 @@ class ScheduleBloc extends Bloc<ScheduleEvent, ScheduleState> {
} }
void _startCountdownTimer( void _startCountdownTimer(
Emitter<ScheduleState> emit, Duration duration, String countdownCode) { Emitter<ScheduleState> emit,
Duration duration,
) {
_countdownTimer?.cancel(); _countdownTimer?.cancel();
_countdownTimer = Timer.periodic(const Duration(seconds: 1), (timer) { _countdownTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
if (_currentCountdown != null && _currentCountdown! > Duration.zero) { if (_currentCountdown != null && _currentCountdown! > Duration.zero) {
@ -489,7 +488,6 @@ class ScheduleBloc extends Bloc<ScheduleEvent, ScheduleState> {
} else { } else {
timer.cancel(); timer.cancel();
add(StopScheduleEvent( add(StopScheduleEvent(
countdownCode: countdownCode,
mode: _currentCountdown == null mode: _currentCountdown == null
? ScheduleModes.countdown ? ScheduleModes.countdown
: ScheduleModes.inching, : ScheduleModes.inching,
@ -526,75 +524,70 @@ class ScheduleBloc extends Bloc<ScheduleEvent, ScheduleState> {
try { try {
final status = final status =
await DevicesManagementApi().getDeviceStatus(event.deviceId); await DevicesManagementApi().getDeviceStatus(event.deviceId);
int totalSeconds = 0; print(status.status);
final countdownItem = status.status.firstWhere(
(item) => item.code == event.countdownCode,
orElse: () => Status(code: '', value: 0),
);
totalSeconds = (countdownItem.value as int?) ?? 0;
final countdownHours = totalSeconds ~/ 3600;
final countdownMinutes = (totalSeconds % 3600) ~/ 60;
final countdownSeconds = totalSeconds % 60;
final deviceStatus = final deviceStatus =
WaterHeaterStatusModel.fromJson(event.deviceId, status.status); WaterHeaterStatusModel.fromJson(event.deviceId, status.status);
final isCountdownActive = totalSeconds > 0;
final isInchingActive = !isCountdownActive &&
(deviceStatus.inchingHours > 0 || deviceStatus.inchingMinutes > 0);
final newState = state is ScheduleLoaded final scheduleMode =
? (state as ScheduleLoaded).copyWith( deviceStatus.countdownHours > 0 || deviceStatus.countdownMinutes > 0
scheduleMode: ScheduleModes.schedule, ? ScheduleModes.countdown
countdownHours: countdownHours, : deviceStatus.inchingHours > 0 || deviceStatus.inchingMinutes > 0
countdownMinutes: countdownMinutes, ? ScheduleModes.inching
countdownSeconds: countdownSeconds, : ScheduleModes.schedule;
inchingHours: deviceStatus.inchingHours, final isCountdown = scheduleMode == ScheduleModes.countdown;
inchingMinutes: deviceStatus.inchingMinutes, final isInching = scheduleMode == ScheduleModes.inching;
isCountdownActive: isCountdownActive,
isInchingActive: isInchingActive,
countdownRemaining: isCountdownActive
? Duration(seconds: totalSeconds)
: Duration.zero,
)
: ScheduleLoaded(
scheduleMode: ScheduleModes.schedule,
schedules: const [],
selectedTime: null,
selectedDays: List.filled(7, false),
functionOn: false,
isEditing: false,
deviceId: event.deviceId,
countdownHours: countdownHours,
countdownMinutes: countdownMinutes,
countdownSeconds: countdownSeconds,
inchingHours: deviceStatus.inchingHours,
inchingMinutes: deviceStatus.inchingMinutes,
isCountdownActive: isCountdownActive,
isInchingActive: isInchingActive,
countdownRemaining: isCountdownActive
? Duration(seconds: totalSeconds)
: Duration.zero,
);
emit(newState);
if (isCountdownActive) { Duration? countdownRemaining;
_countdownTimer?.cancel(); var isCountdownActive = false;
_currentCountdown = Duration(seconds: totalSeconds); var isInchingActive = false;
countdownRemaining = _currentCountdown!;
if (totalSeconds > 0) { if (isCountdown) {
_startCountdownTimer( countdownRemaining = Duration(
emit, Duration(seconds: totalSeconds), event.countdownCode); hours: deviceStatus.countdownHours,
} else { minutes: deviceStatus.countdownMinutes,
add(StopScheduleEvent( );
countdownCode: event.countdownCode, isCountdownActive = countdownRemaining > Duration.zero;
mode: ScheduleModes.countdown, } else if (isInching) {
deviceId: event.deviceId, isInchingActive = Duration(
)); hours: deviceStatus.inchingHours,
} minutes: deviceStatus.inchingMinutes,
} else { ) >
_countdownTimer?.cancel(); Duration.zero;
} }
if (state is ScheduleLoaded) {
final currentState = state as ScheduleLoaded;
emit(currentState.copyWith(
scheduleMode: scheduleMode,
countdownHours: deviceStatus.countdownHours,
countdownMinutes: deviceStatus.countdownMinutes,
inchingHours: deviceStatus.inchingHours,
inchingMinutes: deviceStatus.inchingMinutes,
isCountdownActive: isCountdownActive,
isInchingActive: isInchingActive,
countdownRemaining: countdownRemaining ?? Duration.zero,
));
} else {
emit(ScheduleLoaded(
schedules: const [],
selectedTime: null,
selectedDays: List.filled(7, false),
functionOn: false,
isEditing: false,
deviceId: deviceId,
scheduleMode: scheduleMode,
countdownHours: deviceStatus.countdownHours,
countdownMinutes: deviceStatus.countdownMinutes,
inchingHours: deviceStatus.inchingHours,
inchingMinutes: deviceStatus.inchingMinutes,
isCountdownActive: isCountdownActive,
isInchingActive: isInchingActive,
countdownRemaining: countdownRemaining ?? Duration.zero,
));
}
// if (isCountdownActive && countdownRemaining != null) {
// _startCountdownTimer(emit, countdownRemaining);
// }
} catch (e) { } catch (e) {
emit(ScheduleError('Failed to fetch device status: $e')); emit(ScheduleError('Failed to fetch device status: $e'));
} }

View File

@ -91,7 +91,6 @@ class ScheduleEditEvent extends ScheduleEvent {
final String time; final String time;
final List<String> selectedDays; final List<String> selectedDays;
final bool functionOn; final bool functionOn;
final String deviceType;
const ScheduleEditEvent({ const ScheduleEditEvent({
required this.scheduleId, required this.scheduleId,
@ -99,7 +98,6 @@ class ScheduleEditEvent extends ScheduleEvent {
required this.time, required this.time,
required this.selectedDays, required this.selectedDays,
required this.functionOn, required this.functionOn,
required this.deviceType,
}); });
@override @override
@ -109,7 +107,6 @@ class ScheduleEditEvent extends ScheduleEvent {
time, time,
selectedDays, selectedDays,
functionOn, functionOn,
deviceType,
]; ];
} }
@ -141,13 +138,11 @@ class ScheduleUpdateEntryEvent extends ScheduleEvent {
class UpdateScheduleModeEvent extends ScheduleEvent { class UpdateScheduleModeEvent extends ScheduleEvent {
final ScheduleModes scheduleMode; final ScheduleModes scheduleMode;
final String countdownCode;
const UpdateScheduleModeEvent( const UpdateScheduleModeEvent({required this.scheduleMode});
{required this.scheduleMode, required this.countdownCode});
@override @override
List<Object> get props => [scheduleMode, countdownCode!]; List<Object> get props => [scheduleMode];
} }
class UpdateCountdownTimeEvent extends ScheduleEvent { class UpdateCountdownTimeEvent extends ScheduleEvent {
@ -182,32 +177,28 @@ class StartScheduleEvent extends ScheduleEvent {
final ScheduleModes mode; final ScheduleModes mode;
final int hours; final int hours;
final int minutes; final int minutes;
final String countDownCode;
const StartScheduleEvent({ const StartScheduleEvent({
required this.mode, required this.mode,
required this.hours, required this.hours,
required this.minutes, required this.minutes,
required this.countDownCode,
}); });
@override @override
List<Object?> get props => [mode, hours, minutes, countDownCode]; List<Object?> get props => [mode, hours, minutes];
} }
class StopScheduleEvent extends ScheduleEvent { class StopScheduleEvent extends ScheduleEvent {
final ScheduleModes mode; final ScheduleModes mode;
final String deviceId; final String deviceId;
final String countdownCode;
const StopScheduleEvent({ const StopScheduleEvent({
required this.mode, required this.mode,
required this.deviceId, required this.deviceId,
required this.countdownCode,
}); });
@override @override
List<Object?> get props => [mode, deviceId, countdownCode]; List<Object?> get props => [mode, deviceId];
} }
class ScheduleDecrementCountdownEvent extends ScheduleEvent { class ScheduleDecrementCountdownEvent extends ScheduleEvent {
@ -219,13 +210,11 @@ class ScheduleDecrementCountdownEvent extends ScheduleEvent {
class ScheduleFetchStatusEvent extends ScheduleEvent { class ScheduleFetchStatusEvent extends ScheduleEvent {
final String deviceId; final String deviceId;
final String countdownCode;
const ScheduleFetchStatusEvent( const ScheduleFetchStatusEvent(this.deviceId);
{required this.deviceId, required this.countdownCode});
@override @override
List<Object> get props => [deviceId, countdownCode]; List<Object> get props => [deviceId];
} }
class DeleteScheduleEvent extends ScheduleEvent { class DeleteScheduleEvent extends ScheduleEvent {

View File

@ -29,7 +29,7 @@ class ScheduleLoaded extends ScheduleState {
final int inchingSeconds; final int inchingSeconds;
final bool isInchingActive; final bool isInchingActive;
final ScheduleModes scheduleMode; final ScheduleModes scheduleMode;
final Duration countdownRemaining; final Duration? countdownRemaining;
final int? countdownSeconds; final int? countdownSeconds;
const ScheduleLoaded({ const ScheduleLoaded({
@ -48,7 +48,7 @@ class ScheduleLoaded extends ScheduleState {
this.inchingMinutes = 0, this.inchingMinutes = 0,
this.isInchingActive = false, this.isInchingActive = false,
this.scheduleMode = ScheduleModes.countdown, this.scheduleMode = ScheduleModes.countdown,
this.countdownRemaining = Duration.zero, this.countdownRemaining,
}); });
ScheduleLoaded copyWith({ ScheduleLoaded copyWith({

View File

@ -11,7 +11,6 @@ class CountdownModeButtons extends StatelessWidget {
final String deviceId; final String deviceId;
final int hours; final int hours;
final int minutes; final int minutes;
final String countDownCode;
const CountdownModeButtons({ const CountdownModeButtons({
super.key, super.key,
@ -19,7 +18,6 @@ class CountdownModeButtons extends StatelessWidget {
required this.deviceId, required this.deviceId,
required this.hours, required this.hours,
required this.minutes, required this.minutes,
required this.countDownCode,
}); });
@override @override
@ -45,7 +43,6 @@ class CountdownModeButtons extends StatelessWidget {
StopScheduleEvent( StopScheduleEvent(
mode: ScheduleModes.countdown, mode: ScheduleModes.countdown,
deviceId: deviceId, deviceId: deviceId,
countdownCode: countDownCode,
), ),
); );
}, },
@ -57,10 +54,10 @@ class CountdownModeButtons extends StatelessWidget {
onPressed: () { onPressed: () {
context.read<ScheduleBloc>().add( context.read<ScheduleBloc>().add(
StartScheduleEvent( StartScheduleEvent(
mode: ScheduleModes.countdown, mode: ScheduleModes.countdown,
hours: hours, hours: hours,
minutes: minutes, minutes: minutes,
countDownCode: countDownCode), ),
); );
}, },
backgroundColor: ColorsManager.primaryColor, backgroundColor: ColorsManager.primaryColor,

View File

@ -75,33 +75,23 @@ class _CountdownInchingViewState extends State<CountdownInchingView> {
final isCountDown = state.scheduleMode == ScheduleModes.countdown; final isCountDown = state.scheduleMode == ScheduleModes.countdown;
final isActive = final isActive =
isCountDown ? state.isCountdownActive : state.isInchingActive; isCountDown ? state.isCountdownActive : state.isInchingActive;
final displayHours = isActive && state.countdownRemaining != null
? state.countdownRemaining!.inHours
: (isCountDown ? state.countdownHours : state.inchingHours);
final displayMinutes = isActive && state.countdownRemaining != null
? state.countdownRemaining!.inMinutes.remainder(60)
: (isCountDown ? state.countdownMinutes : state.inchingMinutes);
final displaySeconds = isActive && state.countdownRemaining != null
? state.countdownRemaining!.inSeconds.remainder(60)
: (isCountDown ? state.countdownSeconds : state.inchingSeconds);
final displayHours = _updateControllers(displayHours, displayMinutes, displaySeconds!);
isActive && state.countdownRemaining != Duration.zero
? state.countdownRemaining.inHours
: (isCountDown ? state.countdownHours : state.inchingHours);
final displayMinutes = if (displayHours == 0 && displayMinutes == 0 && displaySeconds == 0) {
isActive && state.countdownRemaining != Duration.zero
? state.countdownRemaining.inMinutes.remainder(60)
: (isCountDown ? state.countdownMinutes : state.inchingMinutes);
final displaySeconds =
isActive && state.countdownRemaining != Duration.zero
? state.countdownRemaining.inSeconds.remainder(60)
: (isCountDown ? (state.countdownSeconds ?? 0) : 0);
_updateControllers(displayHours, displayMinutes, displaySeconds);
if (isActive &&
displayHours == 0 &&
displayMinutes == 0 &&
displaySeconds == 0) {
context.read<ScheduleBloc>().add( context.read<ScheduleBloc>().add(
StopScheduleEvent( StopScheduleEvent(
mode: ScheduleModes.countdown, mode: ScheduleModes.countdown,
deviceId: widget.deviceId, deviceId: widget.deviceId,
countdownCode: '',
), ),
); );
} }

View File

@ -43,9 +43,7 @@ class InchingModeButtons extends StatelessWidget {
onPressed: () { onPressed: () {
context.read<ScheduleBloc>().add( context.read<ScheduleBloc>().add(
StopScheduleEvent( StopScheduleEvent(
deviceId: deviceId, deviceId: deviceId, mode: ScheduleModes.inching),
mode: ScheduleModes.inching,
countdownCode: ''),
); );
}, },
backgroundColor: Colors.red, backgroundColor: Colors.red,

View File

@ -18,15 +18,11 @@ class BuildScheduleView extends StatelessWidget {
super.key, super.key,
required this.deviceUuid, required this.deviceUuid,
required this.category, required this.category,
required this.countdownCode,
this.code, this.code,
required this.deviceType,
}); });
final String deviceUuid; final String deviceUuid;
final String category; final String category;
final String? code; final String? code;
final String? countdownCode;
final String deviceType;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -35,8 +31,7 @@ class BuildScheduleView extends StatelessWidget {
deviceId: deviceUuid, deviceId: deviceUuid,
) )
..add(ScheduleGetEvent(category: category)) ..add(ScheduleGetEvent(category: category))
..add(ScheduleFetchStatusEvent( ..add(ScheduleFetchStatusEvent(deviceUuid)),
deviceId: deviceUuid, countdownCode: countdownCode ?? '')),
child: Dialog( child: Dialog(
backgroundColor: Colors.white, backgroundColor: Colors.white,
insetPadding: const EdgeInsets.all(20), insetPadding: const EdgeInsets.all(20),
@ -57,32 +52,31 @@ class BuildScheduleView extends StatelessWidget {
children: [ children: [
const ScheduleHeader(), const ScheduleHeader(),
const SizedBox(height: 20), const SizedBox(height: 20),
if (deviceType == 'CUR_2') if (category == 'CUR_2')
const SizedBox() const SizedBox()
else else
ScheduleModeSelector( ScheduleModeSelector(
countdownCode: countdownCode ?? '',
currentMode: state.scheduleMode, currentMode: state.scheduleMode,
), ),
const SizedBox(height: 20), const SizedBox(height: 20),
if (state.scheduleMode == ScheduleModes.schedule) if (state.scheduleMode == ScheduleModes.schedule)
ScheduleManagementUI( ScheduleManagementUI(
deviceType: deviceType,
category: category, category: category,
deviceUuid: deviceUuid, deviceUuid: deviceUuid,
onAddSchedule: () async { onAddSchedule: () async {
final entry = await ScheduleDialogHelper final entry = await ScheduleDialogHelper
.showAddScheduleDialog(context, .showAddScheduleDialog(
schedule: ScheduleEntry( context,
category: category, schedule: ScheduleEntry(
time: '', category: category,
function: Status( time: '',
code: code.toString(), value: null), function: Status(
days: [], code: code.toString(), value: null),
), days: [],
isEdit: false, ),
code: code, isEdit: false,
deviceType: deviceType); code: code,
);
if (entry != null) { if (entry != null) {
context.read<ScheduleBloc>().add( context.read<ScheduleBloc>().add(
ScheduleAddEvent( ScheduleAddEvent(
@ -96,16 +90,14 @@ class BuildScheduleView extends StatelessWidget {
} }
}, },
), ),
if (deviceType != 'CUR_2') if (state.scheduleMode == ScheduleModes.countdown ||
if (state.scheduleMode == ScheduleModes.countdown || state.scheduleMode == ScheduleModes.inching)
state.scheduleMode == ScheduleModes.inching) CountdownInchingView(
CountdownInchingView( deviceId: deviceUuid,
deviceId: deviceUuid, ),
),
const SizedBox(height: 20), const SizedBox(height: 20),
if (state.scheduleMode == ScheduleModes.countdown) if (state.scheduleMode == ScheduleModes.countdown)
CountdownModeButtons( CountdownModeButtons(
countDownCode: countdownCode ?? '',
isActive: state.isCountdownActive, isActive: state.isCountdownActive,
deviceId: deviceUuid, deviceId: deviceUuid,
hours: state.countdownHours, hours: state.countdownHours,

View File

@ -8,13 +8,11 @@ class ScheduleManagementUI extends StatelessWidget {
final String deviceUuid; final String deviceUuid;
final VoidCallback onAddSchedule; final VoidCallback onAddSchedule;
final String category; final String category;
final String deviceType;
const ScheduleManagementUI({ const ScheduleManagementUI({
super.key, super.key,
required this.deviceUuid, required this.deviceUuid,
required this.onAddSchedule, required this.onAddSchedule,
required this.deviceType,
this.category = 'switch_1', this.category = 'switch_1',
}); });
@ -46,11 +44,7 @@ class ScheduleManagementUI extends StatelessWidget {
), ),
), ),
const SizedBox(height: 20), const SizedBox(height: 20),
ScheduleTableWidget( ScheduleTableWidget(deviceUuid: deviceUuid, category: category),
deviceUuid: deviceUuid,
category: category,
deviceType: deviceType,
),
], ],
); );
} }

View File

@ -7,12 +7,10 @@ import 'package:syncrow_web/utils/extension/build_context_x.dart';
class ScheduleModeSelector extends StatelessWidget { class ScheduleModeSelector extends StatelessWidget {
final ScheduleModes currentMode; final ScheduleModes currentMode;
final String countdownCode;
const ScheduleModeSelector({ const ScheduleModeSelector({
super.key, super.key,
required this.currentMode, required this.currentMode,
required this.countdownCode,
}); });
@override @override
@ -73,8 +71,7 @@ class ScheduleModeSelector extends StatelessWidget {
onChanged: (ScheduleModes? value) { onChanged: (ScheduleModes? value) {
if (value != null) { if (value != null) {
context.read<ScheduleBloc>().add( context.read<ScheduleBloc>().add(
UpdateScheduleModeEvent( UpdateScheduleModeEvent(scheduleMode: value),
scheduleMode: value, countdownCode: countdownCode),
); );
if (value == ScheduleModes.schedule) { if (value == ScheduleModes.schedule) {
context.read<ScheduleBloc>().add( context.read<ScheduleBloc>().add(

View File

@ -12,13 +12,11 @@ import 'package:syncrow_web/utils/format_date_time.dart';
class ScheduleTableWidget extends StatelessWidget { class ScheduleTableWidget extends StatelessWidget {
final String deviceUuid; final String deviceUuid;
final String category; final String category;
final String deviceType;
const ScheduleTableWidget({ const ScheduleTableWidget({
super.key, super.key,
required this.deviceUuid, required this.deviceUuid,
this.category = 'switch_1', this.category = 'switch_1',
required this.deviceType,
}); });
@override @override
@ -27,14 +25,13 @@ class ScheduleTableWidget extends StatelessWidget {
create: (_) => ScheduleBloc( create: (_) => ScheduleBloc(
deviceId: deviceUuid, deviceId: deviceUuid,
)..add(ScheduleGetEvent(category: category)), )..add(ScheduleGetEvent(category: category)),
child: _ScheduleTableView(deviceType), child: _ScheduleTableView(),
); );
} }
} }
class _ScheduleTableView extends StatelessWidget { class _ScheduleTableView extends StatelessWidget {
final String deviceType; const _ScheduleTableView();
const _ScheduleTableView(this.deviceType);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -84,7 +81,7 @@ class _ScheduleTableView extends StatelessWidget {
bottomLeft: Radius.circular(20), bottomLeft: Radius.circular(20),
bottomRight: Radius.circular(20)), bottomRight: Radius.circular(20)),
), ),
child: _buildTableBody(state.schedules, context, deviceType)); child: _buildTableBody(state.schedules, context));
} }
if (state is ScheduleError) { if (state is ScheduleError) {
return Center(child: Text(state.error)); return Center(child: Text(state.error));
@ -126,8 +123,7 @@ class _ScheduleTableView extends StatelessWidget {
); );
} }
Widget _buildTableBody( Widget _buildTableBody(List<ScheduleModel> schedules, BuildContext context) {
List<ScheduleModel> schedules, BuildContext context, String deviceType) {
return SizedBox( return SizedBox(
height: 200, height: 200,
child: SingleChildScrollView( child: SingleChildScrollView(
@ -136,8 +132,7 @@ class _ScheduleTableView extends StatelessWidget {
defaultVerticalAlignment: TableCellVerticalAlignment.middle, defaultVerticalAlignment: TableCellVerticalAlignment.middle,
children: [ children: [
for (int i = 0; i < schedules.length; i++) for (int i = 0; i < schedules.length; i++)
_buildScheduleRow(schedules[i], i, context, _buildScheduleRow(schedules[i], i, context),
deviceType: deviceType),
], ],
), ),
), ),
@ -160,19 +155,25 @@ class _ScheduleTableView extends StatelessWidget {
} }
TableRow _buildScheduleRow( TableRow _buildScheduleRow(
ScheduleModel schedule, int index, BuildContext context, ScheduleModel schedule, int index, BuildContext context) {
{required String deviceType}) {
return TableRow( return TableRow(
children: [ children: [
Center( Center(
child: GestureDetector( child: GestureDetector(
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
onTap: () { onTap: () {
bool temp;
if (schedule.category == 'CUR_2') {
temp = schedule.function.value == 'open' ? true : false;
} else {
temp = schedule.function.value as bool;
}
context.read<ScheduleBloc>().add( context.read<ScheduleBloc>().add(
ScheduleUpdateEntryEvent( ScheduleUpdateEntryEvent(
category: schedule.category, category: schedule.category,
scheduleId: schedule.scheduleId, scheduleId: schedule.scheduleId,
functionOn: schedule.function.value, functionOn: temp,
// schedule.function.value,
enable: !schedule.enable, enable: !schedule.enable,
), ),
); );
@ -194,9 +195,8 @@ class _ScheduleTableView extends StatelessWidget {
child: Text(_getSelectedDays( child: Text(_getSelectedDays(
ScheduleModel.parseSelectedDays(schedule.days)))), ScheduleModel.parseSelectedDays(schedule.days)))),
Center(child: Text(formatIsoStringToTime(schedule.time, context))), Center(child: Text(formatIsoStringToTime(schedule.time, context))),
if (deviceType == 'CUR_2') if (schedule.category == 'CUR_2')
Center( Center(child: Text(schedule.function.value))
child: Text(schedule.function.value == true ? 'open' : 'close'))
else else
Center(child: Text(schedule.function.value ? 'On' : 'Off')), Center(child: Text(schedule.function.value ? 'On' : 'Off')),
Center( Center(
@ -206,14 +206,14 @@ class _ScheduleTableView extends StatelessWidget {
TextButton( TextButton(
style: TextButton.styleFrom(padding: EdgeInsets.zero), style: TextButton.styleFrom(padding: EdgeInsets.zero),
onPressed: () { onPressed: () {
ScheduleDialogHelper.showAddScheduleDialog(context, ScheduleDialogHelper.showAddScheduleDialog(
schedule: ScheduleEntry.fromScheduleModel(schedule), context,
isEdit: true, schedule: ScheduleEntry.fromScheduleModel(schedule),
deviceType: deviceType) isEdit: true,
.then((updatedSchedule) { ).then((updatedSchedule) {
if (updatedSchedule != null) { if (updatedSchedule != null) {
bool temp; bool temp;
if (deviceType == 'CUR_2') { if (schedule.category == 'CUR_2') {
updatedSchedule.function.value == 'open' updatedSchedule.function.value == 'open'
? temp = true ? temp = true
: temp = false; : temp = false;
@ -222,7 +222,6 @@ class _ScheduleTableView extends StatelessWidget {
} }
context.read<ScheduleBloc>().add( context.read<ScheduleBloc>().add(
ScheduleEditEvent( ScheduleEditEvent(
deviceType: deviceType,
scheduleId: schedule.scheduleId, scheduleId: schedule.scheduleId,
category: schedule.category, category: schedule.category,
time: updatedSchedule.time, time: updatedSchedule.time,

View File

@ -41,7 +41,7 @@ class ThreeGangGlassSwitchBloc
emit(ThreeGangGlassSwitchLoading()); emit(ThreeGangGlassSwitchLoading());
try { try {
final status = await DevicesManagementApi().getDeviceStatus(event.deviceId); final status = await DevicesManagementApi().getDeviceStatus(event.deviceId);
_listenToChanges(event.deviceId); _listenToChanges(event.deviceId, emit);
deviceStatus = deviceStatus =
ThreeGangGlassStatusModel.fromJson(event.deviceId, status.status); ThreeGangGlassStatusModel.fromJson(event.deviceId, status.status);
emit(ThreeGangGlassSwitchStatusLoaded(deviceStatus)); emit(ThreeGangGlassSwitchStatusLoaded(deviceStatus));
@ -50,28 +50,42 @@ class ThreeGangGlassSwitchBloc
} }
} }
StreamSubscription<DatabaseEvent>? _deviceStatusSubscription; void _listenToChanges(
String deviceId,
void _listenToChanges(String deviceId) { Emitter<ThreeGangGlassSwitchState> emit,
) {
try { try {
final ref = FirebaseDatabase.instance.ref('device-status/$deviceId'); final ref = FirebaseDatabase.instance.ref('device-status/$deviceId');
_deviceStatusSubscription = ref.onValue.listen((DatabaseEvent event) async { final stream = ref.onValue;
if (event.snapshot.value == null) return;
final usersMap = event.snapshot.value! as Map<dynamic, dynamic>; stream.listen((DatabaseEvent event) {
final data = event.snapshot.value as Map<dynamic, dynamic>?;
if (data == null) return;
final statusList = <Status>[]; final statusList = <Status>[];
if (data['status'] != null) {
usersMap['status'].forEach((element) { for (var element in data['status']) {
statusList.add(Status(code: element['code'], value: element['value'])); statusList.add(
}); Status(
code: element['code'].toString(),
deviceStatus = value: element['value'].toString(),
ThreeGangGlassStatusModel.fromJson(usersMap['productUuid'], statusList); ),
);
add(StatusUpdated(deviceStatus)); }
}
if (statusList.isNotEmpty) {
final newStatus = ThreeGangGlassStatusModel.fromJson(deviceId, statusList);
if (newStatus != deviceStatus) {
deviceStatus = newStatus;
if (!isClosed) {
add(StatusUpdated(deviceStatus));
}
}
}
}); });
} catch (_) {} } catch (e) {
emit(ThreeGangGlassSwitchError('Failed to listen to changes: $e'));
}
} }
void _onStatusUpdated( void _onStatusUpdated(
@ -170,10 +184,4 @@ class ThreeGangGlassSwitchBloc
break; break;
} }
} }
@override
Future<void> close() {
_deviceStatusSubscription?.cancel();
return super.close();
}
} }

View File

@ -111,8 +111,6 @@ class ThreeGangGlassSwitchControlView extends StatelessWidget
child: BuildScheduleView( child: BuildScheduleView(
category: 'switch_1', category: 'switch_1',
deviceUuid: deviceId, deviceUuid: deviceId,
countdownCode: 'countdown_1',
deviceType: '3GT',
), ),
)); ));
}, },
@ -129,8 +127,6 @@ class ThreeGangGlassSwitchControlView extends StatelessWidget
child: BuildScheduleView( child: BuildScheduleView(
category: 'switch_2', category: 'switch_2',
deviceUuid: deviceId, deviceUuid: deviceId,
countdownCode: 'countdown_2',
deviceType: '3GT',
), ),
)); ));
}, },
@ -147,8 +143,6 @@ class ThreeGangGlassSwitchControlView extends StatelessWidget
child: BuildScheduleView( child: BuildScheduleView(
category: 'switch_3', category: 'switch_3',
deviceUuid: deviceId, deviceUuid: deviceId,
countdownCode: 'countdown_3',
deviceType: '3GT',
), ),
)); ));
}, },

View File

@ -102,8 +102,6 @@ class LivingRoomDeviceControlsView extends StatelessWidget
child: BuildScheduleView( child: BuildScheduleView(
deviceUuid: deviceId, deviceUuid: deviceId,
category: 'switch_1', category: 'switch_1',
countdownCode: 'countdown_1',
deviceType: '3G',
), ),
)); ));
}, },
@ -120,8 +118,6 @@ class LivingRoomDeviceControlsView extends StatelessWidget
child: BuildScheduleView( child: BuildScheduleView(
deviceUuid: deviceId, deviceUuid: deviceId,
category: 'switch_2', category: 'switch_2',
countdownCode: 'countdown_2',
deviceType: '3G',
), ),
)); ));
}, },
@ -138,8 +134,6 @@ class LivingRoomDeviceControlsView extends StatelessWidget
child: BuildScheduleView( child: BuildScheduleView(
deviceUuid: deviceId, deviceUuid: deviceId,
category: 'switch_3', category: 'switch_3',
countdownCode: 'countdown_3',
deviceType: '3G',
), ),
)); ));
}, },

View File

@ -1,177 +1,173 @@
import 'dart:async'; import 'dart:async';
import 'dart:developer';
import 'package:bloc/bloc.dart'; import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
import 'package:firebase_database/firebase_database.dart'; import 'package:firebase_database/firebase_database.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart'; import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart'; import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart';
import 'package:syncrow_web/pages/device_managment/two_g_glass_switch/models/two_gang_glass_status_model.dart'; import 'package:syncrow_web/pages/device_managment/two_g_glass_switch/models/two_gang_glass_status_model.dart';
import 'package:syncrow_web/services/batch_control_devices_service.dart'; import 'package:syncrow_web/services/batch_control_devices_service.dart';
import 'package:syncrow_web/services/control_device_service.dart'; import 'package:syncrow_web/services/control_device_service.dart';
import 'package:syncrow_web/services/devices_mang_api.dart'; import 'package:syncrow_web/services/devices_mang_api.dart';
part 'two_gang_glass_switch_event.dart'; part 'two_gang_glass_switch_event.dart';
part 'two_gang_glass_switch_state.dart'; part 'two_gang_glass_switch_state.dart';
class TwoGangGlassSwitchBloc class TwoGangGlassSwitchBloc
extends Bloc<TwoGangGlassSwitchEvent, TwoGangGlassSwitchState> { extends Bloc<TwoGangGlassSwitchEvent, TwoGangGlassSwitchState> {
final String deviceId; final String deviceId;
final ControlDeviceService controlDeviceService; final ControlDeviceService controlDeviceService;
final BatchControlDevicesService batchControlDevicesService; final BatchControlDevicesService batchControlDevicesService;
late TwoGangGlassStatusModel deviceStatus; late TwoGangGlassStatusModel deviceStatus;
TwoGangGlassSwitchBloc({ TwoGangGlassSwitchBloc({
required this.deviceId, required this.deviceId,
required this.controlDeviceService, required this.controlDeviceService,
required this.batchControlDevicesService, required this.batchControlDevicesService,
}) : super(TwoGangGlassSwitchInitial()) { }) : super(TwoGangGlassSwitchInitial()) {
on<TwoGangGlassSwitchFetchDeviceEvent>(_onFetchDeviceStatus); on<TwoGangGlassSwitchFetchDeviceEvent>(_onFetchDeviceStatus);
on<TwoGangGlassSwitchControl>(_onControl); on<TwoGangGlassSwitchControl>(_onControl);
on<TwoGangGlassSwitchBatchControl>(_onBatchControl); on<TwoGangGlassSwitchBatchControl>(_onBatchControl);
on<TwoGangGlassSwitchFetchBatchStatusEvent>(_onFetchBatchStatus); on<TwoGangGlassSwitchFetchBatchStatusEvent>(_onFetchBatchStatus);
on<TwoGangGlassFactoryReset>(_onFactoryReset); on<TwoGangGlassFactoryReset>(_onFactoryReset);
on<StatusUpdated>(_onStatusUpdated); on<StatusUpdated>(_onStatusUpdated);
}
Future<void> _onFetchDeviceStatus(
TwoGangGlassSwitchFetchDeviceEvent event,
Emitter<TwoGangGlassSwitchState> emit,
) async {
emit(TwoGangGlassSwitchLoading());
try {
final status = await DevicesManagementApi().getDeviceStatus(event.deviceId);
deviceStatus = TwoGangGlassStatusModel.fromJson(event.deviceId, status.status);
_listenToChanges(event.deviceId);
emit(TwoGangGlassSwitchStatusLoaded(deviceStatus));
} catch (e) {
emit(TwoGangGlassSwitchError(e.toString()));
} }
}
Future<void> _onFetchDeviceStatus( void _listenToChanges(String deviceId) {
TwoGangGlassSwitchFetchDeviceEvent event, try {
Emitter<TwoGangGlassSwitchState> emit, final ref = FirebaseDatabase.instance.ref(
) async { 'device-status/$deviceId',
emit(TwoGangGlassSwitchLoading()); );
try {
final status = await DevicesManagementApi().getDeviceStatus(event.deviceId);
deviceStatus = TwoGangGlassStatusModel.fromJson(event.deviceId, status.status);
_listenToChanges(event.deviceId);
emit(TwoGangGlassSwitchStatusLoaded(deviceStatus));
} catch (e) {
emit(TwoGangGlassSwitchError(e.toString()));
}
}
StreamSubscription<DatabaseEvent>? _deviceStatusSubscription; ref.onValue.listen((event) {
final eventsMap = event.snapshot.value as Map<dynamic, dynamic>;
void _listenToChanges(String deviceId) { List<Status> statusList = [];
try { eventsMap['status'].forEach((element) {
final ref = FirebaseDatabase.instance.ref('device-status/$deviceId'); statusList.add(Status(code: element['code'], value: element['value']));
_deviceStatusSubscription = ref.onValue.listen((DatabaseEvent event) async {
if (event.snapshot.value == null) return;
final usersMap = event.snapshot.value! as Map<dynamic, dynamic>;
final statusList = <Status>[];
usersMap['status'].forEach((element) {
statusList.add(Status(code: element['code'], value: element['value']));
});
deviceStatus =
TwoGangGlassStatusModel.fromJson(usersMap['productUuid'], statusList);
add(StatusUpdated(deviceStatus));
}); });
} catch (_) {}
deviceStatus = TwoGangGlassStatusModel.fromJson(deviceId, statusList);
add(StatusUpdated(deviceStatus));
});
} catch (_) {
log(
'Error listening to changes',
name: 'TwoGangGlassSwitchBloc._listenToChanges',
);
} }
}
Future<void> _onControl( Future<void> _onControl(
TwoGangGlassSwitchControl event, TwoGangGlassSwitchControl event,
Emitter<TwoGangGlassSwitchState> emit, Emitter<TwoGangGlassSwitchState> emit,
) async { ) async {
emit(TwoGangGlassSwitchLoading()); emit(TwoGangGlassSwitchLoading());
_updateLocalValue(event.code, event.value); _updateLocalValue(event.code, event.value);
emit(TwoGangGlassSwitchStatusLoaded(deviceStatus)); emit(TwoGangGlassSwitchStatusLoaded(deviceStatus));
try { try {
await controlDeviceService.controlDevice( await controlDeviceService.controlDevice(
deviceUuid: event.deviceId, deviceUuid: event.deviceId,
status: Status(code: event.code, value: event.value), status: Status(code: event.code, value: event.value),
); );
} catch (e) { } catch (e) {
_updateLocalValue(event.code, !event.value); _updateLocalValue(event.code, !event.value);
emit(TwoGangGlassSwitchError(e.toString())); emit(TwoGangGlassSwitchError(e.toString()));
}
} }
}
Future<void> _onBatchControl( Future<void> _onBatchControl(
TwoGangGlassSwitchBatchControl event, TwoGangGlassSwitchBatchControl event,
Emitter<TwoGangGlassSwitchState> emit, Emitter<TwoGangGlassSwitchState> emit,
) async { ) async {
emit(TwoGangGlassSwitchLoading()); emit(TwoGangGlassSwitchLoading());
_updateLocalValue(event.code, event.value); _updateLocalValue(event.code, event.value);
emit(TwoGangGlassSwitchBatchStatusLoaded(deviceStatus));
try {
await batchControlDevicesService.batchControlDevices(
uuids: event.deviceIds,
code: event.code,
value: event.value,
);
} catch (e) {
_updateLocalValue(event.code, !event.value);
emit(TwoGangGlassSwitchError(e.toString()));
}
}
Future<void> _onFetchBatchStatus(
TwoGangGlassSwitchFetchBatchStatusEvent event,
Emitter<TwoGangGlassSwitchState> emit,
) async {
emit(TwoGangGlassSwitchLoading());
try {
final status = await DevicesManagementApi().getBatchStatus(event.deviceIds);
deviceStatus = TwoGangGlassStatusModel.fromJson(
event.deviceIds.first,
status.status,
);
emit(TwoGangGlassSwitchBatchStatusLoaded(deviceStatus)); emit(TwoGangGlassSwitchBatchStatusLoaded(deviceStatus));
} catch (e) {
emit(TwoGangGlassSwitchError(e.toString()));
}
}
try { Future<void> _onFactoryReset(
await batchControlDevicesService.batchControlDevices( TwoGangGlassFactoryReset event,
uuids: event.deviceIds, Emitter<TwoGangGlassSwitchState> emit,
code: event.code, ) async {
value: event.value, emit(TwoGangGlassSwitchLoading());
); try {
} catch (e) { final response = await DevicesManagementApi().factoryReset(
_updateLocalValue(event.code, !event.value); event.factoryReset,
emit(TwoGangGlassSwitchError(e.toString())); event.deviceId,
);
if (!response) {
emit(TwoGangGlassSwitchError('Failed to reset device'));
} else {
add(TwoGangGlassSwitchFetchDeviceEvent(event.deviceId));
} }
} catch (e) {
emit(TwoGangGlassSwitchError(e.toString()));
} }
}
Future<void> _onFetchBatchStatus( void _onStatusUpdated(
TwoGangGlassSwitchFetchBatchStatusEvent event, StatusUpdated event,
Emitter<TwoGangGlassSwitchState> emit, Emitter<TwoGangGlassSwitchState> emit,
) async { ) {
emit(TwoGangGlassSwitchLoading()); deviceStatus = event.deviceStatus;
try { emit(TwoGangGlassSwitchStatusLoaded(deviceStatus));
final status = await DevicesManagementApi().getBatchStatus(event.deviceIds); }
deviceStatus = TwoGangGlassStatusModel.fromJson(
event.deviceIds.first, void _updateLocalValue(String code, bool value) {
status.status, switch (code) {
); case 'switch_1':
emit(TwoGangGlassSwitchBatchStatusLoaded(deviceStatus)); deviceStatus = deviceStatus.copyWith(switch1: value);
} catch (e) { break;
emit(TwoGangGlassSwitchError(e.toString())); case 'switch_2':
} deviceStatus = deviceStatus.copyWith(switch2: value);
break;
} }
Future<void> _onFactoryReset(
TwoGangGlassFactoryReset event,
Emitter<TwoGangGlassSwitchState> emit,
) async {
emit(TwoGangGlassSwitchLoading());
try {
final response = await DevicesManagementApi().factoryReset(
event.factoryReset,
event.deviceId,
);
if (!response) {
emit(TwoGangGlassSwitchError('Failed to reset device'));
} else {
add(TwoGangGlassSwitchFetchDeviceEvent(event.deviceId));
}
} catch (e) {
emit(TwoGangGlassSwitchError(e.toString()));
}
}
void _onStatusUpdated(
StatusUpdated event,
Emitter<TwoGangGlassSwitchState> emit,
) {
deviceStatus = event.deviceStatus;
emit(TwoGangGlassSwitchStatusLoaded(deviceStatus));
}
void _updateLocalValue(String code, bool value) {
switch (code) {
case 'switch_1':
deviceStatus = deviceStatus.copyWith(switch1: value);
break;
case 'switch_2':
deviceStatus = deviceStatus.copyWith(switch2: value);
break;
}
}
@override
Future<void> close() {
_deviceStatusSubscription?.cancel();
return super.close();
} }
} }

View File

@ -102,8 +102,6 @@ class TwoGangGlassSwitchControlView extends StatelessWidget
builder: (ctx) => BlocProvider.value( builder: (ctx) => BlocProvider.value(
value: BlocProvider.of<TwoGangGlassSwitchBloc>(context), value: BlocProvider.of<TwoGangGlassSwitchBloc>(context),
child: BuildScheduleView( child: BuildScheduleView(
deviceType: '2GT',
countdownCode: 'countdown_1',
deviceUuid: deviceId, deviceUuid: deviceId,
category: 'switch_1', category: 'switch_1',
), ),
@ -120,8 +118,6 @@ class TwoGangGlassSwitchControlView extends StatelessWidget
builder: (ctx) => BlocProvider.value( builder: (ctx) => BlocProvider.value(
value: BlocProvider.of<TwoGangGlassSwitchBloc>(context), value: BlocProvider.of<TwoGangGlassSwitchBloc>(context),
child: BuildScheduleView( child: BuildScheduleView(
deviceType: '2GT',
countdownCode: 'countdown_2',
deviceUuid: deviceId, deviceUuid: deviceId,
category: 'switch_2', category: 'switch_2',
), ),

View File

@ -97,8 +97,6 @@ class TwoGangBatchControlView extends StatelessWidget
child: BuildScheduleView( child: BuildScheduleView(
category: 'switch_1', category: 'switch_1',
deviceUuid: deviceIds.first, deviceUuid: deviceIds.first,
countdownCode: 'countdown_1',
deviceType: '2G',
), ),
)); ));
}, },
@ -116,8 +114,6 @@ class TwoGangBatchControlView extends StatelessWidget
child: BuildScheduleView( child: BuildScheduleView(
category: 'switch_2', category: 'switch_2',
deviceUuid: deviceIds.first, deviceUuid: deviceIds.first,
countdownCode: 'countdown_2',
deviceType: '2G',
), ),
)); ));
}, },
@ -125,7 +121,10 @@ class TwoGangBatchControlView extends StatelessWidget
subtitle: 'Scheduling', subtitle: 'Scheduling',
iconPath: Assets.scheduling, iconPath: Assets.scheduling,
), ),
// FirmwareUpdateWidget(
// deviceId: deviceIds.first,
// version: 12,
// ),
FactoryResetWidget(callFactoryReset: () { FactoryResetWidget(callFactoryReset: () {
context.read<TwoGangSwitchBloc>().add( context.read<TwoGangSwitchBloc>().add(
TwoGangFactoryReset( TwoGangFactoryReset(

View File

@ -103,8 +103,6 @@ class TwoGangDeviceControlView extends StatelessWidget
child: BuildScheduleView( child: BuildScheduleView(
deviceUuid: deviceId, deviceUuid: deviceId,
category: 'switch_1', category: 'switch_1',
countdownCode: 'countdown_1',
deviceType: '2G',
), ),
)); ));
}, },
@ -127,8 +125,6 @@ class TwoGangDeviceControlView extends StatelessWidget
child: BuildScheduleView( child: BuildScheduleView(
deviceUuid: deviceId, deviceUuid: deviceId,
category: 'switch_2', category: 'switch_2',
countdownCode: 'countdown_2',
deviceType: '2G',
), ),
)); ));
}, },

View File

@ -18,10 +18,9 @@ class ScheduleDialogHelper {
ScheduleEntry? schedule, ScheduleEntry? schedule,
bool isEdit = false, bool isEdit = false,
String? code, String? code,
required String deviceType,
}) { }) {
bool temp; bool temp;
if (deviceType == 'CUR_2') { if (schedule?.category == 'CUR_2') {
temp = schedule!.function.value == 'open' ? true : false; temp = schedule!.function.value == 'open' ? true : false;
} else { } else {
temp = schedule!.function.value; temp = schedule!.function.value;
@ -104,7 +103,8 @@ class ScheduleDialogHelper {
setState(() => selectedDays[i] = v); setState(() => selectedDays[i] = v);
}), }),
const SizedBox(height: 16), const SizedBox(height: 16),
_buildFunctionSwitch(deviceType, ctx, functionOn!, (v) { _buildFunctionSwitch(schedule!.category, ctx, functionOn!,
(v) {
setState(() => functionOn = v); setState(() => functionOn = v);
}), }),
], ],
@ -120,29 +120,32 @@ class ScheduleDialogHelper {
), ),
), ),
SizedBox( SizedBox(
width: 100, width: 100,
child: ElevatedButton( child: ElevatedButton(
onPressed: () { onPressed: () {
dynamic temp; dynamic temp;
if (deviceType == 'CUR_2') { if (schedule?.category == 'CUR_2') {
temp = functionOn! ? 'open' : 'close'; temp = functionOn! ? 'open' : 'close';
} else { } else {
temp = functionOn; temp = functionOn;
} }
final entry = ScheduleEntry( print(temp);
category: schedule?.category ?? 'switch_1', final entry = ScheduleEntry(
time: _formatTimeOfDayToISO(selectedTime), category: schedule?.category ?? 'switch_1',
function: Status( time: _formatTimeOfDayToISO(selectedTime),
code: code ?? 'switch_1', function: Status(
value: temp, code: code ?? 'switch_1',
), value: temp,
days: _convertSelectedDaysToStrings(selectedDays), // functionOn,
scheduleId: schedule.scheduleId, ),
); days: _convertSelectedDaysToStrings(selectedDays),
Navigator.pop(ctx, entry); scheduleId: schedule?.scheduleId,
}, );
child: const Text('Save'), Navigator.pop(ctx, entry);
)), },
child: const Text('Save'),
),
),
], ],
); );
}, },

View File

@ -84,8 +84,6 @@ class WaterHeaterDeviceControlView extends StatelessWidget
child: BuildScheduleView( child: BuildScheduleView(
deviceUuid: device.uuid ?? '', deviceUuid: device.uuid ?? '',
category: 'switch_1', category: 'switch_1',
countdownCode: 'countdown_1',
deviceType: 'WH',
), ),
)); ));
}, },

View File

@ -105,7 +105,7 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
color: const Color(0xFF0026A2), color: const Color(0xFF0026A2),
), ),
HomeItemModel( HomeItemModel(
title: 'Device Management', title: 'Devices Management',
icon: Assets.devicesIcon, icon: Assets.devicesIcon,
active: true, active: true,
onPress: (context) { onPress: (context) {

View File

@ -455,7 +455,7 @@ class UsersBloc extends Bloc<UsersEvent, UsersState> {
Future<void> checkEmail( Future<void> checkEmail(
CheckEmailEvent event, Emitter<UsersState> emit) async { CheckEmailEvent event, Emitter<UsersState> emit) async {
emit(UsersLoadingState()); emit(UsersLoadingState());
String? res = await UserPermissionApi().checkEmail( String? res = await UserPermissionApi().checkEmail(
emailController.text, emailController.text,
); );
checkEmailValid = res!; checkEmailValid = res!;

View File

@ -34,8 +34,7 @@ class _AddNewUserDialogState extends State<AddNewUserDialog> {
return Dialog( return Dialog(
child: Container( child: Container(
decoration: const BoxDecoration( decoration: const BoxDecoration(
color: Colors.white, color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(20))),
borderRadius: BorderRadius.all(Radius.circular(20))),
width: 900, width: 900,
child: Column( child: Column(
children: [ children: [
@ -64,8 +63,7 @@ class _AddNewUserDialogState extends State<AddNewUserDialog> {
children: [ children: [
_buildStep1Indicator(1, "Basics", _blocRole), _buildStep1Indicator(1, "Basics", _blocRole),
_buildStep2Indicator(2, "Spaces", _blocRole), _buildStep2Indicator(2, "Spaces", _blocRole),
_buildStep3Indicator( _buildStep3Indicator(3, "Role & Permissions", _blocRole),
3, "Role & Permissions", _blocRole),
], ],
), ),
), ),
@ -107,32 +105,18 @@ class _AddNewUserDialogState extends State<AddNewUserDialog> {
), ),
InkWell( InkWell(
onTap: () { onTap: () {
final isBasicsStep = currentStep == 1;
if (isBasicsStep) {
// Validate the form first
final isValid = _blocRole.formKey.currentState
?.validate() ??
false;
if (!isValid)
return; // Stop if form is not valid
}
_blocRole.add(const CheckEmailEvent()); _blocRole.add(const CheckEmailEvent());
setState(() { setState(() {
if (currentStep < 3) { if (currentStep < 3) {
currentStep++; currentStep++;
if (currentStep == 2) { if (currentStep == 2) {
_blocRole.add(const CheckStepStatus( _blocRole.add(const CheckStepStatus(isEditUser: false));
isEditUser: false));
} else if (currentStep == 3) { } else if (currentStep == 3) {
_blocRole _blocRole.add(const CheckSpacesStepStatus());
.add(const CheckSpacesStepStatus());
} }
} else { } else {
_blocRole _blocRole.add(SendInviteUsers(context: context));
.add(SendInviteUsers(context: context));
} }
}); });
}, },
@ -140,11 +124,8 @@ class _AddNewUserDialogState extends State<AddNewUserDialog> {
currentStep < 3 ? "Next" : "Save", currentStep < 3 ? "Next" : "Save",
style: TextStyle( style: TextStyle(
color: (_blocRole.isCompleteSpaces == false || color: (_blocRole.isCompleteSpaces == false ||
_blocRole.isCompleteBasics == _blocRole.isCompleteBasics == false ||
false || _blocRole.isCompleteRolePermissions == false) &&
_blocRole
.isCompleteRolePermissions ==
false) &&
currentStep == 3 currentStep == 3
? ColorsManager.grayColor ? ColorsManager.grayColor
: ColorsManager.secondaryColor), : ColorsManager.secondaryColor),
@ -162,7 +143,7 @@ class _AddNewUserDialogState extends State<AddNewUserDialog> {
Widget _getFormContent() { Widget _getFormContent() {
switch (currentStep) { switch (currentStep) {
case 1: case 1:
return BasicsView( return const BasicsView(
userId: '', userId: '',
); );
case 2: case 2:
@ -215,12 +196,8 @@ class _AddNewUserDialogState extends State<AddNewUserDialog> {
label, label,
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
color: currentStep == step color: currentStep == step ? ColorsManager.blackColor : ColorsManager.greyColor,
? ColorsManager.blackColor fontWeight: currentStep == step ? FontWeight.bold : FontWeight.normal,
: ColorsManager.greyColor,
fontWeight: currentStep == step
? FontWeight.bold
: FontWeight.normal,
), ),
), ),
], ],
@ -283,12 +260,8 @@ class _AddNewUserDialogState extends State<AddNewUserDialog> {
label, label,
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
color: currentStep == step color: currentStep == step ? ColorsManager.blackColor : ColorsManager.greyColor,
? ColorsManager.blackColor fontWeight: currentStep == step ? FontWeight.bold : FontWeight.normal,
: ColorsManager.greyColor,
fontWeight: currentStep == step
? FontWeight.bold
: FontWeight.normal,
), ),
), ),
], ],
@ -345,12 +318,8 @@ class _AddNewUserDialogState extends State<AddNewUserDialog> {
label, label,
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
color: currentStep == step color: currentStep == step ? ColorsManager.blackColor : ColorsManager.greyColor,
? ColorsManager.blackColor fontWeight: currentStep == step ? FontWeight.bold : FontWeight.normal,
: ColorsManager.greyColor,
fontWeight: currentStep == step
? FontWeight.bold
: FontWeight.normal,
), ),
), ),
], ],

View File

@ -1,12 +1,9 @@
import 'dart:async';
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:intl_phone_field/countries.dart'; import 'package:intl_phone_field/countries.dart';
import 'package:intl_phone_field/country_picker_dialog.dart'; import 'package:intl_phone_field/country_picker_dialog.dart';
import 'package:intl_phone_field/intl_phone_field.dart'; import 'package:intl_phone_field/intl_phone_field.dart';
import 'package:syncrow_web/pages/roles_and_permission/users_page/add_user_dialog/bloc/users_bloc.dart'; import 'package:syncrow_web/pages/roles_and_permission/users_page/add_user_dialog/bloc/users_bloc.dart';
import 'package:syncrow_web/pages/roles_and_permission/users_page/add_user_dialog/bloc/users_event.dart';
import 'package:syncrow_web/pages/roles_and_permission/users_page/add_user_dialog/bloc/users_status.dart'; import 'package:syncrow_web/pages/roles_and_permission/users_page/add_user_dialog/bloc/users_status.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'; import 'package:syncrow_web/utils/extension/build_context_x.dart';
@ -14,9 +11,7 @@ import 'package:syncrow_web/utils/style.dart';
class BasicsView extends StatelessWidget { class BasicsView extends StatelessWidget {
final String? userId; final String? userId;
Timer? _debounce; const BasicsView({super.key, this.userId = ''});
BasicsView({super.key, this.userId = ''});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocBuilder<UsersBloc, UsersState>(builder: (context, state) { return BlocBuilder<UsersBloc, UsersState>(builder: (context, state) {
@ -26,7 +21,6 @@ class BasicsView extends StatelessWidget {
} }
return Form( return Form(
key: _blocRole.formKey, key: _blocRole.formKey,
autovalidateMode: AutovalidateMode.onUserInteraction,
child: ListView( child: ListView(
shrinkWrap: true, shrinkWrap: true,
children: [ children: [
@ -214,14 +208,6 @@ class BasicsView extends StatelessWidget {
fontSize: 12, fontSize: 12,
color: ColorsManager.textGray), color: ColorsManager.textGray),
), ),
onChanged: (value) {
if (_debounce?.isActive ?? false) _debounce!.cancel();
_debounce = Timer(const Duration(milliseconds: 800), () {
_blocRole.add(const CheckEmailEvent());
});
},
validator: (value) { validator: (value) {
if (value == null || value.isEmpty) { if (value == null || value.isEmpty) {
return 'Enter Email Address'; return 'Enter Email Address';

View File

@ -7,8 +7,6 @@ import 'package:syncrow_web/pages/space_management_v2/modules/communities/data/s
import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain/params/load_communities_param.dart'; import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain/params/load_communities_param.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/bloc/communities_bloc.dart'; import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/bloc/communities_bloc.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/communities_tree_selection_bloc/communities_tree_selection_bloc.dart'; import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/communities_tree_selection_bloc/communities_tree_selection_bloc.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/data/services/remote_space_details_service.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/presentation/bloc/space_details_bloc.dart';
import 'package:syncrow_web/services/api/http_service.dart'; import 'package:syncrow_web/services/api/http_service.dart';
import 'package:syncrow_web/utils/theme/responsive_text_theme.dart'; import 'package:syncrow_web/utils/theme/responsive_text_theme.dart';
import 'package:syncrow_web/web_layout/web_scaffold.dart'; import 'package:syncrow_web/web_layout/web_scaffold.dart';
@ -28,11 +26,6 @@ class SpaceManagementPage extends StatelessWidget {
)..add(const LoadCommunities(LoadCommunitiesParam())), )..add(const LoadCommunities(LoadCommunitiesParam())),
), ),
BlocProvider(create: (context) => CommunitiesTreeSelectionBloc()), BlocProvider(create: (context) => CommunitiesTreeSelectionBloc()),
BlocProvider(
create: (context) => SpaceDetailsBloc(
RemoteSpaceDetailsService(httpService: HTTPService()),
),
),
], ],
child: WebScaffold( child: WebScaffold(
appBarTitle: Text( appBarTitle: Text(

View File

@ -1,116 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/svg.dart';
import 'package:syncrow_web/pages/space_management_v2/main_module/widgets/community_structure_header_action_buttons.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/communities_tree_selection_bloc/communities_tree_selection_bloc.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/create_community/presentation/create_community_dialog.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/presentation/helpers/space_details_dialog_helper.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
class CommunityStructureHeader extends StatelessWidget {
const CommunityStructureHeader({super.key});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final screenWidth = MediaQuery.of(context).size.width;
return Container(
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0),
decoration: BoxDecoration(
color: ColorsManager.whiteColors,
boxShadow: [
BoxShadow(
color: ColorsManager.shadowBlackColor,
blurRadius: 8,
offset: const Offset(0, 4),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: _buildCommunityInfo(context, theme, screenWidth),
),
const SizedBox(width: 16),
],
),
],
),
);
}
void _showCreateCommunityDialog(BuildContext context) {
showDialog<void>(
context: context,
builder: (context) => CreateCommunityDialog(
title: const Text('Edit Community'),
onCreateCommunity: (community) {
// TODO(FarisArmoush): Implement
},
),
);
}
Widget _buildCommunityInfo(
BuildContext context, ThemeData theme, double screenWidth) {
final selectedCommunity =
context.watch<CommunitiesTreeSelectionBloc>().state.selectedCommunity;
final selectedSpace =
context.watch<CommunitiesTreeSelectionBloc>().state.selectedSpace;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Community Structure',
style: theme.textTheme.headlineLarge
?.copyWith(color: ColorsManager.blackColor),
),
if (selectedCommunity != null)
Row(
children: [
Expanded(
child: Row(
children: [
Flexible(
child: SelectableText(
selectedCommunity.name,
style: theme.textTheme.bodyLarge
?.copyWith(color: ColorsManager.blackColor),
maxLines: 1,
),
),
const SizedBox(width: 2),
GestureDetector(
onTap: () => _showCreateCommunityDialog(context),
child: SvgPicture.asset(
Assets.iconEdit,
width: 16,
height: 16,
),
),
],
),
),
const SizedBox(width: 8),
CommunityStructureHeaderActionButtons(
onDelete: (space) {},
onDuplicate: (space) {},
onEdit: (space) {
SpaceDetailsDialogHelper.showEdit(
context,
spaceModel: selectedSpace!,
);
},
selectedSpace: selectedSpace,
),
],
),
],
);
}
}

View File

@ -1,46 +0,0 @@
import 'package:flutter/material.dart';
import 'package:syncrow_web/pages/space_management_v2/main_module/widgets/community_structure_header_button.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain/models/space_model.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
class CommunityStructureHeaderActionButtons extends StatelessWidget {
const CommunityStructureHeaderActionButtons({
super.key,
required this.onDelete,
required this.selectedSpace,
required this.onDuplicate,
required this.onEdit,
});
final void Function(SpaceModel space) onDelete;
final void Function(SpaceModel space) onDuplicate;
final void Function(SpaceModel space) onEdit;
final SpaceModel? selectedSpace;
@override
Widget build(BuildContext context) {
return Wrap(
alignment: WrapAlignment.end,
spacing: 10,
children: [
if (selectedSpace != null) ...[
CommunityStructureHeaderButton(
label: 'Edit',
svgAsset: Assets.editSpace,
onPressed: () => onEdit(selectedSpace!),
),
CommunityStructureHeaderButton(
label: 'Duplicate',
svgAsset: Assets.duplicate,
onPressed: () => onDuplicate(selectedSpace!),
),
CommunityStructureHeaderButton(
label: 'Delete',
svgAsset: Assets.spaceDelete,
onPressed: () => onDelete(selectedSpace!),
),
],
],
);
}
}

View File

@ -1,61 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:syncrow_web/pages/common/buttons/default_button.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/extension/build_context_x.dart';
class CommunityStructureHeaderButton extends StatelessWidget {
const CommunityStructureHeaderButton({
super.key,
required this.label,
required this.onPressed,
this.svgAsset,
});
final String label;
final VoidCallback onPressed;
final String? svgAsset;
@override
Widget build(BuildContext context) {
const double buttonHeight = 40;
return ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: 130,
minHeight: buttonHeight,
),
child: DefaultButton(
onPressed: onPressed,
borderWidth: 2,
backgroundColor: ColorsManager.textFieldGreyColor,
foregroundColor: ColorsManager.blackColor,
borderRadius: 12.0,
padding: 2.0,
height: buttonHeight,
elevation: 0,
borderColor: ColorsManager.lightGrayColor,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (svgAsset != null)
SvgPicture.asset(
svgAsset!,
width: 20,
height: 20,
),
const SizedBox(width: 10),
Flexible(
child: Text(
label,
style: context.textTheme.bodySmall
?.copyWith(color: ColorsManager.blackColor, fontSize: 14),
overflow: TextOverflow.ellipsis,
maxLines: 1,
),
),
],
),
),
);
}
}

View File

@ -1,7 +1,6 @@
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/space_management_v2/main_module/widgets/community_structure_canvas.dart'; import 'package:syncrow_web/pages/space_management_v2/main_module/widgets/community_structure_canvas.dart';
import 'package:syncrow_web/pages/space_management_v2/main_module/widgets/community_structure_header.dart';
import 'package:syncrow_web/pages/space_management_v2/main_module/widgets/create_space_button.dart'; import 'package:syncrow_web/pages/space_management_v2/main_module/widgets/create_space_button.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/communities_tree_selection_bloc/communities_tree_selection_bloc.dart'; import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/communities_tree_selection_bloc/communities_tree_selection_bloc.dart';
@ -19,17 +18,9 @@ class SpaceManagementCommunityStructure extends StatelessWidget {
replacement: const Row( replacement: const Row(
children: [spacer, Expanded(child: CreateSpaceButton()), spacer], children: [spacer, Expanded(child: CreateSpaceButton()), spacer],
), ),
child: Column( child: CommunityStructureCanvas(
mainAxisSize: MainAxisSize.min, community: selectedCommunity,
children: [ selectedSpace: selectedSpace,
const CommunityStructureHeader(),
Expanded(
child: CommunityStructureCanvas(
community: selectedCommunity,
selectedSpace: selectedSpace,
),
),
],
), ),
); );
} }

View File

@ -19,16 +19,6 @@ class SpaceModel extends Equatable {
required this.parent, required this.parent,
}); });
factory SpaceModel.empty() => const SpaceModel(
uuid: '',
createdAt: null,
updatedAt: null,
spaceName: '',
icon: '',
children: [],
parent: null,
);
factory SpaceModel.fromJson(Map<String, dynamic> json) { factory SpaceModel.fromJson(Map<String, dynamic> json) {
return SpaceModel( return SpaceModel(
uuid: json['uuid'] as String? ?? '', uuid: json['uuid'] as String? ?? '',

View File

@ -1,7 +1,6 @@
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:syncrow_web/pages/common/bloc/project_manager.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/domain/models/space_details_model.dart'; import 'package:syncrow_web/pages/space_management_v2/modules/space_details/domain/models/space_details_model.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/domain/params/load_space_details_param.dart'; import 'package:syncrow_web/pages/space_management_v2/modules/space_details/domain/params/load_spaces_param.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/domain/services/space_details_service.dart'; import 'package:syncrow_web/pages/space_management_v2/modules/space_details/domain/services/space_details_service.dart';
import 'package:syncrow_web/services/api/api_exception.dart'; import 'package:syncrow_web/services/api/api_exception.dart';
import 'package:syncrow_web/services/api/http_service.dart'; import 'package:syncrow_web/services/api/http_service.dart';
@ -16,15 +15,12 @@ class RemoteSpaceDetailsService implements SpaceDetailsService {
static const _defaultErrorMessage = 'Failed to load space details'; static const _defaultErrorMessage = 'Failed to load space details';
@override @override
Future<SpaceDetailsModel> getSpaceDetails(LoadSpaceDetailsParam param) async { Future<SpaceDetailsModel> getSpaceDetails(LoadSpacesParam param) async {
try { try {
final response = await _httpService.get( final response = await _httpService.get(
path: await _makeEndpoint(param), path: 'endpoint',
expectedResponseModel: (data) { expectedResponseModel: (data) {
final response = data as Map<String, dynamic>; return SpaceDetailsModel.fromJson(data as Map<String, dynamic>);
return SpaceDetailsModel.fromJson(
response['data'] as Map<String, dynamic>,
);
}, },
); );
return response; return response;
@ -41,13 +37,4 @@ class RemoteSpaceDetailsService implements SpaceDetailsService {
throw APIException(formattedErrorMessage); throw APIException(formattedErrorMessage);
} }
} }
Future<String> _makeEndpoint(LoadSpaceDetailsParam param) async {
final projectUuid = await ProjectManager.getProjectUUID();
if (projectUuid == null || projectUuid.isEmpty) {
throw APIException('Project UUID is not set');
}
return '/projects/$projectUuid/communities/${param.communityUuid}/spaces/${param.spaceUuid}';
}
} }

View File

@ -1,7 +1,6 @@
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/products/domain/models/product.dart'; import 'package:syncrow_web/pages/space_management_v2/modules/products/domain/models/product.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/tags/domain/models/tag.dart'; import 'package:syncrow_web/pages/space_management_v2/modules/tags/domain/models/tag.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
class SpaceDetailsModel extends Equatable { class SpaceDetailsModel extends Equatable {
final String uuid; final String uuid;
@ -18,21 +17,14 @@ class SpaceDetailsModel extends Equatable {
required this.subspaces, required this.subspaces,
}); });
factory SpaceDetailsModel.empty() => const SpaceDetailsModel(
uuid: '',
spaceName: '',
icon: Assets.villa,
productAllocations: [],
subspaces: [],
);
factory SpaceDetailsModel.fromJson(Map<String, dynamic> json) { factory SpaceDetailsModel.fromJson(Map<String, dynamic> json) {
return SpaceDetailsModel( return SpaceDetailsModel(
uuid: json['uuid'] as String, uuid: json['uuid'] as String,
spaceName: json['spaceName'] as String, spaceName: json['spaceName'] as String,
icon: json['icon'] as String, icon: json['icon'] as String,
productAllocations: (json['productAllocations'] as List) productAllocations: (json['productAllocations'] as List)
.map((e) => ProductAllocation.fromJson(e as Map<String, dynamic>)) .map((e) => ProductAllocation.fromJson(e as Map<String, dynamic>))
.toList(), .toList(),
subspaces: (json['subspaces'] as List) subspaces: (json['subspaces'] as List)
.map((e) => Subspace.fromJson(e as Map<String, dynamic>)) .map((e) => Subspace.fromJson(e as Map<String, dynamic>))
.toList(), .toList(),
@ -49,22 +41,6 @@ class SpaceDetailsModel extends Equatable {
}; };
} }
SpaceDetailsModel copyWith({
String? uuid,
String? spaceName,
String? icon,
List<ProductAllocation>? productAllocations,
List<Subspace>? subspaces,
}) {
return SpaceDetailsModel(
uuid: uuid ?? this.uuid,
spaceName: spaceName ?? this.spaceName,
icon: icon ?? this.icon,
productAllocations: productAllocations ?? this.productAllocations,
subspaces: subspaces ?? this.subspaces,
);
}
@override @override
List<Object?> get props => [uuid, spaceName, icon, productAllocations, subspaces]; List<Object?> get props => [uuid, spaceName, icon, productAllocations, subspaces];
} }
@ -72,10 +48,12 @@ class SpaceDetailsModel extends Equatable {
class ProductAllocation extends Equatable { class ProductAllocation extends Equatable {
final Product product; final Product product;
final Tag tag; final Tag tag;
final String? location;
const ProductAllocation({ const ProductAllocation({
required this.product, required this.product,
required this.tag, required this.tag,
this.location,
}); });
factory ProductAllocation.fromJson(Map<String, dynamic> json) { factory ProductAllocation.fromJson(Map<String, dynamic> json) {
@ -92,16 +70,6 @@ class ProductAllocation extends Equatable {
}; };
} }
ProductAllocation copyWith({
Product? product,
Tag? tag,
}) {
return ProductAllocation(
product: product ?? this.product,
tag: tag ?? this.tag,
);
}
@override @override
List<Object?> get props => [product, tag]; List<Object?> get props => [product, tag];
} }
@ -120,7 +88,7 @@ class Subspace extends Equatable {
factory Subspace.fromJson(Map<String, dynamic> json) { factory Subspace.fromJson(Map<String, dynamic> json) {
return Subspace( return Subspace(
uuid: json['uuid'] as String, uuid: json['uuid'] as String,
name: json['subspaceName'] as String, name: json['name'] as String,
productAllocations: (json['productAllocations'] as List) productAllocations: (json['productAllocations'] as List)
.map((e) => ProductAllocation.fromJson(e as Map<String, dynamic>)) .map((e) => ProductAllocation.fromJson(e as Map<String, dynamic>))
.toList(), .toList(),
@ -135,18 +103,6 @@ class Subspace extends Equatable {
}; };
} }
Subspace copyWith({
String? uuid,
String? name,
List<ProductAllocation>? productAllocations,
}) {
return Subspace(
uuid: uuid ?? this.uuid,
name: name ?? this.name,
productAllocations: productAllocations ?? this.productAllocations,
);
}
@override @override
List<Object?> get props => [uuid, name, productAllocations]; List<Object?> get props => [uuid, name, productAllocations];
} }

View File

@ -1,9 +0,0 @@
class LoadSpaceDetailsParam {
const LoadSpaceDetailsParam({
required this.spaceUuid,
required this.communityUuid,
});
final String spaceUuid;
final String communityUuid;
}

View File

@ -0,0 +1,3 @@
class LoadSpacesParam {
const LoadSpacesParam();
}

View File

@ -1,6 +1,6 @@
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/domain/models/space_details_model.dart'; import 'package:syncrow_web/pages/space_management_v2/modules/space_details/domain/models/space_details_model.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/domain/params/load_space_details_param.dart'; import 'package:syncrow_web/pages/space_management_v2/modules/space_details/domain/params/load_spaces_param.dart';
abstract class SpaceDetailsService { abstract class SpaceDetailsService {
Future<SpaceDetailsModel> getSpaceDetails(LoadSpaceDetailsParam param); Future<SpaceDetailsModel> getSpaceDetails(LoadSpacesParam param);
} }

View File

@ -1,7 +1,7 @@
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/space_management_v2/modules/space_details/domain/models/space_details_model.dart'; import 'package:syncrow_web/pages/space_management_v2/modules/space_details/domain/models/space_details_model.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/domain/params/load_space_details_param.dart'; import 'package:syncrow_web/pages/space_management_v2/modules/space_details/domain/params/load_spaces_param.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/domain/services/space_details_service.dart'; import 'package:syncrow_web/pages/space_management_v2/modules/space_details/domain/services/space_details_service.dart';
import 'package:syncrow_web/services/api/api_exception.dart'; import 'package:syncrow_web/services/api/api_exception.dart';
@ -9,13 +9,12 @@ part 'space_details_event.dart';
part 'space_details_state.dart'; part 'space_details_state.dart';
class SpaceDetailsBloc extends Bloc<SpaceDetailsEvent, SpaceDetailsState> { class SpaceDetailsBloc extends Bloc<SpaceDetailsEvent, SpaceDetailsState> {
final SpaceDetailsService _spaceDetailsService;
SpaceDetailsBloc(this._spaceDetailsService) : super(SpaceDetailsInitial()) { SpaceDetailsBloc(this._spaceDetailsService) : super(SpaceDetailsInitial()) {
on<LoadSpaceDetails>(_onLoadSpaceDetails); on<LoadSpaceDetails>(_onLoadSpaceDetails);
on<ClearSpaceDetails>(_onClearSpaceDetails);
} }
final SpaceDetailsService _spaceDetailsService;
Future<void> _onLoadSpaceDetails( Future<void> _onLoadSpaceDetails(
LoadSpaceDetails event, LoadSpaceDetails event,
Emitter<SpaceDetailsState> emit, Emitter<SpaceDetailsState> emit,
@ -32,11 +31,4 @@ class SpaceDetailsBloc extends Bloc<SpaceDetailsEvent, SpaceDetailsState> {
emit(SpaceDetailsFailure(e.toString())); emit(SpaceDetailsFailure(e.toString()));
} }
} }
void _onClearSpaceDetails(
ClearSpaceDetails event,
Emitter<SpaceDetailsState> emit,
) {
emit(SpaceDetailsInitial());
}
} }

View File

@ -7,18 +7,11 @@ sealed class SpaceDetailsEvent extends Equatable {
List<Object> get props => []; List<Object> get props => [];
} }
final class LoadSpaceDetails extends SpaceDetailsEvent { class LoadSpaceDetails extends SpaceDetailsEvent {
const LoadSpaceDetails(this.param); const LoadSpaceDetails(this.param);
final LoadSpaceDetailsParam param; final LoadSpacesParam param;
@override @override
List<Object> get props => [param]; List<Object> get props => [param];
} }
final class ClearSpaceDetails extends SpaceDetailsEvent {
const ClearSpaceDetails();
@override
List<Object> get props => [];
}

View File

@ -21,10 +21,10 @@ final class SpaceDetailsLoaded extends SpaceDetailsState {
} }
final class SpaceDetailsFailure extends SpaceDetailsState { final class SpaceDetailsFailure extends SpaceDetailsState {
final String errorMessage; final String message;
const SpaceDetailsFailure(this.errorMessage); const SpaceDetailsFailure(this.message);
@override @override
List<Object> get props => [errorMessage]; List<Object> get props => [message];
} }

View File

@ -1,46 +1,11 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain/models/space_model.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/data/services/remote_space_details_service.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/presentation/bloc/space_details_bloc.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/presentation/widgets/space_details_dialog.dart'; import 'package:syncrow_web/pages/space_management_v2/modules/space_details/presentation/widgets/space_details_dialog.dart';
import 'package:syncrow_web/services/api/http_service.dart';
abstract final class SpaceDetailsDialogHelper { abstract final class SpaceDetailsDialogHelper {
static void showCreate(BuildContext context) { static void showCreate(BuildContext context) {
showDialog<void>( showDialog<void>(
context: context, context: context,
builder: (_) => BlocProvider( builder: (context) => const SpaceDetailsDialog(),
create: (context) => SpaceDetailsBloc(
RemoteSpaceDetailsService(httpService: HTTPService()),
),
child: SpaceDetailsDialog(
context: context,
title: const Text('Create Space'),
spaceModel: SpaceModel.empty(),
onSave: print,
),
),
);
}
static void showEdit(
BuildContext context, {
required SpaceModel spaceModel,
}) {
showDialog<void>(
context: context,
builder: (_) => BlocProvider(
create: (context) => SpaceDetailsBloc(
RemoteSpaceDetailsService(httpService: HTTPService()),
),
child: SpaceDetailsDialog(
context: context,
title: const Text('Edit Space'),
spaceModel: spaceModel,
onSave: (space) {},
),
),
); );
} }
} }

View File

@ -1,60 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:syncrow_web/utils/color_manager.dart';
class ButtonContentWidget extends StatelessWidget {
final String label;
final String? svgAssets;
final bool disabled;
const ButtonContentWidget({
required this.label,
this.svgAssets,
this.disabled = false,
super.key,
});
@override
Widget build(BuildContext context) {
final screenWidth = MediaQuery.of(context).size.width;
return Opacity(
opacity: disabled ? 0.5 : 1.0,
child: Container(
width: screenWidth * 0.25,
decoration: BoxDecoration(
color: ColorsManager.textFieldGreyColor,
border: Border.all(
color: ColorsManager.neutralGray,
width: 3.0,
),
borderRadius: BorderRadius.circular(20),
),
padding: const EdgeInsets.symmetric(vertical: 10.0, horizontal: 16.0),
child: Row(
children: [
if (svgAssets != null)
Padding(
padding: const EdgeInsets.only(left: 6.0),
child: SvgPicture.asset(
svgAssets!,
width: screenWidth * 0.015,
height: screenWidth * 0.015,
),
),
const SizedBox(width: 10),
Expanded(
child: Text(
label,
style: const TextStyle(
color: ColorsManager.blackColor,
fontSize: 16,
),
),
),
],
),
),
);
}
}

View File

@ -1,45 +0,0 @@
import 'package:flutter/material.dart';
import 'package:syncrow_web/pages/common/buttons/cancel_button.dart';
import 'package:syncrow_web/pages/common/buttons/default_button.dart';
import 'package:syncrow_web/utils/color_manager.dart';
class SpaceDetailsActionButtons extends StatelessWidget {
const SpaceDetailsActionButtons({
super.key,
required this.onSave,
required this.onCancel,
});
final VoidCallback onCancel;
final VoidCallback? onSave;
@override
Widget build(BuildContext context) {
return Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
spacing: 10,
children: [
Expanded(child: _buildCancelButton(context)),
Expanded(child: _buildSaveButton()),
],
);
}
Widget _buildCancelButton(BuildContext context) {
return CancelButton(
onPressed: onCancel,
label: 'Cancel',
);
}
Widget _buildSaveButton() {
return DefaultButton(
onPressed: onSave,
borderRadius: 10,
backgroundColor: ColorsManager.secondaryColor,
foregroundColor: ColorsManager.whiteColors,
child: const Text('OK'),
);
}
}

View File

@ -1,92 +0,0 @@
import 'package:flutter/material.dart';
import 'package:syncrow_web/common/edit_chip.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/domain/models/space_details_model.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/presentation/widgets/button_content_widget.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
class SpaceDetailsDevicesBox extends StatelessWidget {
const SpaceDetailsDevicesBox({
required this.space,
super.key,
});
final SpaceDetailsModel space;
@override
Widget build(BuildContext context) {
final productAllocations = space.productAllocations;
final subspaces = space.subspaces;
final isAnySubspaceHasProductAllocations =
subspaces.any((subspace) => subspace.productAllocations.isNotEmpty);
if (productAllocations.isNotEmpty || isAnySubspaceHasProductAllocations) {
return Container(
width: double.infinity,
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: ColorsManager.textFieldGreyColor,
borderRadius: BorderRadius.circular(15),
border: Border.all(
color: ColorsManager.textFieldGreyColor,
width: 3.0,
),
),
child: Wrap(
spacing: 8.0,
runSpacing: 8.0,
children: [
// Combine tags from spaceModel and subspaces
// ...TagHelper.groupTags([
// ...?tags,
// ...?subspaces?.expand((subspace) => subspace.tags ?? [])
// ]).entries.map(
// (entry) => Chip(
// avatar: SizedBox(
// width: 24,
// height: 24,
// child: SvgPicture.asset(
// entry.key.icon ?? 'assets/icons/gateway.svg',
// fit: BoxFit.contain,
// ),
// ),
// label: Text(
// 'x${entry.value}',
// style: Theme.of(context)
// .textTheme
// .bodySmall
// ?.copyWith(color: ColorsManager.spaceColor),
// ),
// backgroundColor: ColorsManager.whiteColors,
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(16),
// side: const BorderSide(
// color: ColorsManager.spaceColor,
// ),
// ),
// ),
// ),
EditChip(
onTap: () {},
),
],
),
);
} else {
return TextButton(
onPressed: () {},
style: TextButton.styleFrom(
padding: EdgeInsets.zero,
),
child: const SizedBox(
width: double.infinity,
child: ButtonContentWidget(
svgAssets: Assets.addIcon,
label: 'Add Devices',
// disabled: isTagsAndSubspaceModelDisabled,
),
),
);
}
}
}

View File

@ -1,101 +1,12 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain/models/space_model.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/communities_tree_selection_bloc/communities_tree_selection_bloc.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/domain/models/space_details_model.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/domain/params/load_space_details_param.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/presentation/bloc/space_details_bloc.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/presentation/widgets/space_details_form.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/extension/build_context_x.dart';
class SpaceDetailsDialog extends StatefulWidget { class SpaceDetailsDialog extends StatelessWidget {
const SpaceDetailsDialog({ const SpaceDetailsDialog({super.key});
required this.title,
required this.spaceModel,
required this.onSave,
required this.context,
super.key,
});
final Widget title;
final SpaceModel spaceModel;
final void Function(SpaceDetailsModel space) onSave;
final BuildContext context;
@override
State<SpaceDetailsDialog> createState() => _SpaceDetailsDialogState();
}
class _SpaceDetailsDialogState extends State<SpaceDetailsDialog> {
@override
void initState() {
final isCreateMode = widget.spaceModel.uuid.isEmpty;
if (!isCreateMode) {
final param = LoadSpaceDetailsParam(
spaceUuid: widget.spaceModel.uuid,
communityUuid: widget.context
.read<CommunitiesTreeSelectionBloc>()
.state
.selectedCommunity!
.uuid,
);
widget.context.read<SpaceDetailsBloc>().add(LoadSpaceDetails(param));
}
super.initState();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final isCreateMode = widget.spaceModel.uuid.isEmpty; return const Dialog(
if (isCreateMode) { child: Text('Create Space'),
return SpaceDetailsForm(
title: widget.title,
space: SpaceDetailsModel.empty(),
onSave: widget.onSave,
);
}
return BlocBuilder<SpaceDetailsBloc, SpaceDetailsState>(
bloc: widget.context.read<SpaceDetailsBloc>(),
builder: (context, state) => switch (state) {
SpaceDetailsInitial() => _buildLoadingDialog(),
SpaceDetailsLoading() => _buildLoadingDialog(),
SpaceDetailsLoaded(:final spaceDetails) => SpaceDetailsForm(
title: widget.title,
space: spaceDetails,
onSave: widget.onSave,
),
SpaceDetailsFailure(:final errorMessage) => _buildErrorDialog(
errorMessage,
),
},
);
}
Widget _buildLoadingDialog() {
return AlertDialog(
title: widget.title,
backgroundColor: ColorsManager.whiteColors,
content: const Center(child: CircularProgressIndicator()),
);
}
Widget _buildErrorDialog(String errorMessage) {
return AlertDialog(
title: widget.title,
backgroundColor: ColorsManager.whiteColors,
content: Center(
child: SelectableText(
errorMessage,
style: context.textTheme.bodyLarge?.copyWith(
color: ColorsManager.red,
fontWeight: FontWeight.w500,
fontSize: 18,
),
),
),
); );
} }
} }

View File

@ -1,77 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/domain/models/space_details_model.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/presentation/widgets/space_details_action_buttons.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/presentation/widgets/space_details_devices_box.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/presentation/widgets/space_icon_picker.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/presentation/widgets/space_name_text_field.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/presentation/widgets/space_sub_spaces_box.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/update_space/presentation/bloc/space_details_model_bloc/space_details_model_bloc.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/extension/build_context_x.dart';
class SpaceDetailsForm extends StatelessWidget {
const SpaceDetailsForm({
required this.title,
required this.space,
required this.onSave,
super.key,
});
final Widget title;
final SpaceDetailsModel space;
final void Function(SpaceDetailsModel space) onSave;
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => SpaceDetailsModelBloc(initialState: space),
child: BlocBuilder<SpaceDetailsModelBloc, SpaceDetailsModel>(
buildWhen: (previous, current) => previous != current,
builder: (context, state) {
return AlertDialog(
title: title,
backgroundColor: ColorsManager.whiteColors,
content: SizedBox(
height: context.screenHeight * 0.3,
width: context.screenWidth * 0.5,
child: Row(
spacing: 20,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(child: SpaceIconPicker(iconPath: state.icon)),
Expanded(
flex: 2,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SpaceNameTextField(
initialValue: state.spaceName,
isNameFieldExist: (value) => state.subspaces.any(
(subspace) => subspace.name == value,
),
),
const Spacer(),
SpaceSubSpacesBox(
subspaces: state.subspaces,
),
const SizedBox(height: 16),
SpaceDetailsDevicesBox(space: state),
],
),
),
],
),
),
actions: [
SpaceDetailsActionButtons(
onSave: () => onSave(state),
onCancel: Navigator.of(context).pop,
),
],
);
}),
);
}
}

View File

@ -1,76 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/svg.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/presentation/widgets/space_icon_selection_dialog.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/update_space/presentation/bloc/space_details_model_bloc/space_details_model_bloc.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
import 'package:syncrow_web/utils/extension/build_context_x.dart';
class SpaceIconPicker extends StatelessWidget {
const SpaceIconPicker({
required this.iconPath,
super.key,
});
final String iconPath;
@override
Widget build(BuildContext context) {
return Center(
child: Stack(
alignment: Alignment.center,
children: [
Container(
width: context.screenWidth * 0.175,
height: context.screenHeight * 0.175,
decoration: const BoxDecoration(
color: ColorsManager.boxColor,
shape: BoxShape.circle,
),
padding: const EdgeInsets.all(24),
child: SvgPicture.asset(
iconPath,
width: context.screenWidth * 0.08,
height: context.screenHeight * 0.08,
),
),
Positioned.directional(
top: 12,
start: context.screenHeight * 0.06,
textDirection: Directionality.of(context),
child: InkWell(
onTap: () {
showDialog<String?>(
context: context,
builder: (context) => SpaceIconSelectionDialog(
selectedIcon: iconPath,
),
).then((value) {
if (value != null) {
if (context.mounted) {
context.read<SpaceDetailsModelBloc>().add(
UpdateSpaceDetailsIcon(value),
);
}
}
});
},
child: Container(
decoration: const BoxDecoration(
shape: BoxShape.circle,
),
child: SvgPicture.asset(
Assets.iconEdit,
width: 16,
height: 16,
),
),
),
),
],
),
);
}
}

View File

@ -1,75 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
import 'package:syncrow_web/utils/extension/build_context_x.dart';
class SpaceIconSelectionDialog extends StatelessWidget {
const SpaceIconSelectionDialog({super.key, required this.selectedIcon});
final String selectedIcon;
static const List<String> _icons = [
Assets.location,
Assets.villa,
Assets.gym,
Assets.sauna,
Assets.bbq,
Assets.building,
Assets.desk,
Assets.door,
Assets.parking,
Assets.pool,
Assets.stair,
Assets.steamRoom,
Assets.street,
Assets.unit,
];
@override
Widget build(BuildContext context) {
return AlertDialog(
title: SelectableText(
'Space Icon',
style: context.textTheme.headlineMedium,
),
backgroundColor: ColorsManager.whiteColors,
content: Container(
width: context.screenWidth * 0.45,
height: context.screenHeight * 0.275,
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: ColorsManager.boxColor,
borderRadius: BorderRadius.circular(12),
),
child: GridView.builder(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 7,
crossAxisSpacing: 8,
mainAxisSpacing: 16,
),
itemCount: _icons.length,
itemBuilder: (context, index) {
final isSelected = selectedIcon == _icons[index];
return Container(
padding: const EdgeInsetsDirectional.all(2),
decoration: BoxDecoration(
shape: BoxShape.circle,
border: isSelected
? Border.all(color: ColorsManager.vividBlue, width: 2)
: null,
),
child: IconButton(
onPressed: () => Navigator.of(context).pop(_icons[index]),
icon: SvgPicture.asset(
_icons[index],
width: context.screenWidth * 0.03,
height: context.screenHeight * 0.08,
),
),
);
},
),
),
);
}
}

View File

@ -1,85 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/update_space/presentation/bloc/space_details_model_bloc/space_details_model_bloc.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/extension/build_context_x.dart';
class SpaceNameTextField extends StatefulWidget {
const SpaceNameTextField({
required this.initialValue,
required this.isNameFieldExist,
super.key,
});
final String? initialValue;
final bool Function(String value) isNameFieldExist;
@override
State<SpaceNameTextField> createState() => _SpaceNameTextFieldState();
}
class _SpaceNameTextFieldState extends State<SpaceNameTextField> {
late final TextEditingController _controller;
@override
void initState() {
_controller = TextEditingController(text: widget.initialValue);
super.initState();
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
final _formKey = GlobalKey<FormState>();
String? _validateName(String? value) {
if (value == null || value.isEmpty) {
return '*Space name should not be empty.';
}
if (widget.isNameFieldExist(value)) {
return '*Name already exists';
}
return null;
}
@override
Widget build(BuildContext context) {
return Form(
key: _formKey,
autovalidateMode: AutovalidateMode.onUserInteraction,
child: TextFormField(
controller: _controller,
onChanged: (value) => context.read<SpaceDetailsModelBloc>().add(
UpdateSpaceDetailsName(value),
),
validator: _validateName,
style: context.textTheme.bodyMedium,
decoration: InputDecoration(
hintText: 'Please enter the name',
hintStyle: context.textTheme.bodyMedium!.copyWith(
color: ColorsManager.lightGrayColor,
),
filled: true,
fillColor: ColorsManager.boxColor,
enabledBorder: _buildBorder(context, ColorsManager.vividBlue),
focusedBorder: _buildBorder(context, ColorsManager.primaryColor),
errorBorder: _buildBorder(context, context.theme.colorScheme.error),
focusedErrorBorder: _buildBorder(context, context.theme.colorScheme.error),
errorStyle: context.textTheme.bodySmall?.copyWith(
color: context.theme.colorScheme.error,
),
),
),
);
}
OutlineInputBorder _buildBorder(BuildContext context, [Color? color]) {
return OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(width: 1, color: color ?? ColorsManager.boxColor),
);
}
}

View File

@ -1,74 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/common/edit_chip.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/domain/models/space_details_model.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/presentation/widgets/button_content_widget.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/presentation/widgets/space_sub_spaces_dialog.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/presentation/widgets/subspace_name_display_widget.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/update_space/presentation/bloc/space_details_model_bloc/space_details_model_bloc.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
class SpaceSubSpacesBox extends StatelessWidget {
const SpaceSubSpacesBox({super.key, required this.subspaces});
final List<Subspace> subspaces;
@override
Widget build(BuildContext context) {
if (subspaces.isEmpty) {
return TextButton(
style: TextButton.styleFrom(
padding: EdgeInsets.zero,
overlayColor: ColorsManager.transparentColor,
),
onPressed: () => _showSubSpacesDialog(context),
child: const SizedBox(
width: double.infinity,
child: ButtonContentWidget(
svgAssets: Assets.addIcon,
label: 'Create Sub Spaces',
),
),
);
} else {
return Container(
padding: const EdgeInsets.all(8.0),
width: double.infinity,
decoration: BoxDecoration(
color: ColorsManager.textFieldGreyColor,
borderRadius: BorderRadius.circular(15),
border: Border.all(
color: ColorsManager.textFieldGreyColor,
width: 3.0,
),
),
child: Wrap(
spacing: 8.0,
runSpacing: 8.0,
children: [
...subspaces.map((e) => SubspaceNameDisplayWidget(subSpace: e)),
EditChip(
onTap: () => _showSubSpacesDialog(context),
),
],
),
);
}
}
void _showSubSpacesDialog(BuildContext context) {
showDialog<void>(
context: context,
barrierDismissible: false,
builder: (_) => SpaceSubSpacesDialog(
subspaces: subspaces,
onSave: (subspaces) {
context.read<SpaceDetailsModelBloc>().add(
UpdateSpaceDetailsSubspaces(subspaces),
);
},
),
);
}
}

View File

@ -1,89 +0,0 @@
import 'package:flutter/material.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/domain/models/space_details_model.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/presentation/widgets/space_details_action_buttons.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/presentation/widgets/sub_spaces_input.dart';
import 'package:uuid/uuid.dart';
class SpaceSubSpacesDialog extends StatefulWidget {
const SpaceSubSpacesDialog({
required this.subspaces,
required this.onSave,
super.key,
});
final List<Subspace> subspaces;
final void Function(List<Subspace> subspaces) onSave;
@override
State<SpaceSubSpacesDialog> createState() => _SpaceSubSpacesDialogState();
}
class _SpaceSubSpacesDialogState extends State<SpaceSubSpacesDialog> {
late List<Subspace> _subspaces;
bool get _hasDuplicateNames =>
_subspaces.map((subspace) => subspace.name.toLowerCase()).toSet().length !=
_subspaces.length;
@override
void initState() {
super.initState();
_subspaces = List.from(widget.subspaces);
}
void _handleSubspaceAdded(String name) {
setState(() {
_subspaces = [
..._subspaces,
Subspace(
name: name,
uuid: const Uuid().v4(),
productAllocations: const [],
),
];
});
}
void _handleSubspaceDeleted(String uuid) => setState(
() => _subspaces = _subspaces.where((s) => s.uuid != uuid).toList(),
);
void _handleSave() {
widget.onSave(_subspaces);
Navigator.of(context).pop();
}
@override
Widget build(BuildContext context) {
return AlertDialog(
title: const Text('Create Sub Spaces'),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
SubSpacesInput(
subSpaces: _subspaces,
onSubspaceAdded: _handleSubspaceAdded,
onSubspaceDeleted: _handleSubspaceDeleted,
),
AnimatedSwitcher(
duration: const Duration(milliseconds: 100),
child: Visibility(
key: ValueKey(_hasDuplicateNames),
visible: _hasDuplicateNames,
child: const Text(
'Error: Duplicate subspace names are not allowed.',
style: TextStyle(color: Colors.red),
),
),
),
],
),
actions: [
SpaceDetailsActionButtons(
onSave: _hasDuplicateNames ? null : _handleSave,
onCancel: Navigator.of(context).pop,
)
],
);
}
}

View File

@ -1,107 +0,0 @@
import 'package:flutter/material.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/domain/models/space_details_model.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/presentation/widgets/subspace_chip.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/extension/build_context_x.dart';
class SubSpacesInput extends StatefulWidget {
const SubSpacesInput({
super.key,
required this.subSpaces,
required this.onSubspaceAdded,
required this.onSubspaceDeleted,
});
final List<Subspace> subSpaces;
final void Function(String name) onSubspaceAdded;
final void Function(String uuid) onSubspaceDeleted;
@override
State<SubSpacesInput> createState() => _SubSpacesInputState();
}
class _SubSpacesInputState extends State<SubSpacesInput> {
late final TextEditingController _subspaceNameController;
late final FocusNode _focusNode;
@override
void initState() {
super.initState();
_subspaceNameController = TextEditingController();
_focusNode = FocusNode();
}
@override
void dispose() {
_subspaceNameController.dispose();
_focusNode.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Container(
width: context.screenWidth * 0.35,
padding: const EdgeInsets.symmetric(
vertical: 10,
horizontal: 16,
),
decoration: BoxDecoration(
color: ColorsManager.boxColor,
borderRadius: BorderRadius.circular(10),
),
child: Wrap(
spacing: 8,
runSpacing: 8,
alignment: WrapAlignment.start,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
...widget.subSpaces.asMap().entries.map(
(entry) {
final index = entry.key;
final subSpace = entry.value;
final lowerName = subSpace.name.toLowerCase();
final duplicateIndices = widget.subSpaces
.asMap()
.entries
.where((e) => e.value.name.toLowerCase() == lowerName)
.map((e) => e.key)
.toList();
final isDuplicate = duplicateIndices.length > 1 &&
duplicateIndices.indexOf(index) != 0;
return SubspaceChip(
subSpace: subSpace,
isDuplicate: isDuplicate,
onDeleted: () => widget.onSubspaceDeleted(subSpace.uuid),
);
},
),
SizedBox(
width: 200,
child: TextField(
focusNode: _focusNode,
controller: _subspaceNameController,
decoration: InputDecoration(
border: InputBorder.none,
hintText: widget.subSpaces.isEmpty ? 'Please enter the name' : null,
hintStyle: context.textTheme.bodySmall?.copyWith(
color: ColorsManager.lightGrayColor,
),
),
onSubmitted: (value) {
final trimmedValue = value.trim();
if (trimmedValue.isNotEmpty) {
widget.onSubspaceAdded(trimmedValue);
_subspaceNameController.clear();
_focusNode.requestFocus();
}
},
style: context.textTheme.bodyMedium,
),
),
],
),
);
}
}

View File

@ -1,55 +0,0 @@
import 'package:flutter/material.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/domain/models/space_details_model.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/extension/build_context_x.dart';
class SubspaceChip extends StatelessWidget {
const SubspaceChip({
required this.subSpace,
required this.isDuplicate,
required this.onDeleted,
super.key,
});
final Subspace subSpace;
final bool isDuplicate;
final void Function() onDeleted;
@override
Widget build(BuildContext context) {
return Chip(
label: Text(
subSpace.name,
style: context.textTheme.bodySmall?.copyWith(
color: isDuplicate ? ColorsManager.red : ColorsManager.spaceColor,
),
),
backgroundColor: ColorsManager.whiteColors,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
side: BorderSide(
color: isDuplicate ? ColorsManager.red : ColorsManager.transparentColor,
width: 0,
),
),
deleteIcon: Container(
padding: const EdgeInsetsDirectional.all(1),
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: ColorsManager.lightGrayColor,
width: 1.5,
),
),
child: const FittedBox(
fit: BoxFit.scaleDown,
child: Icon(
Icons.close,
color: ColorsManager.lightGrayColor,
),
),
),
onDeleted: onDeleted,
);
}
}

View File

@ -1,171 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/domain/models/space_details_model.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/update_space/presentation/bloc/space_details_model_bloc/space_details_model_bloc.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/extension/build_context_x.dart';
class SubspaceNameDisplayWidget extends StatefulWidget {
const SubspaceNameDisplayWidget({super.key, required this.subSpace});
final Subspace subSpace;
@override
State<SubspaceNameDisplayWidget> createState() =>
_SubspaceNameDisplayWidgetState();
}
class _SubspaceNameDisplayWidgetState extends State<SubspaceNameDisplayWidget> {
late final TextEditingController _controller;
late final FocusNode _focusNode;
bool _isEditing = false;
bool _hasDuplicateName = false;
@override
void initState() {
_controller = TextEditingController(text: widget.subSpace.name);
_focusNode = FocusNode();
super.initState();
}
@override
void dispose() {
_controller.dispose();
_focusNode.dispose();
super.dispose();
}
bool _checkForDuplicateName(String name) {
final bloc = context.read<SpaceDetailsModelBloc>();
return bloc.state.subspaces
.where((s) => s.uuid != widget.subSpace.uuid)
.any((s) => s.name.toLowerCase() == name.toLowerCase());
}
void _handleNameChange(String value) {
setState(() {
_hasDuplicateName = _checkForDuplicateName(value);
});
}
void _tryToFinishEditing() {
if (!_hasDuplicateName) {
_onFinishEditing();
}
}
void _tryToSubmit(String value) {
if (_hasDuplicateName) return;
final bloc = context.read<SpaceDetailsModelBloc>();
bloc.add(
UpdateSpaceDetailsSubspaces(
bloc.state.subspaces
.map(
(e) => e.uuid == widget.subSpace.uuid ? e.copyWith(name: value) : e,
)
.toList(),
),
);
_onFinishEditing();
}
@override
Widget build(BuildContext context) {
final textStyle = context.textTheme.bodySmall?.copyWith(
color: ColorsManager.spaceColor,
);
return InkWell(
onTap: () {
setState(() => _isEditing = true);
_focusNode.requestFocus();
},
child: Chip(
backgroundColor: ColorsManager.whiteColors,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
side: const BorderSide(color: ColorsManager.transparentColor),
),
onDeleted: () {
final bloc = context.read<SpaceDetailsModelBloc>();
bloc.add(
UpdateSpaceDetailsSubspaces(
bloc.state.subspaces
.where((s) => s.uuid != widget.subSpace.uuid)
.toList(),
),
);
},
deleteIcon: Container(
padding: const EdgeInsetsDirectional.all(1),
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: ColorsManager.lightGrayColor,
width: 1.5,
),
),
child: const FittedBox(
child: Icon(
Icons.close,
color: ColorsManager.lightGrayColor,
),
),
),
label: Visibility(
visible: _isEditing,
replacement: Text(
widget.subSpace.name,
style: textStyle,
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
width: context.screenWidth * 0.065,
height: context.screenHeight * 0.025,
child: TextField(
focusNode: _focusNode,
controller: _controller,
style: textStyle?.copyWith(
color: _hasDuplicateName ? Colors.red : null,
),
decoration: const InputDecoration.collapsed(
hintText: '',
),
onChanged: _handleNameChange,
onTapOutside: (_) => _tryToFinishEditing(),
onSubmitted: _tryToSubmit,
),
),
if (_hasDuplicateName)
AnimatedSwitcher(
duration: const Duration(milliseconds: 250),
child: Visibility(
key: ValueKey(_hasDuplicateName),
visible: _hasDuplicateName,
child: Text(
'Name already exists',
style: textStyle?.copyWith(
color: Colors.red,
fontSize: 8,
),
),
),
),
],
),
),
),
);
}
void _onFinishEditing() {
setState(() {
_isEditing = false;
_hasDuplicateName = false;
});
_focusNode.unfocus();
}
}

View File

@ -1,45 +0,0 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/space_details/domain/models/space_details_model.dart';
part 'space_details_model_event.dart';
class SpaceDetailsModelBloc extends Bloc<SpaceDetailsModelEvent, SpaceDetailsModel> {
SpaceDetailsModelBloc({
required SpaceDetailsModel initialState,
}) : super(initialState) {
on<UpdateSpaceDetailsIcon>(_onUpdateSpaceDetailsIcon);
on<UpdateSpaceDetailsName>(_onUpdateSpaceDetailsName);
on<UpdateSpaceDetailsSubspaces>(_onUpdateSpaceDetailsSubspaces);
on<UpdateSpaceDetailsProductAllocations>(
_onUpdateSpaceDetailsProductAllocations);
}
void _onUpdateSpaceDetailsIcon(
UpdateSpaceDetailsIcon event,
Emitter<SpaceDetailsModel> emit,
) {
emit(state.copyWith(icon: event.icon));
}
void _onUpdateSpaceDetailsName(
UpdateSpaceDetailsName event,
Emitter<SpaceDetailsModel> emit,
) {
emit(state.copyWith(spaceName: event.name));
}
void _onUpdateSpaceDetailsSubspaces(
UpdateSpaceDetailsSubspaces event,
Emitter<SpaceDetailsModel> emit,
) {
emit(state.copyWith(subspaces: event.subspaces));
}
void _onUpdateSpaceDetailsProductAllocations(
UpdateSpaceDetailsProductAllocations event,
Emitter<SpaceDetailsModel> emit,
) {
emit(state.copyWith(productAllocations: event.productAllocations));
}
}

View File

@ -1,44 +0,0 @@
part of 'space_details_model_bloc.dart';
sealed class SpaceDetailsModelEvent extends Equatable {
const SpaceDetailsModelEvent();
@override
List<Object> get props => [];
}
final class UpdateSpaceDetailsIcon extends SpaceDetailsModelEvent {
const UpdateSpaceDetailsIcon(this.icon);
final String icon;
@override
List<Object> get props => [icon];
}
final class UpdateSpaceDetailsName extends SpaceDetailsModelEvent {
const UpdateSpaceDetailsName(this.name);
final String name;
@override
List<Object> get props => [name];
}
final class UpdateSpaceDetailsSubspaces extends SpaceDetailsModelEvent {
const UpdateSpaceDetailsSubspaces(this.subspaces);
final List<Subspace> subspaces;
@override
List<Object> get props => [subspaces];
}
final class UpdateSpaceDetailsProductAllocations extends SpaceDetailsModelEvent {
const UpdateSpaceDetailsProductAllocations(this.productAllocations);
final List<ProductAllocation> productAllocations;
@override
List<Object> get props => [productAllocations];
}

View File

@ -14,7 +14,8 @@ class Assets {
static const String rightLine = 'assets/images/right_line.png'; static const String rightLine = 'assets/images/right_line.png';
static const String google = 'assets/images/google.svg'; static const String google = 'assets/images/google.svg';
static const String facebook = 'assets/images/facebook.svg'; static const String facebook = 'assets/images/facebook.svg';
static const String invisiblePassword = 'assets/images/Password_invisible.svg'; static const String invisiblePassword =
'assets/images/Password_invisible.svg';
static const String visiblePassword = 'assets/images/password_visible.svg'; static const String visiblePassword = 'assets/images/password_visible.svg';
static const String accessIcon = 'assets/images/access_icon.svg'; static const String accessIcon = 'assets/images/access_icon.svg';
static const String spaseManagementIcon = static const String spaseManagementIcon =
@ -33,7 +34,8 @@ class Assets {
static const String emptyTable = 'assets/images/empty_table.svg'; static const String emptyTable = 'assets/images/empty_table.svg';
// General assets // General assets
static const String motionlessDetection = 'assets/icons/motionless_detection.svg'; static const String motionlessDetection =
'assets/icons/motionless_detection.svg';
static const String acHeating = 'assets/icons/ac_heating.svg'; static const String acHeating = 'assets/icons/ac_heating.svg';
static const String acPowerOff = 'assets/icons/ac_power_off.svg'; static const String acPowerOff = 'assets/icons/ac_power_off.svg';
static const String acFanMiddle = 'assets/icons/ac_fan_middle.svg'; static const String acFanMiddle = 'assets/icons/ac_fan_middle.svg';
@ -70,19 +72,22 @@ class Assets {
'assets/icons/automation_functions/temp_password_unlock.svg'; 'assets/icons/automation_functions/temp_password_unlock.svg';
static const String doorlockNormalOpen = static const String doorlockNormalOpen =
'assets/icons/automation_functions/doorlock_normal_open.svg'; 'assets/icons/automation_functions/doorlock_normal_open.svg';
static const String doorbell = 'assets/icons/automation_functions/doorbell.svg'; static const String doorbell =
'assets/icons/automation_functions/doorbell.svg';
static const String remoteUnlockViaApp = static const String remoteUnlockViaApp =
'assets/icons/automation_functions/remote_unlock_via_app.svg'; 'assets/icons/automation_functions/remote_unlock_via_app.svg';
static const String doubleLock = static const String doubleLock =
'assets/icons/automation_functions/double_lock.svg'; 'assets/icons/automation_functions/double_lock.svg';
static const String selfTestResult = static const String selfTestResult =
'assets/icons/automation_functions/self_test_result.svg'; 'assets/icons/automation_functions/self_test_result.svg';
static const String lockAlarm = 'assets/icons/automation_functions/lock_alarm.svg'; static const String lockAlarm =
'assets/icons/automation_functions/lock_alarm.svg';
static const String presenceState = static const String presenceState =
'assets/icons/automation_functions/presence_state.svg'; 'assets/icons/automation_functions/presence_state.svg';
static const String currentTemp = static const String currentTemp =
'assets/icons/automation_functions/current_temp.svg'; 'assets/icons/automation_functions/current_temp.svg';
static const String presence = 'assets/icons/automation_functions/presence.svg'; static const String presence =
'assets/icons/automation_functions/presence.svg';
static const String residualElectricity = static const String residualElectricity =
'assets/icons/automation_functions/residual_electricity.svg'; 'assets/icons/automation_functions/residual_electricity.svg';
static const String hijackAlarm = static const String hijackAlarm =
@ -99,12 +104,15 @@ class Assets {
// Presence Sensor Assets // Presence Sensor Assets
static const String sensorMotionIcon = 'assets/icons/sensor_motion_ic.svg'; static const String sensorMotionIcon = 'assets/icons/sensor_motion_ic.svg';
static const String sensorPresenceIcon = 'assets/icons/sensor_presence_ic.svg'; static const String sensorPresenceIcon =
'assets/icons/sensor_presence_ic.svg';
static const String sensorVacantIcon = 'assets/icons/sensor_vacant_ic.svg'; static const String sensorVacantIcon = 'assets/icons/sensor_vacant_ic.svg';
static const String illuminanceRecordIcon = static const String illuminanceRecordIcon =
'assets/icons/illuminance_record_ic.svg'; 'assets/icons/illuminance_record_ic.svg';
static const String presenceRecordIcon = 'assets/icons/presence_record_ic.svg'; static const String presenceRecordIcon =
static const String helpDescriptionIcon = 'assets/icons/help_description_ic.svg'; 'assets/icons/presence_record_ic.svg';
static const String helpDescriptionIcon =
'assets/icons/help_description_ic.svg';
static const String lightPulp = 'assets/icons/light_pulb.svg'; static const String lightPulp = 'assets/icons/light_pulb.svg';
static const String acDevice = 'assets/icons/ac_device.svg'; static const String acDevice = 'assets/icons/ac_device.svg';
@ -158,10 +166,12 @@ class Assets {
static const String unit = 'assets/icons/unit_icon.svg'; static const String unit = 'assets/icons/unit_icon.svg';
static const String villa = 'assets/icons/villa_icon.svg'; static const String villa = 'assets/icons/villa_icon.svg';
static const String iconEdit = 'assets/icons/icon_edit_icon.svg'; static const String iconEdit = 'assets/icons/icon_edit_icon.svg';
static const String textFieldSearch = 'assets/icons/textfield_search_icon.svg'; static const String textFieldSearch =
'assets/icons/textfield_search_icon.svg';
static const String roundedAddIcon = 'assets/icons/rounded_add_icon.svg'; static const String roundedAddIcon = 'assets/icons/rounded_add_icon.svg';
static const String addIcon = 'assets/icons/add_icon.svg'; static const String addIcon = 'assets/icons/add_icon.svg';
static const String smartThermostatIcon = 'assets/icons/smart_thermostat_icon.svg'; static const String smartThermostatIcon =
'assets/icons/smart_thermostat_icon.svg';
static const String smartLightIcon = 'assets/icons/smart_light_icon.svg'; static const String smartLightIcon = 'assets/icons/smart_light_icon.svg';
static const String presenceSensor = 'assets/icons/presence_sensor.svg'; static const String presenceSensor = 'assets/icons/presence_sensor.svg';
static const String Gang3SwitchIcon = 'assets/icons/3_Gang_switch_icon.svg'; static const String Gang3SwitchIcon = 'assets/icons/3_Gang_switch_icon.svg';
@ -209,7 +219,8 @@ class Assets {
//assets/icons/water_leak_normal.svg //assets/icons/water_leak_normal.svg
static const String waterLeakNormal = 'assets/icons/water_leak_normal.svg'; static const String waterLeakNormal = 'assets/icons/water_leak_normal.svg';
//assets/icons/water_leak_detected.svg //assets/icons/water_leak_detected.svg
static const String waterLeakDetected = 'assets/icons/water_leak_detected.svg'; static const String waterLeakDetected =
'assets/icons/water_leak_detected.svg';
//assets/icons/automation_records.svg //assets/icons/automation_records.svg
static const String automationRecords = 'assets/icons/automation_records.svg'; static const String automationRecords = 'assets/icons/automation_records.svg';
@ -280,13 +291,16 @@ class Assets {
'assets/icons/functions_icons/sensitivity.svg'; 'assets/icons/functions_icons/sensitivity.svg';
static const String assetsSensitivityOperationIcon = static const String assetsSensitivityOperationIcon =
'assets/icons/functions_icons/sesitivity_operation_icon.svg'; 'assets/icons/functions_icons/sesitivity_operation_icon.svg';
static const String assetsAcPower = 'assets/icons/functions_icons/ac_power.svg'; static const String assetsAcPower =
'assets/icons/functions_icons/ac_power.svg';
static const String assetsAcPowerOFF = static const String assetsAcPowerOFF =
'assets/icons/functions_icons/ac_power_off.svg'; 'assets/icons/functions_icons/ac_power_off.svg';
static const String assetsChildLock = static const String assetsChildLock =
'assets/icons/functions_icons/child_lock.svg'; 'assets/icons/functions_icons/child_lock.svg';
static const String assetsFreezing = 'assets/icons/functions_icons/freezing.svg'; static const String assetsFreezing =
static const String assetsFanSpeed = 'assets/icons/functions_icons/fan_speed.svg'; 'assets/icons/functions_icons/freezing.svg';
static const String assetsFanSpeed =
'assets/icons/functions_icons/fan_speed.svg';
static const String assetsAcCooling = static const String assetsAcCooling =
'assets/icons/functions_icons/ac_cooling.svg'; 'assets/icons/functions_icons/ac_cooling.svg';
static const String assetsAcHeating = static const String assetsAcHeating =
@ -295,7 +309,8 @@ class Assets {
'assets/icons/functions_icons/celsius_degrees.svg'; 'assets/icons/functions_icons/celsius_degrees.svg';
static const String assetsTempreture = static const String assetsTempreture =
'assets/icons/functions_icons/tempreture.svg'; 'assets/icons/functions_icons/tempreture.svg';
static const String assetsAcFanLow = 'assets/icons/functions_icons/ac_fan_low.svg'; static const String assetsAcFanLow =
'assets/icons/functions_icons/ac_fan_low.svg';
static const String assetsAcFanMiddle = static const String assetsAcFanMiddle =
'assets/icons/functions_icons/ac_fan_middle.svg'; 'assets/icons/functions_icons/ac_fan_middle.svg';
static const String assetsAcFanHigh = static const String assetsAcFanHigh =
@ -314,7 +329,8 @@ class Assets {
'assets/icons/functions_icons/far_detection.svg'; 'assets/icons/functions_icons/far_detection.svg';
static const String assetsFarDetectionFunction = static const String assetsFarDetectionFunction =
'assets/icons/functions_icons/far_detection_function.svg'; 'assets/icons/functions_icons/far_detection_function.svg';
static const String assetsIndicator = 'assets/icons/functions_icons/indicator.svg'; static const String assetsIndicator =
'assets/icons/functions_icons/indicator.svg';
static const String assetsMotionDetection = static const String assetsMotionDetection =
'assets/icons/functions_icons/motion_detection.svg'; 'assets/icons/functions_icons/motion_detection.svg';
static const String assetsMotionlessDetection = static const String assetsMotionlessDetection =
@ -327,7 +343,8 @@ class Assets {
'assets/icons/functions_icons/master_state.svg'; 'assets/icons/functions_icons/master_state.svg';
static const String assetsSwitchAlarmSound = static const String assetsSwitchAlarmSound =
'assets/icons/functions_icons/switch_alarm_sound.svg'; 'assets/icons/functions_icons/switch_alarm_sound.svg';
static const String assetsResetOff = 'assets/icons/functions_icons/reset_off.svg'; static const String assetsResetOff =
'assets/icons/functions_icons/reset_off.svg';
// Assets for automation_functions // Assets for automation_functions
static const String assetsCardUnlock = static const String assetsCardUnlock =
@ -371,13 +388,15 @@ class Assets {
static const String activeUser = 'assets/icons/active_user.svg'; static const String activeUser = 'assets/icons/active_user.svg';
static const String deActiveUser = 'assets/icons/deactive_user.svg'; static const String deActiveUser = 'assets/icons/deactive_user.svg';
static const String invitedIcon = 'assets/icons/invited_icon.svg'; static const String invitedIcon = 'assets/icons/invited_icon.svg';
static const String rectangleCheckBox = 'assets/icons/rectangle_check_box.png'; static const String rectangleCheckBox =
'assets/icons/rectangle_check_box.png';
static const String CheckBoxChecked = 'assets/icons/box_checked.png'; static const String CheckBoxChecked = 'assets/icons/box_checked.png';
static const String emptyBox = 'assets/icons/empty_box.png'; static const String emptyBox = 'assets/icons/empty_box.png';
static const String completeProcessIcon = static const String completeProcessIcon =
'assets/icons/compleate_process_icon.svg'; 'assets/icons/compleate_process_icon.svg';
static const String completedDoneIcon = 'assets/images/completed_done.svg'; static const String completedDoneIcon = 'assets/images/completed_done.svg';
static const String currentProcessIcon = 'assets/icons/current_process_icon.svg'; static const String currentProcessIcon =
'assets/icons/current_process_icon.svg';
static const String uncomplete_ProcessIcon = static const String uncomplete_ProcessIcon =
'assets/icons/uncompleate_process_icon.svg'; 'assets/icons/uncompleate_process_icon.svg';
static const String wrongProcessIcon = 'assets/icons/wrong_process_icon.svg'; static const String wrongProcessIcon = 'assets/icons/wrong_process_icon.svg';
@ -398,9 +417,11 @@ class Assets {
static const String successIcon = 'assets/icons/success_icon.svg'; static const String successIcon = 'assets/icons/success_icon.svg';
static const String spaceLocationIcon = 'assets/icons/spaseLocationIcon.svg'; static const String spaceLocationIcon = 'assets/icons/spaseLocationIcon.svg';
static const String scenesPlayIcon = 'assets/icons/scenesPlayIcon.png'; static const String scenesPlayIcon = 'assets/icons/scenesPlayIcon.png';
static const String scenesPlayIconCheck = 'assets/icons/scenesPlayIconCheck.png'; static const String scenesPlayIconCheck =
'assets/icons/scenesPlayIconCheck.png';
static const String presenceStateIcon = 'assets/icons/presence_state.svg'; static const String presenceStateIcon = 'assets/icons/presence_state.svg';
static const String currentDistanceIcon = 'assets/icons/current_distance_icon.svg'; static const String currentDistanceIcon =
'assets/icons/current_distance_icon.svg';
static const String farDetectionIcon = 'assets/icons/far_detection_icon.svg'; static const String farDetectionIcon = 'assets/icons/far_detection_icon.svg';
static const String motionDetectionSensitivityIcon = static const String motionDetectionSensitivityIcon =
@ -423,29 +444,44 @@ class Assets {
static const String cpsMode4 = 'assets/icons/cps_mode4.svg'; static const String cpsMode4 = 'assets/icons/cps_mode4.svg';
static const String closeToMotion = 'assets/icons/close_to_motion.svg'; static const String closeToMotion = 'assets/icons/close_to_motion.svg';
static const String farAwayMotion = 'assets/icons/far_away_motion.svg'; static const String farAwayMotion = 'assets/icons/far_away_motion.svg';
static const String communicationFault = 'assets/icons/communication_fault.svg'; static const String communicationFault =
'assets/icons/communication_fault.svg';
static const String radarFault = 'assets/icons/radar_fault.svg'; static const String radarFault = 'assets/icons/radar_fault.svg';
static const String selfTestingSuccess = 'assets/icons/self_testing_success.svg'; static const String selfTestingSuccess =
static const String selfTestingFailure = 'assets/icons/self_testing_failure.svg'; 'assets/icons/self_testing_success.svg';
static const String selfTestingTimeout = 'assets/icons/self_testing_timeout.svg'; static const String selfTestingFailure =
'assets/icons/self_testing_failure.svg';
static const String selfTestingTimeout =
'assets/icons/self_testing_timeout.svg';
static const String movingSpeed = 'assets/icons/moving_speed.svg'; static const String movingSpeed = 'assets/icons/moving_speed.svg';
static const String boundary = 'assets/icons/boundary.svg'; static const String boundary = 'assets/icons/boundary.svg';
static const String motionMeter = 'assets/icons/motion_meter.svg'; static const String motionMeter = 'assets/icons/motion_meter.svg';
static const String spatialStaticValue = 'assets/icons/spatial_static_value.svg'; static const String spatialStaticValue =
static const String spatialMotionValue = 'assets/icons/spatial_motion_value.svg'; 'assets/icons/spatial_static_value.svg';
static const String spatialMotionValue =
'assets/icons/spatial_motion_value.svg';
static const String presenceJudgementThrshold = static const String presenceJudgementThrshold =
'assets/icons/presence_judgement_threshold.svg'; 'assets/icons/presence_judgement_threshold.svg';
static const String spaceType = 'assets/icons/space_type.svg'; static const String spaceType = 'assets/icons/space_type.svg';
static const String sportsPara = 'assets/icons/sports_para.svg'; static const String sportsPara = 'assets/icons/sports_para.svg';
static const String sensitivityFeature1 = 'assets/icons/sensitivity_feature_1.svg'; static const String sensitivityFeature1 =
static const String sensitivityFeature2 = 'assets/icons/sensitivity_feature_2.svg'; 'assets/icons/sensitivity_feature_1.svg';
static const String sensitivityFeature3 = 'assets/icons/sensitivity_feature_3.svg'; static const String sensitivityFeature2 =
static const String sensitivityFeature4 = 'assets/icons/sensitivity_feature_4.svg'; 'assets/icons/sensitivity_feature_2.svg';
static const String sensitivityFeature5 = 'assets/icons/sensitivity_feature_5.svg'; static const String sensitivityFeature3 =
static const String sensitivityFeature6 = 'assets/icons/sensitivity_feature_6.svg'; 'assets/icons/sensitivity_feature_3.svg';
static const String sensitivityFeature7 = 'assets/icons/sensitivity_feature_7.svg'; static const String sensitivityFeature4 =
static const String sensitivityFeature8 = 'assets/icons/sensitivity_feature_8.svg'; 'assets/icons/sensitivity_feature_4.svg';
static const String sensitivityFeature9 = 'assets/icons/sensitivity_feature_9.svg'; static const String sensitivityFeature5 =
'assets/icons/sensitivity_feature_5.svg';
static const String sensitivityFeature6 =
'assets/icons/sensitivity_feature_6.svg';
static const String sensitivityFeature7 =
'assets/icons/sensitivity_feature_7.svg';
static const String sensitivityFeature8 =
'assets/icons/sensitivity_feature_8.svg';
static const String sensitivityFeature9 =
'assets/icons/sensitivity_feature_9.svg';
static const String deviceTagIcon = 'assets/icons/device_tag_ic.svg'; static const String deviceTagIcon = 'assets/icons/device_tag_ic.svg';
static const String targetConfirmTimeIcon = static const String targetConfirmTimeIcon =
'assets/icons/target_confirm_time_icon.svg'; 'assets/icons/target_confirm_time_icon.svg';
@ -453,10 +489,13 @@ class Assets {
static const String indentLevelIcon = 'assets/icons/indent_level_icon.svg'; static const String indentLevelIcon = 'assets/icons/indent_level_icon.svg';
static const String triggerLevelIcon = 'assets/icons/trigger_level_icon.svg'; static const String triggerLevelIcon = 'assets/icons/trigger_level_icon.svg';
static const String blankCalendar = 'assets/icons/blank_calendar.svg'; static const String blankCalendar = 'assets/icons/blank_calendar.svg';
static const String refreshStatusIcon = 'assets/icons/refresh_status_icon.svg'; static const String refreshStatusIcon =
static const String energyConsumedIcon = 'assets/icons/energy_consumed_icon.svg'; 'assets/icons/refresh_status_icon.svg';
static const String energyConsumedIcon =
'assets/icons/energy_consumed_icon.svg';
static const String closeSettingsIcon = 'assets/icons/close_settings_icon.svg'; static const String closeSettingsIcon =
'assets/icons/close_settings_icon.svg';
static const String editNameIconSettings = static const String editNameIconSettings =
'assets/icons/edit_name_icon_settings.svg'; 'assets/icons/edit_name_icon_settings.svg';
@ -469,11 +508,4 @@ class Assets {
static const String humidityAqiSidebar = 'assets/icons/humidity.svg'; static const String humidityAqiSidebar = 'assets/icons/humidity.svg';
static const String autocadOccupancyImage = static const String autocadOccupancyImage =
'assets/images/autocad_occupancy_image.png'; 'assets/images/autocad_occupancy_image.png';
static const String emptyBarredChart = 'assets/icons/empty_barred_chart.svg';
static const String emptyEnergyManagementChart =
'assets/icons/empty_energy_management_chart.svg';
static const String emptyEnergyManagementPerDevice =
'assets/icons/empty_energy_management_per_device.svg';
static const String emptyHeatmap = 'assets/icons/empty_heatmap.svg';
static const String emptyRangeOfAqi = 'assets/icons/empty_range_of_aqi.svg';
} }

View File

@ -52,7 +52,4 @@ final myTheme = ThemeData(
borderRadius: BorderRadius.circular(4), borderRadius: BorderRadius.circular(4),
), ),
), ),
dialogTheme: const DialogThemeData(
backgroundColor: ColorsManager.whiteColors,
),
); );