Fix(ui): Fix some ui bugs

Find Button In DeviceLogsScreen
Fix offlineText when in DarkMode
Update offlineIcons
This commit is contained in:
anhtunz
2025-04-04 10:32:50 +07:00
parent 6230036c04
commit 1ab544afbb
7 changed files with 131 additions and 137 deletions

View File

@@ -89,103 +89,98 @@ class _DevicesManagerScreenState extends State<DevicesManagerScreen> {
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<Color>(
Colors.green),
iconColor:
WidgetStateProperty.all<Color>(
Colors.white,
),
actions: [
if (roleSnapshot.data ==
RoleEnums.USER.name ||
roleSnapshot.data ==
RoleEnums.ADMIN.name)
IconButton(
style: ButtonStyle(
backgroundColor:
WidgetStateProperty.all<Color>(
Colors.green),
iconColor:
WidgetStateProperty.all<Color>(
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(