mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
deselect on outside
This commit is contained in:
@ -4,7 +4,6 @@ import 'package:syncrow_web/pages/common/text_field/custom_text_field.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/all_devices/bloc/device_managment_bloc.dart';
|
||||
import 'package:syncrow_web/pages/common/buttons/search_reset_buttons.dart';
|
||||
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
||||
import 'package:syncrow_web/utils/style.dart';
|
||||
|
||||
class DeviceSearchFilters extends StatefulWidget {
|
||||
const DeviceSearchFilters({super.key});
|
||||
|
@ -94,10 +94,13 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final visibleSpaces = flattenSpaces(widget.spaces);
|
||||
final visibleConnections = createConnections(widget.spaces);
|
||||
|
||||
Size screenSize = MediaQuery.of(context).size;
|
||||
return Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
_deselectSpace();
|
||||
},
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
border: Border(
|
||||
@ -147,17 +150,22 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
_updateNodePosition(entry.value, newPosition);
|
||||
},
|
||||
buildSpaceContainer: (int index) {
|
||||
return SpaceContainerWidget(
|
||||
index: index,
|
||||
onDoubleTap: () {
|
||||
_showEditSpaceDialog(visibleSpaces[index]);
|
||||
},
|
||||
onTap: () {
|
||||
_selectSpace(visibleSpaces[index]);
|
||||
},
|
||||
icon: visibleSpaces[index].icon ?? '',
|
||||
name: visibleSpaces[index].name,
|
||||
);
|
||||
final bool isHighlighted =
|
||||
_isHighlightedSpace(visibleSpaces[index]);
|
||||
|
||||
return Opacity(
|
||||
opacity: isHighlighted ? 1.0 : 0.3,
|
||||
child: SpaceContainerWidget(
|
||||
index: index,
|
||||
onDoubleTap: () {
|
||||
_showEditSpaceDialog(visibleSpaces[index]);
|
||||
},
|
||||
onTap: () {
|
||||
_selectSpace(visibleSpaces[index]);
|
||||
},
|
||||
icon: visibleSpaces[index].icon ?? '',
|
||||
name: visibleSpaces[index].name,
|
||||
));
|
||||
},
|
||||
),
|
||||
),
|
||||
@ -178,7 +186,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
Widget _buildHeader() {
|
||||
@ -570,4 +578,27 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
widget.onSpaceSelected!(space);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
return false; // Otherwise, reduce opacity
|
||||
}
|
||||
|
||||
void _deselectSpace() {
|
||||
if (widget.selectedSpace != null) {
|
||||
setState(() {
|
||||
widget.selectedSpace = null;
|
||||
});
|
||||
|
||||
if (widget.onSpaceSelected != null) {
|
||||
widget.onSpaceSelected!(null); // Notify parent that no space is selected
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user