formatted all files.

This commit is contained in:
Faris Armoush
2025-06-12 15:33:32 +03:00
parent 29959f567e
commit 04250ebc98
474 changed files with 5425 additions and 4338 deletions

View File

@ -32,8 +32,9 @@ class _AddDeviceWidgetState extends State<AddDeviceWidget> {
void initState() {
super.initState();
_scrollController = ScrollController();
productCounts =
widget.initialSelectedProducts != null ? List.from(widget.initialSelectedProducts!) : [];
productCounts = widget.initialSelectedProducts != null
? List.from(widget.initialSelectedProducts!)
: [];
}
@override
@ -96,10 +97,12 @@ class _AddDeviceWidgetState extends State<AddDeviceWidget> {
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
_buildActionButton('Cancel', ColorsManager.boxColor, ColorsManager.blackColor, () {
_buildActionButton(
'Cancel', ColorsManager.boxColor, ColorsManager.blackColor, () {
Navigator.of(context).pop();
}),
_buildActionButton('Continue', ColorsManager.secondaryColor, ColorsManager.whiteColors, () {
_buildActionButton('Continue', ColorsManager.secondaryColor,
ColorsManager.whiteColors, () {
Navigator.of(context).pop();
if (widget.onProductsSelected != null) {
widget.onProductsSelected!(productCounts);
@ -114,7 +117,11 @@ class _AddDeviceWidgetState extends State<AddDeviceWidget> {
Widget _buildDeviceTypeTile(ProductModel product, Size size) {
final selectedProduct = productCounts.firstWhere(
(p) => p.productId == product.uuid,
orElse: () => SelectedProduct(productId: product.uuid, count: 0, productName: product.catName, product: product),
orElse: () => SelectedProduct(
productId: product.uuid,
count: 0,
productName: product.catName,
product: product),
);
return SizedBox(
@ -143,13 +150,17 @@ class _AddDeviceWidgetState extends State<AddDeviceWidget> {
setState(() {
if (newCount > 0) {
if (!productCounts.contains(selectedProduct)) {
productCounts
.add(SelectedProduct(productId: product.uuid, count: newCount, productName: product.catName, product: product));
productCounts.add(SelectedProduct(
productId: product.uuid,
count: newCount,
productName: product.catName,
product: product));
} else {
selectedProduct.count = newCount;
}
} else {
productCounts.removeWhere((p) => p.productId == product.uuid);
productCounts
.removeWhere((p) => p.productId == product.uuid);
}
if (widget.onProductsSelected != null) {
@ -192,7 +203,8 @@ class _AddDeviceWidgetState extends State<AddDeviceWidget> {
height: size.width > 800 ? 35 : 25,
child: Text(
product.name ?? '',
style: context.textTheme.bodySmall?.copyWith(color: ColorsManager.blackColor),
style: context.textTheme.bodySmall
?.copyWith(color: ColorsManager.blackColor),
textAlign: TextAlign.center,
maxLines: 2,
overflow: TextOverflow.ellipsis,

View File

@ -9,7 +9,7 @@ import 'package:syncrow_web/utils/color_manager.dart';
class BlankCommunityWidget extends StatefulWidget {
final List<CommunityModel> communities;
BlankCommunityWidget({required this.communities});
const BlankCommunityWidget({super.key, required this.communities});
@override
_BlankCommunityWidgetState createState() => _BlankCommunityWidgetState();
@ -19,7 +19,7 @@ class _BlankCommunityWidgetState extends State<BlankCommunityWidget> {
@override
Widget build(BuildContext context) {
return Expanded(
child: Container(
child: ColoredBox(
color:
ColorsManager.whiteColors, // Parent container with white background
child: GridView.builder(

View File

@ -36,7 +36,7 @@ class CommunityStructureHeaderActionButtons extends StatelessWidget {
children: [
if (isSave)
CommunityStructureHeaderButton(
label: "Save",
label: 'Save',
icon: const Icon(Icons.save,
size: 18, color: ColorsManager.spaceColor),
onPressed: onSave,
@ -44,19 +44,19 @@ class CommunityStructureHeaderActionButtons extends StatelessWidget {
),
if (canShowActions) ...[
CommunityStructureHeaderButton(
label: "Edit",
label: 'Edit',
svgAsset: Assets.editSpace,
onPressed: onEdit,
theme: theme,
),
CommunityStructureHeaderButton(
label: "Duplicate",
label: 'Duplicate',
svgAsset: Assets.duplicate,
onPressed: onDuplicate,
theme: theme,
),
CommunityStructureHeaderButton(
label: "Delete",
label: 'Delete',
svgAsset: Assets.spaceDelete,
onPressed: onDelete,
theme: theme,

View File

@ -14,7 +14,7 @@ class CommunityStructureHeader extends StatefulWidget {
final TextEditingController nameController;
final VoidCallback onSave;
final VoidCallback onDelete;
final VoidCallback onEdit;
final VoidCallback onEdit;
final VoidCallback onDuplicate;
final VoidCallback onEditName;

View File

@ -3,24 +3,23 @@ import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
// Syncrow project imports
import 'package:syncrow_web/pages/common/buttons/add_space_button.dart';
import 'package:syncrow_web/pages/common/buttons/cancel_button.dart';
import 'package:syncrow_web/pages/common/buttons/default_button.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_bloc.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_event.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/connection_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/selected_product_model.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_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/connection_model.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/subspace_model.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/blank_community_widget.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/community_structure_header_widget.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/dialogs/create_space_dialog.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/curved_line_painter.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/dialogs/create_space_dialog.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/dialogs/duplicate_process_dialog.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/space_card_widget.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/space_container_widget.dart';
@ -41,7 +40,8 @@ class CommunityStructureArea extends StatefulWidget {
final List<Tag> projectTags;
CommunityStructureArea(
{this.selectedCommunity,
{super.key,
this.selectedCommunity,
this.selectedSpace,
required this.communities,
this.products,
@ -120,7 +120,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
);
}
Size screenSize = MediaQuery.of(context).size;
final screenSize = MediaQuery.of(context).size;
return Expanded(
child: GestureDetector(
onTap: () {
@ -173,16 +173,16 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
children: [
InteractiveViewer(
transformationController: _transformationController,
boundaryMargin: EdgeInsets.all(500),
boundaryMargin: const EdgeInsets.all(500),
minScale: 0.5,
maxScale: 3.0,
constrained: false,
child: Container(
child: SizedBox(
width: canvasWidth,
height: canvasHeight,
child: Stack(
children: [
for (var connection in connections)
for (final connection in connections)
Opacity(
opacity: ConnectionHelper.isHighlightedConnection(
connection, widget.selectedSpace)
@ -191,7 +191,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
child: CustomPaint(
painter: CurvedLinePainter([connection])),
),
for (var entry in spaces.asMap().entries)
for (final entry in spaces.asMap().entries)
if (entry.value.status != SpaceStatus.deleted &&
entry.value.status != SpaceStatus.parentDeleted)
Positioned(
@ -214,7 +214,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
_updateNodePosition(entry.value, newPosition);
},
buildSpaceContainer: (int index) {
final bool isHighlighted =
final isHighlighted =
SpaceHelper.isHighlightedSpace(
spaces[index], widget.selectedSpace);
@ -267,9 +267,9 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
canvasHeight += 200;
}
if (node.position.dx <= 200) {
double shiftAmount = 200;
const double shiftAmount = 200;
canvasWidth += shiftAmount;
for (var n in spaces) {
for (final n in spaces) {
n.position = Offset(n.position.dx + shiftAmount, n.position.dy);
}
}
@ -280,7 +280,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
}
void _adjustCanvasSizeForSpaces() {
for (var space in spaces) {
for (final space in spaces) {
if (space.position.dx >= canvasWidth - 200) {
canvasWidth = space.position.dx + 200;
}
@ -324,7 +324,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
position ?? ConnectionHelper.getCenterPosition(screenSize);
}
SpaceModel newSpace = SpaceModel(
final newSpace = SpaceModel(
name: name,
icon: icon,
position: newPosition,
@ -336,7 +336,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
tags: tags);
if (parentIndex != null) {
SpaceModel parentSpace = spaces[parentIndex];
final parentSpace = spaces[parentIndex];
parentSpace.internalId = spaces[parentIndex].internalId;
newSpace.parent = parentSpace;
final newConnection = Connection(
@ -406,7 +406,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
SpaceStatus.modified; // Mark as modified
}
for (var space in spaces) {
for (final space in spaces) {
if (space.internalId == widget.selectedSpace?.internalId) {
space.status = SpaceStatus.modified;
space.subspaces = subspaces;
@ -430,8 +430,8 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
}
List<SpaceModel> flattenSpaces(List<SpaceModel> spaces) {
List<SpaceModel> result = [];
Map<String, SpaceModel> idToSpace = {};
final result = <SpaceModel>[];
final idToSpace = <String, SpaceModel>{};
void flatten(SpaceModel space) {
if (space.status == SpaceStatus.deleted ||
@ -441,16 +441,16 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
result.add(space);
idToSpace[space.internalId] = space;
for (var child in space.children) {
for (final child in space.children) {
flatten(child);
}
}
for (var space in spaces) {
for (final space in spaces) {
flatten(space);
}
for (var space in result) {
for (final space in result) {
if (space.parent != null) {
space.parent = idToSpace[space.parent!.internalId];
}
@ -460,12 +460,12 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
}
List<Connection> createConnections(List<SpaceModel> spaces) {
List<Connection> connections = [];
final connections = <Connection>[];
void addConnections(SpaceModel parent, String direction) {
if (parent.status == SpaceStatus.deleted) return;
for (var child in parent.children) {
for (final child in parent.children) {
if (child.status == SpaceStatus.deleted) continue;
connections.add(
@ -480,8 +480,8 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
}
}
for (var space in spaces) {
addConnections(space, "down");
for (final space in spaces) {
addConnections(space, 'down');
}
return connections;
@ -492,7 +492,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
return;
}
List<SpaceModel> spacesToSave = spaces.where((space) {
final spacesToSave = spaces.where((space) {
return space.status == SpaceStatus.newSpace ||
space.status == SpaceStatus.modified ||
space.status == SpaceStatus.deleted;
@ -502,7 +502,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
return;
}
String communityUuid = widget.selectedCommunity!.uuid;
final communityUuid = widget.selectedCommunity!.uuid;
context.read<SpaceManagementBloc>().add(SaveSpacesEvent(
context,
spaces: spacesToSave,
@ -513,7 +513,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
void _onDelete() {
if (widget.selectedSpace != null) {
setState(() {
for (var space in spaces) {
for (final space in spaces) {
if (space.internalId == widget.selectedSpace?.internalId) {
space.status = SpaceStatus.deleted;
_markChildrenAsDeleted(space);
@ -526,7 +526,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
}
void _markChildrenAsDeleted(SpaceModel parent) {
for (var child in parent.children) {
for (final child in parent.children) {
child.status = SpaceStatus.parentDeleted;
_markChildrenAsDeleted(child);
@ -543,11 +543,11 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
}
void _moveToSpace(SpaceModel space) {
final double viewportWidth = MediaQuery.of(context).size.width;
final double viewportHeight = MediaQuery.of(context).size.height;
final viewportWidth = MediaQuery.of(context).size.width;
final viewportHeight = MediaQuery.of(context).size.height;
final double dx = -space.position.dx + (viewportWidth / 2) - 400;
final double dy = -space.position.dy + (viewportHeight / 2) - 300;
final dx = -space.position.dx + (viewportWidth / 2) - 400;
final dy = -space.position.dy + (viewportHeight / 2) - 300;
_transformationController.value = Matrix4.identity()
..translate(dx, dy)
@ -578,10 +578,10 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
return Offset(parent.position.dx, parent.position.dy + verticalGap);
} else {
// More children → arrange them spaced horizontally
double totalWidth = (parent.children.length) * (nodeWidth + 60);
double startX = parent.position.dx - (totalWidth / 2);
final totalWidth = (parent.children.length) * (nodeWidth + 60);
final startX = parent.position.dx - (totalWidth / 2);
double childX = startX + (parent.children.length * (nodeWidth + 60));
final childX = startX + (parent.children.length * (nodeWidth + 60));
return Offset(childX, parent.position.dy + verticalGap);
}
}
@ -599,15 +599,15 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
double calculateSubtreeWidth(SpaceModel node) {
if (node.children.isEmpty) return nodeWidth;
double totalWidth = 0;
for (var child in node.children) {
for (final child in node.children) {
totalWidth += calculateSubtreeWidth(child) + horizontalGap;
}
return totalWidth - horizontalGap;
}
void layoutSubtree(SpaceModel node, double startX, double y) {
double subtreeWidth = calculateSubtreeWidth(node);
double centerX = startX + subtreeWidth / 2 - nodeWidth / 2;
final subtreeWidth = calculateSubtreeWidth(node);
final centerX = startX + subtreeWidth / 2 - nodeWidth / 2;
node.position = Offset(centerX, y);
canvasRightEdge = max(canvasRightEdge, centerX + nodeWidth);
@ -617,9 +617,9 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
final child = node.children.first;
layoutSubtree(child, centerX, y + verticalGap);
} else {
double childX = startX;
for (var child in node.children) {
double childWidth = calculateSubtreeWidth(child);
var childX = startX;
for (final child in node.children) {
final childWidth = calculateSubtreeWidth(child);
layoutSubtree(child, childX, y + verticalGap);
childX += childWidth + horizontalGap;
}
@ -627,7 +627,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
}
// ⚡ New: layout each root separately
final List<SpaceModel> roots = spaces
final roots = spaces
.where((s) =>
s.parent == null &&
s.status != SpaceStatus.deleted &&
@ -635,11 +635,11 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
.toList();
double currentX = 100; // start some margin from left
double currentY = 100; // top margin
const double currentY = 100; // top margin
for (var root in roots) {
for (final root in roots) {
layoutSubtree(root, currentX, currentY);
double rootWidth = calculateSubtreeWidth(root);
final rootWidth = calculateSubtreeWidth(root);
currentX += rootWidth + rootGap;
}
@ -659,7 +659,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
return AlertDialog(
backgroundColor: ColorsManager.whiteColors,
title: Text(
"Duplicate Space",
'Duplicate Space',
textAlign: TextAlign.center,
style: Theme.of(context)
.textTheme
@ -671,11 +671,11 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text("Are you sure you want to duplicate?",
Text('Are you sure you want to duplicate?',
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.headlineSmall),
const SizedBox(height: 15),
Text("All the child spaces will be duplicated.",
Text('All the child spaces will be duplicated.',
textAlign: TextAlign.center,
style: Theme.of(context)
.textTheme
@ -693,7 +693,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
onPressed: () {
Navigator.of(context).pop();
},
label: "Cancel",
label: 'Cancel',
),
),
const SizedBox(width: 10),
@ -731,16 +731,16 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
void _duplicateSpace(SpaceModel space) {
setState(() {
SpaceModel? parent = space.parent;
final parent = space.parent;
SpaceModel duplicated = _deepCloneSpaceTree(space, parent: parent);
final duplicated = _deepCloneSpaceTree(space, parent: parent);
duplicated.position =
Offset(space.position.dx + 300, space.position.dy + 100);
List<SpaceModel> duplicatedSubtree = [];
final duplicatedSubtree = <SpaceModel>[];
void collectSubtree(SpaceModel node) {
duplicatedSubtree.add(node);
for (var child in node.children) {
for (final child in node.children) {
collectSubtree(child);
}
}
@ -782,7 +782,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
parent: parent,
);
for (var child in original.children) {
for (final child in original.children) {
final duplicatedChild = _deepCloneSpaceTree(child, parent: newSpace);
newSpace.children.add(duplicatedChild);

View File

@ -7,11 +7,10 @@ class CounterWidget extends StatefulWidget {
final bool isCreate;
const CounterWidget(
{Key? key,
{super.key,
this.initialCount = 0,
required this.onCountChanged,
required this.isCreate})
: super(key: key);
required this.isCreate});
@override
State<CounterWidget> createState() => _CounterWidgetState();
@ -55,7 +54,8 @@ class _CounterWidgetState extends State<CounterWidget> {
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
_buildCounterButton(Icons.remove, _decrementCounter,!widget.isCreate ),
_buildCounterButton(
Icons.remove, _decrementCounter, !widget.isCreate),
const SizedBox(width: 8),
Text(
'$_counter',
@ -69,12 +69,15 @@ class _CounterWidgetState extends State<CounterWidget> {
);
}
Widget _buildCounterButton(IconData icon, VoidCallback onPressed, bool isDisabled) {
Widget _buildCounterButton(
IconData icon, VoidCallback onPressed, bool isDisabled) {
return GestureDetector(
onTap: isDisabled? null: onPressed,
onTap: isDisabled ? null : onPressed,
child: Icon(
icon,
color: isDisabled? ColorsManager.spaceColor.withOpacity(0.3): ColorsManager.spaceColor,
color: isDisabled
? ColorsManager.spaceColor.withValues(alpha: 0.3)
: ColorsManager.spaceColor,
size: 18,
),
);

View File

@ -1,12 +1,11 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import '../../../../../common/edit_chip.dart';
import '../../../../../utils/color_manager.dart';
import '../../../helper/tag_helper.dart';
import '../../../space_model/widgets/button_content_widget.dart';
import '../../model/subspace_model.dart';
import '../../model/tag.dart';
import 'package:syncrow_web/common/edit_chip.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/subspace_model.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
import 'package:syncrow_web/pages/spaces_management/helper/tag_helper.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/button_content_widget.dart';
import 'package:syncrow_web/utils/color_manager.dart';
class DevicesPartWidget extends StatelessWidget {
const DevicesPartWidget({
@ -28,73 +27,73 @@ class DevicesPartWidget extends StatelessWidget {
Widget build(BuildContext context) {
return Column(
children: [
(tags?.isNotEmpty == true ||
subspaces?.any(
(subspace) => subspace.tags?.isNotEmpty == true) ==
true)
? SizedBox(
width: screenWidth * 0.25,
child: Container(
padding: const EdgeInsets.all(8.0),
decoration: BoxDecoration(
color: ColorsManager.textFieldGreyColor,
borderRadius: BorderRadius.circular(15),
border: Border.all(
color: ColorsManager.textFieldGreyColor,
width: 3.0, // Border width
),
),
child: Wrap(
spacing: 8.0,
runSpacing: 8.0,
children: [
// Combine tags from spaceModel and subspaces
...TagHelper.groupTags([
...?tags,
...?subspaces?.expand((subspace) => subspace.tags ?? [])
]).entries.map(
(entry) => Chip(
avatar: SizedBox(
width: 24,
height: 24,
child: SvgPicture.asset(
entry.key.icon ?? 'assets/icons/gateway.svg',
fit: BoxFit.contain,
),
),
label: Text(
'x${entry.value}', // Show count
style: Theme.of(context)
.textTheme
.bodySmall
?.copyWith(color: ColorsManager.spaceColor),
),
backgroundColor: ColorsManager.whiteColors,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
side: const BorderSide(
color: ColorsManager.spaceColor,
),
),
if (tags?.isNotEmpty == true ||
subspaces?.any((subspace) => subspace.tags?.isNotEmpty == true) ==
true)
SizedBox(
width: screenWidth * 0.25,
child: Container(
padding: const EdgeInsets.all(8.0),
decoration: BoxDecoration(
color: ColorsManager.textFieldGreyColor,
borderRadius: BorderRadius.circular(15),
border: Border.all(
color: ColorsManager.textFieldGreyColor,
width: 3.0, // Border width
),
),
child: Wrap(
spacing: 8.0,
runSpacing: 8.0,
children: [
// Combine tags from spaceModel and subspaces
...TagHelper.groupTags([
...?tags,
...?subspaces?.expand((subspace) => subspace.tags ?? [])
]).entries.map(
(entry) => Chip(
avatar: SizedBox(
width: 24,
height: 24,
child: SvgPicture.asset(
entry.key.icon ?? 'assets/icons/gateway.svg',
fit: BoxFit.contain,
),
),
label: Text(
'x${entry.value}', // Show count
style: Theme.of(context)
.textTheme
.bodySmall
?.copyWith(color: ColorsManager.spaceColor),
),
backgroundColor: ColorsManager.whiteColors,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
side: const BorderSide(
color: ColorsManager.spaceColor,
),
),
),
),
EditChip(onTap: onEditChip)
],
),
),
)
: TextButton(
onPressed: onTextButtonPressed,
style: TextButton.styleFrom(
padding: EdgeInsets.zero,
),
child: ButtonContentWidget(
icon: Icons.add,
label: 'Add Devices',
disabled: isTagsAndSubspaceModelDisabled,
),
)
EditChip(onTap: onEditChip)
],
),
),
)
else
TextButton(
onPressed: onTextButtonPressed,
style: TextButton.styleFrom(
padding: EdgeInsets.zero,
),
child: ButtonContentWidget(
icon: Icons.add,
label: 'Add Devices',
disabled: isTagsAndSubspaceModelDisabled,
),
)
],
);
}

View File

@ -1,8 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import '../../../../../utils/color_manager.dart';
import '../../../../../utils/constants/assets.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
class IconChoosePartWidget extends StatelessWidget {
const IconChoosePartWidget({

View File

@ -1,9 +1,8 @@
import 'package:flutter/material.dart';
import '../../../../../utils/color_manager.dart';
import '../../../../../utils/constants/assets.dart';
import '../../../space_model/models/space_template_model.dart';
import '../../../space_model/widgets/button_content_widget.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/button_content_widget.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
class SpaceModelLinkingWidget extends StatelessWidget {
const SpaceModelLinkingWidget({
@ -23,66 +22,67 @@ class SpaceModelLinkingWidget extends StatelessWidget {
Widget build(BuildContext context) {
return Column(
children: [
selectedSpaceModel == null
? TextButton(
style: TextButton.styleFrom(
padding: EdgeInsets.zero,
),
onPressed: onPressed,
child: ButtonContentWidget(
svgAssets: Assets.link,
label: 'Link a space model',
disabled: isSpaceModelDisabled,
),
)
: Container(
width: screenWidth * 0.25,
padding: const EdgeInsets.symmetric(
vertical: 10.0, horizontal: 16.0),
decoration: BoxDecoration(
color: ColorsManager.boxColor,
borderRadius: BorderRadius.circular(10),
),
child: Wrap(
spacing: 8.0,
runSpacing: 8.0,
children: [
Chip(
label: Text(
selectedSpaceModel?.modelName ?? '',
style: Theme.of(context)
.textTheme
.bodyMedium!
.copyWith(color: ColorsManager.spaceColor),
if (selectedSpaceModel == null)
TextButton(
style: TextButton.styleFrom(
padding: EdgeInsets.zero,
),
onPressed: onPressed,
child: ButtonContentWidget(
svgAssets: Assets.link,
label: 'Link a space model',
disabled: isSpaceModelDisabled,
),
)
else
Container(
width: screenWidth * 0.25,
padding:
const EdgeInsets.symmetric(vertical: 10.0, horizontal: 16.0),
decoration: BoxDecoration(
color: ColorsManager.boxColor,
borderRadius: BorderRadius.circular(10),
),
child: Wrap(
spacing: 8.0,
runSpacing: 8.0,
children: [
Chip(
label: Text(
selectedSpaceModel?.modelName ?? '',
style: Theme.of(context)
.textTheme
.bodyMedium!
.copyWith(color: ColorsManager.spaceColor),
),
backgroundColor: ColorsManager.whiteColors,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
side: const BorderSide(
color: ColorsManager.transparentColor,
width: 0,
),
),
deleteIcon: Container(
width: 24,
height: 24,
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: ColorsManager.lightGrayColor,
width: 1.5,
),
backgroundColor: ColorsManager.whiteColors,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
side: const BorderSide(
color: ColorsManager.transparentColor,
width: 0,
),
),
deleteIcon: Container(
width: 24,
height: 24,
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: ColorsManager.lightGrayColor,
width: 1.5,
),
),
child: const Icon(
Icons.close,
size: 16,
color: ColorsManager.lightGrayColor,
),
),
onDeleted: onDeleted),
],
),
),
),
child: const Icon(
Icons.close,
size: 16,
color: ColorsManager.lightGrayColor,
),
),
onDeleted: onDeleted),
],
),
),
],
);
}

View File

@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import '../../../../../utils/color_manager.dart';
import 'package:syncrow_web/utils/color_manager.dart';
class SpaceNameTextfieldWidget extends StatelessWidget {
SpaceNameTextfieldWidget({

View File

@ -1,10 +1,9 @@
import 'package:flutter/material.dart';
import '../../../../../common/edit_chip.dart';
import '../../../../../utils/color_manager.dart';
import '../../../space_model/widgets/button_content_widget.dart';
import '../../../space_model/widgets/subspace_name_label_widget.dart';
import '../../model/subspace_model.dart';
import 'package:syncrow_web/common/edit_chip.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/subspace_model.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/button_content_widget.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/subspace_name_label_widget.dart';
import 'package:syncrow_web/utils/color_manager.dart';
class SubSpacePartWidget extends StatefulWidget {
SubSpacePartWidget({
@ -30,71 +29,72 @@ class _SubSpacePartWidgetState extends State<SubSpacePartWidget> {
Widget build(BuildContext context) {
return Column(
children: [
widget.subspaces == null || widget.subspaces!.isEmpty
? TextButton(
style: TextButton.styleFrom(
padding: EdgeInsets.zero,
overlayColor: ColorsManager.transparentColor,
if (widget.subspaces == null || widget.subspaces!.isEmpty)
TextButton(
style: TextButton.styleFrom(
padding: EdgeInsets.zero,
overlayColor: ColorsManager.transparentColor,
),
onPressed: widget.onPressed,
child: ButtonContentWidget(
icon: Icons.add,
label: 'Create Sub Spaces',
disabled: widget.isTagsAndSubspaceModelDisabled,
),
)
else
SizedBox(
width: widget.screenWidth * 0.25,
child: Container(
padding: const EdgeInsets.all(8.0),
decoration: BoxDecoration(
color: ColorsManager.textFieldGreyColor,
borderRadius: BorderRadius.circular(15),
border: Border.all(
color: ColorsManager.textFieldGreyColor,
width: 3.0, // Border width
),
onPressed: widget.onPressed,
child: ButtonContentWidget(
icon: Icons.add,
label: 'Create Sub Spaces',
disabled: widget.isTagsAndSubspaceModelDisabled,
),
)
: SizedBox(
width: widget.screenWidth * 0.25,
child: Container(
padding: const EdgeInsets.all(8.0),
decoration: BoxDecoration(
color: ColorsManager.textFieldGreyColor,
borderRadius: BorderRadius.circular(15),
border: Border.all(
color: ColorsManager.textFieldGreyColor,
width: 3.0, // Border width
),
),
child: Wrap(
spacing: 8.0,
runSpacing: 8.0,
children: [
if (widget.subspaces != null)
...widget.subspaces!.map((subspace) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SubspaceNameDisplayWidget(
text: subspace.subspaceName,
validateName: (updatedName) {
bool nameExists = widget.subspaces!.any((s) {
bool isSameId =
s.internalId == subspace.internalId;
bool isSameName =
s.subspaceName.trim().toLowerCase() ==
updatedName.trim().toLowerCase();
),
child: Wrap(
spacing: 8.0,
runSpacing: 8.0,
children: [
if (widget.subspaces != null)
...widget.subspaces!.map((subspace) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SubspaceNameDisplayWidget(
text: subspace.subspaceName,
validateName: (updatedName) {
final nameExists = widget.subspaces!.any((s) {
final isSameId =
s.internalId == subspace.internalId;
final isSameName =
s.subspaceName.trim().toLowerCase() ==
updatedName.trim().toLowerCase();
return !isSameId && isSameName;
});
return !isSameId && isSameName;
});
return !nameExists;
},
onNameChanged: (updatedName) {
setState(() {
subspace.subspaceName = updatedName;
});
},
),
],
);
}),
EditChip(
onTap: widget.editChipOnTap,
)
],
),
),
)
return !nameExists;
},
onNameChanged: (updatedName) {
setState(() {
subspace.subspaceName = updatedName;
});
},
),
],
);
}),
EditChip(
onTap: widget.editChipOnTap,
)
],
),
),
)
],
);
}

View File

@ -19,15 +19,11 @@ class CurvedLinePainter extends CustomPainter {
return; // Nothing to paint if there are no connections
}
for (var connection in connections) {
for (final connection in connections) {
// Ensure positions are valid before drawing lines
if (connection.endSpace.position == null) {
continue;
}
Offset start = connection.startSpace.position +
final start = connection.startSpace.position +
const Offset(75, 60); // Center bottom of start space
Offset end = connection.endSpace.position +
final end = connection.endSpace.position +
const Offset(75, 0); // Center top of end space
// Curved line for down connections

View File

@ -9,7 +9,6 @@ import 'package:syncrow_web/pages/spaces_management/all_spaces/model/subspace_mo
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/create_space_widgets/devices_part_widget.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/create_space_widgets/icon_choose_part_widget.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/create_space_widgets/space_model_linking_widget.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/create_space_widgets/space_name_textfield_widget.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/create_space_widgets/sub_space_part_widget.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/dialogs/icon_selection_dialog.dart';
@ -99,9 +98,9 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
@override
Widget build(BuildContext context) {
bool isSpaceModelDisabled = (tags != null && tags!.isNotEmpty ||
subspaces != null && subspaces!.isNotEmpty);
bool isTagsAndSubspaceModelDisabled = (selectedSpaceModel != null);
final isSpaceModelDisabled = tags != null && tags!.isNotEmpty ||
subspaces != null && subspaces!.isNotEmpty;
final isTagsAndSubspaceModelDisabled = (selectedSpaceModel != null);
final screenWidth = MediaQuery.of(context).size.width;
return AlertDialog(
@ -298,7 +297,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
} else if (isNameFieldExist) {
return;
} else {
String newName = enteredName.isNotEmpty
final newName = enteredName.isNotEmpty
? enteredName
: (widget.name ?? '');
if (newName.isNotEmpty) {
@ -381,7 +380,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
products: products,
existingSubSpaces: existingSubSpaces,
onSave: (slectedSubspaces, updatedSubSpaces) {
final List<Tag> tagsToAppendToSpace = [];
final tagsToAppendToSpace = <Tag>[];
if (slectedSubspaces != null && slectedSubspaces.isNotEmpty) {
final updatedIds =
@ -390,11 +389,11 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
final deletedSubspaces = existingSubSpaces
.where((s) => !updatedIds.contains(s.internalId))
.toList();
for (var s in deletedSubspaces) {
for (final s in deletedSubspaces) {
if (s.tags != null) {
s.tags!.forEach(
(tag) => tag.location = null,
);
for (final tag in s.tags!) {
tag.location = null;
}
tagsToAppendToSpace.addAll(s.tags!);
}
}
@ -403,11 +402,11 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
if (existingSubSpaces != null) {
final deletedSubspaces = existingSubSpaces;
for (var s in deletedSubspaces) {
for (final s in deletedSubspaces) {
if (s.tags != null) {
s.tags!.forEach(
(tag) => tag.location = null,
);
for (final tag in s.tags!) {
tag.location = null;
}
tagsToAppendToSpace.addAll(s.tags!);
}
}

View File

@ -2,9 +2,10 @@ import 'package:flutter/material.dart';
import 'package:syncrow_web/pages/common/buttons/cancel_button.dart';
import 'package:syncrow_web/utils/color_manager.dart';
void showDeleteConfirmationDialog(BuildContext context, VoidCallback onConfirm, bool isSpace) {
final String title = isSpace ? 'Delete Space' : 'Delete Community';
final String subtitle = isSpace
void showDeleteConfirmationDialog(
BuildContext context, VoidCallback onConfirm, bool isSpace) {
final title = isSpace ? 'Delete Space' : 'Delete Community';
final subtitle = isSpace
? 'All the data in the space will be lost'
: 'All the data in the community will be lost';
@ -13,7 +14,8 @@ void showDeleteConfirmationDialog(BuildContext context, VoidCallback onConfirm,
barrierDismissible: false,
builder: (BuildContext context) {
return Dialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16.0)),
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(16.0)),
child: SizedBox(
width: 500,
child: Container(
@ -41,7 +43,8 @@ void showDeleteConfirmationDialog(BuildContext context, VoidCallback onConfirm,
showProcessingPopup(context, isSpace, onConfirm);
},
style: _dialogButtonStyle(ColorsManager.spaceColor),
child: const Text('Continue', style: TextStyle(color: ColorsManager.whiteColors)),
child: const Text('Continue',
style: TextStyle(color: ColorsManager.whiteColors)),
),
],
),
@ -54,15 +57,17 @@ void showDeleteConfirmationDialog(BuildContext context, VoidCallback onConfirm,
);
}
void showProcessingPopup(BuildContext context, bool isSpace, VoidCallback onDelete) {
final String title = isSpace ? 'Delete Space' : 'Delete Community';
void showProcessingPopup(
BuildContext context, bool isSpace, VoidCallback onDelete) {
final title = isSpace ? 'Delete Space' : 'Delete Community';
showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return Dialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16.0)),
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(16.0)),
child: SizedBox(
width: 500,
child: Container(
@ -75,7 +80,8 @@ void showProcessingPopup(BuildContext context, bool isSpace, VoidCallback onDele
const SizedBox(height: 20),
_buildDialogTitle(context, title),
const SizedBox(height: 10),
_buildDialogSubtitle(context, 'Are you sure you want to delete?'),
_buildDialogSubtitle(
context, 'Are you sure you want to delete?'),
const SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
@ -83,7 +89,8 @@ void showProcessingPopup(BuildContext context, bool isSpace, VoidCallback onDele
ElevatedButton(
onPressed: onDelete,
style: _dialogButtonStyle(ColorsManager.warningRed),
child: const Text('Delete', style: TextStyle(color: ColorsManager.whiteColors)),
child: const Text('Delete',
style: TextStyle(color: ColorsManager.whiteColors)),
),
CancelButton(
label: 'Cancel',
@ -104,7 +111,7 @@ Widget _buildWarningIcon() {
return Container(
width: 50,
height: 50,
decoration: BoxDecoration(
decoration: const BoxDecoration(
color: ColorsManager.warningRed,
shape: BoxShape.circle,
),
@ -123,7 +130,10 @@ Widget _buildDialogSubtitle(BuildContext context, String subtitle) {
return Text(
subtitle,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(color: ColorsManager.grayColor),
style: Theme.of(context)
.textTheme
.bodyMedium
?.copyWith(color: ColorsManager.grayColor),
);
}

View File

@ -4,8 +4,7 @@ import 'package:syncrow_web/utils/color_manager.dart';
class DuplicateProcessDialog extends StatefulWidget {
final VoidCallback onDuplicate;
const DuplicateProcessDialog({required this.onDuplicate, Key? key})
: super(key: key);
const DuplicateProcessDialog({required this.onDuplicate, super.key});
@override
_DuplicateProcessDialogState createState() => _DuplicateProcessDialogState();
@ -20,7 +19,7 @@ class _DuplicateProcessDialogState extends State<DuplicateProcessDialog> {
_startDuplication();
}
void _startDuplication() async {
Future<void> _startDuplication() async {
WidgetsBinding.instance.addPostFrameCallback((_) {
widget.onDuplicate();
});
@ -55,7 +54,7 @@ class _DuplicateProcessDialogState extends State<DuplicateProcessDialog> {
),
const SizedBox(height: 15),
Text(
"Duplicating in progress",
'Duplicating in progress',
style: Theme.of(context)
.textTheme
.headlineSmall
@ -70,7 +69,7 @@ class _DuplicateProcessDialogState extends State<DuplicateProcessDialog> {
),
const SizedBox(height: 15),
Text(
"Duplicating successful",
'Duplicating successful',
textAlign: TextAlign.center,
style: Theme.of(context)
.textTheme

View File

@ -7,10 +7,10 @@ class IconSelectionDialog extends StatelessWidget {
final Function(String selectedIcon) onIconSelected;
const IconSelectionDialog({
Key? key,
super.key,
required this.spaceIconList,
required this.onIconSelected,
}) : super(key: key);
});
@override
Widget build(BuildContext context) {
@ -21,21 +21,23 @@ class IconSelectionDialog extends StatelessWidget {
elevation: 0,
backgroundColor: ColorsManager.transparentColor,
child: Container(
width: screenWidth * 0.44,
width: screenWidth * 0.44,
height: screenHeight * 0.45,
decoration: BoxDecoration(
color: ColorsManager.whiteColors,
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: ColorsManager.blackColor.withOpacity(0.2), // Shadow color
color: ColorsManager.blackColor
.withValues(alpha: 0.2), // Shadow color
blurRadius: 20, // Spread of the blur
offset: const Offset(0, 8), // Offset of the shadow
),
],
),
child: AlertDialog(
title: Text('Space Icon',style: Theme.of(context).textTheme.headlineMedium),
title: Text('Space Icon',
style: Theme.of(context).textTheme.headlineMedium),
backgroundColor: ColorsManager.whiteColors,
content: Container(
width: screenWidth * 0.4,

View File

@ -28,7 +28,7 @@ class GradientCanvasBorderWidget extends StatelessWidget {
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [
ColorsManager.semiTransparentBlackColor.withOpacity(0.1),
ColorsManager.semiTransparentBlackColor.withValues(alpha: 0.1),
ColorsManager.transparentColor,
],
),

View File

@ -8,11 +8,11 @@ class HoverableButton extends StatefulWidget {
final VoidCallback onTap;
const HoverableButton({
Key? key,
super.key,
required this.iconPath,
required this.text,
required this.onTap,
}) : super(key: key);
});
@override
State<HoverableButton> createState() => _HoverableButtonState();
@ -34,14 +34,17 @@ class _HoverableButtonState extends State<HoverableButton> {
child: SizedBox(
width: screenWidth * .07,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 13, vertical: 8),
padding:
const EdgeInsets.symmetric(horizontal: 13, vertical: 8),
decoration: BoxDecoration(
color: isHovered ? ColorsManager.warningRed : ColorsManager.whiteColors,
color: isHovered
? ColorsManager.warningRed
: ColorsManager.whiteColors,
borderRadius: BorderRadius.circular(16),
boxShadow: [
if (isHovered)
BoxShadow(
color: ColorsManager.warningRed.withOpacity(0.4),
color: ColorsManager.warningRed.withValues(alpha: 0.4),
blurRadius: 8,
offset: const Offset(0, 4),
),

View File

@ -81,49 +81,51 @@ class _LoadedSpaceViewState extends State<LoadedSpaceView> {
return Stack(
clipBehavior: Clip.none,
children: [
widget.shouldNavigateToSpaceModelPage
? Row(
children: [
SizedBox(width: 300, child: SpaceTreeView(onSelect: () {})),
Expanded(
child: BlocProvider(
create: (context) => SpaceModelBloc(
BlocProvider.of<SpaceTreeBloc>(context),
api: SpaceModelManagementApi(),
initialSpaceModels: widget.spaceModels ?? [],
),
child: SpaceModelPage(
products: widget.products,
onSpaceModelsUpdated: _onSpaceModelsUpdated,
projectTags: widget.projectTags,
),
),
if (widget.shouldNavigateToSpaceModelPage)
Row(
children: [
SizedBox(width: 300, child: SpaceTreeView(onSelect: () {})),
Expanded(
child: BlocProvider(
create: (context) => SpaceModelBloc(
BlocProvider.of<SpaceTreeBloc>(context),
api: SpaceModelManagementApi(),
initialSpaceModels: widget.spaceModels ?? [],
),
],
)
: Row(
children: [
SidebarWidget(
communities: widget.communities,
selectedSpaceUuid:
widget.selectedSpace?.uuid ?? widget.selectedCommunity?.uuid ?? '',
onCreateCommunity: (name, description) {
context.read<SpaceManagementBloc>().add(
CreateCommunityEvent(name, description, context),
);
},
),
CommunityStructureArea(
selectedCommunity: widget.selectedCommunity,
selectedSpace: widget.selectedSpace,
spaces: widget.selectedCommunity?.spaces ?? [],
child: SpaceModelPage(
products: widget.products,
communities: widget.communities,
spaceModels: _spaceModels,
onSpaceModelsUpdated: _onSpaceModelsUpdated,
projectTags: widget.projectTags,
),
],
),
),
],
)
else
Row(
children: [
SidebarWidget(
communities: widget.communities,
selectedSpaceUuid: widget.selectedSpace?.uuid ??
widget.selectedCommunity?.uuid ??
'',
onCreateCommunity: (name, description) {
context.read<SpaceManagementBloc>().add(
CreateCommunityEvent(name, description, context),
);
},
),
CommunityStructureArea(
selectedCommunity: widget.selectedCommunity,
selectedSpace: widget.selectedSpace,
spaces: widget.selectedCommunity?.spaces ?? [],
products: widget.products,
communities: widget.communities,
spaceModels: _spaceModels,
projectTags: widget.projectTags,
),
],
),
const GradientCanvasBorderWidget(),
],
);

View File

@ -13,12 +13,12 @@ class SelectedProductsButtons extends StatelessWidget {
final BuildContext context;
const SelectedProductsButtons({
Key? key,
super.key,
required this.products,
required this.selectedProducts,
required this.onProductsUpdated,
required this.context,
}) : super(key: key);
});
@override
Widget build(BuildContext context) {
@ -86,9 +86,7 @@ class SelectedProductsButtons extends StatelessWidget {
builder: (context) => AddDeviceWidget(
products: products,
initialSelectedProducts: selectedProducts,
onProductsSelected: (selectedProductsMap) {
onProductsUpdated(selectedProductsMap);
},
onProductsSelected: onProductsUpdated,
),
);
}

View File

@ -5,6 +5,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/common/widgets/search_bar.dart';
import 'package:syncrow_web/common/widgets/sidebar_communities_list.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/space_tree/bloc/space_tree_state.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_bloc.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_event.dart';
@ -18,8 +19,6 @@ 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/style.dart';
import '../../../space_tree/bloc/space_tree_event.dart';
class SidebarWidget extends StatefulWidget {
final List<CommunityModel> communities;
final String? selectedSpaceUuid;
@ -55,13 +54,15 @@ class _SidebarWidgetState extends State<SidebarWidget> {
}
void _onScroll() {
if (_scrollController.position.pixels >= _scrollController.position.maxScrollExtent - 100) {
if (_scrollController.position.pixels >=
_scrollController.position.maxScrollExtent - 100) {
// Trigger pagination event
final bloc = context.read<SpaceTreeBloc>();
if (!bloc.state.paginationIsLoading && bloc.state.paginationModel?.hasNext == true) {
if (!bloc.state.paginationIsLoading &&
bloc.state.paginationModel.hasNext == true) {
bloc.add(
PaginationEvent(
bloc.state.paginationModel!,
bloc.state.paginationModel,
bloc.state.communityList,
),
);
@ -134,24 +135,28 @@ class _SidebarWidgetState extends State<SidebarWidget> {
communities: filteredCommunities,
itemBuilder: (context, index) {
if (index == filteredCommunities.length) {
final spaceTreeState = context.read<SpaceTreeBloc>().state;
final spaceTreeState =
context.read<SpaceTreeBloc>().state;
if (spaceTreeState.paginationIsLoading) {
return const Padding(
padding: EdgeInsets.all(8.0),
child: Center(child: CircularProgressIndicator()),
child:
Center(child: CircularProgressIndicator()),
);
} else {
return const SizedBox.shrink();
}
}
return _buildCommunityTile(context, filteredCommunities[index]);
return _buildCommunityTile(
context, filteredCommunities[index]);
},
);
},
),
),
if (spaceTreeState.paginationIsLoading || spaceTreeState.isSearching)
Center(
if (spaceTreeState.paginationIsLoading ||
spaceTreeState.isSearching)
const Center(
child: CircularProgressIndicator(),
)
],
@ -214,7 +219,8 @@ class _SidebarWidgetState extends State<SidebarWidget> {
});
context.read<SpaceManagementBloc>().add(
SelectSpaceEvent(selectedCommunity: community, selectedSpace: space),
SelectSpaceEvent(
selectedCommunity: community, selectedSpace: space),
);
},
children: space.children
@ -229,8 +235,9 @@ class _SidebarWidgetState extends State<SidebarWidget> {
);
}
void _onAddCommunity() =>
_selectedId?.isNotEmpty ?? true ? _clearSelection() : _showCreateCommunityDialog();
void _onAddCommunity() => _selectedId?.isNotEmpty ?? true
? _clearSelection()
: _showCreateCommunityDialog();
void _clearSelection() {
setState(() => _selectedId = '');

View File

@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'plus_button_widget.dart'; // Make sure to import your PlusButtonWidget
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/plus_button_widget.dart'; // Make sure to import your PlusButtonWidget
class SpaceCardWidget extends StatelessWidget {
final int index;

View File

@ -78,7 +78,7 @@ class SpaceContainerWidget extends StatelessWidget {
borderRadius: BorderRadius.circular(15),
boxShadow: [
BoxShadow(
color: ColorsManager.lightGrayColor.withOpacity(0.5),
color: ColorsManager.lightGrayColor.withValues(alpha: 0.5),
spreadRadius: 2,
blurRadius: 5,
offset: const Offset(0, 3), // Shadow position

View File

@ -27,7 +27,7 @@ class SpaceWidget extends StatelessWidget {
borderRadius: BorderRadius.circular(8),
boxShadow: [
BoxShadow(
color: ColorsManager.lightGrayColor.withOpacity(0.5),
color: ColorsManager.lightGrayColor.withValues(alpha: 0.5),
spreadRadius: 5,
blurRadius: 7,
offset: const Offset(0, 3),