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