mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
refactor: streamline context usage and improve readability in SidebarWidget
This commit is contained in:
@ -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(() {
|
||||
|
Reference in New Issue
Block a user