mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-17 02:25:31 +00:00
push add ac fucntions and handle doplicate adding to the then or if items
This commit is contained in:
@ -10,24 +10,32 @@ class DraggableCard extends StatelessWidget {
|
||||
required this.title,
|
||||
this.titleColor,
|
||||
this.isDragged = false,
|
||||
this.isDisabled = false,
|
||||
});
|
||||
|
||||
final String imagePath;
|
||||
final String title;
|
||||
final Color? titleColor;
|
||||
final bool isDragged;
|
||||
final bool isDisabled;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Draggable<Map<String, String>>(
|
||||
Widget card = Draggable<Map<String, String>>(
|
||||
data: {'key': UniqueKey().toString(), 'imagePath': imagePath, 'title': title},
|
||||
feedback: Transform.rotate(
|
||||
angle: -0.1,
|
||||
child: _buildCardContent(context),
|
||||
),
|
||||
childWhenDragging: _buildGreyContainer(),
|
||||
child: isDragged ? _buildGreyContainer() : _buildCardContent(context),
|
||||
child: _buildCardContent(context),
|
||||
);
|
||||
|
||||
if (isDisabled) {
|
||||
card = AbsorbPointer(child: card);
|
||||
}
|
||||
|
||||
return card;
|
||||
}
|
||||
|
||||
Widget _buildCardContent(BuildContext context) {
|
||||
|
@ -28,12 +28,14 @@ class RoutineDevices extends StatelessWidget {
|
||||
return Wrap(
|
||||
spacing: 10,
|
||||
runSpacing: 10,
|
||||
children: deviceList
|
||||
.map((device) => DraggableCard(
|
||||
imagePath: device.getDefaultIcon(device.productType),
|
||||
title: device.name ?? '',
|
||||
))
|
||||
.toList(),
|
||||
children: deviceList.asMap().entries.map((entry) {
|
||||
final index = entry.key;
|
||||
final device = entry.value;
|
||||
return DraggableCard(
|
||||
imagePath: device.getDefaultIcon(device.productType),
|
||||
title: device.name ?? '',
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
}
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
|
@ -26,12 +26,14 @@ class ScenesAndAutomations extends StatelessWidget {
|
||||
return Wrap(
|
||||
spacing: 10,
|
||||
runSpacing: 10,
|
||||
children: scenes
|
||||
.map((scene) => DraggableCard(
|
||||
imagePath: Assets.logo,
|
||||
title: scene.name ?? '',
|
||||
))
|
||||
.toList(),
|
||||
children: scenes.asMap().entries.map((entry) {
|
||||
final index = entry.key;
|
||||
final scene = entry.value;
|
||||
return DraggableCard(
|
||||
imagePath: Assets.logo,
|
||||
title: scene.name ?? '',
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
}
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
|
Reference in New Issue
Block a user