Fix bugs in app
This commit is contained in:
@@ -7,7 +7,7 @@ import '../../product/constant/enums/role_enums.dart';
|
||||
import '../../product/services/api_services.dart';
|
||||
import '../../product/utils/qr_utils.dart';
|
||||
import '../../product/constant/icon/icon_constants.dart';
|
||||
import '../../product/extention/context_extention.dart';
|
||||
import '../../product/extension/context_extension.dart';
|
||||
import '../../product/services/language_services.dart';
|
||||
|
||||
addNewDevice(BuildContext context, String role) async {
|
||||
|
||||
@@ -2,14 +2,14 @@ import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:sfm_app/feature/device_log/device_logs_model.dart';
|
||||
import 'package:sfm_app/product/constant/image/image_constants.dart';
|
||||
import 'package:sfm_app/product/shared/shared_line_chart.dart';
|
||||
import 'package:simple_ripple_animation/simple_ripple_animation.dart';
|
||||
import 'package:sfm_app/feature/device_log/device_logs_model.dart';
|
||||
import '../../../product/constant/image/image_constants.dart';
|
||||
import '../../../product/shared/shared_line_chart.dart';
|
||||
import '../../../product/shared/shared_curve.dart';
|
||||
import '../device_model.dart';
|
||||
import '../../../product/base/bloc/base_bloc.dart';
|
||||
import '../../../product/extention/context_extention.dart';
|
||||
import '../../../product/extension/context_extension.dart';
|
||||
import '../../../product/services/language_services.dart';
|
||||
import '../../../product/utils/device_utils.dart';
|
||||
|
||||
@@ -18,7 +18,9 @@ import '../../../bloc/device_detail_bloc.dart';
|
||||
|
||||
class DetailDeviceScreen extends StatefulWidget {
|
||||
const DetailDeviceScreen({super.key, required this.thingID});
|
||||
|
||||
final String thingID;
|
||||
|
||||
@override
|
||||
State<DetailDeviceScreen> createState() => _DetailDeviceScreenState();
|
||||
}
|
||||
@@ -44,18 +46,29 @@ class _DetailDeviceScreenState extends State<DetailDeviceScreen> {
|
||||
|
||||
late DetailDeviceBloc detailDeviceBloc;
|
||||
Completer<GoogleMapController> controller = Completer();
|
||||
CameraPosition initialCamera = const CameraPosition(
|
||||
target: LatLng(20.966048511844402, 105.74977710843086), zoom: 15);
|
||||
CameraPosition initialCamera =
|
||||
const CameraPosition(target: LatLng(20.966048511844402, 105.74977710843086), zoom: 15);
|
||||
Timer? getDeviceDetailTimer;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
detailDeviceBloc = BlocProvider.of(context);
|
||||
const duration = Duration(seconds: 10);
|
||||
getDeviceDetailTimer = Timer.periodic(
|
||||
duration,
|
||||
(Timer t) => detailDeviceBloc.getDeviceDetail(
|
||||
context,
|
||||
widget.thingID,
|
||||
controller,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
TextStyle textstyle = const TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.w600,
|
||||
);
|
||||
@override
|
||||
void dispose() {
|
||||
getDeviceDetailTimer?.cancel();
|
||||
}
|
||||
|
||||
BoxDecoration boxDecoration = BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
@@ -105,8 +118,7 @@ class _DetailDeviceScreenState extends State<DetailDeviceScreen> {
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: Image.asset(
|
||||
ImageConstants.instance
|
||||
.getImage('smoke-detector'),
|
||||
ImageConstants.instance.getImage('smoke-detector'),
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
),
|
||||
@@ -116,11 +128,9 @@ class _DetailDeviceScreenState extends State<DetailDeviceScreen> {
|
||||
width: 400,
|
||||
// color: Colors.blueAccent,
|
||||
alignment: Alignment.centerRight,
|
||||
margin: const EdgeInsets.fromLTRB(
|
||||
0, 0, 0, 50),
|
||||
margin: const EdgeInsets.fromLTRB(0, 0, 0, 50),
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const SizedBox(),
|
||||
Text(
|
||||
@@ -146,14 +156,13 @@ class _DetailDeviceScreenState extends State<DetailDeviceScreen> {
|
||||
height: context.dynamicHeight(0.08),
|
||||
width: context.dynamicWidth(0.5),
|
||||
decoration: BoxDecoration(
|
||||
color: DeviceUtils.instance.getTableRowColor(
|
||||
deviceSnapshot.data?.state ?? 3),
|
||||
color: DeviceUtils.instance
|
||||
.getTableRowColor(deviceSnapshot.data?.state ?? 3),
|
||||
borderRadius: BorderRadius.circular(50),
|
||||
),
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceAround,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: context.mediumValue,
|
||||
@@ -161,18 +170,17 @@ class _DetailDeviceScreenState extends State<DetailDeviceScreen> {
|
||||
child: deviceSnapshot.data?.state == 1
|
||||
? RippleAnimation(
|
||||
color: Colors.red,
|
||||
delay: context
|
||||
.dynamicMilliSecondDuration(
|
||||
delay: context.dynamicMilliSecondDuration(
|
||||
800,
|
||||
),
|
||||
repeat: true,
|
||||
minRadius: 10,
|
||||
ripplesCount: 5,
|
||||
duration: context
|
||||
.dynamicMilliSecondDuration(
|
||||
duration: context.dynamicMilliSecondDuration(
|
||||
1800,
|
||||
),
|
||||
child: CircleAvatar(
|
||||
backgroundColor: Colors.transparent,
|
||||
minRadius: context.mediumValue,
|
||||
maxRadius: context.mediumValue,
|
||||
backgroundImage: AssetImage(
|
||||
@@ -183,9 +191,8 @@ class _DetailDeviceScreenState extends State<DetailDeviceScreen> {
|
||||
),
|
||||
)
|
||||
: CircleAvatar(
|
||||
backgroundColor: DeviceUtils
|
||||
.instance
|
||||
.getTableRowColor(
|
||||
backgroundColor:
|
||||
DeviceUtils.instance.getTableRowColor(
|
||||
deviceSnapshot.data?.state ?? 3,
|
||||
),
|
||||
minRadius: context.mediumValue,
|
||||
@@ -230,12 +237,10 @@ class _DetailDeviceScreenState extends State<DetailDeviceScreen> {
|
||||
child: Padding(
|
||||
padding: context.paddingLow,
|
||||
child: Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
appLocalization(context)
|
||||
@@ -254,8 +259,7 @@ class _DetailDeviceScreenState extends State<DetailDeviceScreen> {
|
||||
sensorSnapshot.data!['sensorCsq'],
|
||||
),
|
||||
size: 30,
|
||||
color: DeviceUtils.instance
|
||||
.getSignalIconColor(
|
||||
color: DeviceUtils.instance.getSignalIconColor(
|
||||
context,
|
||||
sensorSnapshot.data!['sensorCsq'],
|
||||
),
|
||||
@@ -264,10 +268,8 @@ class _DetailDeviceScreenState extends State<DetailDeviceScreen> {
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.start,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
height: context.dynamicHeight(0.09),
|
||||
@@ -275,11 +277,9 @@ class _DetailDeviceScreenState extends State<DetailDeviceScreen> {
|
||||
child: Text(
|
||||
sensorSnapshot.data!['sensorCsq'],
|
||||
style: TextStyle(
|
||||
color: DeviceUtils.instance
|
||||
.getSignalIconColor(
|
||||
color: DeviceUtils.instance.getSignalIconColor(
|
||||
context,
|
||||
sensorSnapshot
|
||||
.data!['sensorCsq'],
|
||||
sensorSnapshot.data!['sensorCsq'],
|
||||
),
|
||||
fontSize: 40,
|
||||
fontWeight: FontWeight.w900,
|
||||
@@ -299,12 +299,10 @@ class _DetailDeviceScreenState extends State<DetailDeviceScreen> {
|
||||
child: Padding(
|
||||
padding: context.paddingLow,
|
||||
child: Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
appLocalization(context)
|
||||
@@ -318,18 +316,14 @@ class _DetailDeviceScreenState extends State<DetailDeviceScreen> {
|
||||
height: context.dynamicWidth(0.12),
|
||||
width: context.dynamicWidth(0.12),
|
||||
child: Image.asset(
|
||||
DeviceUtils.instance
|
||||
.getDeviceBatteryImg(
|
||||
DeviceUtils.instance.getDeviceBatteryImg(
|
||||
int.parse(
|
||||
sensorSnapshot
|
||||
.data!['sensorBattery'],
|
||||
sensorSnapshot.data!['sensorBattery'],
|
||||
),
|
||||
),
|
||||
color: DeviceUtils.instance
|
||||
.getDeviceBatteryColor(
|
||||
color: DeviceUtils.instance.getDeviceBatteryColor(
|
||||
int.parse(
|
||||
sensorSnapshot
|
||||
.data!['sensorBattery'],
|
||||
sensorSnapshot.data!['sensorBattery'],
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -337,23 +331,18 @@ class _DetailDeviceScreenState extends State<DetailDeviceScreen> {
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.start,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
height: context.dynamicHeight(0.09),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
sensorSnapshot
|
||||
.data!['sensorBattery'],
|
||||
sensorSnapshot.data!['sensorBattery'],
|
||||
style: TextStyle(
|
||||
color: DeviceUtils.instance
|
||||
.getDeviceBatteryColor(
|
||||
color: DeviceUtils.instance.getDeviceBatteryColor(
|
||||
int.parse(
|
||||
sensorSnapshot
|
||||
.data!['sensorBattery'],
|
||||
sensorSnapshot.data!['sensorBattery'],
|
||||
),
|
||||
),
|
||||
fontSize: 50,
|
||||
@@ -371,11 +360,9 @@ class _DetailDeviceScreenState extends State<DetailDeviceScreen> {
|
||||
child: Text(
|
||||
'%',
|
||||
style: TextStyle(
|
||||
color: DeviceUtils.instance
|
||||
.getDeviceBatteryColor(
|
||||
color: DeviceUtils.instance.getDeviceBatteryColor(
|
||||
int.parse(
|
||||
sensorSnapshot
|
||||
.data!['sensorBattery'],
|
||||
sensorSnapshot.data!['sensorBattery'],
|
||||
),
|
||||
),
|
||||
fontSize: 30,
|
||||
@@ -403,8 +390,7 @@ class _DetailDeviceScreenState extends State<DetailDeviceScreen> {
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
appLocalization(context)
|
||||
@@ -419,11 +405,9 @@ class _DetailDeviceScreenState extends State<DetailDeviceScreen> {
|
||||
width: context.dynamicWidth(0.12),
|
||||
child: Image.asset(
|
||||
'assets/icons/temperature.png',
|
||||
color: DeviceUtils.instance
|
||||
.getDeviceTempColor(
|
||||
color: DeviceUtils.instance.getDeviceTempColor(
|
||||
int.parse(
|
||||
sensorSnapshot
|
||||
.data!['sensorTemp'],
|
||||
sensorSnapshot.data!['sensorTemp'],
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -439,28 +423,20 @@ class _DetailDeviceScreenState extends State<DetailDeviceScreen> {
|
||||
width: double.infinity,
|
||||
height: 20,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey
|
||||
.withValues(alpha: 0.3),
|
||||
borderRadius:
|
||||
BorderRadius.circular(10),
|
||||
color: Colors.grey.withValues(alpha: 0.3),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
LayoutBuilder(
|
||||
builder: (context, constraints) =>
|
||||
Container(
|
||||
builder: (context, constraints) => Container(
|
||||
width: constraints.maxWidth *
|
||||
(int.parse(sensorSnapshot
|
||||
.data!['sensorTemp']) /
|
||||
75),
|
||||
(int.parse(sensorSnapshot.data!['sensorTemp']) / 75),
|
||||
height: 20,
|
||||
decoration: BoxDecoration(
|
||||
color: DeviceUtils.instance
|
||||
.getDeviceTempColor(
|
||||
int.parse(sensorSnapshot
|
||||
.data!['sensorTemp']),
|
||||
color: DeviceUtils.instance.getDeviceTempColor(
|
||||
int.parse(sensorSnapshot.data!['sensorTemp']),
|
||||
),
|
||||
borderRadius:
|
||||
BorderRadius.circular(10),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
)
|
||||
@@ -470,17 +446,14 @@ class _DetailDeviceScreenState extends State<DetailDeviceScreen> {
|
||||
height: 5,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"${sensorSnapshot.data!['sensorTemp']} °C",
|
||||
style: TextStyle(
|
||||
color: DeviceUtils.instance
|
||||
.getDeviceTempColor(
|
||||
color: DeviceUtils.instance.getDeviceTempColor(
|
||||
int.parse(
|
||||
sensorSnapshot
|
||||
.data!['sensorTemp'],
|
||||
sensorSnapshot.data!['sensorTemp'],
|
||||
),
|
||||
),
|
||||
fontSize: 30,
|
||||
@@ -507,8 +480,7 @@ class _DetailDeviceScreenState extends State<DetailDeviceScreen> {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
appLocalization(context)
|
||||
.paginated_data_table_column_devicePower,
|
||||
appLocalization(context).paginated_data_table_column_devicePower,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -532,8 +504,7 @@ class _DetailDeviceScreenState extends State<DetailDeviceScreen> {
|
||||
stream: detailDeviceBloc.streamSensorTemps,
|
||||
builder: (context, sensorTempsSnapshot) {
|
||||
if (sensorTempsSnapshot.data == null) {
|
||||
detailDeviceBloc
|
||||
.getNearerSensorValue(widget.thingID);
|
||||
detailDeviceBloc.getNearerSensorValue(widget.thingID);
|
||||
return const AspectRatio(
|
||||
aspectRatio: 3,
|
||||
child: Center(
|
||||
@@ -552,8 +523,7 @@ class _DetailDeviceScreenState extends State<DetailDeviceScreen> {
|
||||
child: Container(
|
||||
margin: context.paddingLow,
|
||||
child: sharedLineChart(
|
||||
appLocalization(context)
|
||||
.detail_device_volt_message,
|
||||
appLocalization(context).detail_device_volt_message,
|
||||
sensorTempsSnapshot.data ?? [],
|
||||
),
|
||||
),
|
||||
@@ -580,48 +550,33 @@ class _DetailDeviceScreenState extends State<DetailDeviceScreen> {
|
||||
Radius.circular(15),
|
||||
),
|
||||
),
|
||||
child: deviceSnapshot
|
||||
.data!.settings!.latitude !=
|
||||
""
|
||||
child: deviceSnapshot.data!.settings!.latitude != ""
|
||||
? StreamBuilder<String>(
|
||||
stream: detailDeviceBloc
|
||||
.streamDeviceLocation,
|
||||
stream: detailDeviceBloc.streamDeviceLocation,
|
||||
builder: (context, locationSnapshot) {
|
||||
if (locationSnapshot.data == null) {
|
||||
detailDeviceBloc.findLocation(
|
||||
context,
|
||||
deviceSnapshot
|
||||
.data!.areaPath!);
|
||||
context, deviceSnapshot.data!.areaPath!);
|
||||
}
|
||||
return GoogleMap(
|
||||
initialCameraPosition:
|
||||
initialCamera,
|
||||
initialCameraPosition: initialCamera,
|
||||
mapType: MapType.normal,
|
||||
markers: {
|
||||
Marker(
|
||||
infoWindow: InfoWindow(
|
||||
title:
|
||||
locationSnapshot.data ??
|
||||
"",
|
||||
title: locationSnapshot.data ?? "",
|
||||
),
|
||||
markerId: MarkerId(
|
||||
deviceSnapshot
|
||||
.data!.thingId!),
|
||||
markerId: MarkerId(deviceSnapshot.data!.thingId!),
|
||||
position: LatLng(
|
||||
double.parse(deviceSnapshot
|
||||
.data!
|
||||
.settings!
|
||||
.latitude!),
|
||||
double.parse(deviceSnapshot
|
||||
.data!
|
||||
.settings!
|
||||
.longitude!),
|
||||
double.parse(
|
||||
deviceSnapshot.data!.settings!.latitude!),
|
||||
double.parse(
|
||||
deviceSnapshot.data!.settings!.longitude!),
|
||||
),
|
||||
),
|
||||
},
|
||||
onMapCreated: (mapcontroller) {
|
||||
controller
|
||||
.complete(mapcontroller);
|
||||
controller.complete(mapcontroller);
|
||||
},
|
||||
mapToolbarEnabled: false,
|
||||
zoomControlsEnabled: false,
|
||||
@@ -636,8 +591,7 @@ class _DetailDeviceScreenState extends State<DetailDeviceScreen> {
|
||||
),
|
||||
),
|
||||
Text(
|
||||
appLocalization(context)
|
||||
.device_update_location,
|
||||
appLocalization(context).device_update_location,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
|
||||
@@ -5,7 +5,7 @@ import '../device_model.dart';
|
||||
import '../../../bloc/device_update_bloc.dart';
|
||||
import 'map_dialog.dart';
|
||||
import '../../../product/base/bloc/base_bloc.dart';
|
||||
import '../../../product/extention/context_extention.dart';
|
||||
import '../../../product/extension/context_extension.dart';
|
||||
import '../../../product/services/api_services.dart';
|
||||
import '../../../product/services/language_services.dart';
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart' ;
|
||||
import '../../../bloc/device_update_bloc.dart';
|
||||
import '../../../product/constant/app/app_constants.dart';
|
||||
import '../../../product/extention/context_extention.dart';
|
||||
import '../../../product/extension/context_extension.dart';
|
||||
import '../../../product/services/language_services.dart';
|
||||
import '../../../product/shared/find_location_maps/shared_map_search_location.dart';
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import '../../product/base/bloc/base_bloc.dart';
|
||||
import '../../product/constant/enums/app_route_enums.dart';
|
||||
import '../../product/constant/enums/role_enums.dart';
|
||||
import '../../product/constant/icon/icon_constants.dart';
|
||||
import '../../product/extention/context_extention.dart';
|
||||
import '../../product/extension/context_extension.dart';
|
||||
import '../../product/services/api_services.dart';
|
||||
import '../../product/services/language_services.dart';
|
||||
import '../../product/utils/device_utils.dart';
|
||||
|
||||
Reference in New Issue
Block a user