mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
75 lines
2.3 KiB
Dart
75 lines
2.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'plus_button_widget.dart'; // Make sure to import your PlusButtonWidget
|
|
|
|
class SpaceCardWidget extends StatelessWidget {
|
|
final int index;
|
|
final Size screenSize;
|
|
final Offset position;
|
|
final bool isHovered;
|
|
final Function(int index, Offset delta) onPanUpdate;
|
|
final Function(int index, bool isHovered) onHoverChanged;
|
|
final Function(int index, Offset newPosition, String direction) onButtonTap;
|
|
final Widget Function(int index) buildSpaceContainer;
|
|
|
|
const SpaceCardWidget({
|
|
super.key,
|
|
required this.index,
|
|
required this.screenSize,
|
|
required this.position,
|
|
required this.isHovered,
|
|
required this.onPanUpdate,
|
|
required this.onHoverChanged,
|
|
required this.onButtonTap,
|
|
required this.buildSpaceContainer,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GestureDetector(
|
|
onPanUpdate: (details) {
|
|
// Call the provided callback to update the position
|
|
onPanUpdate(index, details.delta);
|
|
},
|
|
child: MouseRegion(
|
|
onEnter: (_) {
|
|
// Call the provided callback to handle hover state
|
|
onHoverChanged(index, true);
|
|
},
|
|
onExit: (_) {
|
|
// Call the provided callback to handle hover state
|
|
onHoverChanged(index, false);
|
|
},
|
|
child: Stack(
|
|
clipBehavior: Clip.none, // Allow hovering elements to be displayed outside the boundary
|
|
children: [
|
|
buildSpaceContainer(index), // Build the space container
|
|
if (isHovered) ...[
|
|
PlusButtonWidget(
|
|
index: index,
|
|
direction: 'left',
|
|
offset: const Offset(-21, 20),
|
|
screenSize: screenSize,
|
|
onButtonTap: onButtonTap,
|
|
),
|
|
PlusButtonWidget(
|
|
index: index,
|
|
direction: 'right',
|
|
offset: const Offset(140, 20),
|
|
screenSize: screenSize,
|
|
onButtonTap: onButtonTap,
|
|
),
|
|
PlusButtonWidget(
|
|
index: index,
|
|
direction: 'down',
|
|
offset: const Offset(63, 50),
|
|
screenSize: screenSize,
|
|
onButtonTap: onButtonTap,
|
|
),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|