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