mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
community header
This commit is contained in:
@ -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,
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user