mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-16 10:06:19 +00:00
formatted all files.
This commit is contained in:
@ -33,7 +33,8 @@ class AirQualityDistributionBloc
|
||||
state.copyWith(
|
||||
status: AirQualityDistributionStatus.success,
|
||||
chartData: result,
|
||||
filteredChartData: _arrangeChartDataByType(result, state.selectedAqiType),
|
||||
filteredChartData:
|
||||
_arrangeChartDataByType(result, state.selectedAqiType),
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
@ -61,7 +62,8 @@ class AirQualityDistributionBloc
|
||||
emit(
|
||||
state.copyWith(
|
||||
selectedAqiType: event.aqiType,
|
||||
filteredChartData: _arrangeChartDataByType(state.chartData, event.aqiType),
|
||||
filteredChartData:
|
||||
_arrangeChartDataByType(state.chartData, event.aqiType),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -7,7 +7,8 @@ import 'package:syncrow_web/pages/analytics/services/device_location/device_loca
|
||||
part 'device_location_event.dart';
|
||||
part 'device_location_state.dart';
|
||||
|
||||
class DeviceLocationBloc extends Bloc<DeviceLocationEvent, DeviceLocationState> {
|
||||
class DeviceLocationBloc
|
||||
extends Bloc<DeviceLocationEvent, DeviceLocationState> {
|
||||
DeviceLocationBloc(
|
||||
this._deviceLocationService,
|
||||
) : super(const DeviceLocationState()) {
|
||||
|
@ -53,7 +53,8 @@ class RangeOfAqiBloc extends Bloc<RangeOfAqiEvent, RangeOfAqiState> {
|
||||
emit(
|
||||
state.copyWith(
|
||||
selectedAqiType: event.aqiType,
|
||||
filteredRangeOfAqi: _arrangeChartDataByType(state.rangeOfAqi, event.aqiType),
|
||||
filteredRangeOfAqi:
|
||||
_arrangeChartDataByType(state.rangeOfAqi, event.aqiType),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -105,7 +105,8 @@ abstract final class RangeOfAqiChartsHelper {
|
||||
tooltipRoundedRadius: 16,
|
||||
showOnTopOfTheChartBoxArea: false,
|
||||
tooltipPadding: const EdgeInsets.all(8),
|
||||
getTooltipItems: (touchedSpots) => RangeOfAqiChartsHelper.getTooltipItems(
|
||||
getTooltipItems: (touchedSpots) =>
|
||||
RangeOfAqiChartsHelper.getTooltipItems(
|
||||
touchedSpots,
|
||||
chartData,
|
||||
),
|
||||
|
@ -81,7 +81,8 @@ class AqiDeviceInfo extends StatelessWidget {
|
||||
aqiLevel: status
|
||||
.firstWhere(
|
||||
(e) => e.code == 'air_quality_index',
|
||||
orElse: () => Status(code: 'air_quality_index', value: ''),
|
||||
orElse: () =>
|
||||
Status(code: 'air_quality_index', value: ''),
|
||||
)
|
||||
.value
|
||||
.toString(),
|
||||
|
@ -36,23 +36,25 @@ class AqiDistributionChart extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
List<BarChartGroupData> _buildBarGroups(List<AirQualityDataModel> sortedData) {
|
||||
List<BarChartGroupData> _buildBarGroups(
|
||||
List<AirQualityDataModel> sortedData) {
|
||||
return List.generate(sortedData.length, (index) {
|
||||
final data = sortedData[index];
|
||||
final stackItems = <BarChartRodData>[];
|
||||
double currentY = 0;
|
||||
bool isFirstElement = true;
|
||||
var isFirstElement = true;
|
||||
|
||||
// Sort data by type to ensure consistent order
|
||||
final sortedPercentageData = List<AirQualityPercentageData>.from(data.data)
|
||||
..sort((a, b) => a.type.compareTo(b.type));
|
||||
final sortedPercentageData =
|
||||
List<AirQualityPercentageData>.from(data.data)
|
||||
..sort((a, b) => a.type.compareTo(b.type));
|
||||
|
||||
for (final percentageData in sortedPercentageData) {
|
||||
stackItems.add(
|
||||
BarChartRodData(
|
||||
fromY: currentY,
|
||||
toY: currentY + percentageData.percentage ,
|
||||
color: AirQualityDataModel.metricColors[percentageData.name]!,
|
||||
toY: currentY + percentageData.percentage,
|
||||
color: AirQualityDataModel.metricColors[percentageData.name],
|
||||
borderRadius: isFirstElement
|
||||
? const BorderRadius.only(
|
||||
topLeft: Radius.circular(22),
|
||||
@ -84,9 +86,9 @@ class AqiDistributionChart extends StatelessWidget {
|
||||
tooltipRoundedRadius: 16,
|
||||
tooltipPadding: const EdgeInsets.all(8),
|
||||
getTooltipItem: (group, groupIndex, rod, rodIndex) {
|
||||
final data = chartData[group.x.toInt()];
|
||||
final data = chartData[group.x];
|
||||
|
||||
final List<TextSpan> children = [];
|
||||
final children = <TextSpan>[];
|
||||
|
||||
final textStyle = context.textTheme.bodySmall?.copyWith(
|
||||
color: ColorsManager.blackColor,
|
||||
@ -94,8 +96,9 @@ class AqiDistributionChart extends StatelessWidget {
|
||||
);
|
||||
|
||||
// Sort data by type to ensure consistent order
|
||||
final sortedPercentageData = List<AirQualityPercentageData>.from(data.data)
|
||||
..sort((a, b) => a.type.compareTo(b.type));
|
||||
final sortedPercentageData =
|
||||
List<AirQualityPercentageData>.from(data.data)
|
||||
..sort((a, b) => a.type.compareTo(b.type));
|
||||
|
||||
for (final percentageData in sortedPercentageData) {
|
||||
children.add(TextSpan(
|
||||
|
@ -49,7 +49,7 @@ class AqiSubValueWidget extends StatelessWidget {
|
||||
|
||||
int _getActiveSegmentByRange(double value, (double min, double max) range) {
|
||||
final ranges = _getRangesForValue(range);
|
||||
for (int i = 0; i < ranges.length; i++) {
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
if (value <= ranges[i].max) return i;
|
||||
}
|
||||
return ranges.length - 1;
|
||||
|
@ -29,7 +29,8 @@ class AqiTypeDropdown extends StatefulWidget {
|
||||
class _AqiTypeDropdownState extends State<AqiTypeDropdown> {
|
||||
AqiType? _selectedItem = AqiType.aqi;
|
||||
|
||||
void _updateSelectedItem(AqiType? item) => setState(() => _selectedItem = item);
|
||||
void _updateSelectedItem(AqiType? item) =>
|
||||
setState(() => _selectedItem = item);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -63,7 +63,7 @@ class RangeOfAqiChart extends StatelessWidget {
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.bottomCenter,
|
||||
end: Alignment.topCenter,
|
||||
stops: [0.0, 0.2, 0.4, 0.6, 0.8, 1.0],
|
||||
stops: const [0.0, 0.2, 0.4, 0.6, 0.8, 1.0],
|
||||
colors: RangeOfAqiChartsHelper.gradientData.map((e) {
|
||||
final (color, _) = e;
|
||||
return color.withValues(alpha: 0.6);
|
||||
@ -99,7 +99,8 @@ class RangeOfAqiChart extends StatelessWidget {
|
||||
}) {
|
||||
const invisibleDot = FlDotData(show: false);
|
||||
return LineChartBarData(
|
||||
spots: List.generate(values.length, (i) => FlSpot(i.toDouble(), values[i])),
|
||||
spots:
|
||||
List.generate(values.length, (i) => FlSpot(i.toDouble(), values[i])),
|
||||
isCurved: true,
|
||||
color: color,
|
||||
barWidth: 4,
|
||||
|
@ -32,7 +32,8 @@ class RangeOfAqiChartBox extends StatelessWidget {
|
||||
const SizedBox(height: 10),
|
||||
const Divider(),
|
||||
const SizedBox(height: 20),
|
||||
Expanded(child: RangeOfAqiChart(chartData: state.filteredRangeOfAqi)),
|
||||
Expanded(
|
||||
child: RangeOfAqiChart(chartData: state.filteredRangeOfAqi)),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
Reference in New Issue
Block a user