diff --git a/lib/pages/spaces_management/widgets/community_stricture_header_widget.dart b/lib/pages/spaces_management/widgets/community_stricture_header_widget.dart index 90376bb4..c1de16c1 100644 --- a/lib/pages/spaces_management/widgets/community_stricture_header_widget.dart +++ b/lib/pages/spaces_management/widgets/community_stricture_header_widget.dart @@ -1,11 +1,13 @@ 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'; import 'package:syncrow_web/utils/constants/assets.dart'; class CommunityStructureHeader extends StatelessWidget { final String? communityName; final bool isEditingName; + final bool isSave; final TextEditingController nameController; final VoidCallback onSave; final VoidCallback onDelete; @@ -15,6 +17,7 @@ class CommunityStructureHeader extends StatelessWidget { const CommunityStructureHeader({ Key? key, required this.communityName, + required this.isSave, required this.isEditingName, required this.nameController, required this.onSave, @@ -25,15 +28,15 @@ class CommunityStructureHeader extends StatelessWidget { @override Widget build(BuildContext context) { + final theme = Theme.of(context); + return Container( padding: const EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 27.0), - width: double.infinity, decoration: BoxDecoration( color: ColorsManager.whiteColors, boxShadow: [ BoxShadow( color: ColorsManager.shadowBlackColor, - spreadRadius: 0, blurRadius: 8, offset: const Offset(0, 4), ), @@ -42,94 +45,109 @@ class CommunityStructureHeader extends StatelessWidget { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'Community Structure', - style: Theme.of(context) - .textTheme - .headlineLarge - ?.copyWith(color: ColorsManager.blackColor), - ), - if (communityName != null) - Row( - children: [ - if (!isEditingName) - Text( - communityName!, - style: Theme.of(context) - .textTheme - .bodyLarge - ?.copyWith(color: ColorsManager.blackColor), - ), - if (isEditingName) - SizedBox( - width: 200, - child: TextField( - controller: nameController, - decoration: const InputDecoration( - border: InputBorder.none, - isDense: true, - ), - style: const TextStyle(fontSize: 16, color: ColorsManager.blackColor), - onSubmitted: onNameSubmitted, - ), - ), - const SizedBox(width: 8), - GestureDetector( - onTap: onEditName, - child: SvgPicture.asset( - Assets.iconEdit, - width: 16, - height: 16, - ), - ), - ], - ), - ], - ), - Row( - children: [ - ElevatedButton.icon( - onPressed: onSave, - icon: const Icon(Icons.save, size: 18, color: ColorsManager.spaceColor), - label: const Text("Save"), - style: ElevatedButton.styleFrom( - backgroundColor: ColorsManager.textFieldGreyColor, - foregroundColor: ColorsManager.blackColor, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8.0), - ), - padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0), - side: BorderSide(color: Colors.grey.shade300), - elevation: 0, - ), - ), - const SizedBox(width: 10), - ElevatedButton.icon( - onPressed: onDelete, - icon: SvgPicture.asset( - Assets.delete, - width: 18, - height: 18, - ), - label: const Text("Delete"), - style: ElevatedButton.styleFrom( - backgroundColor: ColorsManager.textFieldGreyColor, - foregroundColor: Colors.black, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8.0), - ), - padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0), - side: BorderSide(color: ColorsManager.neutralGray), - elevation: 0, - ), - ), - ], - ), + _buildCommunityInfo(theme), + _buildActionButtons(), ], ), ); } + + Widget _buildCommunityInfo(ThemeData theme) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Community Structure', + style: theme.textTheme.headlineLarge?.copyWith(color: ColorsManager.blackColor), + ), + if (communityName != null) _buildCommunityName(), + ], + ); + } + + Widget _buildCommunityName() { + return Row( + children: [ + if (!isEditingName) + Text( + communityName!, + style: const TextStyle(fontSize: 16, color: ColorsManager.blackColor), + ), + if (isEditingName) + SizedBox( + width: 200, + child: TextField( + controller: nameController, + decoration: const InputDecoration( + border: InputBorder.none, + isDense: true, + ), + style: const TextStyle(fontSize: 16, color: ColorsManager.blackColor), + onSubmitted: onNameSubmitted, + ), + ), + const SizedBox(width: 8), + GestureDetector( + onTap: onEditName, + child: SvgPicture.asset( + Assets.iconEdit, + width: 16, + height: 16, + ), + ), + ], + ); + } + + Widget _buildActionButtons() { + return Row( + children: [ + if (isSave) + _buildButton( + label: "Save", + icon: const Icon(Icons.save, size: 18, color: ColorsManager.spaceColor), + onPressed: onSave, + ), + if (isSave) const SizedBox(width: 10), + if (communityName != null && communityName != '') + _buildButton( + label: "Delete", + icon: SvgPicture.asset( + Assets.delete, + width: 18, + height: 18, + ), + onPressed: onDelete, + ), + ], + ); + } + + Widget _buildButton({ + required String label, + required Widget icon, + required VoidCallback onPressed, + }) { + return SizedBox( + width: 100, + height: 30, + child: DefaultButton( + onPressed: onPressed, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + icon, + const SizedBox(width: 8), + Text(label), + ], + ), + backgroundColor: ColorsManager.textFieldGreyColor, + foregroundColor: ColorsManager.blackColor, + borderRadius: 8.0, + padding: 2.0, + elevation: 0, + borderColor: Colors.grey.shade300, + ), + ); + } } diff --git a/lib/pages/spaces_management/widgets/community_structure_widget.dart b/lib/pages/spaces_management/widgets/community_structure_widget.dart index f93d66c6..71b2ed27 100644 --- a/lib/pages/spaces_management/widgets/community_structure_widget.dart +++ b/lib/pages/spaces_management/widgets/community_structure_widget.dart @@ -1,7 +1,6 @@ // Flutter imports import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_svg/flutter_svg.dart'; // Syncrow project imports import 'package:syncrow_web/pages/common/buttons/add_space_button.dart'; @@ -14,12 +13,10 @@ import 'package:syncrow_web/pages/spaces_management/model/community_model.dart'; import 'package:syncrow_web/pages/spaces_management/model/connection_model.dart'; import 'package:syncrow_web/pages/spaces_management/widgets/community_stricture_header_widget.dart'; import 'package:syncrow_web/pages/spaces_management/widgets/dialogs/create_space_dialog.dart'; -import 'package:syncrow_web/pages/spaces_management/widgets/dialogs/delete_dialogue.dart'; import 'package:syncrow_web/pages/spaces_management/widgets/curved_line_painter.dart'; import 'package:syncrow_web/pages/spaces_management/widgets/space_card_widget.dart'; import 'package:syncrow_web/pages/spaces_management/widgets/space_container_widget.dart'; import 'package:syncrow_web/utils/color_manager.dart'; -import 'package:syncrow_web/utils/constants/assets.dart'; class CommunityStructureArea extends StatefulWidget { final CommunityModel? selectedCommunity; @@ -112,6 +109,7 @@ class _CommunityStructureAreaState extends State { children: [ CommunityStructureHeader( communityName: widget.selectedCommunity?.name, + isSave: widget.spaces.isNotEmpty, isEditingName: isEditingName, nameController: _nameController, onSave: _saveSpaces,