Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class _MyHomeView extends StatefulWidget {
}

class _MyHomeViewState extends State<_MyHomeView> {
bool isDraggableDeskShown = false;
List<DeskPayload> desks = [];
DeskPayload? lastModifiedObject;

Expand All @@ -103,18 +102,19 @@ class _MyHomeViewState extends State<_MyHomeView> {
)
: null,
actions: [
InkWell(
onTap: () {
if (lastModifiedObject != null) {
desks = desks.toList()..add(lastModifiedObject!);
lastModifiedObject = null;
setState(() {});
}
},
child: const Center(
child: Text('Save'),
if (lastModifiedObject != null)
InkWell(
onTap: () {
if (lastModifiedObject != null) {
desks = desks.toList()..add(lastModifiedObject!);
lastModifiedObject = null;
setState(() {});
}
},
child: const Center(
child: Text('Save'),
),
),
),
InkWell(
onTap: () {
lastModifiedObject =
Expand Down
2 changes: 0 additions & 2 deletions lib/src/edit_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,6 @@ class _DraggableDeskWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Transform.rotate(
origin: Offset(-commonDeskSize.width * officeMap!.ratio / 2,
-commonDeskSize.height * officeMap!.ratio / 2),
angle: rotation * math.pi / 180,
child: Container(
padding: const EdgeInsets.all(_draggableDeskPadding),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/src/builders/graphic/desk_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DeskBuilder {
params.area.position!.dy,
rotation: params.area.rotation,
stateType: StateType.main,
size: commonTabletopSize,
size: commonDeskSize,
states: Params(
params.isBooked ? bookedDeskState : defaultDeskState,
activeDeskState,
Expand Down
4 changes: 3 additions & 1 deletion lib/src/src/models/graphic/base_graphic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ abstract class BaseGraphic implements ObjectInterface {
Offset(topLeft.dx, topLeft.dy + commonDeskSize.height),
];

final center = determinateRectCenter(shape);

return rotation == 0
? shape
: shape.map((e) => rotatePoint(e, shape.first, rotation)).toList();
: shape.map((e) => rotatePoint(e, center, rotation)).toList();
}

Size getSize() {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/src/models/graphic/desk/desk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ class Desk extends BaseGraphic {
void draw(Canvas canvas) {
canvas.save();

canvas.translate(x, y);
canvas.translate(x + (size.width / 2), y + (size.height / 2));
canvas.rotate(rotation * math.pi / 180);
canvas.translate(-(x), -(y));
canvas.translate(-(x + (size.width / 2)), -(y + (size.height / 2)));

final DeskState state =
stateType == StateType.active ? states.active : states.main;
Expand Down
14 changes: 0 additions & 14 deletions lib/src/src/models/graphic/office_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,6 @@ class OfficeMap extends Object with IterableMixin<BaseGraphic> {
// the center of the board in both coordinate systems. If no BoardPoint at the
// location, return null.
BaseGraphic? determinateSelectedObject(Offset offset) {
// final pointCentered = Offset(
// point.dx - size.width / 2,
// point.dy - size.height / 2,
// );
// final boardPoint = ObjectInterface(
// ((sqrt(3) / 3 * pointCentered.dx - 1 / 3 * pointCentered.dy) /
// hexagonRadius)
// .round(),
// ((2 / 3 * pointCentered.dy) / hexagonRadius).round(),
// );

// if (!_validateBoardPoint(boardPoint)) {
// return null;
// }
Offset point = Offset(offset.dx, offset.dy);
BaseGraphic? selectedGraphic;
for (final object in _mapObjects) {
Expand Down