mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-15 09:45:25 +00:00
Add loading indicator to analytics device dropdown (#299)
<!-- Thanks for contributing! Provide a description of your changes below and a general summary in the title Please look at the following checklist to ensure that your PR can be accepted quickly: --> ## Description Added a loading indicator to analytics device dropdown, for a better UX, and since the occupancy devices api takes longer than the other tabs, it makes more sense to add this feature. ## Type of Change <!--- Put an `x` in all the boxes that apply: --> - [x] ✨ New feature (non-breaking change which adds functionality) - [ ] 🛠️ Bug fix (non-breaking change which fixes an issue) - [ ] ❌ Breaking change (fix or feature that would cause existing functionality to change) - [ ] 🧹 Code refactor - [ ] ✅ Build configuration change - [ ] 📝 Documentation - [ ] 🗑️ Chore
This commit is contained in:
@ -19,7 +19,9 @@ class OccupancyHeatMapModel extends Equatable {
|
|||||||
eventDate: DateTime.parse(
|
eventDate: DateTime.parse(
|
||||||
json['event_date'] as String? ?? '${DateTime.now()}',
|
json['event_date'] as String? ?? '${DateTime.now()}',
|
||||||
),
|
),
|
||||||
countTotalPresenceDetected: json['count_total_presence_detected'] as int? ?? 0,
|
countTotalPresenceDetected: num.parse(
|
||||||
|
json['count_total_presence_detected']?.toString() ?? '900',
|
||||||
|
).toInt(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ enum AqiType {
|
|||||||
aqi('AQI', '', 'aqi'),
|
aqi('AQI', '', 'aqi'),
|
||||||
pm25('PM2.5', 'µg/m³', 'pm25'),
|
pm25('PM2.5', 'µg/m³', 'pm25'),
|
||||||
pm10('PM10', 'µg/m³', 'pm10'),
|
pm10('PM10', 'µg/m³', 'pm10'),
|
||||||
hcho('HCHO', 'mg/m³', 'cho2'),
|
hcho('HCHO', 'mg/m³', 'ch2o'),
|
||||||
tvoc('TVOC', 'mg/m³', 'voc'),
|
tvoc('TVOC', 'mg/m³', 'voc'),
|
||||||
co2('CO2', 'ppm', 'co2');
|
co2('CO2', 'ppm', 'co2');
|
||||||
|
|
||||||
|
@ -27,16 +27,30 @@ class AnalyticsDeviceDropdown extends StatelessWidget {
|
|||||||
width: 1,
|
width: 1,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
child: Visibility(
|
||||||
|
visible: state.status != AnalyticsDevicesStatus.loading,
|
||||||
|
replacement: _buildLoadingIndicator(),
|
||||||
child: Visibility(
|
child: Visibility(
|
||||||
visible: state.devices.isNotEmpty,
|
visible: state.devices.isNotEmpty,
|
||||||
replacement: _buildNoDevicesFound(context),
|
replacement: _buildNoDevicesFound(context),
|
||||||
child: _buildDevicesDropdown(context, state),
|
child: _buildDevicesDropdown(context, state),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildLoadingIndicator() {
|
||||||
|
return const Center(
|
||||||
|
child: SizedBox(
|
||||||
|
width: 24,
|
||||||
|
height: 24,
|
||||||
|
child: CircularProgressIndicator(strokeWidth: 3),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
static const _defaultPadding = EdgeInsetsDirectional.symmetric(
|
static const _defaultPadding = EdgeInsetsDirectional.symmetric(
|
||||||
horizontal: 20,
|
horizontal: 20,
|
||||||
vertical: 2,
|
vertical: 2,
|
||||||
|
Reference in New Issue
Block a user