diff --git a/assets/images/calendar_icon.svg b/assets/images/calendar_icon.svg
new file mode 100644
index 00000000..bdf23bee
--- /dev/null
+++ b/assets/images/calendar_icon.svg
@@ -0,0 +1,13 @@
+
diff --git a/assets/images/device_note.svg b/assets/images/device_note.svg
new file mode 100644
index 00000000..f0b94043
--- /dev/null
+++ b/assets/images/device_note.svg
@@ -0,0 +1,5 @@
+
diff --git a/assets/images/empty_table.svg b/assets/images/empty_table.svg
new file mode 100644
index 00000000..24ac359d
--- /dev/null
+++ b/assets/images/empty_table.svg
@@ -0,0 +1,23 @@
+
diff --git a/assets/images/time_icon.svg b/assets/images/time_icon.svg
new file mode 100644
index 00000000..a8f06677
--- /dev/null
+++ b/assets/images/time_icon.svg
@@ -0,0 +1,4 @@
+
diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj
index 6094b4c6..dffe452f 100644
--- a/ios/Runner.xcodeproj/project.pbxproj
+++ b/ios/Runner.xcodeproj/project.pbxproj
@@ -14,6 +14,8 @@
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
+ E44A9405B1EB1B638DD05A58 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7ABF0EC746A2D686A0ED574F /* Pods_RunnerTests.framework */; };
+ FF49F60EC38658783D8D66DA /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2AFAE479A87ECDEBD5D6EB30 /* Pods_Runner.framework */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -42,12 +44,19 @@
/* Begin PBXFileReference section */
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; };
+ 22428D486F110EE0B969469D /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; };
+ 253C5EA6840355311DB030EA /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; };
+ 2AFAE479A87ECDEBD5D6EB30 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
+ 2C0D722D2ED971BF672D18D5 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; };
331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; };
331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; };
+ 544621C7727C798253BAB2C8 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = ""; };
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; };
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
+ 7ABF0EC746A2D686A0ED574F /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; };
+ 877FDC97D8B87080E35B3EB7 /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; };
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -55,19 +64,52 @@
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
+ D3AD250AADBF93406007C9EB /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
+ 759A57780A409ED209817654 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ E44A9405B1EB1B638DD05A58 /* Pods_RunnerTests.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
97C146EB1CF9000F007C117D /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
+ FF49F60EC38658783D8D66DA /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
+ 1454C118FFCECEEDF59152D2 /* Pods */ = {
+ isa = PBXGroup;
+ children = (
+ 253C5EA6840355311DB030EA /* Pods-Runner.debug.xcconfig */,
+ 22428D486F110EE0B969469D /* Pods-Runner.release.xcconfig */,
+ D3AD250AADBF93406007C9EB /* Pods-Runner.profile.xcconfig */,
+ 2C0D722D2ED971BF672D18D5 /* Pods-RunnerTests.debug.xcconfig */,
+ 877FDC97D8B87080E35B3EB7 /* Pods-RunnerTests.release.xcconfig */,
+ 544621C7727C798253BAB2C8 /* Pods-RunnerTests.profile.xcconfig */,
+ );
+ name = Pods;
+ path = Pods;
+ sourceTree = "";
+ };
+ 20A3C64D2B1CFED5A81C3251 /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ 2AFAE479A87ECDEBD5D6EB30 /* Pods_Runner.framework */,
+ 7ABF0EC746A2D686A0ED574F /* Pods_RunnerTests.framework */,
+ );
+ name = Frameworks;
+ sourceTree = "";
+ };
331C8082294A63A400263BE5 /* RunnerTests */ = {
isa = PBXGroup;
children = (
@@ -94,6 +136,8 @@
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
331C8082294A63A400263BE5 /* RunnerTests */,
+ 1454C118FFCECEEDF59152D2 /* Pods */,
+ 20A3C64D2B1CFED5A81C3251 /* Frameworks */,
);
sourceTree = "";
};
@@ -128,8 +172,10 @@
isa = PBXNativeTarget;
buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */;
buildPhases = (
+ B9A66CAAF434B6A1BD8C4E09 /* [CP] Check Pods Manifest.lock */,
331C807D294A63A400263BE5 /* Sources */,
331C807F294A63A400263BE5 /* Resources */,
+ 759A57780A409ED209817654 /* Frameworks */,
);
buildRules = (
);
@@ -145,12 +191,14 @@
isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
+ C1C48B0232C0B26BFF405512 /* [CP] Check Pods Manifest.lock */,
9740EEB61CF901F6004384FC /* Run Script */,
97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */,
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
+ 33590C9CD073D3D5EBA02CDE /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
@@ -222,6 +270,23 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
+ 33590C9CD073D3D5EBA02CDE /* [CP] Embed Pods Frameworks */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputFileListPaths = (
+ "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
+ );
+ name = "[CP] Embed Pods Frameworks";
+ outputFileListPaths = (
+ "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
+ showEnvVarsInLog = 0;
+ };
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
@@ -253,6 +318,50 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
};
+ B9A66CAAF434B6A1BD8C4E09 /* [CP] Check Pods Manifest.lock */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputFileListPaths = (
+ );
+ inputPaths = (
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
+ "${PODS_ROOT}/Manifest.lock",
+ );
+ name = "[CP] Check Pods Manifest.lock";
+ outputFileListPaths = (
+ );
+ outputPaths = (
+ "$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
+ showEnvVarsInLog = 0;
+ };
+ C1C48B0232C0B26BFF405512 /* [CP] Check Pods Manifest.lock */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputFileListPaths = (
+ );
+ inputPaths = (
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
+ "${PODS_ROOT}/Manifest.lock",
+ );
+ name = "[CP] Check Pods Manifest.lock";
+ outputFileListPaths = (
+ );
+ outputPaths = (
+ "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
+ showEnvVarsInLog = 0;
+ };
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
@@ -378,6 +487,7 @@
};
331C8088294A63A400263BE5 /* Debug */ = {
isa = XCBuildConfiguration;
+ baseConfigurationReference = 2C0D722D2ED971BF672D18D5 /* Pods-RunnerTests.debug.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
@@ -395,6 +505,7 @@
};
331C8089294A63A400263BE5 /* Release */ = {
isa = XCBuildConfiguration;
+ baseConfigurationReference = 877FDC97D8B87080E35B3EB7 /* Pods-RunnerTests.release.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
@@ -410,6 +521,7 @@
};
331C808A294A63A400263BE5 /* Profile */ = {
isa = XCBuildConfiguration;
+ baseConfigurationReference = 544621C7727C798253BAB2C8 /* Pods-RunnerTests.profile.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
diff --git a/ios/Runner.xcworkspace/contents.xcworkspacedata b/ios/Runner.xcworkspace/contents.xcworkspacedata
index 1d526a16..21a3cc14 100644
--- a/ios/Runner.xcworkspace/contents.xcworkspacedata
+++ b/ios/Runner.xcworkspace/contents.xcworkspacedata
@@ -4,4 +4,7 @@
+
+
diff --git a/lib/main.dart b/lib/main.dart
index d52c6541..01911d05 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -1,8 +1,11 @@
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/auth/bloc/auth_bloc.dart';
import 'package:syncrow_web/pages/auth/view/login_page.dart';
+import 'package:syncrow_web/pages/home/bloc/home_bloc.dart';
import 'package:syncrow_web/pages/home/view/home_page.dart';
+import 'package:syncrow_web/pages/visitor_password/bloc/visitor_password_bloc.dart';
import 'package:syncrow_web/services/locator.dart';
import 'package:syncrow_web/utils/color_manager.dart';
@@ -23,7 +26,13 @@ class MyApp extends StatelessWidget {
});
@override
Widget build(BuildContext context) {
- return MaterialApp(
+ return MultiBlocProvider(
+ providers: [
+ BlocProvider(create: (context) => HomeBloc()),
+ BlocProvider(
+ create: (context) => VisitorPasswordBloc(),)
+ ],
+ child: MaterialApp(
debugShowCheckedModeBanner: false, // Hide debug banner
scrollBehavior: const MaterialScrollBehavior().copyWith(
dragDevices: {
@@ -33,10 +42,10 @@ class MyApp extends StatelessWidget {
PointerDeviceKind.unknown,
},
),
+
theme: ThemeData(
textTheme: const TextTheme(
- bodySmall: TextStyle(
- fontSize: 13, color: ColorsManager.whiteColors, fontWeight: FontWeight.bold),
+ bodySmall: TextStyle(fontSize: 13, color: ColorsManager.whiteColors, fontWeight: FontWeight.bold),
bodyMedium: TextStyle(color: Colors.black87, fontSize: 14),
bodyLarge: TextStyle(fontSize: 16, color: Colors.white),
headlineSmall: TextStyle(color: Colors.black87, fontSize: 18),
@@ -47,10 +56,11 @@ class MyApp extends StatelessWidget {
fontWeight: FontWeight.bold,
),
),
+
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), // Set up color scheme
useMaterial3: true, // Enable Material 3
),
- home: isLoggedIn == 'Success' ? const HomePage() : const LoginPage(),
- );
+ home:isLoggedIn == 'Success' ? const HomePage() : const LoginPage(),
+ ));
}
}
diff --git a/lib/pages/access_management/bloc/access_bloc.dart b/lib/pages/access_management/bloc/access_bloc.dart
new file mode 100644
index 00000000..47f865ef
--- /dev/null
+++ b/lib/pages/access_management/bloc/access_bloc.dart
@@ -0,0 +1,229 @@
+import 'package:flutter/material.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:syncrow_web/pages/access_management/bloc/access_event.dart';
+import 'package:syncrow_web/pages/access_management/bloc/access_state.dart';
+import 'package:syncrow_web/pages/access_management/model/password_model.dart';
+import 'package:syncrow_web/services/access_mang_api.dart';
+import 'package:syncrow_web/utils/color_manager.dart';
+import 'package:syncrow_web/utils/constants/const.dart';
+import 'package:syncrow_web/utils/snack_bar.dart';
+
+class AccessBloc extends Bloc {
+ AccessBloc() : super((AccessInitial())) {
+ on(_onFetchTableData);
+ // on(selectFilterTap);
+ on(selectTime);
+ on(_filterData);
+ on(resetSearch);
+ on(onTabChanged);
+ }
+ String startTime = 'Start Date';
+ String endTime = 'End Date';
+
+ int? effectiveTimeTimeStamp;
+ int? expirationTimeTimeStamp;
+ TextEditingController passwordName= TextEditingController();
+ List filteredData = [];
+ List data=[];
+
+ Future _onFetchTableData(
+ FetchTableData event, Emitter emit) async {
+ try {
+ emit(AccessLoaded());
+ data = await AccessMangApi().fetchVisitorPassword();
+ filteredData= data;
+ updateTabsCount();
+ emit(TableLoaded(data));
+ } catch (e) {
+ emit(FailedState(e.toString()));
+ }
+ }
+ void updateTabsCount() {
+ 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)';
+ tabs[2] = 'Effective ($effectiveCount)';
+ tabs[3] = 'Expired ($expiredCount)';
+ }
+
+
+
+ int selectedIndex = 0;
+ final List tabs = [
+ 'All',
+ 'To Be Effective (0)',
+ 'Effective (0)',
+ 'Expired'
+ ];
+
+
+ Future selectFilterTap(TabChangedEvent event, Emitter emit) async {
+ try {
+ emit(AccessLoaded());
+ selectedIndex= event.selectedIndex;
+ emit(AccessInitial());
+ emit(TableLoaded(data));
+ } catch (e) {
+ emit(FailedState( e.toString()));
+ return;
+ }
+ }
+
+
+ Future selectTime(SelectTime event, Emitter emit) async {
+ emit(AccessLoaded());
+
+ final DateTime? picked = await showDatePicker(
+ context: event.context,
+ initialDate: DateTime.now(),
+ firstDate: DateTime(2015, 8),
+ lastDate: DateTime(2101),
+ );
+ if (picked != null) {
+ final TimeOfDay? timePicked = await showTimePicker(
+ context: event.context,
+ initialTime: TimeOfDay.now(),
+
+ builder: (context, child) {
+ return Theme(
+ data: ThemeData.light().copyWith(
+ colorScheme: const ColorScheme.light(
+ primary: ColorsManager.primaryColor,
+ onSurface: Colors.black,
+ ),
+ buttonTheme: const ButtonThemeData(
+ colorScheme: ColorScheme.light(
+ primary: Colors.green,
+ ),
+ ),
+ ),
+ child: child!,
+ );
+ },
+ );
+ if (timePicked != null) {
+ final selectedDateTime = DateTime(
+ picked.year,
+ picked.month,
+ picked.day,
+ timePicked.hour,
+ timePicked.minute,
+ );
+ final selectedTimestamp = DateTime(
+ selectedDateTime.year,
+ selectedDateTime.month,
+ selectedDateTime.day,
+ selectedDateTime.hour,
+ selectedDateTime.minute,
+ ).millisecondsSinceEpoch ~/ 1000; // Divide by 1000 to remove milliseconds
+ if (event.isStart) {
+ if (expirationTimeTimeStamp != null && selectedTimestamp > expirationTimeTimeStamp!) {
+ CustomSnackBar.displaySnackBar('Effective Time cannot be later than Expiration Time.');
+ } else {
+ startTime = selectedDateTime.toString().split('.').first; // Remove seconds and milliseconds
+ effectiveTimeTimeStamp = selectedTimestamp;
+ }
+ } else {
+ if (effectiveTimeTimeStamp != null && selectedTimestamp < effectiveTimeTimeStamp!) {
+ CustomSnackBar.displaySnackBar('Expiration Time cannot be earlier than Effective Time.');
+ } else {
+ endTime = selectedDateTime.toString().split('.').first; // Remove seconds and milliseconds
+ expirationTimeTimeStamp = selectedTimestamp;
+ }
+ }
+ }
+ }
+ emit(ChangeTimeState());
+ }
+
+
+ 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());
+ startTime = 'Start Time';
+ endTime = 'End Time';
+ passwordName.clear();
+ selectedIndex=0;
+ effectiveTimeTimeStamp=null;
+ expirationTimeTimeStamp=null;
+ add(FetchTableData());
+ }
+
+ String timestampToDate(dynamic timestamp) {
+ DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(int.parse(timestamp) * 1000);
+ return "${dateTime.year}/${dateTime.month.toString().padLeft(2, '0')}/${dateTime.day.toString().padLeft(2, '0')}";
+ }
+
+ Future onTabChanged(TabChangedEvent event, Emitter emit) async {
+ try {
+ emit(AccessLoaded());
+ selectedIndex = event.selectedIndex;
+ switch (selectedIndex) {
+ case 0: // All
+ filteredData = data;
+ break;
+ case 1: // To Be Effective
+ filteredData = data.where((item) => item.passwordStatus.value == "To Be Effective").toList();
+ break;
+ case 2: // Effective
+ filteredData = data.where((item) => item.passwordStatus.value == "Effective").toList();
+ break;
+ case 3: // Expired
+ filteredData = data.where((item) => item.passwordStatus.value == "Expired").toList();
+ break;
+ default:
+ filteredData = data;
+ }
+ add(FilterDataEvent(
+ selectedTabIndex: selectedIndex,
+ passwordName: passwordName.text.toLowerCase(),
+ startTime: effectiveTimeTimeStamp,
+ endTime: expirationTimeTimeStamp
+ ));
+ emit(TableLoaded(filteredData));
+ } catch (e) {
+ emit(FailedState(e.toString()));
+ }
+ }
+
+}
diff --git a/lib/pages/access_management/bloc/access_event.dart b/lib/pages/access_management/bloc/access_event.dart
new file mode 100644
index 00000000..f2f631b4
--- /dev/null
+++ b/lib/pages/access_management/bloc/access_event.dart
@@ -0,0 +1,46 @@
+
+import 'package:equatable/equatable.dart';
+import 'package:flutter/material.dart';
+
+abstract class AccessEvent extends Equatable {
+ const AccessEvent();
+
+ @override
+ List