mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
added loading state to range of aqi chart.
This commit is contained in:
@ -26,7 +26,9 @@ class RangeOfAqiChartBox extends StatelessWidget {
|
||||
AnalyticsErrorWidget(state.errorMessage),
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
const RangeOfAqiChartTitle(),
|
||||
RangeOfAqiChartTitle(
|
||||
isLoading: state.status == RangeOfAqiStatus.loading,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
const Divider(),
|
||||
const SizedBox(height: 20),
|
||||
|
@ -5,10 +5,12 @@ import 'package:syncrow_web/pages/analytics/modules/air_quality/widgets/aqi_type
|
||||
import 'package:syncrow_web/pages/analytics/modules/analytics/blocs/analytics_date_picker_bloc/analytics_date_picker_bloc.dart';
|
||||
import 'package:syncrow_web/pages/analytics/modules/analytics/widgets/chart_informative_cell.dart';
|
||||
import 'package:syncrow_web/pages/analytics/modules/energy_management/widgets/chart_title.dart';
|
||||
import 'package:syncrow_web/pages/analytics/widgets/charts_loading_widget.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
||||
|
||||
class RangeOfAqiChartTitle extends StatelessWidget {
|
||||
const RangeOfAqiChartTitle({super.key});
|
||||
const RangeOfAqiChartTitle({required this.isLoading, super.key});
|
||||
final bool isLoading;
|
||||
|
||||
static const List<(Color color, String title, bool hasBorder)> _colors = [
|
||||
(Color(0xFF962DFF), 'Max', false),
|
||||
@ -20,6 +22,7 @@ class RangeOfAqiChartTitle extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
ChartsLoadingWidget(isLoading: isLoading),
|
||||
const Expanded(
|
||||
flex: 3,
|
||||
child: FittedBox(
|
||||
|
@ -5,24 +5,26 @@ import 'package:syncrow_web/pages/analytics/services/range_of_aqi/range_of_aqi_s
|
||||
class FakeRangeOfAqiService implements RangeOfAqiService {
|
||||
@override
|
||||
Future<List<RangeOfAqi>> load(GetRangeOfAqiParam param) async {
|
||||
final random = DateTime.now().millisecondsSinceEpoch;
|
||||
return await Future.delayed(const Duration(milliseconds: 800), () {
|
||||
final random = DateTime.now().millisecondsSinceEpoch;
|
||||
|
||||
return List.generate(30, (index) {
|
||||
final date = DateTime(2025, 5, 1).add(Duration(days: index));
|
||||
return List.generate(30, (index) {
|
||||
final date = DateTime(2025, 5, 1).add(Duration(days: index));
|
||||
|
||||
final min = ((random + index * 17) % 200).toDouble();
|
||||
final avgDelta = ((random + index * 23) % 50).toDouble() + 20;
|
||||
final maxDelta = ((random + index * 31) % 50).toDouble() + 30;
|
||||
final min = ((random + index * 17) % 200).toDouble();
|
||||
final avgDelta = ((random + index * 23) % 50).toDouble() + 20;
|
||||
final maxDelta = ((random + index * 31) % 50).toDouble() + 30;
|
||||
|
||||
final avg = (min + avgDelta).clamp(0.0, 301.0);
|
||||
final max = (avg + maxDelta).clamp(0.0, 301.0);
|
||||
final avg = (min + avgDelta).clamp(0.0, 301.0);
|
||||
final max = (avg + maxDelta).clamp(0.0, 301.0);
|
||||
|
||||
return RangeOfAqi(
|
||||
min: min,
|
||||
avg: avg,
|
||||
max: max,
|
||||
date: date,
|
||||
);
|
||||
return RangeOfAqi(
|
||||
min: min,
|
||||
avg: avg,
|
||||
max: max,
|
||||
date: date,
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user