fix(bugs): update message when in progress
This commit is contained in:
@@ -3,6 +3,7 @@ import 'dart:developer';
|
||||
import 'package:dropdown_button2/dropdown_button2.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:sfm_app/product/constant/app/app_constants.dart';
|
||||
import 'widgets/tag_widget.dart';
|
||||
import '../devices/device_model.dart';
|
||||
import '../../bloc/device_logs_bloc.dart';
|
||||
@@ -116,9 +117,7 @@ class _DeviceLogsScreenState extends State<DeviceLogsScreen> {
|
||||
thingID = value!;
|
||||
setState(() {});
|
||||
},
|
||||
onSaved: (value) {
|
||||
log("On Saved");
|
||||
},
|
||||
onSaved: (value) {},
|
||||
iconStyleData: const IconStyleData(
|
||||
icon: Icon(
|
||||
Icons.arrow_drop_down,
|
||||
@@ -217,47 +216,56 @@ class _DeviceLogsScreenState extends State<DeviceLogsScreen> {
|
||||
height: context.lowValue,
|
||||
),
|
||||
Expanded(
|
||||
child: sensorsSnapshot.data?.isEmpty ?? false
|
||||
? Center(
|
||||
child: Text(appLocalization(context)
|
||||
.no_data_message),
|
||||
)
|
||||
: RefreshIndicator(
|
||||
onRefresh: refresh,
|
||||
child: ListView.builder(
|
||||
controller: controller,
|
||||
itemCount:
|
||||
sensorsSnapshot.data!.length + 1,
|
||||
itemBuilder: (context, index) {
|
||||
if (index <
|
||||
sensorsSnapshot.data!.length) {
|
||||
return logDetail(
|
||||
sensorsSnapshot.data![index],
|
||||
index,
|
||||
);
|
||||
} else {
|
||||
return Padding(
|
||||
padding: context.paddingLow,
|
||||
child: StreamBuilder<bool>(
|
||||
stream:
|
||||
deviceLogsBloc.streamHasMore,
|
||||
builder:
|
||||
(context, hasMoreSnapshot) {
|
||||
return Center(
|
||||
child: hasMoreSnapshot.data ??
|
||||
hasMore
|
||||
? const CircularProgressIndicator()
|
||||
: Text(appLocalization(
|
||||
context)
|
||||
.main_no_data),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
child: (() {
|
||||
if (sensorsSnapshot.data?.isEmpty ?? false) {
|
||||
return StreamBuilder<String>(
|
||||
stream: deviceLogsBloc.streammessage,
|
||||
builder: (context, messageSnapshot) {
|
||||
return Center(
|
||||
child: Text(getMessageData(
|
||||
messageSnapshot.data ?? '',
|
||||
)),
|
||||
);
|
||||
},
|
||||
);
|
||||
} else {
|
||||
return RefreshIndicator(
|
||||
onRefresh: refresh,
|
||||
child: ListView.builder(
|
||||
controller: controller,
|
||||
itemCount: sensorsSnapshot.data!.length + 1,
|
||||
itemBuilder: (context, index) {
|
||||
if (index <
|
||||
sensorsSnapshot.data!.length) {
|
||||
return logDetail(
|
||||
sensorsSnapshot.data![index],
|
||||
index,
|
||||
);
|
||||
} else {
|
||||
return Padding(
|
||||
padding: context.paddingLow,
|
||||
child: StreamBuilder<bool>(
|
||||
stream:
|
||||
deviceLogsBloc.streamHasMore,
|
||||
builder:
|
||||
(context, hasMoreSnapshot) {
|
||||
return Center(
|
||||
child: hasMoreSnapshot.data ??
|
||||
hasMore
|
||||
? const CircularProgressIndicator()
|
||||
: Text(
|
||||
appLocalization(context)
|
||||
.main_no_data),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
})(),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -272,13 +280,22 @@ class _DeviceLogsScreenState extends State<DeviceLogsScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
String getMessageData(String data) {
|
||||
if (data == ApplicationConstants.LOADING) {
|
||||
return appLocalization(context).loading_message;
|
||||
} else if (data == ApplicationConstants.NO_DATA) {
|
||||
return appLocalization(context).main_no_data;
|
||||
} else {
|
||||
return appLocalization(context).no_data_message;
|
||||
}
|
||||
}
|
||||
|
||||
Widget logDetail(SensorLogs sensor, int index) {
|
||||
return Column(
|
||||
children: [
|
||||
ListTile(
|
||||
subtitle:
|
||||
Text(DeviceUtils.instance.getDeviceSensorsLog(context, sensor)),
|
||||
// leading: leadingList(sensor),
|
||||
title: Text(
|
||||
DateTimeUtils.instance
|
||||
.convertCurrentMillisToDateTimeString(sensor.time ?? 0),
|
||||
|
||||
Reference in New Issue
Block a user