mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-11-27 18:04:56 +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/device_managment/all_devices/bloc/device_managment_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/common/buttons/search_reset_buttons.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/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
||||||
import 'package:syncrow_web/utils/style.dart';
|
|
||||||
|
|
||||||
class DeviceSearchFilters extends StatefulWidget {
|
class DeviceSearchFilters extends StatefulWidget {
|
||||||
const DeviceSearchFilters({super.key});
|
const DeviceSearchFilters({super.key});
|
||||||
|
|||||||
@ -94,10 +94,13 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final visibleSpaces = flattenSpaces(widget.spaces);
|
final visibleSpaces = flattenSpaces(widget.spaces);
|
||||||
final visibleConnections = createConnections(widget.spaces);
|
|
||||||
|
|
||||||
Size screenSize = MediaQuery.of(context).size;
|
Size screenSize = MediaQuery.of(context).size;
|
||||||
return Expanded(
|
return Expanded(
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
_deselectSpace();
|
||||||
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
border: Border(
|
border: Border(
|
||||||
@ -147,7 +150,12 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
|||||||
_updateNodePosition(entry.value, newPosition);
|
_updateNodePosition(entry.value, newPosition);
|
||||||
},
|
},
|
||||||
buildSpaceContainer: (int index) {
|
buildSpaceContainer: (int index) {
|
||||||
return SpaceContainerWidget(
|
final bool isHighlighted =
|
||||||
|
_isHighlightedSpace(visibleSpaces[index]);
|
||||||
|
|
||||||
|
return Opacity(
|
||||||
|
opacity: isHighlighted ? 1.0 : 0.3,
|
||||||
|
child: SpaceContainerWidget(
|
||||||
index: index,
|
index: index,
|
||||||
onDoubleTap: () {
|
onDoubleTap: () {
|
||||||
_showEditSpaceDialog(visibleSpaces[index]);
|
_showEditSpaceDialog(visibleSpaces[index]);
|
||||||
@ -157,7 +165,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
|||||||
},
|
},
|
||||||
icon: visibleSpaces[index].icon ?? '',
|
icon: visibleSpaces[index].icon ?? '',
|
||||||
name: visibleSpaces[index].name,
|
name: visibleSpaces[index].name,
|
||||||
);
|
));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -178,7 +186,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildHeader() {
|
Widget _buildHeader() {
|
||||||
@ -570,4 +578,27 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
|||||||
widget.onSpaceSelected!(space);
|
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