updated first space position

This commit is contained in:
hannathkadher
2024-11-27 12:10:36 +04:00
parent ee50c414c3
commit 670be70567

View File

@ -209,7 +209,8 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
Center( Center(
child: AddSpaceButton( child: AddSpaceButton(
onTap: () { onTap: () {
_showCreateSpaceDialog(screenSize); _showCreateSpaceDialog(screenSize,
canvasHeight: canvasHeight, canvasWidth: canvasWidth);
}, },
), ),
), ),
@ -259,7 +260,11 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
} }
void _showCreateSpaceDialog(Size screenSize, void _showCreateSpaceDialog(Size screenSize,
{Offset? position, int? parentIndex, String? direction}) { {Offset? position,
int? parentIndex,
String? direction,
double? canvasWidth,
double? canvasHeight}) {
showDialog( showDialog(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
@ -268,11 +273,8 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
onCreateSpace: (String name, String icon, List<SelectedProduct> selectedProducts) { onCreateSpace: (String name, String icon, List<SelectedProduct> selectedProducts) {
setState(() { setState(() {
// Set the first space in the center or use passed position // Set the first space in the center or use passed position
Offset centerPosition = position ??
Offset( Offset centerPosition = position ?? _getCenterPosition(screenSize);
screenSize.width / 2 - 75, // Center horizontally
screenSize.height / 2 - 50, // Slightly above the center vertically
);
SpaceModel newSpace = SpaceModel( SpaceModel newSpace = SpaceModel(
name: name, name: name,
icon: icon, icon: icon,
@ -476,7 +478,6 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
bool _isHighlightedSpace(SpaceModel space) { bool _isHighlightedSpace(SpaceModel space) {
if (widget.selectedSpace == null) return true; if (widget.selectedSpace == null) return true;
if (space == widget.selectedSpace) return true; if (space == widget.selectedSpace) return true;
if (widget.selectedSpace?.parent?.name == space.name && if (widget.selectedSpace?.parent?.name == space.name &&
widget.selectedSpace?.parent?.position == space.position) return true; widget.selectedSpace?.parent?.position == space.position) return true;
if (widget.selectedSpace?.children.contains(space) == true) return true; if (widget.selectedSpace?.children.contains(space) == true) return true;
@ -502,4 +503,11 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
return connection.startSpace == widget.selectedSpace || return connection.startSpace == widget.selectedSpace ||
connection.endSpace == widget.selectedSpace; connection.endSpace == widget.selectedSpace;
} }
Offset _getCenterPosition(Size screenSize) {
return Offset(
screenSize.width / 2 - 260,
screenSize.height / 2 - 200,
);
}
} }