diff --git a/assets/icons/delete.svg b/assets/icons/delete.svg
new file mode 100644
index 00000000..050a4521
--- /dev/null
+++ b/assets/icons/delete.svg
@@ -0,0 +1,9 @@
+
diff --git a/lib/pages/spaces_management/bloc/space_management_bloc.dart b/lib/pages/spaces_management/bloc/space_management_bloc.dart
index 41c7e234..3ff8216e 100644
--- a/lib/pages/spaces_management/bloc/space_management_bloc.dart
+++ b/lib/pages/spaces_management/bloc/space_management_bloc.dart
@@ -110,6 +110,7 @@ class SpaceManagementBloc extends Bloc emit,
@@ -146,6 +147,7 @@ class SpaceManagementBloc extends Bloc {
return SpaceContainerWidget(
index: index,
onDoubleTap: () {
+ print(spaces[index].toString());
_showEditSpaceDialog(spaces[index]);
},
icon: spaces[index].icon ?? '',
@@ -178,23 +182,55 @@ class _CommunityStructureAreaState extends State {
),
// Show "Save" button only if there are spaces
if (spaces.isNotEmpty && widget.selectedCommunity != null)
- ElevatedButton.icon(
- onPressed: () {
- _saveSpaces();
- },
- icon: const Icon(Icons.save, size: 18),
- label: const Text("Save"),
- style: ElevatedButton.styleFrom(
- backgroundColor: ColorsManager.whiteColors,
- foregroundColor: Colors.black,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(8.0),
+ Row(children: [
+ ElevatedButton.icon(
+ onPressed: () {
+ _saveSpaces();
+ },
+ icon: const Icon(
+ Icons.save,
+ size: 18,
+ color: ColorsManager.spaceColor,
+ ),
+ label: const Text("Save"),
+ style: ElevatedButton.styleFrom(
+ backgroundColor: ColorsManager.textFieldGreyColor,
+ foregroundColor: ColorsManager.blackColor,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(8.0),
+ ),
+ padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
+ side: BorderSide(color: Colors.grey.shade300),
+ elevation: 0,
),
- padding: const EdgeInsets.symmetric(horizontal: 12.0, vertical: 8.0),
- side: BorderSide(color: Colors.grey.shade300),
- elevation: 0,
),
- ),
+ const SizedBox(width: 10),
+ ElevatedButton.icon(
+ onPressed: () {
+ showDeleteConfirmationDialog(context, () {
+ // Handle the delete action here
+ print("Delete confirmed");
+ Navigator.of(context).pop(); // Close the dialog after confirming
+ }, widget.selectedSpace != null);
+ },
+ icon: SvgPicture.asset(
+ Assets.acFanAuto, // Path to your SVG asset
+ width: 18, // Adjust width as needed
+ height: 18, // Adjust height as needed
+ ),
+ label: const Text("Delete"),
+ style: ElevatedButton.styleFrom(
+ backgroundColor: ColorsManager.textFieldGreyColor,
+ foregroundColor: Colors.black,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(8.0),
+ ),
+ padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
+ side: BorderSide(color: ColorsManager.neutralGray),
+ elevation: 0,
+ ),
+ ),
+ ])
],
),
);
@@ -284,35 +320,35 @@ class _CommunityStructureAreaState extends State {
);
}
+ void _showEditSpaceDialog(SpaceModel space) {
+ showDialog(
+ context: context,
+ builder: (BuildContext context) {
+ return CreateSpaceDialog(
+ products: widget.products,
+ name: space.name,
+ icon: space.icon,
+ isEdit: true,
+ selectedProducts: space.selectedProducts,
+ onCreateSpace: (String name, String icon, List selectedProducts) {
+ setState(() {
+ // Update the space's properties
+ space.name = name;
+ space.icon = icon;
+ space.selectedProducts = selectedProducts;
-void _showEditSpaceDialog(SpaceModel space) {
- showDialog(
- context: context,
- builder: (BuildContext context) {
- return CreateSpaceDialog(
- products: widget.products,
- name: space.name,
- icon: space.icon,
- isEdit: true,
- selectedProducts: space.selectedProducts,
- onCreateSpace: (String name, String icon, List selectedProducts) {
- setState(() {
- // Update the space's properties
- space.name = name;
- space.icon = icon;
- space.selectedProducts = selectedProducts;
+ if (space.status != SpaceStatus.newSpace) {
+ space.status = SpaceStatus.modified; // Mark as modified
+ }
+ });
+ },
+ // Pre-fill the dialog with current space data
+ key: Key(space.name), // Add a unique key to ensure dialog refresh
+ );
+ },
+ );
+ }
- if (space.status != SpaceStatus.newSpace) {
- space.status = SpaceStatus.modified; // Mark as modified
- }
- });
- },
- // Pre-fill the dialog with current space data
- key: Key(space.name), // Add a unique key to ensure dialog refresh
- );
- },
- );
-}
void _handleHoverChanged(int index, bool isHovered) {
setState(() {
spaces[index].isHovered = isHovered;
diff --git a/lib/pages/spaces_management/view/dialogs/create_community_dialog.dart b/lib/pages/spaces_management/widgets/dialogs/create_community_dialog.dart
similarity index 100%
rename from lib/pages/spaces_management/view/dialogs/create_community_dialog.dart
rename to lib/pages/spaces_management/widgets/dialogs/create_community_dialog.dart
diff --git a/lib/pages/spaces_management/view/dialogs/create_space_dialog.dart b/lib/pages/spaces_management/widgets/dialogs/create_space_dialog.dart
similarity index 99%
rename from lib/pages/spaces_management/view/dialogs/create_space_dialog.dart
rename to lib/pages/spaces_management/widgets/dialogs/create_space_dialog.dart
index 76987253..54218d22 100644
--- a/lib/pages/spaces_management/view/dialogs/create_space_dialog.dart
+++ b/lib/pages/spaces_management/widgets/dialogs/create_space_dialog.dart
@@ -369,6 +369,7 @@ class CreateSpaceDialogState extends State {
),
);
+
return product.icon ?? Assets.presenceSensor;
}
diff --git a/lib/pages/spaces_management/widgets/dialogs/delete_dialogue.dart b/lib/pages/spaces_management/widgets/dialogs/delete_dialogue.dart
new file mode 100644
index 00000000..4e9b25fc
--- /dev/null
+++ b/lib/pages/spaces_management/widgets/dialogs/delete_dialogue.dart
@@ -0,0 +1,225 @@
+import 'package:flutter/material.dart';
+import 'package:syncrow_web/utils/color_manager.dart';
+
+void showDeleteConfirmationDialog(BuildContext context, VoidCallback onConfirm, bool isSpace) {
+ showDialog(
+ context: context,
+ barrierDismissible: false, // Prevent dismissing by tapping outside
+ builder: (BuildContext context) {
+ return Dialog(
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(16.0),
+ ),
+ child: SizedBox(
+ width: 500, // Set the desired width
+ child: Container(
+ color: ColorsManager.whiteColors,
+ padding: const EdgeInsets.all(20.0),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ // Icon
+ Container(
+ width: 50,
+ height: 50,
+ decoration: BoxDecoration(
+ color: ColorsManager.warningRed,
+ shape: BoxShape.circle,
+ ),
+ child: const Icon(
+ Icons.close,
+ color: Colors.white,
+ size: 40,
+ ),
+ ),
+ const SizedBox(height: 20),
+ // Title
+ isSpace
+ ? const Text(
+ 'Delete Space',
+ style: TextStyle(
+ fontSize: 20,
+ fontWeight: FontWeight.bold,
+ ),
+ )
+ : const Text(
+ 'Delete Community',
+ style: TextStyle(
+ fontSize: 20,
+ fontWeight: FontWeight.bold,
+ ),
+ ),
+ const SizedBox(height: 10),
+ // Subtitle
+ isSpace
+ ? const Text(
+ 'All the data in the space will be lost',
+ textAlign: TextAlign.center,
+ style: TextStyle(
+ fontSize: 14,
+ color: Colors.grey,
+ ),
+ )
+ : const Text(
+ 'All the data in the community will be lost',
+ textAlign: TextAlign.center,
+ style: TextStyle(
+ fontSize: 14,
+ color: Colors.grey,
+ ),
+ ),
+
+ const SizedBox(height: 20),
+ // Buttons
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceEvenly,
+ children: [
+ ElevatedButton(
+ onPressed: () {
+ Navigator.of(context).pop(); // Close the first dialog
+ // Trigger the second popup
+ },
+ style: ElevatedButton.styleFrom(
+ backgroundColor: Colors.white,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(12),
+ side: const BorderSide(color: ColorsManager.boxColor), // Black border
+ ),
+ ),
+ child: const Text(
+ 'Cancel',
+ style: TextStyle(color: Colors.black),
+ ),
+ ),
+ ElevatedButton(
+ onPressed: () {
+ Navigator.of(context).pop(); // Close the first dialog
+ showProcessingPopup(context, isSpace, onConfirm);
+ },
+ style: ElevatedButton.styleFrom(
+ backgroundColor: Colors.blue,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(8.0),
+ ),
+ ),
+ child: const Text(
+ 'Continue',
+ style: TextStyle(color: Colors.white),
+ ),
+ ),
+ ],
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ },
+ );
+}
+
+void showProcessingPopup(BuildContext context, bool isSpace, VoidCallback onDelete) {
+ showDialog(
+ context: context,
+ barrierDismissible: false,
+ builder: (BuildContext context) {
+ return Dialog(
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(16.0),
+ ),
+ child: SizedBox(
+ width: 500,
+ child: Container(
+ color: ColorsManager.whiteColors,
+ padding: const EdgeInsets.all(20.0),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ // Icon
+ Container(
+ width: 50,
+ height: 50,
+ decoration: BoxDecoration(
+ color: ColorsManager.warningRed,
+ shape: BoxShape.circle,
+ ),
+ child: const Icon(
+ Icons.close,
+ color: Colors.white,
+ size: 40,
+ ),
+ ),
+ const SizedBox(height: 20),
+ // Title
+ isSpace
+ ? const Text(
+ 'Delete Space',
+ style: TextStyle(
+ fontSize: 20,
+ fontWeight: FontWeight.bold,
+ ),
+ )
+ : const Text(
+ 'Delete Community',
+ style: TextStyle(
+ fontSize: 20,
+ fontWeight: FontWeight.bold,
+ ),
+ ),
+ const SizedBox(height: 10),
+ // Subtitle
+ const Text(
+ 'Are you sure you want to Delete?',
+ textAlign: TextAlign.center,
+ style: TextStyle(
+ fontSize: 14,
+ color: Colors.grey,
+ ),
+ ),
+ const SizedBox(height: 20),
+ // Buttons (Optional)
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceEvenly,
+ children: [
+ ElevatedButton(
+ onPressed: () {
+ // Trigger the second popup
+ onDelete();
+ },
+ style: ElevatedButton.styleFrom(
+ backgroundColor: ColorsManager.warningRed,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(12),
+ side: const BorderSide(color: ColorsManager.boxColor), // Black border
+ ),
+ ),
+ child: const Text(
+ 'Delete',
+ style: TextStyle(color: Colors.white),
+ ),
+ ),
+ ElevatedButton(
+ onPressed: () {
+ Navigator.of(context).pop(); // Close the first dialog
+ },
+ style: ElevatedButton.styleFrom(
+ backgroundColor: Colors.white,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(8.0),
+ ),
+ ),
+ child: const Text(
+ 'Cancel',
+ style: TextStyle(color: Colors.black),
+ ),
+ ),
+ ],
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ },
+ );
+}
diff --git a/lib/pages/spaces_management/widgets/sidebar_widget.dart b/lib/pages/spaces_management/widgets/sidebar_widget.dart
index 44a45f0e..4e8a9046 100644
--- a/lib/pages/spaces_management/widgets/sidebar_widget.dart
+++ b/lib/pages/spaces_management/widgets/sidebar_widget.dart
@@ -7,7 +7,7 @@ import 'package:syncrow_web/pages/spaces_management/bloc/space_management_event.
import 'package:syncrow_web/pages/spaces_management/model/community_model.dart';
import 'package:syncrow_web/pages/spaces_management/model/space_model.dart';
import 'package:syncrow_web/pages/spaces_management/widgets/community_tile.dart';
-import 'package:syncrow_web/pages/spaces_management/view/dialogs/create_community_dialog.dart';
+import 'package:syncrow_web/pages/spaces_management/widgets/dialogs/create_community_dialog.dart';
import 'package:syncrow_web/pages/spaces_management/widgets/space_tile_widget.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
diff --git a/lib/services/space_mana_api.dart b/lib/services/space_mana_api.dart
index 892d9ecd..e09fe8f6 100644
--- a/lib/services/space_mana_api.dart
+++ b/lib/services/space_mana_api.dart
@@ -183,6 +183,7 @@ class CommunitySpaceManagementApi {
String? direction,
bool isPrivate = false,
required Offset position,
+ required List products,
}) async {
try {
final body = {
@@ -191,7 +192,8 @@ class CommunitySpaceManagementApi {
'x': position.dx,
'y': position.dy,
'direction': direction,
- 'icon': icon
+ 'icon': icon,
+ 'products': products.map((product) => product.toJson()).toList(),
};
if (parentId != null) {
body['parentUuid'] = parentId;
@@ -235,7 +237,10 @@ class CommunitySpaceManagementApi {
final response = await HTTPService().get(
path: ApiEndpoints.getSpaceHierarchy.replaceAll('{communityId}', communityId),
expectedResponseModel: (json) {
- return (json['data'] as List).map((spaceJson) => SpaceModel.fromJson(spaceJson)).toList();
+ final spaceModels =
+ (json['data'] as List).map((spaceJson) => SpaceModel.fromJson(spaceJson)).toList();
+
+ return spaceModels;
},
);
return response;
diff --git a/lib/utils/constants/assets.dart b/lib/utils/constants/assets.dart
index e37c36a1..4c359771 100644
--- a/lib/utils/constants/assets.dart
+++ b/lib/utils/constants/assets.dart
@@ -234,4 +234,6 @@ class Assets {
static const String garageDoor = 'assets/icons/garage_opener.svg';
static const String doorSensor = 'assets/icons/door_sensor.svg';
+
+ static const String delete = 'assets/icons/delete_svg';
}