mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +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/pages/spaces_management/structure_selector/bloc/center_body_event.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.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';
|
import 'package:syncrow_web/utils/style.dart';
|
||||||
|
|
||||||
class SidebarWidget extends StatefulWidget {
|
class SidebarWidget extends StatefulWidget {
|
||||||
@ -111,7 +112,7 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
|||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'Communities',
|
'Communities',
|
||||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
style: context.textTheme.titleMedium?.copyWith(
|
||||||
color: ColorsManager.blackColor,
|
color: ColorsManager.blackColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -153,9 +154,7 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _navigateToBlank(BuildContext context) {
|
void _navigateToBlank(BuildContext context) {
|
||||||
setState(() {
|
setState(() => _selectedId = '');
|
||||||
_selectedId = '';
|
|
||||||
});
|
|
||||||
context.read<SpaceManagementBloc>().add(
|
context.read<SpaceManagementBloc>().add(
|
||||||
NewCommunityEvent(communities: widget.communities),
|
NewCommunityEvent(communities: widget.communities),
|
||||||
);
|
);
|
||||||
@ -194,14 +193,14 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
|||||||
|
|
||||||
Widget _buildSpaceTile(SpaceModel space, CommunityModel community,
|
Widget _buildSpaceTile(SpaceModel space, CommunityModel community,
|
||||||
{int depth = 1}) {
|
{int depth = 1}) {
|
||||||
bool isExpandedSpace = _isSpaceOrChildSelected(space);
|
bool spaceIsExpanded = _isSpaceOrChildSelected(space);
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.only(left: depth * 16.0),
|
padding: EdgeInsets.only(left: depth * 16.0),
|
||||||
child: SpaceTile(
|
child: SpaceTile(
|
||||||
title: space.name,
|
title: space.name,
|
||||||
key: ValueKey(space.uuid),
|
key: ValueKey(space.uuid),
|
||||||
isSelected: _selectedId == space.uuid,
|
isSelected: _selectedId == space.uuid,
|
||||||
initiallyExpanded: isExpandedSpace,
|
initiallyExpanded: spaceIsExpanded,
|
||||||
onExpansionChanged: (expanded) {},
|
onExpansionChanged: (expanded) {},
|
||||||
onItemSelected: () {
|
onItemSelected: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
Reference in New Issue
Block a user