chore(ui): update device state colors to match web

Change color and dynamic height table
This commit is contained in:
anhtunz
2025-04-08 09:47:23 +07:00
parent 1ab544afbb
commit 725d35aa5b
3 changed files with 40 additions and 48 deletions

View File

@@ -88,13 +88,14 @@ class _DevicesManagerScreenState extends State<DevicesManagerScreen> {
initialData: role, initialData: role,
builder: (context, roleSnapshot) { builder: (context, roleSnapshot) {
return SizedBox( return SizedBox(
height: context.dynamicHeight(0.4), height: getTableHeight(allDeviceSnapshot.data?.length ?? 1),
child: PaginatedDataTable2( child: PaginatedDataTable2(
wrapInCard: false,
headingRowHeight: 30, headingRowHeight: 30,
columnSpacing: 30, columnSpacing: 35,
horizontalMargin: 10, horizontalMargin: 10,
fixedLeftColumns: 1, fixedLeftColumns: 1,
autoRowsToHeight: true, // autoRowsToHeight: true,
renderEmptyRowsInTheEnd: false, renderEmptyRowsInTheEnd: false,
dragStartBehavior: DragStartBehavior.down, dragStartBehavior: DragStartBehavior.down,
minWidth: 950, minWidth: 950,
@@ -146,11 +147,11 @@ class _DevicesManagerScreenState extends State<DevicesManagerScreen> {
onPageChanged: (int pageIndex) { onPageChanged: (int pageIndex) {
// log('Chuyen page: $pageIndex'); // log('Chuyen page: $pageIndex');
}, },
// rowsPerPage: rowsPerPage:
// (allDeviceSnapshot.data?.length ?? 1) < 6 (allDeviceSnapshot.data?.length ?? 1) < 6
// ? (allDeviceSnapshot.data?.length ?? ? (allDeviceSnapshot.data?.length ??
// 0) 0)
// : 5, : 5,
actions: [ actions: [
if (roleSnapshot.data == if (roleSnapshot.data ==
@@ -224,7 +225,16 @@ class _DevicesManagerScreenState extends State<DevicesManagerScreen> {
void getUserRole() async { void getUserRole() async {
role = await apiServices.getUserRole(); role = await apiServices.getUserRole();
devicesManagerBloc.sinkUserRole.add(role); devicesManagerBloc.sinkUserRole.add(role);F:
cd
}
double getTableHeight(int dataLength){
if(dataLength < 3){
return context.dynamicHeight(0.3);
}else {
return context.dynamicHeight(0.4);
}
} }
} }

View File

@@ -1,6 +1,6 @@
import 'package:flex_color_scheme/flex_color_scheme.dart'; import 'package:flex_color_scheme/flex_color_scheme.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:sfm_app/product/theme/app_theme.dart'; import 'app_theme.dart';
class AppThemeLight extends AppTheme { class AppThemeLight extends AppTheme {
static AppThemeLight? _instance; static AppThemeLight? _instance;
@@ -29,27 +29,7 @@ class AppThemeLight extends AppTheme {
navigationRailUseIndicator: true, navigationRailUseIndicator: true,
navigationRailLabelType: NavigationRailLabelType.all, navigationRailLabelType: NavigationRailLabelType.all,
), ),
visualDensity: FlexColorScheme.comfortablePlatformDensity, visualDensity: FlexColorScheme.comfortablePlatformDensity,
); );
// ThemeData.light().copyWith(
// useMaterial3: true,
// colorScheme: _buildColorScheme,
// );
// ColorScheme get _buildColorScheme => FlexColorScheme.light(
// ).toScheme;
// const ColorScheme(
// brightness: Brightness.light,
// primary: Colors.black,
// onPrimary: Colors.white,
// secondary: Colors.black,
// onSecondary: Colors.black45,
// error: Colors.red,
// onError: Colors.orange,
// background: Colors.white,
// onBackground: Colors.red,
// surface: Colors.white,
// onSurface: Colors.black,
// );
} }

View File

@@ -153,15 +153,15 @@ class DeviceUtils {
Color getTableRowColor(BuildContext context, int state) { Color getTableRowColor(BuildContext context, int state) {
if (state == 1) { if (state == 1) {
return Colors.red; return const Color(0xFFF57070);
} else if (state == 0) { } else if (state == 0) {
return Colors.green; return const Color(0xFF9EF16D);
} else if (state == 2) { } else if (state == 2) {
return Colors.orange; return const Color(0xFFF5EF44);;
} else if (state == -1) { } else if (state == -1) {
return Colors.grey; return const Color(0xFFBBBAC2);;
} else { } else {
return Theme.of(context).colorScheme.onSurface; return const Color(0xFFF5EF44);;
} }
} }
@@ -269,17 +269,19 @@ class DeviceUtils {
} }
} }
Color getColorRiple(int state) { // Color getColorRipple(int state) {
if (state == 1) { // if (state == 1) {
return Colors.red; // return const Color(0xFFF57070);
} else if (state == 3) { // } else if (state == 0) {
return Colors.orange; // return const Color(0xFF9EF16D);
} else if (state == -1) { // } else if (state == 2) {
return Colors.grey; // return const Color(0xFFF5EF44);;
} else { // } else if (state == -1) {
return Colors.green; // return const Color(0xFFBBBAC2);;
} // } else {
} // return const Color(0xFFF5EF44);;
// }
// }
List<String> deviceBatteryImg = [ List<String> deviceBatteryImg = [
IconConstants.instance.getIcon("full-battery"), IconConstants.instance.getIcon("full-battery"),