From 83b95559203fa25fddb4c76ba9879d8316b8d97c Mon Sep 17 00:00:00 2001 From: hannathkadher Date: Sun, 9 Mar 2025 10:26:30 +0400 Subject: [PATCH 1/3] added padding to space tree on community structure --- lib/common/widgets/custom_expansion_tile.dart | 2 +- .../space_tree/view/custom_expansion.dart | 2 +- .../all_spaces/widgets/community_tile.dart | 2 +- .../widgets/loaded_space_widget.dart | 10 ++-- .../all_spaces/widgets/sidebar_widget.dart | 46 ++++++++++--------- .../all_spaces/widgets/space_tile_widget.dart | 28 +++++------ .../space_model/bloc/space_model_bloc.dart | 32 +++++-------- 7 files changed, 59 insertions(+), 63 deletions(-) diff --git a/lib/common/widgets/custom_expansion_tile.dart b/lib/common/widgets/custom_expansion_tile.dart index 3823b18f..74151ca2 100644 --- a/lib/common/widgets/custom_expansion_tile.dart +++ b/lib/common/widgets/custom_expansion_tile.dart @@ -101,7 +101,7 @@ class CustomExpansionTileState extends State { widget.children != null && widget.children!.isNotEmpty) Padding( - padding: const EdgeInsets.only(left: 48.0), // Indented children + padding: const EdgeInsets.only(left: 24.0), // Indented children child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: widget.children!, diff --git a/lib/pages/space_tree/view/custom_expansion.dart b/lib/pages/space_tree/view/custom_expansion.dart index 9e40f320..515a8448 100644 --- a/lib/pages/space_tree/view/custom_expansion.dart +++ b/lib/pages/space_tree/view/custom_expansion.dart @@ -83,7 +83,7 @@ class CustomExpansionTileSpaceTree extends StatelessWidget { ), if (isExpanded && children != null && children!.isNotEmpty) Padding( - padding: const EdgeInsets.only(left: 48.0), + padding: const EdgeInsets.only(left: 24.0), child: Column( children: children ?? [], ), diff --git a/lib/pages/spaces_management/all_spaces/widgets/community_tile.dart b/lib/pages/spaces_management/all_spaces/widgets/community_tile.dart index 9bd45671..b097b0c3 100644 --- a/lib/pages/spaces_management/all_spaces/widgets/community_tile.dart +++ b/lib/pages/spaces_management/all_spaces/widgets/community_tile.dart @@ -22,7 +22,7 @@ class CommunityTile extends StatelessWidget { @override Widget build(BuildContext context) { return Padding( - padding: const EdgeInsets.only(left: 16.0), + padding: const EdgeInsets.all(8.0), child: CustomExpansionTile( title: title, initiallyExpanded: isExpanded, diff --git a/lib/pages/spaces_management/all_spaces/widgets/loaded_space_widget.dart b/lib/pages/spaces_management/all_spaces/widgets/loaded_space_widget.dart index 4d6fc3fb..2961116f 100644 --- a/lib/pages/spaces_management/all_spaces/widgets/loaded_space_widget.dart +++ b/lib/pages/spaces_management/all_spaces/widgets/loaded_space_widget.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart'; import 'package:syncrow_web/pages/space_tree/view/space_tree_view.dart'; import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart'; import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart'; @@ -81,11 +82,11 @@ class _LoadedSpaceViewState extends State { ? _spaceModels.isNotEmpty ? Row( children: [ - SizedBox( - width: 300, child: SpaceTreeView(onSelect: () {})), + SizedBox(width: 300, child: SpaceTreeView(onSelect: () {})), Expanded( child: BlocProvider( create: (context) => SpaceModelBloc( + BlocProvider.of(context), api: SpaceModelManagementApi(), initialSpaceModels: _spaceModels, ), @@ -102,9 +103,8 @@ class _LoadedSpaceViewState extends State { children: [ SidebarWidget( communities: widget.communities, - selectedSpaceUuid: widget.selectedSpace?.uuid ?? - widget.selectedCommunity?.uuid ?? - '', + selectedSpaceUuid: + widget.selectedSpace?.uuid ?? widget.selectedCommunity?.uuid ?? '', ), CommunityStructureArea( selectedCommunity: widget.selectedCommunity, diff --git a/lib/pages/spaces_management/all_spaces/widgets/sidebar_widget.dart b/lib/pages/spaces_management/all_spaces/widgets/sidebar_widget.dart index a38743dc..17566da7 100644 --- a/lib/pages/spaces_management/all_spaces/widgets/sidebar_widget.dart +++ b/lib/pages/spaces_management/all_spaces/widgets/sidebar_widget.dart @@ -205,30 +205,32 @@ class _SidebarWidgetState extends State { ); } - Widget _buildSpaceTile(SpaceModel space, CommunityModel community) { + Widget _buildSpaceTile(SpaceModel space, CommunityModel community, {int depth = 1}) { bool isExpandedSpace = _isSpaceOrChildSelected(space); - return SpaceTile( - title: space.name, - key: ValueKey(space.uuid), - isSelected: _selectedId == space.uuid, - initiallyExpanded: isExpandedSpace, - onExpansionChanged: (bool expanded) { - _handleExpansionChange(space.uuid ?? '', expanded); - }, - onItemSelected: () { - setState(() { - _selectedId = space.uuid; - _selectedSpaceUuid = space.uuid; - }); + return Padding( + padding: EdgeInsets.only(left: depth * 16.0), + child: SpaceTile( + title: space.name, + key: ValueKey(space.uuid), + isSelected: _selectedId == space.uuid, + initiallyExpanded: isExpandedSpace, + onExpansionChanged: (bool expanded) { + _handleExpansionChange(space.uuid ?? '', expanded); + }, + onItemSelected: () { + setState(() { + _selectedId = space.uuid; + _selectedSpaceUuid = space.uuid; + }); - context.read().add( - SelectSpaceEvent(selectedCommunity: community, selectedSpace: space), - ); - }, - children: space.children.isNotEmpty - ? space.children.map((childSpace) => _buildSpaceTile(childSpace, community)).toList() - : [], // Recursively render child spaces if available - ); + context.read().add( + SelectSpaceEvent(selectedCommunity: community, selectedSpace: space), + ); + }, + children: space.children.isNotEmpty + ? space.children.map((childSpace) => _buildSpaceTile(childSpace, community)).toList() + : [], // Recursively render child spaces if available + )); } void _handleExpansionChange(String uuid, bool expanded) {} diff --git a/lib/pages/spaces_management/all_spaces/widgets/space_tile_widget.dart b/lib/pages/spaces_management/all_spaces/widgets/space_tile_widget.dart index 63cf9b7d..d72f22ac 100644 --- a/lib/pages/spaces_management/all_spaces/widgets/space_tile_widget.dart +++ b/lib/pages/spaces_management/all_spaces/widgets/space_tile_widget.dart @@ -35,18 +35,20 @@ class _SpaceTileState extends State { @override Widget build(BuildContext context) { - return CustomExpansionTile( - isSelected: widget.isSelected, - title: widget.title, - initiallyExpanded: _isExpanded, - onItemSelected: widget.onItemSelected, - onExpansionChanged: (bool expanded) { - setState(() { - _isExpanded = expanded; - }); - widget.onExpansionChanged(expanded); - }, - children: widget.children ?? [], - ); + return Padding( + padding: const EdgeInsets.only(left: 8.0, right: 8.0, top: 8.0), + child: CustomExpansionTile( + isSelected: widget.isSelected, + title: widget.title, + initiallyExpanded: _isExpanded, + onItemSelected: widget.onItemSelected, + onExpansionChanged: (bool expanded) { + setState(() { + _isExpanded = expanded; + }); + widget.onExpansionChanged(expanded); + }, + children: widget.children ?? [], + )); } } diff --git a/lib/pages/spaces_management/space_model/bloc/space_model_bloc.dart b/lib/pages/spaces_management/space_model/bloc/space_model_bloc.dart index ed6ffa71..4623a0ae 100644 --- a/lib/pages/spaces_management/space_model/bloc/space_model_bloc.dart +++ b/lib/pages/spaces_management/space_model/bloc/space_model_bloc.dart @@ -1,7 +1,6 @@ -import 'dart:developer'; - import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:syncrow_web/pages/common/bloc/project_manager.dart'; +import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart'; import 'package:syncrow_web/pages/spaces_management/space_model/bloc/space_model_event.dart'; import 'package:syncrow_web/pages/spaces_management/space_model/bloc/space_model_state.dart'; import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart'; @@ -9,33 +8,30 @@ import 'package:syncrow_web/services/space_model_mang_api.dart'; class SpaceModelBloc extends Bloc { final SpaceModelManagementApi api; + final SpaceTreeBloc _spaceTreeBloc; - SpaceModelBloc({ + SpaceModelBloc( + this._spaceTreeBloc, { required this.api, required List initialSpaceModels, }) : super(SpaceModelLoaded(spaceModels: initialSpaceModels)) { - log('Initial Space Models in: ${initialSpaceModels.map((e) => e.toJson()).toList()}'); - on(_onCreateSpaceModel); on(_onUpdateSpaceModel); on(_onDeleteSpaceModel); } - Future _onCreateSpaceModel( - CreateSpaceModel event, Emitter emit) async { + Future _onCreateSpaceModel(CreateSpaceModel event, Emitter emit) async { final currentState = state; if (currentState is SpaceModelLoaded) { try { final projectUuid = await ProjectManager.getProjectUUID() ?? ''; - final newSpaceModel = await api.getSpaceModel( - event.newSpaceModel.uuid ?? '', projectUuid); + final newSpaceModel = await api.getSpaceModel(event.newSpaceModel.uuid ?? '', projectUuid); if (newSpaceModel != null) { - final updatedSpaceModels = - List.from(currentState.spaceModels) - ..add(newSpaceModel); + final updatedSpaceModels = List.from(currentState.spaceModels) + ..add(newSpaceModel); emit(SpaceModelLoaded(spaceModels: updatedSpaceModels)); } } catch (e) { @@ -44,15 +40,13 @@ class SpaceModelBloc extends Bloc { } } - Future _onUpdateSpaceModel( - UpdateSpaceModel event, Emitter emit) async { + Future _onUpdateSpaceModel(UpdateSpaceModel event, Emitter emit) async { final currentState = state; if (currentState is SpaceModelLoaded) { try { final projectUuid = await ProjectManager.getProjectUUID() ?? ''; - final newSpaceModel = - await api.getSpaceModel(event.spaceModelUuid, projectUuid); + final newSpaceModel = await api.getSpaceModel(event.spaceModelUuid, projectUuid); if (newSpaceModel != null) { final updatedSpaceModels = currentState.spaceModels.map((model) { return model.uuid == event.spaceModelUuid ? newSpaceModel : model; @@ -65,16 +59,14 @@ class SpaceModelBloc extends Bloc { } } - Future _onDeleteSpaceModel( - DeleteSpaceModel event, Emitter emit) async { + Future _onDeleteSpaceModel(DeleteSpaceModel event, Emitter emit) async { final currentState = state; if (currentState is SpaceModelLoaded) { try { final projectUuid = await ProjectManager.getProjectUUID() ?? ''; - final deletedSuccessfully = - await api.deleteSpaceModel(event.spaceModelUuid, projectUuid); + final deletedSuccessfully = await api.deleteSpaceModel(event.spaceModelUuid, projectUuid); if (deletedSuccessfully) { final updatedSpaceModels = currentState.spaceModels From ada19a59923cab236892200f3e4aa786fb71fcf0 Mon Sep 17 00:00:00 2001 From: hannathkadher Date: Sun, 9 Mar 2025 10:47:09 +0400 Subject: [PATCH 2/3] fetch communities and spaces on space model update --- .../spaces_management/space_model/bloc/space_model_bloc.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/pages/spaces_management/space_model/bloc/space_model_bloc.dart b/lib/pages/spaces_management/space_model/bloc/space_model_bloc.dart index 4623a0ae..37a8c0a9 100644 --- a/lib/pages/spaces_management/space_model/bloc/space_model_bloc.dart +++ b/lib/pages/spaces_management/space_model/bloc/space_model_bloc.dart @@ -1,6 +1,7 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:syncrow_web/pages/common/bloc/project_manager.dart'; import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart'; +import 'package:syncrow_web/pages/space_tree/bloc/space_tree_event.dart'; import 'package:syncrow_web/pages/spaces_management/space_model/bloc/space_model_event.dart'; import 'package:syncrow_web/pages/spaces_management/space_model/bloc/space_model_state.dart'; import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart'; @@ -51,6 +52,7 @@ class SpaceModelBloc extends Bloc { final updatedSpaceModels = currentState.spaceModels.map((model) { return model.uuid == event.spaceModelUuid ? newSpaceModel : model; }).toList(); + _spaceTreeBloc.add(InitialEvent()); emit(SpaceModelLoaded(spaceModels: updatedSpaceModels)); } } catch (e) { @@ -72,7 +74,7 @@ class SpaceModelBloc extends Bloc { final updatedSpaceModels = currentState.spaceModels .where((model) => model.uuid != event.spaceModelUuid) .toList(); - + _spaceTreeBloc.add(InitialEvent()); emit(SpaceModelLoaded(spaceModels: updatedSpaceModels)); } } catch (e) { From 24280549ec4541efa80ecfe354ac97a14095bdbf Mon Sep 17 00:00:00 2001 From: hannathkadher Date: Sun, 9 Mar 2025 14:06:33 +0400 Subject: [PATCH 3/3] revert back color change --- lib/utils/color_manager.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utils/color_manager.dart b/lib/utils/color_manager.dart index 4e506093..a4bcc0da 100644 --- a/lib/utils/color_manager.dart +++ b/lib/utils/color_manager.dart @@ -52,7 +52,7 @@ abstract class ColorsManager { static const Color semiTransparentBlackColor = Color(0x3F000000); static const Color transparentColor = Color(0x00000000); static const Color spaceColor = Color(0xB2023DFE); - static const Color counterBackgroundColor = Color.fromARGB(204, 105, 2, 2); + static const Color counterBackgroundColor = Color(0xCCF4F4F4); static const Color neutralGray = Color(0xFFE5E5E5); static const Color warningRed = Color(0xFFFF6465); static const Color borderColor = Color(0xFFE5E5E5);