diff --git a/lib/pages/auth/bloc/auth_bloc.dart b/lib/pages/auth/bloc/auth_bloc.dart index bfd42eaf..120de89a 100644 --- a/lib/pages/auth/bloc/auth_bloc.dart +++ b/lib/pages/auth/bloc/auth_bloc.dart @@ -34,7 +34,7 @@ class AuthBloc extends Bloc { TextEditingController(); final TextEditingController forgetOtp = TextEditingController(); final forgetFormKey = GlobalKey(); - late bool checkValidate = false; + late bool checkValidate = false; Timer? _timer; int _remainingTime = 0; @@ -58,8 +58,7 @@ class AuthBloc extends Bloc { add(const UpdateTimerEvent(remainingTime: 0, isButtonEnabled: true)); } else { add(UpdateTimerEvent( - remainingTime: _remainingTime, - isButtonEnabled: false)); + remainingTime: _remainingTime, isButtonEnabled: false)); } }); } @@ -152,29 +151,35 @@ class AuthBloc extends Bloc { key: UserModel.userUuidKey, value: Token.decodeToken(token.accessToken)['uuid'].toString()); user = UserModel.fromToken(token); + debugPrint(token.accessToken); loginEmailController.clear(); loginPasswordController.clear(); emit(LoginSuccess()); } else { - emit(const LoginFailure(error: 'Something went wrong')); } } else { - emit(const LoginFailure(error: 'Accept terms and condition')); } } - checkBoxToggle(CheckBoxEvent event, Emitter emit,) { + checkBoxToggle( + CheckBoxEvent event, + Emitter emit, + ) { emit(AuthLoading()); isChecked = event.newValue!; add(CheckEnableEvent()); emit(LoginInitial()); } - checkOtpCode(ChangePasswordEvent event, Emitter emit,) async { + checkOtpCode( + ChangePasswordEvent event, + Emitter emit, + ) async { emit(LoadingForgetState()); - await AuthenticationAPI.verifyOtp(email: forgetEmailController.text, otpCode: forgetOtp.text); + await AuthenticationAPI.verifyOtp( + email: forgetEmailController.text, otpCode: forgetOtp.text); emit(SuccessForgetState()); } @@ -202,19 +207,17 @@ class AuthBloc extends Bloc { } else if (regionUuid == '') { return 'Please select your region'; } - validate=''; + validate = ''; return null; } String? loginValidateEmail(String? value) { - if (!RegExp(r'^[^@]+@[^@]+\.[^@]+').hasMatch(value!)) { + if (!RegExp(r'^[^@]+@[^@]+\.[^@]+').hasMatch(value!)) { return ''; } return null; } - - bool _validateInputs(Emitter emit) { emit(LoadingForgetState()); final nameError = validateEmail(forgetEmailController.text); @@ -357,7 +360,9 @@ class AuthBloc extends Bloc { final String formattedTime = [ if (days > 0) '${days}d', // Append 'd' for days if (days > 0 || hours > 0) - hours.toString().padLeft(2, '0'), // Show hours if there are days or hours + hours + .toString() + .padLeft(2, '0'), // Show hours if there are days or hours minutes.toString().padLeft(2, '0'), seconds.toString().padLeft(2, '0'), ].join(':'); @@ -365,9 +370,12 @@ class AuthBloc extends Bloc { return formattedTime; } - bool checkEnable( CheckEnableEvent event, Emitter emit,) { + bool checkEnable( + CheckEnableEvent event, + Emitter emit, + ) { emit(AuthLoading()); - checkValidate = isChecked==true && + checkValidate = isChecked == true && loginPasswordController.text.isNotEmpty && loginEmailController.text.isNotEmpty && regionUuid != ''; @@ -375,14 +383,21 @@ class AuthBloc extends Bloc { return checkValidate; } - changeValidate(ChangeValidateEvent event, Emitter emit,){ + changeValidate( + ChangeValidateEvent event, + Emitter emit, + ) { emit(AuthLoading()); - validate=''; + validate = ''; emit(LoginInitial()); } - changeForgetValidate(ChangeValidateEvent event, Emitter emit,){ + + changeForgetValidate( + ChangeValidateEvent event, + Emitter emit, + ) { emit(AuthLoading()); - forgetValidate=''; + forgetValidate = ''; emit(LoginInitial()); } } diff --git a/lib/pages/common/custom_table.dart b/lib/pages/common/custom_table.dart index c2a83273..93ae29ce 100644 --- a/lib/pages/common/custom_table.dart +++ b/lib/pages/common/custom_table.dart @@ -75,8 +75,7 @@ class _DynamicTableState extends State { BoxDecoration(color: Colors.grey[200]), child: Row( children: [ - if (widget.withCheckBox) - _buildSelectAllCheckbox(), + if (widget.withCheckBox) _buildSelectAllCheckbox(), ...widget.headers .map((header) => _buildTableHeaderCell(header)) .toList(), @@ -93,10 +92,11 @@ class _DynamicTableState extends State { final row = widget.data[index]; return Row( children: [ - if (widget.withCheckBox) - _buildRowCheckbox(index), - ...row.map((cell) => - _buildTableCell(cell.toString())).toList(), + if (widget.withCheckBox) _buildRowCheckbox(index), + ...row + .map((cell) => + _buildTableCell(cell.toString())) + .toList(), ], ); }, @@ -143,7 +143,10 @@ class _DynamicTableState extends State { alignment: Alignment.centerLeft, child: Padding( padding: const EdgeInsets.all(8.0), - child: Text(title, style: const TextStyle(fontWeight: FontWeight.bold)), + child: Text(title, + style: const TextStyle( + fontWeight: FontWeight.w400, + color: ColorsManager.lightGreyColor)), ), ), ); @@ -156,11 +159,11 @@ class _DynamicTableState extends State { padding: const EdgeInsets.all(15.0), decoration: const BoxDecoration( border: Border( - bottom: BorderSide( - color: ColorsManager.boxDivider, - width: 1.0, - ), - )), + bottom: BorderSide( + color: ColorsManager.boxDivider, + width: 1.0, + ), + )), alignment: Alignment.centerLeft, child: Text( content, diff --git a/lib/pages/device_managment/widgets/device_managment_body.dart b/lib/pages/device_managment/widgets/device_managment_body.dart index 1f3b11e1..a3c2a807 100644 --- a/lib/pages/device_managment/widgets/device_managment_body.dart +++ b/lib/pages/device_managment/widgets/device_managment_body.dart @@ -1,9 +1,11 @@ import 'package:flutter/material.dart'; import 'package:syncrow_web/core/extension/build_context_x.dart'; import 'package:syncrow_web/pages/common/buttons/search_reset_buttons.dart'; +import 'package:syncrow_web/pages/common/custom_table.dart'; import 'package:syncrow_web/pages/common/filter/filter_widget.dart'; import 'package:syncrow_web/pages/common/text_field/custom_text_field.dart'; import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart'; +import 'package:syncrow_web/utils/style.dart'; class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout { const DeviceManagementBody({super.key}); @@ -80,6 +82,46 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout { ], ), ], + const SizedBox( + height: 12, + ), + Expanded( + child: DynamicTable( + cellDecoration: containerDecoration, + selectAll: (p0) { + // visitorBloc.selectedDeviceIds.clear(); + // for (var item in state.data) { + // visitorBloc.add(SelectDeviceEvent(item.uuid)); + // } + }, + onRowCheckboxChanged: (index, isSelected) { + // final deviceId = state.data[index].uuid; + // visitorBloc.add(SelectDeviceEvent(deviceId)); + }, + withCheckBox: true, + size: context.screenSize, + headers: const [ + 'Device Name', + 'Product Name', + 'Device ID', + 'Unit Name', + 'Room', + 'Battery Level', + 'Installation Date and Time', + 'Status', + 'Last Offline Date and Time', + ], + data: [] + // state.data.map((item) { + // return [ + // item.name.toString(), + // item.uuid.toString(), + // item.productType.toString(), + // '', + // item.online.value.toString(), + // ]; + // }).toList(), + )), ], ), ); diff --git a/lib/utils/color_manager.dart b/lib/utils/color_manager.dart index 9b5b6d44..f0d64814 100644 --- a/lib/utils/color_manager.dart +++ b/lib/utils/color_manager.dart @@ -3,9 +3,10 @@ import 'package:flutter/material.dart'; abstract class ColorsManager { static const Color textPrimaryColor = Color(0xFF5D5D5D); static const Color switchOffColor = Color(0x7F8D99AE); - static const Color primaryColor = Color(0xFF0030CB);//023DFE + static const Color primaryColor = Color(0xFF0030CB); //023DFE static const Color secondaryTextColor = Color(0xFF848484); - static Color primaryColorWithOpacity = const Color(0xFF023DFE).withOpacity(0.6); + static Color primaryColorWithOpacity = + const Color(0xFF023DFE).withOpacity(0.6); static const Color whiteColors = Colors.white; static const Color secondaryColor = Color(0xFF023DFE); static const Color onSecondaryColor = Color(0xFF023DFE); @@ -13,7 +14,7 @@ abstract class ColorsManager { static const Color primaryTextColor = Colors.black; static const Color greyColor = Color(0xFFd5d5d5); - + static const Color lightGreyColor = Color(0xFF999999); static const Color backgroundColor = Color(0xFFececec); static const Color dozeColor = Color(0xFFFEC258); static const Color relaxColor = Color(0xFFFBD288);