diff --git a/assets/icons/offline_icon.png b/assets/icons/offline_icon.png index 0d4cbc9..9f00077 100644 Binary files a/assets/icons/offline_icon.png and b/assets/icons/offline_icon.png differ diff --git a/lib/feature/device_log/device_logs_screen.dart b/lib/feature/device_log/device_logs_screen.dart index 1e7bf60..d12c218 100644 --- a/lib/feature/device_log/device_logs_screen.dart +++ b/lib/feature/device_log/device_logs_screen.dart @@ -2,10 +2,10 @@ 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'; +import '../../product/constant/app/app_constants.dart'; import '../../product/constant/icon/icon_constants.dart'; import '../../product/extension/context_extension.dart'; import '../../product/services/language_services.dart'; @@ -175,11 +175,11 @@ class _DeviceLogsScreenState extends State { ), Center( child: TextButton.icon( - style: const ButtonStyle( + style: ButtonStyle( backgroundColor: - WidgetStatePropertyAll(Colors.green), + WidgetStatePropertyAll(Theme.of(context).primaryColor), foregroundColor: - WidgetStatePropertyAll(Colors.white), + WidgetStatePropertyAll(Theme.of(context).colorScheme.surfaceBright), ), onPressed: () { if (fromDateApi.isEmpty) { @@ -200,8 +200,7 @@ class _DeviceLogsScreenState extends State { // log("ThingID: $thingID"); // log("From Date: ${DateTimeUtils.instance.formatDateTimeToString(dateTime!)}"); }, - icon: IconConstants.instance - .getMaterialIcon(Icons.search), + icon: Icon(Icons.search,color: Theme.of(context).colorScheme.surfaceBright,), label: Text( appLocalization(context) .find_button_content, diff --git a/lib/feature/devices/device_detail/device_detail_screen.dart b/lib/feature/devices/device_detail/device_detail_screen.dart index 33e6c92..f5c0dcc 100644 --- a/lib/feature/devices/device_detail/device_detail_screen.dart +++ b/lib/feature/devices/device_detail/device_detail_screen.dart @@ -100,7 +100,7 @@ class _DetailDeviceScreenState extends State { if (sensorSnapshot.data != null) { return Scaffold( appBar: AppBar( - title: Text(appLocalization(context).detail_message), + title: Text(deviceSnapshot.data?.name ?? ""), centerTitle: true, ), body: SingleChildScrollView( @@ -122,28 +122,28 @@ class _DetailDeviceScreenState extends State { fit: BoxFit.fill, ), ), - Center( - child: Container( - height: 50, - width: 400, - // color: Colors.blueAccent, - alignment: Alignment.centerRight, - margin: const EdgeInsets.fromLTRB(0, 0, 0, 50), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - const SizedBox(), - Text( - deviceSnapshot.data?.name ?? "", - style: const TextStyle( - fontSize: 25, - fontWeight: FontWeight.w600, - ), - ), - ], - ), - ), - ), + // Center( + // child: Container( + // height: 50, + // width: 400, + // // color: Colors.blueAccent, + // alignment: Alignment.centerRight, + // margin: const EdgeInsets.fromLTRB(0, 0, 0, 50), + // child: Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // const SizedBox(), + // Text( + // deviceSnapshot.data?.name ?? "", + // style: const TextStyle( + // fontSize: 25, + // fontWeight: FontWeight.w600, + // ), + // ), + // ], + // ), + // ), + // ), ], ), ), @@ -157,7 +157,7 @@ class _DetailDeviceScreenState extends State { width: context.dynamicWidth(0.5), decoration: BoxDecoration( color: DeviceUtils.instance - .getTableRowColor(deviceSnapshot.data?.state ?? 3), + .getTableRowColor(context,deviceSnapshot.data?.state ?? 3), borderRadius: BorderRadius.circular(50), ), alignment: Alignment.bottomCenter, @@ -192,7 +192,7 @@ class _DetailDeviceScreenState extends State { ) : CircleAvatar( backgroundColor: - DeviceUtils.instance.getTableRowColor( + DeviceUtils.instance.getTableRowColor(context, deviceSnapshot.data?.state ?? 3, ), minRadius: context.mediumValue, diff --git a/lib/feature/devices/devices_manager_screen.dart b/lib/feature/devices/devices_manager_screen.dart index 12844f7..6772f56 100644 --- a/lib/feature/devices/devices_manager_screen.dart +++ b/lib/feature/devices/devices_manager_screen.dart @@ -89,103 +89,98 @@ class _DevicesManagerScreenState extends State { builder: (context, roleSnapshot) { return SizedBox( height: context.dynamicHeight(0.4), - child: CardTheme( - color: Theme.of(context).colorScheme.onPrimary, - shadowColor: - Theme.of(context).colorScheme.onPrimary, - child: PaginatedDataTable2( - headingRowHeight: 30, - columnSpacing: 30, - horizontalMargin: 10, - fixedLeftColumns: 1, - autoRowsToHeight: true, - renderEmptyRowsInTheEnd: false, - dragStartBehavior: DragStartBehavior.down, - minWidth: 950, - header: Center( - child: Text( - appLocalization(context) - .paginated_data_table_title, - style: context.headlineMediumTextStyle, - ), + child: PaginatedDataTable2( + headingRowHeight: 30, + columnSpacing: 30, + horizontalMargin: 10, + fixedLeftColumns: 1, + autoRowsToHeight: true, + renderEmptyRowsInTheEnd: false, + dragStartBehavior: DragStartBehavior.down, + minWidth: 950, + header: Center( + child: Text( + appLocalization(context) + .paginated_data_table_title, + style: context.headlineMediumTextStyle, ), - columns: [ - if (roleSnapshot.data == - RoleEnums.ADMIN.name || - roleSnapshot.data == - RoleEnums.USER.name) - DataColumn( - label: Text(appLocalization(context) - .paginated_data_table_column_deviceName), - ), + ), + columns: [ + if (roleSnapshot.data == + RoleEnums.ADMIN.name || + roleSnapshot.data == + RoleEnums.USER.name) DataColumn( label: Text(appLocalization(context) - .paginated_data_table_column_deviceStatus), + .paginated_data_table_column_deviceName), ), - DataColumn( - label: Text(appLocalization(context) - .paginated_data_table_column_deviceBaterry), - ), - DataColumn( - label: Text(appLocalization(context) - .paginated_data_table_column_deviceSignal), - ), - DataColumn( - label: Text(appLocalization(context) - .paginated_data_table_column_deviceTemperature), - ), - DataColumn( - label: Text(appLocalization(context) - .paginated_data_table_column_deviceHump), - ), - DataColumn( - label: Text(appLocalization(context) - .paginated_data_table_column_devicePower), - ), - DataColumn( - label: Text(appLocalization(context) - .paginated_data_table_column_action), - ), - ], - onPageChanged: (int pageIndex) { - // log('Chuyen page: $pageIndex'); - }, - // rowsPerPage: - // (allDeviceSnapshot.data?.length ?? 1) < 6 - // ? (allDeviceSnapshot.data?.length ?? - // 0) - // : 5, + DataColumn( + label: Text(appLocalization(context) + .paginated_data_table_column_deviceStatus), + ), + DataColumn( + label: Text(appLocalization(context) + .paginated_data_table_column_deviceBaterry), + ), + DataColumn( + label: Text(appLocalization(context) + .paginated_data_table_column_deviceSignal), + ), + DataColumn( + label: Text(appLocalization(context) + .paginated_data_table_column_deviceTemperature), + ), + DataColumn( + label: Text(appLocalization(context) + .paginated_data_table_column_deviceHump), + ), + DataColumn( + label: Text(appLocalization(context) + .paginated_data_table_column_devicePower), + ), + DataColumn( + label: Text(appLocalization(context) + .paginated_data_table_column_action), + ), + ], + onPageChanged: (int pageIndex) { + // log('Chuyen page: $pageIndex'); + }, + // rowsPerPage: + // (allDeviceSnapshot.data?.length ?? 1) < 6 + // ? (allDeviceSnapshot.data?.length ?? + // 0) + // : 5, - actions: [ - if (roleSnapshot.data == - RoleEnums.USER.name || - roleSnapshot.data == - RoleEnums.ADMIN.name) - IconButton( - style: ButtonStyle( - backgroundColor: - WidgetStateProperty.all( - Colors.green), - iconColor: - WidgetStateProperty.all( - Colors.white, - ), + actions: [ + if (roleSnapshot.data == + RoleEnums.USER.name || + roleSnapshot.data == + RoleEnums.ADMIN.name) + IconButton( + style: ButtonStyle( + backgroundColor: + WidgetStateProperty.all( + Colors.green), + iconColor: + WidgetStateProperty.all( + Colors.white, ), - onPressed: () { - ScaffoldMessenger.of(context) - .clearSnackBars(); - addNewDevice(context, - roleSnapshot.data ?? role); - }, - icon: IconConstants.instance - .getMaterialIcon(Icons.add)) - ], - source: DeviceSource( - devices: allDeviceSnapshot.data ?? devices, - context: context, - devicesBloc: devicesManagerBloc, - role: role, - ), + ), + onPressed: () { + ScaffoldMessenger.of(context) + .clearSnackBars(); + addNewDevice(context, + roleSnapshot.data ?? role); + }, + icon: IconConstants.instance + .getMaterialIcon(Icons.add)) + ], + source: DeviceSource( + devices: allDeviceSnapshot.data ?? devices, + context: context, + devicesBloc: devicesManagerBloc, + role: role, ), ), ); @@ -265,7 +260,7 @@ class DeviceSource extends DataTableSource { Text(device.name!, style: TextStyle( color: DeviceUtils.instance - .getTableRowColor(device.state!))), onTap: () { + .getTableRowColor(context,device.state!))), onTap: () { context.pushNamed(AppRoutes.DEVICE_DETAIL.name, pathParameters: {'thingID': device.thingId!}); }), @@ -273,36 +268,36 @@ class DeviceSource extends DataTableSource { Text(deviceState, style: TextStyle( color: DeviceUtils.instance - .getTableRowColor(device.state!))), onTap: () { + .getTableRowColor(context,device.state!))), onTap: () { context.pushNamed(AppRoutes.DEVICE_DETAIL.name, pathParameters: {'thingID': device.thingId!}); }), DataCell( Text(sensorMap['sensorBattery'] + "%", style: TextStyle( - color: DeviceUtils.instance.getTableRowColor(device.state!))), + color: DeviceUtils.instance.getTableRowColor(context,device.state!))), onTap: () => context.pushNamed(AppRoutes.DEVICE_DETAIL.name, pathParameters: {'thingID': device.thingId!}), ), DataCell( Text(sensorMap['sensorCsq'], style: TextStyle( - color: DeviceUtils.instance.getTableRowColor(device.state!))), + color: DeviceUtils.instance.getTableRowColor(context,device.state!))), ), DataCell( Text("${sensorMap['sensorTemp']}°C", style: TextStyle( - color: DeviceUtils.instance.getTableRowColor(device.state!))), + color: DeviceUtils.instance.getTableRowColor(context,device.state!))), ), DataCell( Text("${sensorMap['sensorHum']}%", style: TextStyle( - color: DeviceUtils.instance.getTableRowColor(device.state!))), + color: DeviceUtils.instance.getTableRowColor(context,device.state!))), ), DataCell( Text("${sensorMap['sensorVolt']}V", style: TextStyle( - color: DeviceUtils.instance.getTableRowColor(device.state!))), + color: DeviceUtils.instance.getTableRowColor(context,device.state!))), ), DataCell( Center( @@ -354,7 +349,7 @@ class TagState extends StatelessWidget { height: context.mediumValue, width: context.dynamicWidth(0.35), decoration: BoxDecoration( - color: DeviceUtils.instance.getTableRowColor(state), + color: DeviceUtils.instance.getTableRowColor(context,state), borderRadius: BorderRadius.circular(context.mediumValue), ), child: Row( diff --git a/lib/feature/inter_family/group_detail/group_detail_screen.dart b/lib/feature/inter_family/group_detail/group_detail_screen.dart index 80f788a..8ee2552 100644 --- a/lib/feature/inter_family/group_detail/group_detail_screen.dart +++ b/lib/feature/inter_family/group_detail/group_detail_screen.dart @@ -461,7 +461,7 @@ class _DetailGroupScreenState extends State { DeviceUtils.instance.checkStateDevice( context, devices[index].state!), style: TextStyle( - color: DeviceUtils.instance.getTableRowColor( + color: DeviceUtils.instance.getTableRowColor(context, devices[index].state!, ), ), diff --git a/lib/feature/map/widget/on_tap_marker_widget.dart b/lib/feature/map/widget/on_tap_marker_widget.dart index 45c5a31..8dc8940 100644 --- a/lib/feature/map/widget/on_tap_marker_widget.dart +++ b/lib/feature/map/widget/on_tap_marker_widget.dart @@ -294,7 +294,7 @@ class DeviceSource extends DataTableSource { device.name!, style: TextStyle( color: - DeviceUtils.instance.getTableRowColor(device.state ?? -1)), + DeviceUtils.instance.getTableRowColor(context,device.state ?? -1)), ), onTap: () { mapBloc.updateCameraPosition( @@ -311,7 +311,7 @@ class DeviceSource extends DataTableSource { deviceState, style: TextStyle( color: - DeviceUtils.instance.getTableRowColor(device.state ?? -1)), + DeviceUtils.instance.getTableRowColor(context,device.state ?? -1)), ), onTap: () { mapBloc.updateCameraPosition( @@ -327,7 +327,7 @@ class DeviceSource extends DataTableSource { sensorMap['sensorBattery'] + "%", style: TextStyle( color: - DeviceUtils.instance.getTableRowColor(device.state ?? -1)), + DeviceUtils.instance.getTableRowColor(context,device.state ?? -1)), ), onTap: () { mapBloc.updateCameraPosition( @@ -343,7 +343,7 @@ class DeviceSource extends DataTableSource { sensorMap['sensorCsq'], style: TextStyle( color: - DeviceUtils.instance.getTableRowColor(device.state ?? -1)), + DeviceUtils.instance.getTableRowColor(context,device.state ?? -1)), ), onTap: () { mapBloc.updateCameraPosition( diff --git a/lib/product/utils/device_utils.dart b/lib/product/utils/device_utils.dart index 473a97a..ed45cb5 100644 --- a/lib/product/utils/device_utils.dart +++ b/lib/product/utils/device_utils.dart @@ -151,7 +151,7 @@ class DeviceUtils { return devices..sort((a, b) => (a.name ?? '').compareTo(b.name ?? '')); } - Color getTableRowColor(int state) { + Color getTableRowColor(BuildContext context, int state) { if (state == 1) { return Colors.red; } else if (state == 0) { @@ -161,7 +161,7 @@ class DeviceUtils { } else if (state == -1) { return Colors.grey; } else { - return Colors.black87; + return Theme.of(context).colorScheme.onSurface; } }