community header

This commit is contained in:
hannathkadher
2025-01-24 20:41:31 +04:00
parent d4ed4efcd8
commit cb71b51565
8 changed files with 178 additions and 70 deletions
+8 -3
View File
@@ -19,12 +19,14 @@ class DefaultButton extends StatelessWidget {
this.padding,
this.borderColor,
this.elevation,
this.borderWidth = 1.0,
});
final void Function()? onPressed;
final Widget child;
final double? height;
final bool isSecondary;
final double? borderRadius;
final double borderWidth;
final bool enabled;
final double? padding;
final bool isDone;
@@ -66,13 +68,16 @@ class DefaultButton extends StatelessWidget {
}),
shape: WidgetStateProperty.all(
RoundedRectangleBorder(
side: BorderSide(color: borderColor ?? Colors.transparent),
side: BorderSide(
color: borderColor ?? Colors.transparent,
width: borderWidth,
),
borderRadius: BorderRadius.circular(borderRadius ?? 20),
),
),
fixedSize: height != null
? WidgetStateProperty.all(Size.fromHeight(height!))
: null,
? WidgetStateProperty.all(Size.fromHeight(height!))
: null,
padding: WidgetStateProperty.all(
EdgeInsets.all(padding ?? 10),
),
@@ -0,0 +1,59 @@
import 'package:flutter/material.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/community_structure_header_button.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
class CommunityStructureHeaderActionButtons extends StatelessWidget {
const CommunityStructureHeaderActionButtons({
super.key,
required this.theme,
required this.isSave,
required this.onSave,
required this.onDelete,
required this.selectedSpace,
});
final ThemeData theme;
final bool isSave;
final VoidCallback onSave;
final VoidCallback onDelete;
final SpaceModel? selectedSpace;
@override
Widget build(BuildContext context) {
final canShowActions = selectedSpace != null &&
selectedSpace?.status != SpaceStatus.deleted &&
selectedSpace?.status != SpaceStatus.parentDeleted;
return Wrap(
alignment: WrapAlignment.end,
spacing: 10,
children: [
if (isSave)
CommunityStructureHeaderButton(
label: "Save",
icon: const Icon(Icons.save,
size: 18, color: ColorsManager.spaceColor),
onPressed: onSave,
theme: theme,
),
if (canShowActions) ...[
CommunityStructureHeaderButton(
label: "Edit",
svgAsset: Assets.editSpace,
onPressed: () => {},
theme: theme,
),
CommunityStructureHeaderButton(
label: "Delete",
icon: const Icon(Icons.delete,
size: 18, color: ColorsManager.warningRed),
onPressed: onDelete,
theme: theme,
),
],
],
);
}
}
@@ -0,0 +1,65 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_web/pages/common/buttons/default_button.dart';
import 'package:syncrow_web/utils/color_manager.dart';
class CommunityStructureHeaderButton extends StatelessWidget {
const CommunityStructureHeaderButton({
super.key,
required this.label,
this.icon,
required this.onPressed,
this.svgAsset,
required this.theme,
});
final String label;
final Widget? icon;
final VoidCallback onPressed;
final String? svgAsset;
final ThemeData theme;
@override
Widget build(BuildContext context) {
const double buttonHeight = 40;
return ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: 100,
minHeight: buttonHeight,
),
child: DefaultButton(
onPressed: onPressed,
borderWidth: 3,
backgroundColor: ColorsManager.textFieldGreyColor,
foregroundColor: ColorsManager.blackColor,
borderRadius: 12.0,
padding: 2.0,
height: buttonHeight,
elevation: 0,
borderColor: ColorsManager.lightGrayColor,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (icon != null) icon!,
if (svgAsset != null)
SvgPicture.asset(
svgAsset!,
width: 30,
height: 30,
),
const SizedBox(width: 10),
Flexible(
child: Text(
label,
style: theme.textTheme.bodySmall
?.copyWith(color: ColorsManager.blackColor, fontSize: 14),
overflow: TextOverflow.ellipsis,
maxLines: 1,
),
),
],
),
),
);
}
}
@@ -1,8 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_web/pages/common/buttons/default_button.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/community_structure_header_action_button.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/community_structure_header_button.dart';
import 'package:syncrow_web/pages/spaces_management/create_community/view/create_community_dialog.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
@@ -141,70 +142,11 @@ class _CommunityStructureHeaderState extends State<CommunityStructureHeader> {
),
),
const SizedBox(width: 8),
_buildActionButtons(theme),
CommunityStructureHeaderActionButtons(theme),
],
),
],
);
}
Widget _buildActionButtons(ThemeData theme) {
return Wrap(
alignment: WrapAlignment.end,
spacing: 10,
children: [
if (widget.isSave)
_buildButton(
label: "Save",
icon: const Icon(Icons.save,
size: 18, color: ColorsManager.spaceColor),
onPressed: widget.onSave,
theme: theme),
if(widget.selectedSpace!= null)
_buildButton(
label: "Delete",
icon: const Icon(Icons.delete,
size: 18, color: ColorsManager.warningRed),
onPressed: widget.onDelete,
theme: theme),
],
);
}
Widget _buildButton(
{required String label,
required Widget icon,
required VoidCallback onPressed,
required ThemeData theme}) {
const double buttonHeight = 30;
return ConstrainedBox(
constraints: BoxConstraints(maxWidth: 80, minHeight: buttonHeight),
child: DefaultButton(
onPressed: onPressed,
backgroundColor: ColorsManager.textFieldGreyColor,
foregroundColor: ColorsManager.blackColor,
borderRadius: 8.0,
padding: 2.0,
height: buttonHeight,
elevation: 0,
borderColor: ColorsManager.lightGrayColor,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
icon,
const SizedBox(width: 5),
Flexible(
child: Text(
label,
style: theme.textTheme.bodySmall
?.copyWith(color: ColorsManager.blackColor),
overflow: TextOverflow.ellipsis,
maxLines: 1,
),
),
],
),
),
);
}
}
@@ -199,9 +199,11 @@ class _SidebarWidgetState extends State<SidebarWidget> {
},
children: hasChildren
? community.spaces
.where((space) => (space.status != SpaceStatus.deleted ||
space.status != SpaceStatus.parentDeleted))
.map((space) => _buildSpaceTile(space, community))
.toList()
: null, // Render spaces within the community
: null,
);
}
@@ -135,7 +135,8 @@ class CreateSpaceModelBloc
final updatedSpace =
currentState.space.copyWith(subspaceModels: updatedSubspaces);
emit(CreateSpaceModelLoaded(updatedSpace,errorMessage: currentState.errorMessage));
emit(CreateSpaceModelLoaded(updatedSpace,
errorMessage: currentState.errorMessage));
} else {
emit(CreateSpaceModelError("Space template not initialized"));
}
@@ -217,8 +218,8 @@ class CreateSpaceModelBloc
if (prevSubspaces != null || newSubspaces != null) {
if (prevSubspaces != null && newSubspaces != null) {
for (var prevSubspace in prevSubspaces!) {
final existsInNew = newSubspaces!
for (var prevSubspace in prevSubspaces) {
final existsInNew = newSubspaces
.any((newTag) => newTag.uuid == prevSubspace.uuid);
if (!existsInNew) {
subspaceUpdates.add(UpdateSubspaceTemplateModel(
@@ -260,9 +261,20 @@ class CreateSpaceModelBloc
for (var subspace in newSubspaces!) subspace.uuid: subspace
};
for (var prevSubspace in prevSubspaces!) {
for (var prevSubspace in prevSubspaces) {
final newSubspace = newSubspaceMap[prevSubspace.uuid];
if (newSubspace != null) {
if(prevSubspace.tags!=null){
for(var t in prevSubspace.tags!){
print("old tags are ${t.tag} ${t.uuid}");
}}
if(newSubspace.tags!=null){
for(var t in newSubspace.tags!){
print("new tags are ${t.tag} ${t.uuid}");
}}
final List<TagModelUpdate> tagSubspaceUpdates =
processTagUpdates(prevSubspace.tags, newSubspace.tags);
subspaceUpdates.add(UpdateSubspaceTemplateModel(
@@ -270,7 +282,7 @@ class CreateSpaceModelBloc
uuid: newSubspace.uuid,
subspaceName: newSubspace.subspaceName,
tags: tagSubspaceUpdates));
} else {}
}
}
}
}
+1
View File
@@ -259,6 +259,7 @@ class Assets {
static const String delete = 'assets/icons/delete.svg';
static const String edit = 'assets/icons/edit.svg';
static const String editSpace = 'assets/icons/edit_space.svg';
//assets/icons/routine/tab_to_run.svg
static const String tabToRun = 'assets/icons/routine/tab_to_run.svg';