mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
fixed moving space on selecting space
This commit is contained in:
@ -44,6 +44,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
|||||||
List<Connection> connections = [];
|
List<Connection> connections = [];
|
||||||
late TextEditingController _nameController;
|
late TextEditingController _nameController;
|
||||||
bool isEditingName = false;
|
bool isEditingName = false;
|
||||||
|
late TransformationController _transformationController;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -54,11 +55,18 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
|||||||
_nameController = TextEditingController(
|
_nameController = TextEditingController(
|
||||||
text: widget.selectedCommunity?.name ?? '',
|
text: widget.selectedCommunity?.name ?? '',
|
||||||
);
|
);
|
||||||
|
_transformationController = TransformationController();
|
||||||
|
if (widget.selectedSpace != null) {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
_moveToSpace(widget.selectedSpace!);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_nameController.dispose();
|
_nameController.dispose();
|
||||||
|
_transformationController.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,6 +81,12 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
|||||||
_adjustCanvasSizeForSpaces();
|
_adjustCanvasSizeForSpaces();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (widget.selectedSpace != oldWidget.selectedSpace && widget.selectedSpace != null) {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
_moveToSpace(widget.selectedSpace!);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -97,6 +111,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
|||||||
children: [
|
children: [
|
||||||
if (visibleSpaces.isNotEmpty)
|
if (visibleSpaces.isNotEmpty)
|
||||||
InteractiveViewer(
|
InteractiveViewer(
|
||||||
|
transformationController: _transformationController,
|
||||||
boundaryMargin: EdgeInsets.all(500),
|
boundaryMargin: EdgeInsets.all(500),
|
||||||
minScale: 0.5,
|
minScale: 0.5,
|
||||||
maxScale: 3.0,
|
maxScale: 3.0,
|
||||||
@ -528,4 +543,16 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
|||||||
connection.endSpace.status == SpaceStatus.deleted;
|
connection.endSpace.status == SpaceStatus.deleted;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _moveToSpace(SpaceModel space) {
|
||||||
|
final double viewportWidth = MediaQuery.of(context).size.width;
|
||||||
|
final double viewportHeight = MediaQuery.of(context).size.height;
|
||||||
|
|
||||||
|
final double dx = -space.position.dx + (viewportWidth / 2) - 400;
|
||||||
|
final double dy = -space.position.dy + (viewportHeight / 2) - 350;
|
||||||
|
|
||||||
|
_transformationController.value = Matrix4.identity()
|
||||||
|
..translate(dx, dy)
|
||||||
|
..scale(1.2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user