diff --git a/lib/pages/common/custom_table.dart b/lib/pages/common/custom_table.dart index 04334393..62760a16 100644 --- a/lib/pages/common/custom_table.dart +++ b/lib/pages/common/custom_table.dart @@ -21,6 +21,7 @@ class DynamicTable extends StatefulWidget { final List? initialSelectedIds; final int uuidIndex; final Function(dynamic selectedRows)? onSelectionChanged; + final Function(int rowIndex)? onSettingsPressed; const DynamicTable({ super.key, required this.headers, @@ -37,6 +38,7 @@ class DynamicTable extends StatefulWidget { this.initialSelectedIds, required this.uuidIndex, this.onSelectionChanged, + this.onSettingsPressed, }); @override @@ -48,11 +50,20 @@ class _DynamicTableState extends State { bool _selectAll = false; final ScrollController _verticalScrollController = ScrollController(); final ScrollController _horizontalScrollController = ScrollController(); - + late ScrollController _horizontalHeaderScrollController; + late ScrollController _horizontalBodyScrollController; @override void initState() { super.initState(); _initializeSelection(); + _horizontalHeaderScrollController = ScrollController(); + _horizontalBodyScrollController = ScrollController(); + + // Synchronize horizontal scrolling + _horizontalBodyScrollController.addListener(() { + _horizontalHeaderScrollController + .jumpTo(_horizontalBodyScrollController.offset); + }); } @override @@ -102,101 +113,87 @@ class _DynamicTableState extends State { context.read().add(UpdateSelection(_selectedRows)); } + @override + void dispose() { + _horizontalHeaderScrollController.dispose(); + _horizontalBodyScrollController.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { return Container( decoration: widget.cellDecoration, - child: Scrollbar( - controller: _verticalScrollController, - thumbVisibility: true, - trackVisibility: true, - child: Scrollbar( - controller: _horizontalScrollController, - thumbVisibility: true, - trackVisibility: true, - notificationPredicate: (notif) => notif.depth == 1, - child: SingleChildScrollView( - controller: _verticalScrollController, + child: Column( + children: [ + Container( + decoration: widget.headerDecoration ?? + const BoxDecoration(color: ColorsManager.boxColor), child: SingleChildScrollView( - controller: _horizontalScrollController, scrollDirection: Axis.horizontal, + physics: const NeverScrollableScrollPhysics(), + controller: _horizontalHeaderScrollController, child: SizedBox( width: widget.size.width, - child: Column( + child: Row( children: [ - Container( - decoration: widget.headerDecoration ?? - const BoxDecoration( - color: ColorsManager.boxColor, - ), - child: Row( - children: [ - if (widget.withCheckBox) _buildSelectAllCheckbox(), - ...List.generate(widget.headers.length, (index) { - return _buildTableHeaderCell( - widget.headers[index], index); - }) - //...widget.headers.map((header) => _buildTableHeaderCell(header)), - ], - ), - ), - widget.isEmpty - ? SizedBox( - height: widget.size.height * 0.5, - width: widget.size.width, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Column( - children: [ - SvgPicture.asset(Assets.emptyTable), - const SizedBox( - height: 15, - ), - Text( - widget.tableName == 'AccessManagement' - ? 'No Password ' - : 'No Devices', - style: Theme.of(context) - .textTheme - .bodySmall! - .copyWith( - color: - ColorsManager.grayColor), - ) - ], - ), - ], - ), - ], - ), - ) - : Column( - children: - List.generate(widget.data.length, (index) { - final row = widget.data[index]; - return Row( - children: [ - if (widget.withCheckBox) - _buildRowCheckbox( - index, widget.size.height * 0.08), - ...row.map((cell) => _buildTableCell( - cell.toString(), - widget.size.height * 0.08)), - ], - ); - }), - ), + if (widget.withCheckBox) _buildSelectAllCheckbox(), + ...List.generate(widget.headers.length, (index) { + return _buildTableHeaderCell( + widget.headers[index], index); + }), ], ), ), ), ), - ), + Expanded( + child: Scrollbar( + controller: _verticalScrollController, + thumbVisibility: true, + trackVisibility: true, + child: SingleChildScrollView( + controller: _verticalScrollController, + child: Scrollbar( + controller: _horizontalBodyScrollController, + thumbVisibility: false, + trackVisibility: false, + notificationPredicate: (notif) => notif.depth == 1, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + controller: _horizontalBodyScrollController, + child: SizedBox( + width: widget.size.width, + child: widget.isEmpty + ? _buildEmptyState() + : Column( + children: + List.generate(widget.data.length, (rowIndex) { + final row = widget.data[rowIndex]; + return Row( + children: [ + if (widget.withCheckBox) + _buildRowCheckbox( + rowIndex, widget.size.height * 0.08), + ...row.asMap().entries.map((entry) { + return _buildTableCell( + entry.value.toString(), + widget.size.height * 0.08, + rowIndex: rowIndex, + columnIndex: entry.key, + ); + }).toList(), + ], + ); + }), + ), + ), + ), + ), + ), + ), + ), + ], ), ); } @@ -218,6 +215,32 @@ class _DynamicTableState extends State { ); } + Widget _buildEmptyState() => Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Column( + children: [ + SvgPicture.asset(Assets.emptyTable), + const SizedBox(height: 15), + Text( + widget.tableName == 'AccessManagement' + ? 'No Password ' + : 'No Devices', + style: Theme.of(context) + .textTheme + .bodySmall! + .copyWith(color: ColorsManager.grayColor), + ) + ], + ), + ], + ), + ], + ); Widget _buildRowCheckbox(int index, double size) { return Container( width: 50, @@ -272,13 +295,23 @@ class _DynamicTableState extends State { ); } - Widget _buildTableCell(String content, double size) { + Widget _buildTableCell( + String content, + double size, { + required int rowIndex, + required int columnIndex, + }) { bool isBatteryLevel = content.endsWith('%'); double? batteryLevel; if (isBatteryLevel) { batteryLevel = double.tryParse(content.replaceAll('%', '').trim()); } + bool isSettingsColumn = widget.headers[columnIndex] == 'Settings'; + + if (isSettingsColumn) { + return _buildSettingsIcon(rowIndex, size); + } Color? statusColor; switch (content) { @@ -330,4 +363,23 @@ class _DynamicTableState extends State { ), ); } + + Widget _buildSettingsIcon(int rowIndex, double size) { + return Container( + height: size, + width: 120, + padding: const EdgeInsets.all(5.0), + decoration: const BoxDecoration( + border: Border( + bottom: BorderSide(color: ColorsManager.boxDivider, width: 1.0), + ), + color: Colors.white, + ), + alignment: Alignment.center, + child: IconButton( + icon: SvgPicture.asset(Assets.settings), + onPressed: () => widget.onSettingsPressed?.call(rowIndex), + ), + ); + } } diff --git a/lib/pages/roles_and_permission/users_page/users_table/view/user_table.dart b/lib/pages/roles_and_permission/users_page/users_table/view/user_table.dart index b26c09c4..9b10b5d4 100644 --- a/lib/pages/roles_and_permission/users_page/users_table/view/user_table.dart +++ b/lib/pages/roles_and_permission/users_page/users_table/view/user_table.dart @@ -95,7 +95,7 @@ class _TableRow extends StatelessWidget { ], ), if (!isLast) - Divider( + const Divider( height: 1, thickness: 1, color: ColorsManager.boxDivider, @@ -110,12 +110,14 @@ class DynamicTableScreen extends StatefulWidget { final List titles; final List> rows; final void Function(int columnIndex)? onFilter; + final double tableSize; const DynamicTableScreen({ required this.titles, required this.rows, required this.onFilter, Key? key, + required this.tableSize, }) : super(key: key); @override @@ -205,7 +207,8 @@ class _DynamicTableScreenState extends State { bottomRight: Radius.circular(15), ), ), - child: Column( + child: ListView( + shrinkWrap: true, children: [ for (int rowIndex = 0; rowIndex < widget.rows.length; rowIndex++) _TableRow( @@ -253,7 +256,7 @@ class _DynamicTableScreenState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ _buildHeader(), - _buildBody(), + Container(height: widget.tableSize - 37, child: _buildBody()), ], ), ), diff --git a/lib/pages/roles_and_permission/users_page/users_table/view/users_page.dart b/lib/pages/roles_and_permission/users_page/users_table/view/users_page.dart index b5455646..26c41201 100644 --- a/lib/pages/roles_and_permission/users_page/users_table/view/users_page.dart +++ b/lib/pages/roles_and_permission/users_page/users_table/view/users_page.dart @@ -27,7 +27,8 @@ class UsersPage extends StatelessWidget { Widget build(BuildContext context) { final TextEditingController searchController = TextEditingController(); - Widget actionButton({bool isActive = false, required String title, Function()? onTap}) { + Widget actionButton( + {bool isActive = false, required String title, Function()? onTap}) { return InkWell( onTap: onTap, child: Padding( @@ -60,7 +61,8 @@ class UsersPage extends StatelessWidget { : ColorsManager.disabledPink.withOpacity(0.5), ), child: Padding( - padding: const EdgeInsets.only(left: 10, right: 10, bottom: 5, top: 5), + padding: + const EdgeInsets.only(left: 10, right: 10, bottom: 5, top: 5), child: Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, @@ -84,12 +86,15 @@ class UsersPage extends StatelessWidget { } Widget changeIconStatus( - {required String userId, required String status, required Function()? onTap}) { + {required String userId, + required String status, + required Function()? onTap}) { return Center( child: InkWell( onTap: onTap, child: Padding( - padding: const EdgeInsets.only(left: 5, right: 5, bottom: 5, top: 5), + padding: + const EdgeInsets.only(left: 5, right: 5, bottom: 5, top: 5), child: SvgPicture.asset( status == "invited" ? Assets.invitedIcon @@ -114,8 +119,7 @@ class UsersPage extends StatelessWidget { padding: const EdgeInsets.all(20), child: Align( alignment: Alignment.topCenter, - child: ListView( - shrinkWrap: true, + child: Column( children: [ Row( children: [ @@ -188,292 +192,325 @@ class UsersPage extends StatelessWidget { ), ], ), - const SizedBox(height: 25), - DynamicTableScreen( - onFilter: (columnIndex) { - if (columnIndex == 0) { - showNameMenu( - context: context, - isSelected: _blocRole.currentSortOrder, - aToZTap: () { - context.read().add(const SortUsersByNameAsc()); - }, - zToaTap: () { - context.read().add(const SortUsersByNameDesc()); - }, - ); - } - if (columnIndex == 2) { - final Map checkboxStates = { - for (var item in _blocRole.jobTitle) - item: _blocRole.selectedJobTitles.contains(item), - }; - final RenderBox overlay = - Overlay.of(context).context.findRenderObject() as RenderBox; + const SizedBox(height: 20), + Container( + height: screenSize.height * 0.65, + child: DynamicTableScreen( + tableSize: screenSize.height * 0.65, + onFilter: (columnIndex) { + if (columnIndex == 0) { + showNameMenu( + context: context, + isSelected: _blocRole.currentSortOrder, + aToZTap: () { + context + .read() + .add(const SortUsersByNameAsc()); + }, + zToaTap: () { + context + .read() + .add(const SortUsersByNameDesc()); + }, + ); + } + if (columnIndex == 2) { + final Map checkboxStates = { + for (var item in _blocRole.jobTitle) + item: _blocRole.selectedJobTitles.contains(item), + }; + final RenderBox overlay = Overlay.of(context) + .context + .findRenderObject() as RenderBox; - showPopUpFilterMenu( - position: RelativeRect.fromLTRB( - overlay.size.width / 5.3, - 240, - overlay.size.width / 4, - 0, - ), - list: _blocRole.jobTitle, - context: context, - checkboxStates: checkboxStates, - isSelected: _blocRole.currentSortJopTitle, - onOkPressed: () { - searchController.clear(); - _blocRole.add(FilterClearEvent()); - final selectedItems = checkboxStates.entries - .where((entry) => entry.value) - .map((entry) => entry.key) - .toList(); - Navigator.of(context).pop(); - _blocRole.add(FilterUsersByJobEvent( - selectedJob: selectedItems, - sortOrder: _blocRole.currentSortJopTitle, - )); - }, - onSortAtoZ: (v) { - _blocRole.currentSortJopTitle = v; - }, - onSortZtoA: (v) { - _blocRole.currentSortJopTitle = v; - }, - ); - } + showPopUpFilterMenu( + position: RelativeRect.fromLTRB( + overlay.size.width / 5.3, + 240, + overlay.size.width / 4, + 0, + ), + list: _blocRole.jobTitle, + context: context, + checkboxStates: checkboxStates, + isSelected: _blocRole.currentSortJopTitle, + onOkPressed: () { + searchController.clear(); + _blocRole.add(FilterClearEvent()); + final selectedItems = checkboxStates.entries + .where((entry) => entry.value) + .map((entry) => entry.key) + .toList(); + Navigator.of(context).pop(); + _blocRole.add(FilterUsersByJobEvent( + selectedJob: selectedItems, + sortOrder: _blocRole.currentSortJopTitle, + )); + }, + onSortAtoZ: (v) { + _blocRole.currentSortJopTitle = v; + }, + onSortZtoA: (v) { + _blocRole.currentSortJopTitle = v; + }, + ); + } - if (columnIndex == 3) { - final Map checkboxStates = { - for (var item in _blocRole.roleTypes) - item: _blocRole.selectedRoles.contains(item), - }; - final RenderBox overlay = - Overlay.of(context).context.findRenderObject() as RenderBox; - showPopUpFilterMenu( - position: RelativeRect.fromLTRB( - overlay.size.width / 4, - 240, - overlay.size.width / 4, - 0, - ), - list: _blocRole.roleTypes, - context: context, - checkboxStates: checkboxStates, - isSelected: _blocRole.currentSortRole, - onOkPressed: () { - searchController.clear(); - _blocRole.add(FilterClearEvent()); - final selectedItems = checkboxStates.entries - .where((entry) => entry.value) - .map((entry) => entry.key) - .toList(); - Navigator.of(context).pop(); - context.read().add(FilterUsersByRoleEvent( - selectedRoles: selectedItems, - sortOrder: _blocRole.currentSortRole)); - }, - onSortAtoZ: (v) { - _blocRole.currentSortRole = v; - }, - onSortZtoA: (v) { - _blocRole.currentSortRole = v; - }, - ); - } - if (columnIndex == 4) { - showDateFilterMenu( - context: context, - isSelected: _blocRole.currentSortOrder, - aToZTap: () { - context.read().add(const DateNewestToOldestEvent()); - }, - zToaTap: () { - context.read().add(const DateOldestToNewestEvent()); - }, - ); - } - if (columnIndex == 6) { - final Map checkboxStates = { - for (var item in _blocRole.createdBy) - item: _blocRole.selectedCreatedBy.contains(item), - }; - final RenderBox overlay = - Overlay.of(context).context.findRenderObject() as RenderBox; - showPopUpFilterMenu( - position: RelativeRect.fromLTRB( - overlay.size.width / 1, - 240, - overlay.size.width / 4, - 0, - ), - list: _blocRole.createdBy, - context: context, - checkboxStates: checkboxStates, - isSelected: _blocRole.currentSortCreatedBy, - onOkPressed: () { - searchController.clear(); - _blocRole.add(FilterClearEvent()); - final selectedItems = checkboxStates.entries - .where((entry) => entry.value) - .map((entry) => entry.key) - .toList(); - Navigator.of(context).pop(); - _blocRole.add(FilterUsersByCreatedEvent( - selectedCreatedBy: selectedItems, - sortOrder: _blocRole.currentSortCreatedBy)); - }, - onSortAtoZ: (v) { - _blocRole.currentSortCreatedBy = v; - }, - onSortZtoA: (v) { - _blocRole.currentSortCreatedBy = v; - }, - ); - } - if (columnIndex == 7) { - final Map checkboxStates = { - for (var item in _blocRole.status) - item: _blocRole.selectedStatuses.contains(item), - }; + if (columnIndex == 3) { + final Map checkboxStates = { + for (var item in _blocRole.roleTypes) + item: _blocRole.selectedRoles.contains(item), + }; + final RenderBox overlay = Overlay.of(context) + .context + .findRenderObject() as RenderBox; + showPopUpFilterMenu( + position: RelativeRect.fromLTRB( + overlay.size.width / 4, + 240, + overlay.size.width / 4, + 0, + ), + list: _blocRole.roleTypes, + context: context, + checkboxStates: checkboxStates, + isSelected: _blocRole.currentSortRole, + onOkPressed: () { + searchController.clear(); + _blocRole.add(FilterClearEvent()); + final selectedItems = checkboxStates.entries + .where((entry) => entry.value) + .map((entry) => entry.key) + .toList(); + Navigator.of(context).pop(); + context.read().add( + FilterUsersByRoleEvent( + selectedRoles: selectedItems, + sortOrder: _blocRole.currentSortRole)); + }, + onSortAtoZ: (v) { + _blocRole.currentSortRole = v; + }, + onSortZtoA: (v) { + _blocRole.currentSortRole = v; + }, + ); + } + if (columnIndex == 4) { + showDateFilterMenu( + context: context, + isSelected: _blocRole.currentSortOrder, + aToZTap: () { + context + .read() + .add(const DateNewestToOldestEvent()); + }, + zToaTap: () { + context + .read() + .add(const DateOldestToNewestEvent()); + }, + ); + } + if (columnIndex == 6) { + final Map checkboxStates = { + for (var item in _blocRole.createdBy) + item: _blocRole.selectedCreatedBy.contains(item), + }; + final RenderBox overlay = Overlay.of(context) + .context + .findRenderObject() as RenderBox; + showPopUpFilterMenu( + position: RelativeRect.fromLTRB( + overlay.size.width / 1, + 240, + overlay.size.width / 4, + 0, + ), + list: _blocRole.createdBy, + context: context, + checkboxStates: checkboxStates, + isSelected: _blocRole.currentSortCreatedBy, + onOkPressed: () { + searchController.clear(); + _blocRole.add(FilterClearEvent()); + final selectedItems = checkboxStates.entries + .where((entry) => entry.value) + .map((entry) => entry.key) + .toList(); + Navigator.of(context).pop(); + _blocRole.add(FilterUsersByCreatedEvent( + selectedCreatedBy: selectedItems, + sortOrder: _blocRole.currentSortCreatedBy)); + }, + onSortAtoZ: (v) { + _blocRole.currentSortCreatedBy = v; + }, + onSortZtoA: (v) { + _blocRole.currentSortCreatedBy = v; + }, + ); + } + if (columnIndex == 7) { + final Map checkboxStates = { + for (var item in _blocRole.status) + item: _blocRole.selectedStatuses.contains(item), + }; - final RenderBox overlay = - Overlay.of(context).context.findRenderObject() as RenderBox; - showPopUpFilterMenu( - position: RelativeRect.fromLTRB( - overlay.size.width / 0, - 240, - overlay.size.width / 5, - 0, + final RenderBox overlay = Overlay.of(context) + .context + .findRenderObject() as RenderBox; + showPopUpFilterMenu( + position: RelativeRect.fromLTRB( + overlay.size.width / 0, + 240, + overlay.size.width / 5, + 0, + ), + list: _blocRole.status, + context: context, + checkboxStates: checkboxStates, + isSelected: _blocRole.currentSortStatus, + onOkPressed: () { + searchController.clear(); + _blocRole.add(FilterClearEvent()); + final selectedItems = checkboxStates.entries + .where((entry) => entry.value) + .map((entry) => entry.key) + .toList(); + Navigator.of(context).pop(); + _blocRole.add(FilterUsersByDeActevateEvent( + selectedActivate: selectedItems, + sortOrder: _blocRole.currentSortStatus)); + }, + onSortAtoZ: (v) { + _blocRole.currentSortStatus = v; + }, + onSortZtoA: (v) { + _blocRole.currentSortStatus = v; + }, + ); + } + if (columnIndex == 8) { + showDeActivateFilterMenu( + context: context, + isSelected: _blocRole.currentSortOrderDate, + aToZTap: () { + context + .read() + .add(const DateNewestToOldestEvent()); + }, + zToaTap: () { + context + .read() + .add(const DateOldestToNewestEvent()); + }, + ); + } + }, + titles: const [ + "Full Name", + "Email Address", + "Job Title", + "Role", + "Creation Date", + "Creation Time", + "Created By", + "Status", + "De/Activate", + "Action" + ], + rows: state.users.map((user) { + return [ + Text('${user.firstName} ${user.lastName}'), + Text(user.email), + Text(user.jobTitle), + Text(user.roleType ?? ''), + Text(user.createdDate ?? ''), + Text(user.createdTime ?? ''), + Text(user.invitedBy), + status( + status: user.isEnabled == false + ? 'disabled' + : user.status, ), - list: _blocRole.status, - context: context, - checkboxStates: checkboxStates, - isSelected: _blocRole.currentSortStatus, - onOkPressed: () { - searchController.clear(); - _blocRole.add(FilterClearEvent()); - final selectedItems = checkboxStates.entries - .where((entry) => entry.value) - .map((entry) => entry.key) - .toList(); - Navigator.of(context).pop(); - _blocRole.add(FilterUsersByDeActevateEvent( - selectedActivate: selectedItems, - sortOrder: _blocRole.currentSortStatus)); - }, - onSortAtoZ: (v) { - _blocRole.currentSortStatus = v; - }, - onSortZtoA: (v) { - _blocRole.currentSortStatus = v; - }, - ); - } - if (columnIndex == 8) { - showDeActivateFilterMenu( - context: context, - isSelected: _blocRole.currentSortOrderDate, - aToZTap: () { - context.read().add(const DateNewestToOldestEvent()); - }, - zToaTap: () { - context.read().add(const DateOldestToNewestEvent()); - }, - ); - } - }, - titles: const [ - "Full Name", - "Email Address", - "Job Title", - "Role", - "Creation Date", - "Creation Time", - "Created By", - "Status", - "De/Activate", - "Action" - ], - rows: state.users.map((user) { - return [ - Text('${user.firstName} ${user.lastName}'), - Text(user.email), - Text(user.jobTitle), - Text(user.roleType ?? ''), - Text(user.createdDate ?? ''), - Text(user.createdTime ?? ''), - Text(user.invitedBy), - status( - status: user.isEnabled == false ? 'disabled' : user.status, - ), - changeIconStatus( - status: user.isEnabled == false ? 'disabled' : user.status, - userId: user.uuid, - onTap: user.status != "invited" - ? () { - context.read().add(ChangeUserStatus( - userId: user.uuid, - newStatus: - user.isEnabled == false ? 'disabled' : user.status)); - } - : null, - ), - Row( - children: [ - user.isEnabled != false - ? actionButton( - isActive: true, - title: "Edit", - onTap: () { - context.read().add(ClearCachedData()); - showDialog( - context: context, - barrierDismissible: false, - builder: (BuildContext context) { - return EditUserDialog(userId: user.uuid); - }, - ).then((v) { - if (v != null) { + changeIconStatus( + status: user.isEnabled == false + ? 'disabled' + : user.status, + userId: user.uuid, + onTap: user.status != "invited" + ? () { + context.read().add( + ChangeUserStatus( + userId: user.uuid, + newStatus: user.isEnabled == false + ? 'disabled' + : user.status)); + } + : null, + ), + Row( + children: [ + user.isEnabled != false + ? actionButton( + isActive: true, + title: "Edit", + onTap: () { + context + .read() + .add(ClearCachedData()); + showDialog( + context: context, + barrierDismissible: false, + builder: (BuildContext context) { + return EditUserDialog( + userId: user.uuid); + }, + ).then((v) { if (v != null) { - _blocRole.add(const GetUsers()); + if (v != null) { + _blocRole.add(const GetUsers()); + } } + }); + }, + ) + : actionButton( + title: "Edit", + ), + actionButton( + title: "Delete", + onTap: () { + showDialog( + context: context, + barrierDismissible: false, + builder: (BuildContext context) { + return DeleteUserDialog( + onTapDelete: () async { + try { + _blocRole.add(DeleteUserEvent( + user.uuid, context)); + await Future.delayed( + const Duration(seconds: 2)); + return true; + } catch (e) { + return false; } }); }, - ) - : actionButton( - title: "Edit", - ), - actionButton( - title: "Delete", - onTap: () { - showDialog( - context: context, - barrierDismissible: false, - builder: (BuildContext context) { - return DeleteUserDialog(onTapDelete: () async { - try { - _blocRole.add(DeleteUserEvent(user.uuid, context)); - await Future.delayed(const Duration(seconds: 2)); - return true; - } catch (e) { - return false; - } - }); - }, - ).then((v) { - if (v != null) { - _blocRole.add(const GetUsers()); - } - }); - }, - ), - ], - ), - ]; - }).toList(), + ).then((v) { + if (v != null) { + _blocRole.add(const GetUsers()); + } + }); + }, + ), + ], + ), + ]; + }).toList(), + ), ), Padding( padding: const EdgeInsets.all(8.0), @@ -486,14 +523,20 @@ class UsersPage extends StatelessWidget { visiblePagesCount: 4, buttonRadius: 10, selectedButtonColor: ColorsManager.secondaryColor, - buttonUnSelectedBorderColor: ColorsManager.grayBorder, - lastPageIcon: const Icon(Icons.keyboard_double_arrow_right), - firstPageIcon: const Icon(Icons.keyboard_double_arrow_left), - totalPages: - (_blocRole.totalUsersCount.length / _blocRole.itemsPerPage).ceil(), + buttonUnSelectedBorderColor: + ColorsManager.grayBorder, + lastPageIcon: + const Icon(Icons.keyboard_double_arrow_right), + firstPageIcon: + const Icon(Icons.keyboard_double_arrow_left), + totalPages: (_blocRole.totalUsersCount.length / + _blocRole.itemsPerPage) + .ceil(), currentPage: _blocRole.currentPage, onPageChanged: (int pageNumber) { - context.read().add(ChangePage(pageNumber)); + context + .read() + .add(ChangePage(pageNumber)); }, ), ),