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,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -9,6 +9,7 @@ import 'package:go_router/go_router.dart';
|
||||
import 'package:badges/badges.dart' as badges;
|
||||
import 'package:persistent_bottom_nav_bar/persistent_bottom_nav_bar.dart';
|
||||
import 'package:sfm_app/feature/sound_notification_test/notification_screen.dart';
|
||||
import 'package:sfm_app/product/permission/notification_permission.dart';
|
||||
import '../settings/profile/profile_model.dart';
|
||||
import '../../product/extention/context_extention.dart';
|
||||
import '../../bloc/home_bloc.dart';
|
||||
@@ -72,6 +73,7 @@ class _MainScreenState extends State<MainScreen> with WidgetsBindingObserver {
|
||||
mainBloc.sinkIsVNIcon.add(isVN);
|
||||
mainBloc.sinkThemeMode.add(isLight);
|
||||
LocationPermissionRequest.instance.checkLocationPermission(context);
|
||||
NotificationPermission.instance.checkNotificationPermission(context);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -148,15 +150,15 @@ class _MainScreenState extends State<MainScreen> with WidgetsBindingObserver {
|
||||
inactiveIcon:
|
||||
IconConstants.instance.getMaterialIcon(Icons.group_outlined),
|
||||
),
|
||||
PersistentBottomNavBarItem(
|
||||
icon: IconConstants.instance
|
||||
.getMaterialIcon(Icons.notifications_outlined),
|
||||
title: appLocalization(context).notification,
|
||||
activeColorPrimary: Colors.blue,
|
||||
inactiveColorPrimary: Colors.grey,
|
||||
inactiveIcon: IconConstants.instance
|
||||
.getMaterialIcon(Icons.notifications_outlined),
|
||||
),
|
||||
// PersistentBottomNavBarItem(
|
||||
// icon: IconConstants.instance
|
||||
// .getMaterialIcon(Icons.notifications_outlined),
|
||||
// title: appLocalization(context).notification,
|
||||
// activeColorPrimary: Colors.blue,
|
||||
// inactiveColorPrimary: Colors.grey,
|
||||
// inactiveIcon: IconConstants.instance
|
||||
// .getMaterialIcon(Icons.notifications_outlined),
|
||||
// ),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -181,10 +183,10 @@ class _MainScreenState extends State<MainScreen> with WidgetsBindingObserver {
|
||||
child: const InterFamilyScreen(),
|
||||
blocBuilder: () => InterFamilyBloc(),
|
||||
),
|
||||
BlocProvider(
|
||||
/*BlocProvider(
|
||||
child: const NotificationScreen(),
|
||||
blocBuilder: () => NotificationBloc(),
|
||||
),
|
||||
),*/
|
||||
];
|
||||
}
|
||||
|
||||
@@ -221,8 +223,8 @@ class _MainScreenState extends State<MainScreen> with WidgetsBindingObserver {
|
||||
},
|
||||
icon: Icon(
|
||||
themeModeSnapshot.data ?? isLight
|
||||
? Icons.dark_mode_outlined
|
||||
: Icons.light_mode_outlined,
|
||||
? Icons.light_mode_outlined
|
||||
: Icons.dark_mode_outlined,
|
||||
),
|
||||
),
|
||||
StreamBuilder<bool>(
|
||||
|
||||
@@ -106,7 +106,7 @@ class _MapScreenState extends State<MapScreen> with WidgetsBindingObserver {
|
||||
onMapCreated: onMapCreated,
|
||||
markers: markerSnapshot.data ?? markersAll
|
||||
..addAll(markers),
|
||||
zoomControlsEnabled: false,
|
||||
zoomControlsEnabled: true,
|
||||
myLocationEnabled: true,
|
||||
mapToolbarEnabled: false,
|
||||
onCameraMove: (position) {
|
||||
@@ -138,10 +138,10 @@ class _MapScreenState extends State<MapScreen> with WidgetsBindingObserver {
|
||||
|
||||
void checkTheme() async {
|
||||
String theme = await apiServices.checkTheme();
|
||||
if (theme == AppThemes.LIGHT.name) {
|
||||
themeMode = '';
|
||||
} else {
|
||||
if (theme == AppThemes.DARK.name) {
|
||||
themeMode = await _getFileData('assets/map_themes/maps_dark_theme.json');
|
||||
} else {
|
||||
themeMode = '';
|
||||
}
|
||||
mapBloc.sinkMapTheme.add(themeMode);
|
||||
}
|
||||
@@ -274,10 +274,16 @@ class _MapScreenState extends State<MapScreen> with WidgetsBindingObserver {
|
||||
if (response != "") {
|
||||
final data = jsonDecode(response);
|
||||
List<dynamic> result = data['items'];
|
||||
final devicesList = Device.fromJsonDynamicList(result);
|
||||
for (var device in devicesList) {
|
||||
devices.add(device);
|
||||
if(result.isNotEmpty){
|
||||
devices.clear();
|
||||
final devicesList = Device.fromJsonDynamicList(result);
|
||||
for (var device in devicesList) {
|
||||
devices.add(device);
|
||||
}
|
||||
}else{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -188,8 +188,7 @@ showNearPlacesSideSheet(
|
||||
longitude,
|
||||
);
|
||||
},
|
||||
icon: IconConstants.instance
|
||||
.getMaterialIcon(Icons.turn_right),
|
||||
icon: const Icon(Icons.turn_right,color: Colors.white),
|
||||
label: Text(appLocalization(listViewContext)
|
||||
.map_show_direction),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user