mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
fixed aqi filter bugs.
This commit is contained in:
@ -46,11 +46,11 @@ class AirQualityDistributionBloc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onClearAirQualityDistribution(
|
void _onClearAirQualityDistribution(
|
||||||
ClearAirQualityDistribution event,
|
ClearAirQualityDistribution event,
|
||||||
Emitter<AirQualityDistributionState> emit,
|
Emitter<AirQualityDistributionState> emit,
|
||||||
) async {
|
) {
|
||||||
emit(const AirQualityDistributionState());
|
emit(AirQualityDistributionState(selectedAqiType: state.selectedAqiType));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onUpdateAqiTypeEvent(
|
void _onUpdateAqiTypeEvent(
|
||||||
|
@ -75,6 +75,6 @@ class RangeOfAqiBloc extends Bloc<RangeOfAqiEvent, RangeOfAqiState> {
|
|||||||
ClearRangeOfAqiEvent event,
|
ClearRangeOfAqiEvent event,
|
||||||
Emitter<RangeOfAqiState> emit,
|
Emitter<RangeOfAqiState> emit,
|
||||||
) {
|
) {
|
||||||
emit(const RangeOfAqiState());
|
emit(RangeOfAqiState(selectedAqiType: state.selectedAqiType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ class AqiDistributionChartTitle extends StatelessWidget {
|
|||||||
alignment: AlignmentDirectional.centerEnd,
|
alignment: AlignmentDirectional.centerEnd,
|
||||||
fit: BoxFit.scaleDown,
|
fit: BoxFit.scaleDown,
|
||||||
child: AqiTypeDropdown(
|
child: AqiTypeDropdown(
|
||||||
|
selectedAqiType: context.watch<AirQualityDistributionBloc>().state.selectedAqiType,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
final bloc = context.read<AirQualityDistributionBloc>();
|
final bloc = context.read<AirQualityDistributionBloc>();
|
||||||
|
@ -18,19 +18,20 @@ enum AqiType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class AqiTypeDropdown extends StatefulWidget {
|
class AqiTypeDropdown extends StatefulWidget {
|
||||||
const AqiTypeDropdown({super.key, required this.onChanged});
|
const AqiTypeDropdown({
|
||||||
|
required this.onChanged,
|
||||||
|
this.selectedAqiType,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
final ValueChanged<AqiType?> onChanged;
|
final ValueChanged<AqiType?> onChanged;
|
||||||
|
final AqiType? selectedAqiType;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<AqiTypeDropdown> createState() => _AqiTypeDropdownState();
|
State<AqiTypeDropdown> createState() => _AqiTypeDropdownState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _AqiTypeDropdownState extends State<AqiTypeDropdown> {
|
class _AqiTypeDropdownState extends State<AqiTypeDropdown> {
|
||||||
AqiType? _selectedItem = AqiType.aqi;
|
|
||||||
|
|
||||||
void _updateSelectedItem(AqiType? item) => setState(() => _selectedItem = item);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
@ -41,8 +42,8 @@ class _AqiTypeDropdownState extends State<AqiTypeDropdown> {
|
|||||||
width: 1,
|
width: 1,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: DropdownButton<AqiType?>(
|
child: DropdownButton<AqiType>(
|
||||||
value: _selectedItem,
|
value: widget.selectedAqiType,
|
||||||
isDense: true,
|
isDense: true,
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
dropdownColor: ColorsManager.whiteColors,
|
dropdownColor: ColorsManager.whiteColors,
|
||||||
@ -59,10 +60,7 @@ class _AqiTypeDropdownState extends State<AqiTypeDropdown> {
|
|||||||
items: AqiType.values
|
items: AqiType.values
|
||||||
.map((e) => DropdownMenuItem(value: e, child: Text(e.value)))
|
.map((e) => DropdownMenuItem(value: e, child: Text(e.value)))
|
||||||
.toList(),
|
.toList(),
|
||||||
onChanged: (value) {
|
onChanged: widget.onChanged,
|
||||||
_updateSelectedItem(value);
|
|
||||||
widget.onChanged(value);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -63,15 +63,15 @@ class RangeOfAqiChartTitle extends StatelessWidget {
|
|||||||
fit: BoxFit.scaleDown,
|
fit: BoxFit.scaleDown,
|
||||||
alignment: AlignmentDirectional.centerEnd,
|
alignment: AlignmentDirectional.centerEnd,
|
||||||
child: AqiTypeDropdown(
|
child: AqiTypeDropdown(
|
||||||
|
selectedAqiType: context.watch<RangeOfAqiBloc>().state.selectedAqiType,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
final spaceTreeState = context.read<SpaceTreeBloc>().state;
|
final spaceTreeState = context.read<SpaceTreeBloc>().state;
|
||||||
final spaceUuid = spaceTreeState.selectedSpaces.firstOrNull;
|
final spaceUuid = spaceTreeState.selectedSpaces.firstOrNull;
|
||||||
|
|
||||||
if (spaceUuid == null) return;
|
|
||||||
|
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
context.read<RangeOfAqiBloc>().add(UpdateAqiTypeEvent(value));
|
context.read<RangeOfAqiBloc>().add(UpdateAqiTypeEvent(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (spaceUuid == null) return;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user