mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
added padding to space tree on community structure
This commit is contained in:
@ -101,7 +101,7 @@ class CustomExpansionTileState extends State<CustomExpansionTile> {
|
|||||||
widget.children != null &&
|
widget.children != null &&
|
||||||
widget.children!.isNotEmpty)
|
widget.children!.isNotEmpty)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 48.0), // Indented children
|
padding: const EdgeInsets.only(left: 24.0), // Indented children
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: widget.children!,
|
children: widget.children!,
|
||||||
|
@ -83,7 +83,7 @@ class CustomExpansionTileSpaceTree extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
if (isExpanded && children != null && children!.isNotEmpty)
|
if (isExpanded && children != null && children!.isNotEmpty)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 48.0),
|
padding: const EdgeInsets.only(left: 24.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: children ?? [],
|
children: children ?? [],
|
||||||
),
|
),
|
||||||
|
@ -22,7 +22,7 @@ class CommunityTile extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(left: 16.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: CustomExpansionTile(
|
child: CustomExpansionTile(
|
||||||
title: title,
|
title: title,
|
||||||
initiallyExpanded: isExpanded,
|
initiallyExpanded: isExpanded,
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.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/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/community_model.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart';
|
||||||
@ -81,11 +82,11 @@ class _LoadedSpaceViewState extends State<LoadedSpaceView> {
|
|||||||
? _spaceModels.isNotEmpty
|
? _spaceModels.isNotEmpty
|
||||||
? Row(
|
? Row(
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
SizedBox(width: 300, child: SpaceTreeView(onSelect: () {})),
|
||||||
width: 300, child: SpaceTreeView(onSelect: () {})),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: BlocProvider(
|
child: BlocProvider(
|
||||||
create: (context) => SpaceModelBloc(
|
create: (context) => SpaceModelBloc(
|
||||||
|
BlocProvider.of<SpaceTreeBloc>(context),
|
||||||
api: SpaceModelManagementApi(),
|
api: SpaceModelManagementApi(),
|
||||||
initialSpaceModels: _spaceModels,
|
initialSpaceModels: _spaceModels,
|
||||||
),
|
),
|
||||||
@ -102,9 +103,8 @@ class _LoadedSpaceViewState extends State<LoadedSpaceView> {
|
|||||||
children: [
|
children: [
|
||||||
SidebarWidget(
|
SidebarWidget(
|
||||||
communities: widget.communities,
|
communities: widget.communities,
|
||||||
selectedSpaceUuid: widget.selectedSpace?.uuid ??
|
selectedSpaceUuid:
|
||||||
widget.selectedCommunity?.uuid ??
|
widget.selectedSpace?.uuid ?? widget.selectedCommunity?.uuid ?? '',
|
||||||
'',
|
|
||||||
),
|
),
|
||||||
CommunityStructureArea(
|
CommunityStructureArea(
|
||||||
selectedCommunity: widget.selectedCommunity,
|
selectedCommunity: widget.selectedCommunity,
|
||||||
|
@ -205,9 +205,11 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildSpaceTile(SpaceModel space, CommunityModel community) {
|
Widget _buildSpaceTile(SpaceModel space, CommunityModel community, {int depth = 1}) {
|
||||||
bool isExpandedSpace = _isSpaceOrChildSelected(space);
|
bool isExpandedSpace = _isSpaceOrChildSelected(space);
|
||||||
return SpaceTile(
|
return Padding(
|
||||||
|
padding: EdgeInsets.only(left: depth * 16.0),
|
||||||
|
child: SpaceTile(
|
||||||
title: space.name,
|
title: space.name,
|
||||||
key: ValueKey(space.uuid),
|
key: ValueKey(space.uuid),
|
||||||
isSelected: _selectedId == space.uuid,
|
isSelected: _selectedId == space.uuid,
|
||||||
@ -228,7 +230,7 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
|||||||
children: space.children.isNotEmpty
|
children: space.children.isNotEmpty
|
||||||
? space.children.map((childSpace) => _buildSpaceTile(childSpace, community)).toList()
|
? space.children.map((childSpace) => _buildSpaceTile(childSpace, community)).toList()
|
||||||
: [], // Recursively render child spaces if available
|
: [], // Recursively render child spaces if available
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleExpansionChange(String uuid, bool expanded) {}
|
void _handleExpansionChange(String uuid, bool expanded) {}
|
||||||
|
@ -35,7 +35,9 @@ class _SpaceTileState extends State<SpaceTile> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return CustomExpansionTile(
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 8.0, right: 8.0, top: 8.0),
|
||||||
|
child: CustomExpansionTile(
|
||||||
isSelected: widget.isSelected,
|
isSelected: widget.isSelected,
|
||||||
title: widget.title,
|
title: widget.title,
|
||||||
initiallyExpanded: _isExpanded,
|
initiallyExpanded: _isExpanded,
|
||||||
@ -47,6 +49,6 @@ class _SpaceTileState extends State<SpaceTile> {
|
|||||||
widget.onExpansionChanged(expanded);
|
widget.onExpansionChanged(expanded);
|
||||||
},
|
},
|
||||||
children: widget.children ?? [],
|
children: widget.children ?? [],
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import 'dart:developer';
|
|
||||||
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/common/bloc/project_manager.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_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/bloc/space_model_state.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
|
||||||
@ -9,32 +8,29 @@ import 'package:syncrow_web/services/space_model_mang_api.dart';
|
|||||||
|
|
||||||
class SpaceModelBloc extends Bloc<SpaceModelEvent, SpaceModelState> {
|
class SpaceModelBloc extends Bloc<SpaceModelEvent, SpaceModelState> {
|
||||||
final SpaceModelManagementApi api;
|
final SpaceModelManagementApi api;
|
||||||
|
final SpaceTreeBloc _spaceTreeBloc;
|
||||||
|
|
||||||
SpaceModelBloc({
|
SpaceModelBloc(
|
||||||
|
this._spaceTreeBloc, {
|
||||||
required this.api,
|
required this.api,
|
||||||
required List<SpaceTemplateModel> initialSpaceModels,
|
required List<SpaceTemplateModel> initialSpaceModels,
|
||||||
}) : super(SpaceModelLoaded(spaceModels: initialSpaceModels)) {
|
}) : super(SpaceModelLoaded(spaceModels: initialSpaceModels)) {
|
||||||
log('Initial Space Models in: ${initialSpaceModels.map((e) => e.toJson()).toList()}');
|
|
||||||
|
|
||||||
on<CreateSpaceModel>(_onCreateSpaceModel);
|
on<CreateSpaceModel>(_onCreateSpaceModel);
|
||||||
on<UpdateSpaceModel>(_onUpdateSpaceModel);
|
on<UpdateSpaceModel>(_onUpdateSpaceModel);
|
||||||
on<DeleteSpaceModel>(_onDeleteSpaceModel);
|
on<DeleteSpaceModel>(_onDeleteSpaceModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onCreateSpaceModel(
|
Future<void> _onCreateSpaceModel(CreateSpaceModel event, Emitter<SpaceModelState> emit) async {
|
||||||
CreateSpaceModel event, Emitter<SpaceModelState> emit) async {
|
|
||||||
final currentState = state;
|
final currentState = state;
|
||||||
|
|
||||||
if (currentState is SpaceModelLoaded) {
|
if (currentState is SpaceModelLoaded) {
|
||||||
try {
|
try {
|
||||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||||
|
|
||||||
final newSpaceModel = await api.getSpaceModel(
|
final newSpaceModel = await api.getSpaceModel(event.newSpaceModel.uuid ?? '', projectUuid);
|
||||||
event.newSpaceModel.uuid ?? '', projectUuid);
|
|
||||||
|
|
||||||
if (newSpaceModel != null) {
|
if (newSpaceModel != null) {
|
||||||
final updatedSpaceModels =
|
final updatedSpaceModels = List<SpaceTemplateModel>.from(currentState.spaceModels)
|
||||||
List<SpaceTemplateModel>.from(currentState.spaceModels)
|
|
||||||
..add(newSpaceModel);
|
..add(newSpaceModel);
|
||||||
emit(SpaceModelLoaded(spaceModels: updatedSpaceModels));
|
emit(SpaceModelLoaded(spaceModels: updatedSpaceModels));
|
||||||
}
|
}
|
||||||
@ -44,15 +40,13 @@ class SpaceModelBloc extends Bloc<SpaceModelEvent, SpaceModelState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onUpdateSpaceModel(
|
Future<void> _onUpdateSpaceModel(UpdateSpaceModel event, Emitter<SpaceModelState> emit) async {
|
||||||
UpdateSpaceModel event, Emitter<SpaceModelState> emit) async {
|
|
||||||
final currentState = state;
|
final currentState = state;
|
||||||
if (currentState is SpaceModelLoaded) {
|
if (currentState is SpaceModelLoaded) {
|
||||||
try {
|
try {
|
||||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||||
|
|
||||||
final newSpaceModel =
|
final newSpaceModel = await api.getSpaceModel(event.spaceModelUuid, projectUuid);
|
||||||
await api.getSpaceModel(event.spaceModelUuid, projectUuid);
|
|
||||||
if (newSpaceModel != null) {
|
if (newSpaceModel != null) {
|
||||||
final updatedSpaceModels = currentState.spaceModels.map((model) {
|
final updatedSpaceModels = currentState.spaceModels.map((model) {
|
||||||
return model.uuid == event.spaceModelUuid ? newSpaceModel : model;
|
return model.uuid == event.spaceModelUuid ? newSpaceModel : model;
|
||||||
@ -65,16 +59,14 @@ class SpaceModelBloc extends Bloc<SpaceModelEvent, SpaceModelState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onDeleteSpaceModel(
|
Future<void> _onDeleteSpaceModel(DeleteSpaceModel event, Emitter<SpaceModelState> emit) async {
|
||||||
DeleteSpaceModel event, Emitter<SpaceModelState> emit) async {
|
|
||||||
final currentState = state;
|
final currentState = state;
|
||||||
|
|
||||||
if (currentState is SpaceModelLoaded) {
|
if (currentState is SpaceModelLoaded) {
|
||||||
try {
|
try {
|
||||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||||
|
|
||||||
final deletedSuccessfully =
|
final deletedSuccessfully = await api.deleteSpaceModel(event.spaceModelUuid, projectUuid);
|
||||||
await api.deleteSpaceModel(event.spaceModelUuid, projectUuid);
|
|
||||||
|
|
||||||
if (deletedSuccessfully) {
|
if (deletedSuccessfully) {
|
||||||
final updatedSpaceModels = currentState.spaceModels
|
final updatedSpaceModels = currentState.spaceModels
|
||||||
|
Reference in New Issue
Block a user