updated edit flow

This commit is contained in:
hannathkadher
2025-01-27 01:25:04 +04:00
parent 812dc4792b
commit d0c6b13072

View File

@ -137,7 +137,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
selectedSpace: widget.selectedSpace,
onDelete: _onDelete,
onDuplicate: () => {_onDuplicate(context)},
onEdit: () => {},
onEdit: () => {_showEditSpaceDialog()},
onEditName: () {
setState(() {
isEditingName = !isEditingName;
@ -214,9 +214,6 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
opacity: isHighlighted ? 1.0 : 0.3,
child: SpaceContainerWidget(
index: index,
onDoubleTap: () {
_showEditSpaceDialog(spaces[index]);
},
onTap: () {
_selectSpace(context, spaces[index]);
},
@ -342,16 +339,17 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
);
}
void _showEditSpaceDialog(SpaceModel space) {
void _showEditSpaceDialog() {
if (widget.selectedSpace != null) {
showDialog(
context: context,
builder: (BuildContext context) {
return CreateSpaceDialog(
products: widget.products,
spaceModels: widget.spaceModels,
name: space.name,
icon: space.icon,
editSpace: space,
name: widget.selectedSpace!.name,
icon: widget.selectedSpace!.icon,
editSpace: widget.selectedSpace,
isEdit: true,
onCreateSpace: (String name,
String icon,
@ -361,22 +359,24 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
List<Tag>? tags) {
setState(() {
// Update the space's properties
space.name = name;
space.icon = icon;
space.spaceModel = spaceModel;
space.subspaces = subspaces;
space.tags = tags;
widget.selectedSpace!.name = name;
widget.selectedSpace!.icon = icon;
widget.selectedSpace!.spaceModel = spaceModel;
widget.selectedSpace!.subspaces = subspaces;
widget.selectedSpace!.tags = tags;
if (space.status != SpaceStatus.newSpace) {
space.status = SpaceStatus.modified; // Mark as modified
if (widget.selectedSpace!.status != SpaceStatus.newSpace) {
widget.selectedSpace!.status =
SpaceStatus.modified; // Mark as modified
}
});
},
key: Key(space.name),
key: Key(widget.selectedSpace!.name),
);
},
);
}
}
void _handleHoverChanged(int index, bool isHovered) {
setState(() {