diff --git a/lib/pages/access_management/bloc/access_bloc.dart b/lib/pages/access_management/bloc/access_bloc.dart index febdb9d3..dd60237e 100644 --- a/lib/pages/access_management/bloc/access_bloc.dart +++ b/lib/pages/access_management/bloc/access_bloc.dart @@ -38,8 +38,9 @@ class AccessBloc extends Bloc { emit(FailedState(e.toString())); } } + void updateTabsCount() { - int toBeEffectiveCount = data.where((item) => item.passwordStatus.value== 'To Be Effective').length; + int toBeEffectiveCount = data.where((item) => item.passwordStatus.value== 'To be effective').length; int effectiveCount = data.where((item) => item.passwordStatus.value == 'Effective').length; int expiredCount = data.where((item) => item.passwordStatus.value == 'Expired').length; tabs[1] = 'To Be Effective ($toBeEffectiveCount)'; @@ -48,7 +49,6 @@ class AccessBloc extends Bloc { } - int selectedIndex = 0; final List tabs = [ 'All', @@ -73,7 +73,6 @@ class AccessBloc extends Bloc { Future selectTime(SelectTime event, Emitter emit) async { emit(AccessLoaded()); - final DateTime? picked = await showDatePicker( context: event.context, initialDate: DateTime.now(), @@ -81,7 +80,6 @@ class AccessBloc extends Bloc { lastDate: DateTime(2101), ); if (picked != null) { - final selectedDateTime = DateTime( picked.year, picked.month, @@ -110,7 +108,6 @@ class AccessBloc extends Bloc { expirationTimeTimeStamp = selectedTimestamp; } } - } emit(ChangeTimeState()); } @@ -165,7 +162,7 @@ class AccessBloc extends Bloc { } // Filter by selected tab index - if (event.selectedTabIndex == 1 && item.passwordStatus.value != 'To Be Effective') { + if (event.selectedTabIndex == 1 && item.passwordStatus.value != 'To be effective') { matchesCriteria = false; } else if (event.selectedTabIndex == 2 && item.passwordStatus.value != 'Effective') { matchesCriteria = false; @@ -183,110 +180,6 @@ class AccessBloc extends Bloc { } - // Future _filterData(FilterDataEvent event, Emitter emit) async { - // emit(AccessLoaded()); - // try { - // filteredData = data.where((item) { - // bool matchesCriteria = true; - // - // // Filter by password name - // if (event.passwordName != null && event.passwordName!.isNotEmpty) { - // final bool matchesName = item.passwordName != null && - // item.passwordName.contains(event.passwordName); - // if (!matchesName) { - // matchesCriteria = false; - // } - // } - // - // // Filter by start time only - // if (event.startTime != null && event.endTime == null) { - // final int? effectiveTime = int.tryParse(item.effectiveTime.toString()); - // if (effectiveTime == null || effectiveTime < event.startTime!) { - // matchesCriteria = false; - // } - // } - // - // // Filter by end time only - // if (event.endTime != null && event.startTime == null) { - // final int? invalidTime = int.tryParse(item.invalidTime.toString()); - // if (invalidTime == null || invalidTime > event.endTime!) { - // matchesCriteria = false; - // } - // } - // - // // Filter by both start time and end time - // if (event.startTime != null && event.endTime != null) { - // final int? effectiveTime = int.tryParse(item.effectiveTime.toString()); - // final int? invalidTime = int.tryParse(item.invalidTime.toString()); - // if (effectiveTime == null || invalidTime == null) { - // matchesCriteria = false; - // } else { - // final bool matchesStartTime = effectiveTime >= event.startTime!; - // final bool matchesEndTime = invalidTime <= event.endTime!; - // if (!matchesStartTime || !matchesEndTime) { - // matchesCriteria = false; - // } - // } - // } - // - // // Filter by selected tab index - // if (event.selectedTabIndex == 1 && item.passwordStatus.value != 'To Be Effective') { - // matchesCriteria = false; - // } else if (event.selectedTabIndex == 2 && item.passwordStatus.value != 'Effective') { - // matchesCriteria = false; - // } else if (event.selectedTabIndex == 3 && item.passwordStatus.value != 'Expired') { - // matchesCriteria = false; - // } - // - // return matchesCriteria; - // }).toList(); - // - // emit(TableLoaded(filteredData)); - // } catch (e) { - // emit(FailedState(e.toString())); - // } - // } - - - // Future _filterData(FilterDataEvent event, Emitter emit) async { - // emit(AccessLoaded()); - // try { - // filteredData = data.where((item) { - // bool matchesCriteria = true; - // if (event.passwordName != null && event.passwordName!.isNotEmpty) { - // final bool matchesName = item.passwordName != null && - // item.passwordName.contains(event.passwordName); - // if (!matchesName) { - // matchesCriteria = false; - // } - // } - // if (event.startTime != null || event.endTime != null) { - // final int? effectiveTime = int.tryParse(item.effectiveTime.toString()); - // final int? invalidTime = int.tryParse(item.invalidTime.toString()); - // if (effectiveTime == null || invalidTime == null) { - // matchesCriteria = false; - // } else { - // final bool matchesStartTime = effectiveTime >= event.startTime!; - // final bool matchesEndTime = invalidTime <= event.endTime!; - // if (!matchesStartTime || !matchesEndTime) { - // matchesCriteria = false; - // } - // } - // } - // if (event.selectedTabIndex == 1 && item.passwordStatus.value != 'To Be Effective') { - // matchesCriteria = false; - // } else if (event.selectedTabIndex == 2 && item.passwordStatus.value != 'Effective') { - // matchesCriteria = false; - // } else if (event.selectedTabIndex == 3 && item.passwordStatus.value != 'Expired') { - // matchesCriteria = false; - // } - // return matchesCriteria; - // }).toList(); - // emit(TableLoaded(filteredData)); - // } catch (e) { - // emit(FailedState(e.toString())); - // } - // } resetSearch(ResetSearch event, Emitter emit) async{ emit(AccessLoaded()); diff --git a/lib/pages/access_management/view/access_management.dart b/lib/pages/access_management/view/access_management.dart index 80efcd3c..6eea85e8 100644 --- a/lib/pages/access_management/view/access_management.dart +++ b/lib/pages/access_management/view/access_management.dart @@ -133,7 +133,6 @@ class AccessManagementPage extends StatelessWidget { ), SizedBox( - height:45, width: size.width * 0.06, child:Container( @@ -153,7 +152,6 @@ class AccessManagementPage extends StatelessWidget { width: 10, ), SizedBox( - height:45, width: size.width * 0.06, child: Container( decoration: containerDecoration, @@ -237,6 +235,7 @@ class AccessManagementPage extends StatelessWidget { 'Access Status' ], data: filteredData.map((item) { + return [ item.passwordName.toString(), item.passwordType.value, @@ -244,7 +243,7 @@ class AccessManagementPage extends StatelessWidget { item.deviceUuid.toString(), '', '', - item.passwordStatus.value + item.passwordStatus.value, ]; }).toList(), ) diff --git a/lib/pages/common/custom_table.dart b/lib/pages/common/custom_table.dart index 76e3b663..dc3c3afb 100644 --- a/lib/pages/common/custom_table.dart +++ b/lib/pages/common/custom_table.dart @@ -14,7 +14,6 @@ class DynamicTable extends StatefulWidget { final void Function(bool?)? selectAll; final void Function(int, bool?)? onRowCheckboxChanged; final List? initialSelectedIds; - const DynamicTable({ super.key, required this.headers, @@ -199,6 +198,20 @@ class _DynamicTableState extends State { } Widget _buildTableCell(String content,size) { + Color? statusColor; + switch (content) { + case 'Effective': + statusColor = ColorsManager.textGreen; + break; + case 'Expired': + statusColor = ColorsManager.red; + break; + case 'To be effective': + statusColor = ColorsManager.yaGreen; + break; + default: + statusColor = Colors.black; // Default color + } return Expanded( child: Container( height:size , @@ -213,7 +226,11 @@ class _DynamicTableState extends State { alignment: Alignment.centerLeft, child: Text( content, - style: const TextStyle(color: Colors.black, fontSize: 10,fontWeight: FontWeight.w400), + style: TextStyle( + color:statusColor, // Use the passed color or default to black + fontSize: 10, + fontWeight: FontWeight.w400 + ), ), ), ); diff --git a/lib/pages/common/custom_web_textfield.dart b/lib/pages/common/custom_web_textfield.dart index e58f51b4..a41bc662 100644 --- a/lib/pages/common/custom_web_textfield.dart +++ b/lib/pages/common/custom_web_textfield.dart @@ -73,7 +73,7 @@ class CustomWebTextField extends StatelessWidget { decoration: textBoxDecoration()! .copyWith( errorStyle: const TextStyle(height: 0), // Hide the error text space - hintStyle: TextStyle(color: ColorsManager.grayColor), + hintStyle: const TextStyle(color: ColorsManager.grayColor), hintText: 'Please enter'), ), ), diff --git a/lib/pages/visitor_password/bloc/visitor_password_bloc.dart b/lib/pages/visitor_password/bloc/visitor_password_bloc.dart index 8ee44298..e1ee0edd 100644 --- a/lib/pages/visitor_password/bloc/visitor_password_bloc.dart +++ b/lib/pages/visitor_password/bloc/visitor_password_bloc.dart @@ -461,7 +461,7 @@ class VisitorPasswordBloc return null; } - Future stateDialog({ + Future stateDialog({ BuildContext? context, String? message, String? title, @@ -469,6 +469,7 @@ class VisitorPasswordBloc Widget? widgeta, }) { return showCustomDialog( + barrierDismissible: false, context: context!, message: message!, iconPath: Assets.deviceNoteIcon, @@ -479,7 +480,7 @@ class VisitorPasswordBloc [ TextButton( onPressed: () { - Navigator.of(context).pop(); + Navigator.of(context).pop(true); }, child: const Text('OK'), ), @@ -487,30 +488,5 @@ class VisitorPasswordBloc ); } - // - // Future stateAndDeviseDialog({ - // BuildContext? context, - // String? message, - // String? title, - // dynamic actions, - // }) { - // return showCustomDialog( - // context: context!, - // message: message!, - // iconPath: Assets.deviceNoteIcon, - // title: title, - // dialogHeight: 150, - // actions: actions ?? - // [ - // TextButton( - // onPressed: () { - // Navigator.of(context).pop(); - // }, - // child: const Text('OK'), - // ), - // ], - // ); - // } - } diff --git a/lib/pages/visitor_password/view/visitor_password_dialog.dart b/lib/pages/visitor_password/view/visitor_password_dialog.dart index e3a9a291..1200ce0e 100644 --- a/lib/pages/visitor_password/view/visitor_password_dialog.dart +++ b/lib/pages/visitor_password/view/visitor_password_dialog.dart @@ -82,7 +82,9 @@ class VisitorPasswordDialog extends StatelessWidget { ), ], ) - ); + ).then((v){ + Navigator.of(context).pop(); + }); } else if (state is FailedState) { visitorBloc.stateDialog( context: context, @@ -423,7 +425,6 @@ class VisitorPasswordDialog extends StatelessWidget { ), ), ], - ), ), if (visitorBloc.usageFrequencySelected == 'Periodic' && @@ -485,8 +486,14 @@ class VisitorPasswordDialog extends StatelessWidget { onPressed: () { if (visitorBloc.forgetFormKey.currentState!.validate()) { if(visitorBloc.selectedDevices.isNotEmpty){ + if(visitorBloc.usageFrequencySelected == 'One-Time' && visitorBloc.accessTypeSelected == 'Offline Password'){ setPasswordFunction(context, size, visitorBloc); + } + else if(visitorBloc.accessTypeSelected == 'Dynamic Password'){ + print('objectobjectobjectobject'); + setPasswordFunction(context, size, visitorBloc); + }else{ if(visitorBloc.effectiveTimeTimeStamp!=null&&visitorBloc.expirationTimeTimeStamp!=null) { if(isRepeat==true){ @@ -668,37 +675,45 @@ class VisitorPasswordDialog extends StatelessWidget { borderRadius: 8, onPressed: () { Navigator.pop(context); - if (visitorBloc.usageFrequencySelected == 'One-Time' && - visitorBloc.accessTypeSelected == 'Online Password') { - visitorBloc.add(OnlineOneTimePasswordEvent( - context: context, - passwordName: visitorBloc.userNameController.text, - email: visitorBloc.emailController.text, - )); - } else if (visitorBloc.usageFrequencySelected == 'Periodic' && - visitorBloc.accessTypeSelected == 'Online Password') { - visitorBloc.add(OnlineMultipleTimePasswordEvent( - passwordName: visitorBloc.userNameController.text, - email: visitorBloc.emailController.text, - effectiveTime: visitorBloc.effectiveTimeTimeStamp.toString(), - invalidTime: visitorBloc.expirationTimeTimeStamp.toString(), - )); - } else if (visitorBloc.usageFrequencySelected == 'One-Time' && - visitorBloc.accessTypeSelected == 'Offline Password') { - visitorBloc.add(OfflineOneTimePasswordEvent( - context: context, - passwordName: visitorBloc.userNameController.text, - email: visitorBloc.emailController.text, - )); - } else if (visitorBloc.usageFrequencySelected == 'Periodic' && - visitorBloc.accessTypeSelected == 'Offline Password') { - visitorBloc.add(OfflineMultipleTimePasswordEvent( - passwordName: visitorBloc.userNameController.text, - email: visitorBloc.emailController.text, - effectiveTime: visitorBloc.effectiveTimeTimeStamp.toString(), - invalidTime: visitorBloc.expirationTimeTimeStamp.toString(), - )); + if(visitorBloc.accessTypeSelected == 'Dynamic Password'){ + + }else{ + if (visitorBloc.usageFrequencySelected == 'One-Time' && + visitorBloc.accessTypeSelected == 'Online Password') { + visitorBloc.add(OnlineOneTimePasswordEvent( + context: context, + passwordName: visitorBloc.userNameController.text, + email: visitorBloc.emailController.text, + )); + } + else if (visitorBloc.usageFrequencySelected == 'Periodic' && + visitorBloc.accessTypeSelected == 'Online Password') { + visitorBloc.add(OnlineMultipleTimePasswordEvent( + passwordName: visitorBloc.userNameController.text, + email: visitorBloc.emailController.text, + effectiveTime: visitorBloc.effectiveTimeTimeStamp.toString(), + invalidTime: visitorBloc.expirationTimeTimeStamp.toString(), + )); + } + else if (visitorBloc.usageFrequencySelected == 'One-Time' && + visitorBloc.accessTypeSelected == 'Offline Password') { + visitorBloc.add(OfflineOneTimePasswordEvent( + context: context, + passwordName: visitorBloc.userNameController.text, + email: visitorBloc.emailController.text, + )); + } + else if (visitorBloc.usageFrequencySelected == 'Periodic' && + visitorBloc.accessTypeSelected == 'Offline Password') { + visitorBloc.add(OfflineMultipleTimePasswordEvent( + passwordName: visitorBloc.userNameController.text, + email: visitorBloc.emailController.text, + effectiveTime: visitorBloc.effectiveTimeTimeStamp.toString(), + invalidTime: visitorBloc.expirationTimeTimeStamp.toString(), + )); + } } + }, child: Text( 'Ok', diff --git a/lib/utils/color_manager.dart b/lib/utils/color_manager.dart index 723c7f02..8118ac97 100644 --- a/lib/utils/color_manager.dart +++ b/lib/utils/color_manager.dart @@ -36,5 +36,7 @@ abstract class ColorsManager { static const Color blue2 = Color(0xFF0026A2); static const Color blue3 = Color(0xFF00165E); static const Color blue4 = Color(0xFF001E7E); + static const Color textGreen = Color(0xFF008905); + static const Color yaGreen = Color(0xFFFFBF44); } //0036E6 \ No newline at end of file