feat(api_service): Update try-catch funtion and handle exception
update(loading_animation): Update loading animation using Lottie
This commit is contained in:
anhtunz
2025-06-09 14:29:43 +07:00
parent 477646ab9d
commit 3a8fa3633c
44 changed files with 1659 additions and 1065 deletions

View File

@@ -2,6 +2,8 @@
import 'package:dropdown_button2/dropdown_button2.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import '../../product/shared/shared_component_loading_animation.dart';
import '../../product/shared/shared_loading_animation.dart';
import 'widgets/tag_widget.dart';
import '../devices/device_model.dart';
import '../../bloc/device_logs_bloc.dart';
@@ -42,7 +44,7 @@ class _DeviceLogsScreenState extends State<DeviceLogsScreen> {
() {
if (controller.position.maxScrollExtent == controller.offset) {
offset += 30;
deviceLogsBloc.getDeviceLogByThingID(
deviceLogsBloc.getDeviceLogByThingID(context,
offset, thingID, dateTime!, sensors);
}
},
@@ -64,10 +66,8 @@ class _DeviceLogsScreenState extends State<DeviceLogsScreen> {
stream: deviceLogsBloc.streamAllDevices,
builder: (context, allDevicesSnapshot) {
if (allDevicesSnapshot.data == null) {
deviceLogsBloc.getAllDevices();
return const Center(
child: CircularProgressIndicator(),
);
deviceLogsBloc.getAllDevices(context);
return const SharedLoadingAnimation();
} else {
return StreamBuilder<List<SensorLogs>>(
stream: deviceLogsBloc.streamSensors,
@@ -188,6 +188,7 @@ class _DeviceLogsScreenState extends State<DeviceLogsScreen> {
);
} else {
deviceLogsBloc.getDeviceLogByThingID(
context,
offset,
thingID,
dateTime!,
@@ -246,7 +247,7 @@ class _DeviceLogsScreenState extends State<DeviceLogsScreen> {
return Center(
child: hasMoreSnapshot.data ??
hasMore
? const CircularProgressIndicator()
? const SharedComponentLoadingAnimation()
: Text(
appLocalization(context)
.main_no_data),
@@ -310,7 +311,7 @@ class _DeviceLogsScreenState extends State<DeviceLogsScreen> {
deviceLogsBloc.sensors.add(sensors);
hasMore = true;
deviceLogsBloc.sinkHasMore.add(hasMore);
deviceLogsBloc.getDeviceLogByThingID(offset, thingID, dateTime!, sensors);
deviceLogsBloc.getDeviceLogByThingID(context,offset, thingID, dateTime!, sensors);
}
Widget leadingList(SensorLogs sensor) {