refactor: streamline context usage and improve readability in SidebarWidget

This commit is contained in:
Faris Armoush
2025-04-13 12:31:17 +03:00
parent cd9821679e
commit c2f5a8df10

View File

@ -12,6 +12,7 @@ import 'package:syncrow_web/pages/spaces_management/structure_selector/bloc/cent
import 'package:syncrow_web/pages/spaces_management/structure_selector/bloc/center_body_event.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
import 'package:syncrow_web/utils/extension/build_context_x.dart';
import 'package:syncrow_web/utils/style.dart';
class SidebarWidget extends StatefulWidget {
@ -111,7 +112,7 @@ class _SidebarWidgetState extends State<SidebarWidget> {
children: [
Text(
'Communities',
style: Theme.of(context).textTheme.titleMedium?.copyWith(
style: context.textTheme.titleMedium?.copyWith(
color: ColorsManager.blackColor,
),
),
@ -153,9 +154,7 @@ class _SidebarWidgetState extends State<SidebarWidget> {
}
void _navigateToBlank(BuildContext context) {
setState(() {
_selectedId = '';
});
setState(() => _selectedId = '');
context.read<SpaceManagementBloc>().add(
NewCommunityEvent(communities: widget.communities),
);
@ -194,14 +193,14 @@ class _SidebarWidgetState extends State<SidebarWidget> {
Widget _buildSpaceTile(SpaceModel space, CommunityModel community,
{int depth = 1}) {
bool isExpandedSpace = _isSpaceOrChildSelected(space);
bool spaceIsExpanded = _isSpaceOrChildSelected(space);
return Padding(
padding: EdgeInsets.only(left: depth * 16.0),
child: SpaceTile(
title: space.name,
key: ValueKey(space.uuid),
isSelected: _selectedId == space.uuid,
initiallyExpanded: isExpandedSpace,
initiallyExpanded: spaceIsExpanded,
onExpansionChanged: (expanded) {},
onItemSelected: () {
setState(() {