mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
Connected data coming from DeviceLocationBloc
into the respective widgets.
This commit is contained in:
@ -6,7 +6,34 @@ import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
|||||||
import 'package:syncrow_web/utils/style.dart';
|
import 'package:syncrow_web/utils/style.dart';
|
||||||
|
|
||||||
class AqiLocation extends StatelessWidget {
|
class AqiLocation extends StatelessWidget {
|
||||||
const AqiLocation({super.key});
|
const AqiLocation({
|
||||||
|
required this.city,
|
||||||
|
required this.country,
|
||||||
|
required this.address,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String? city;
|
||||||
|
final String? country;
|
||||||
|
final String? address;
|
||||||
|
|
||||||
|
String _getFormattedLocation() {
|
||||||
|
if (city == null && country == null && address == null) {
|
||||||
|
return 'N/A';
|
||||||
|
}
|
||||||
|
|
||||||
|
final parts = <String>[];
|
||||||
|
|
||||||
|
if (city != null) parts.add(city!);
|
||||||
|
if (address != null) parts.add(address!);
|
||||||
|
final locationPart = parts.join(', ');
|
||||||
|
|
||||||
|
if (country != null) {
|
||||||
|
return locationPart.isEmpty ? country! : '$locationPart - $country';
|
||||||
|
}
|
||||||
|
|
||||||
|
return locationPart;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -24,7 +51,7 @@ class AqiLocation extends StatelessWidget {
|
|||||||
_buildLocationPin(),
|
_buildLocationPin(),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
'Business Bay, Dubai - UAE',
|
_getFormattedLocation(),
|
||||||
style: context.textTheme.bodySmall?.copyWith(
|
style: context.textTheme.bodySmall?.copyWith(
|
||||||
color: ColorsManager.textPrimaryColor,
|
color: ColorsManager.textPrimaryColor,
|
||||||
fontWeight: FontWeight.w400,
|
fontWeight: FontWeight.w400,
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/analytics/modules/air_quality/blocs/device_location/device_location_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/modules/air_quality/widgets/aqi_location.dart';
|
import 'package:syncrow_web/pages/analytics/modules/air_quality/widgets/aqi_location.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/modules/air_quality/widgets/aqi_location_info_cell.dart';
|
import 'package:syncrow_web/pages/analytics/modules/air_quality/widgets/aqi_location_info_cell.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
@ -9,37 +11,46 @@ class AqiLocationInfo extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return BlocBuilder<DeviceLocationBloc, DeviceLocationState>(
|
||||||
decoration: secondarySection.copyWith(boxShadow: const []),
|
builder: (context, state) {
|
||||||
padding: const EdgeInsetsDirectional.all(20),
|
final info = state.locationInfo;
|
||||||
child: const Column(
|
return Container(
|
||||||
spacing: 8,
|
decoration: secondarySection.copyWith(boxShadow: const []),
|
||||||
children: [
|
padding: const EdgeInsetsDirectional.all(20),
|
||||||
AqiLocation(),
|
child: Column(
|
||||||
Expanded(
|
|
||||||
child: Row(
|
|
||||||
spacing: 8,
|
spacing: 8,
|
||||||
children: [
|
children: [
|
||||||
AqiLocationInfoCell(
|
AqiLocation(
|
||||||
label: 'Temperature',
|
city: info?.city,
|
||||||
value: ' 25°',
|
country: info?.country,
|
||||||
svgPath: Assets.aqiTemperature,
|
address: info?.address,
|
||||||
),
|
),
|
||||||
AqiLocationInfoCell(
|
Expanded(
|
||||||
label: 'Humidity',
|
child: Row(
|
||||||
value: '25%',
|
spacing: 8,
|
||||||
svgPath: Assets.aqiHumidity,
|
children: [
|
||||||
),
|
AqiLocationInfoCell(
|
||||||
AqiLocationInfoCell(
|
label: 'Temperature',
|
||||||
label: 'Air Quality',
|
value: ' ${info?.temperature?.roundToDouble() ?? '--'}°',
|
||||||
value: ' 120',
|
svgPath: Assets.aqiTemperature,
|
||||||
svgPath: Assets.aqiAirQuality,
|
),
|
||||||
|
AqiLocationInfoCell(
|
||||||
|
label: 'Humidity',
|
||||||
|
value: '${info?.humidity?.roundToDouble() ?? '--'}%',
|
||||||
|
svgPath: Assets.aqiHumidity,
|
||||||
|
),
|
||||||
|
AqiLocationInfoCell(
|
||||||
|
label: 'Air Quality',
|
||||||
|
value: ' ${info?.airQuality?.roundToDouble() ?? '--'}',
|
||||||
|
svgPath: Assets.aqiAirQuality,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
);
|
||||||
),
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user