fix(ui): Fix some ui bugs
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:data_table_2/data_table_2.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'add_new_device_widget.dart';
|
||||
@@ -85,112 +87,105 @@ class _DevicesManagerScreenState extends State<DevicesManagerScreen> {
|
||||
stream: devicesManagerBloc.streamUserRole,
|
||||
initialData: role,
|
||||
builder: (context, roleSnapshot) {
|
||||
return CardTheme(
|
||||
color: Theme.of(context).colorScheme.onPrimary,
|
||||
shadowColor:
|
||||
Theme.of(context).colorScheme.onPrimary,
|
||||
child: PaginatedDataTable(
|
||||
headingRowHeight: 30,
|
||||
columnSpacing: 30,
|
||||
horizontalMargin: 10,
|
||||
header: Center(
|
||||
child: Text(
|
||||
appLocalization(context)
|
||||
.paginated_data_table_title,
|
||||
style: context.headlineMediumTextStyle,
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
columns: [
|
||||
if (roleSnapshot.data ==
|
||||
RoleEnums.ADMIN.name ||
|
||||
roleSnapshot.data ==
|
||||
RoleEnums.USER.name)
|
||||
DataColumn(
|
||||
label: Center(
|
||||
child: Text(appLocalization(context)
|
||||
columns: [
|
||||
if (roleSnapshot.data ==
|
||||
RoleEnums.ADMIN.name ||
|
||||
roleSnapshot.data ==
|
||||
RoleEnums.USER.name)
|
||||
DataColumn(
|
||||
label: Text(appLocalization(context)
|
||||
.paginated_data_table_column_deviceName),
|
||||
),
|
||||
),
|
||||
DataColumn(
|
||||
label: Center(
|
||||
child: Text(appLocalization(context)
|
||||
DataColumn(
|
||||
label: Text(appLocalization(context)
|
||||
.paginated_data_table_column_deviceStatus),
|
||||
),
|
||||
),
|
||||
DataColumn(
|
||||
label: Center(
|
||||
child: Text(appLocalization(context)
|
||||
DataColumn(
|
||||
label: Text(appLocalization(context)
|
||||
.paginated_data_table_column_deviceBaterry),
|
||||
),
|
||||
),
|
||||
DataColumn(
|
||||
label: Center(
|
||||
child: Text(appLocalization(context)
|
||||
DataColumn(
|
||||
label: Text(appLocalization(context)
|
||||
.paginated_data_table_column_deviceSignal),
|
||||
),
|
||||
),
|
||||
DataColumn(
|
||||
label: Center(
|
||||
child: Text(appLocalization(context)
|
||||
DataColumn(
|
||||
label: Text(appLocalization(context)
|
||||
.paginated_data_table_column_deviceTemperature),
|
||||
),
|
||||
),
|
||||
DataColumn(
|
||||
label: Center(
|
||||
child: Text(appLocalization(context)
|
||||
DataColumn(
|
||||
label: Text(appLocalization(context)
|
||||
.paginated_data_table_column_deviceHump),
|
||||
),
|
||||
),
|
||||
DataColumn(
|
||||
label: Center(
|
||||
child: Text(appLocalization(context)
|
||||
DataColumn(
|
||||
label: Text(appLocalization(context)
|
||||
.paginated_data_table_column_devicePower),
|
||||
),
|
||||
),
|
||||
DataColumn(
|
||||
label: Center(
|
||||
child: Text(appLocalization(context)
|
||||
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,
|
||||
],
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user