From 47340c3235b5935b570f1b3024c60a66eae86179 Mon Sep 17 00:00:00 2001 From: Faris Armoush Date: Thu, 24 Jul 2025 12:34:06 +0300 Subject: [PATCH] Rework fixes. --- ...ce_management_community_dialog_helper.dart | 19 +++- .../widgets/create_space_button.dart | 99 +++++++++---------- .../presentation/create_community_dialog.dart | 23 ++--- .../widgets/space_details_action_buttons.dart | 34 +++++-- .../widgets/space_sub_spaces_dialog.dart | 13 ++- .../widgets/sub_spaces_input.dart | 2 +- .../widgets/subspace_name_display_widget.dart | 6 +- 7 files changed, 113 insertions(+), 83 deletions(-) diff --git a/lib/pages/space_management_v2/main_module/shared/helpers/space_management_community_dialog_helper.dart b/lib/pages/space_management_v2/main_module/shared/helpers/space_management_community_dialog_helper.dart index e1981208..b9d4265c 100644 --- a/lib/pages/space_management_v2/main_module/shared/helpers/space_management_community_dialog_helper.dart +++ b/lib/pages/space_management_v2/main_module/shared/helpers/space_management_community_dialog_helper.dart @@ -1,12 +1,29 @@ import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain/models/community_model.dart'; +import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/bloc/communities_bloc.dart'; +import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/communities_tree_selection_bloc/communities_tree_selection_bloc.dart'; import 'package:syncrow_web/pages/space_management_v2/modules/create_community/presentation/create_community_dialog.dart'; import 'package:syncrow_web/pages/space_management_v2/modules/update_community/presentation/edit_community_dialog.dart'; +import 'package:syncrow_web/utils/extension/app_snack_bar.dart'; abstract final class SpaceManagementCommunityDialogHelper { static void showCreateDialog(BuildContext context) => showDialog( context: context, - builder: (_) => const CreateCommunityDialog(), + builder: (_) => CreateCommunityDialog( + onSuccess: (community) { + context.showSuccessSnackbar( + '${community.name} community created successfully', + ); + context.read().add( + InsertCommunity(community), + ); + + context.read().add( + SelectCommunityEvent(community: community), + ); + }, + ), ); static void showEditDialog( diff --git a/lib/pages/space_management_v2/main_module/widgets/create_space_button.dart b/lib/pages/space_management_v2/main_module/widgets/create_space_button.dart index 4032c2ab..0906f31b 100644 --- a/lib/pages/space_management_v2/main_module/widgets/create_space_button.dart +++ b/lib/pages/space_management_v2/main_module/widgets/create_space_button.dart @@ -23,62 +23,55 @@ class _CreateSpaceButtonState extends State { @override Widget build(BuildContext context) { - return Tooltip( - margin: const EdgeInsets.symmetric(vertical: 24), - message: 'Create a new space', - child: InkWell( - onTap: () => SpaceDetailsDialogHelper.showCreate( - context, - communityUuid: widget.community.uuid, - onSuccess: (updatedSpaceModel) { - final newCommunity = widget.community.copyWith( - spaces: [...widget.community.spaces, updatedSpaceModel], - ); - context.read().add( - CommunitiesUpdateCommunity(newCommunity), - ); - context.read().add( - SelectSpaceEvent( - space: updatedSpaceModel, - community: newCommunity, - ), - ); - }, - ), - child: MouseRegion( - onEnter: (_) => setState(() => _isHovered = true), - onExit: (_) => setState(() => _isHovered = false), - child: AnimatedOpacity( - duration: const Duration(milliseconds: 100), - opacity: _isHovered ? 1.0 : 0.45, + return InkWell( + onTap: () => SpaceDetailsDialogHelper.showCreate( + context, + communityUuid: widget.community.uuid, + onSuccess: (updatedSpaceModel) { + final newCommunity = widget.community.copyWith( + spaces: [...widget.community.spaces, updatedSpaceModel], + ); + context.read().add( + CommunitiesUpdateCommunity(newCommunity), + ); + context.read().add( + SelectSpaceEvent( + space: updatedSpaceModel, + community: newCommunity, + ), + ); + }, + ), + child: MouseRegion( + onEnter: (_) => setState(() => _isHovered = true), + onExit: (_) => setState(() => _isHovered = false), + child: AnimatedOpacity( + duration: const Duration(milliseconds: 100), + opacity: _isHovered ? 1.0 : 0.45, + child: Container( + width: 150, + height: 90, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(20), + boxShadow: [ + BoxShadow( + color: Colors.grey.withValues(alpha: 0.8), + spreadRadius: 3, + blurRadius: 8, + offset: const Offset(0, 4), + ), + ], + ), child: Container( - width: 150, - height: 90, + margin: const EdgeInsets.symmetric(vertical: 20), decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(20), - boxShadow: [ - BoxShadow( - color: Colors.grey.withValues(alpha: 0.2), - spreadRadius: 3, - blurRadius: 8, - offset: const Offset(0, 4), - ), - ], + border: Border.all(color: ColorsManager.borderColor, width: 2), + color: ColorsManager.boxColor, + shape: BoxShape.circle, ), - child: Container( - margin: const EdgeInsets.symmetric(vertical: 20), - decoration: BoxDecoration( - border: Border.all(color: ColorsManager.borderColor, width: 2), - color: ColorsManager.boxColor, - shape: BoxShape.circle, - ), - child: const Center( - child: Icon( - Icons.add, - color: Colors.blue, - ), - ), + child: const Center( + child: Icon(Icons.add, color: ColorsManager.vividBlue), ), ), ), diff --git a/lib/pages/space_management_v2/modules/create_community/presentation/create_community_dialog.dart b/lib/pages/space_management_v2/modules/create_community/presentation/create_community_dialog.dart index 299c0078..0bd63616 100644 --- a/lib/pages/space_management_v2/modules/create_community/presentation/create_community_dialog.dart +++ b/lib/pages/space_management_v2/modules/create_community/presentation/create_community_dialog.dart @@ -2,15 +2,19 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:syncrow_web/pages/space_management_v2/main_module/shared/helpers/space_management_community_dialog_helper.dart'; import 'package:syncrow_web/pages/space_management_v2/main_module/shared/widgets/community_dialog.dart'; -import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/bloc/communities_bloc.dart'; -import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/communities_tree_selection_bloc/communities_tree_selection_bloc.dart'; +import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain/models/community_model.dart'; import 'package:syncrow_web/pages/space_management_v2/modules/create_community/data/services/remote_create_community_service.dart'; import 'package:syncrow_web/pages/space_management_v2/modules/create_community/domain/param/create_community_param.dart'; import 'package:syncrow_web/pages/space_management_v2/modules/create_community/presentation/bloc/create_community_bloc.dart'; import 'package:syncrow_web/services/api/http_service.dart'; class CreateCommunityDialog extends StatelessWidget { - const CreateCommunityDialog({super.key}); + const CreateCommunityDialog({ + required this.onSuccess, + super.key, + }); + + final void Function(CommunityModel community) onSuccess; @override Widget build(BuildContext context) { @@ -27,23 +31,14 @@ class CreateCommunityDialog extends StatelessWidget { case CreateCommunitySuccess(:final community): Navigator.of(context).pop(); Navigator.of(context).pop(); - SpaceManagementCommunityDialogHelper.showSuccessSnackBar( - context, - '${community.name} community created successfully', - ); - context.read().add( - InsertCommunity(community), - ); - context.read().add( - SelectCommunityEvent(community: community), - ); + onSuccess(community); break; case CreateCommunityFailure(): Navigator.of(context).pop(); break; } }, - builder: (BuildContext context, CreateCommunityState state) { + builder: (context, state) { return CommunityDialog( title: const Text('Create Community'), initialName: null, diff --git a/lib/pages/space_management_v2/modules/space_details/presentation/widgets/space_details_action_buttons.dart b/lib/pages/space_management_v2/modules/space_details/presentation/widgets/space_details_action_buttons.dart index 5a0d6d63..4d462091 100644 --- a/lib/pages/space_management_v2/modules/space_details/presentation/widgets/space_details_action_buttons.dart +++ b/lib/pages/space_management_v2/modules/space_details/presentation/widgets/space_details_action_buttons.dart @@ -1,6 +1,4 @@ import 'package:flutter/material.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/utils/color_manager.dart'; class SpaceDetailsActionButtons extends StatelessWidget { @@ -10,12 +8,14 @@ class SpaceDetailsActionButtons extends StatelessWidget { required this.onCancel, this.saveButtonLabel = 'OK', this.cancelButtonLabel = 'Cancel', + this.spacerFlex = 1, }); final VoidCallback onCancel; final VoidCallback? onSave; final String saveButtonLabel; final String cancelButtonLabel; + final int spacerFlex; @override Widget build(BuildContext context) { @@ -24,24 +24,40 @@ class SpaceDetailsActionButtons extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, spacing: 10, children: [ - const Spacer(), + if (spacerFlex > 0) Spacer(flex: spacerFlex), Expanded(flex: 2, child: _buildCancelButton(context)), Expanded(flex: 2, child: _buildSaveButton()), - const Spacer(), + if (spacerFlex > 0) Spacer(flex: spacerFlex), ], ); } Widget _buildCancelButton(BuildContext context) { - return CancelButton(onPressed: onCancel, label: cancelButtonLabel); + return ElevatedButton( + onPressed: onSave, + style: ElevatedButton.styleFrom( + elevation: 4, + backgroundColor: ColorsManager.boxColor, + foregroundColor: ColorsManager.blackColor, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + ), + child: Text(cancelButtonLabel), + ); } Widget _buildSaveButton() { - return DefaultButton( + return ElevatedButton( onPressed: onSave, - borderRadius: 10, - backgroundColor: ColorsManager.secondaryColor, - foregroundColor: ColorsManager.white, + style: ElevatedButton.styleFrom( + elevation: 4, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + backgroundColor: ColorsManager.secondaryColor, + foregroundColor: ColorsManager.white, + ), child: Text(saveButtonLabel), ); } diff --git a/lib/pages/space_management_v2/modules/space_details/presentation/widgets/space_sub_spaces_dialog.dart b/lib/pages/space_management_v2/modules/space_details/presentation/widgets/space_sub_spaces_dialog.dart index 6b05ab8a..34d16465 100644 --- a/lib/pages/space_management_v2/modules/space_details/presentation/widgets/space_sub_spaces_dialog.dart +++ b/lib/pages/space_management_v2/modules/space_details/presentation/widgets/space_sub_spaces_dialog.dart @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; import 'package:syncrow_web/pages/space_management_v2/modules/space_details/domain/models/subspace.dart'; import 'package:syncrow_web/pages/space_management_v2/modules/space_details/presentation/widgets/space_details_action_buttons.dart'; import 'package:syncrow_web/pages/space_management_v2/modules/space_details/presentation/widgets/sub_spaces_input.dart'; +import 'package:syncrow_web/utils/color_manager.dart'; +import 'package:syncrow_web/utils/extension/build_context_x.dart'; import 'package:uuid/uuid.dart'; class SpaceSubSpacesDialog extends StatefulWidget { @@ -68,7 +70,14 @@ class _SpaceSubSpacesDialogState extends State { @override Widget build(BuildContext context) { return AlertDialog( - title: const SelectableText('Create Sub Spaces'), + title: DefaultTextStyle( + style: context.textTheme.titleLarge!.copyWith( + fontSize: 30, + fontWeight: FontWeight.w400, + color: ColorsManager.blackColor, + ), + child: const SelectableText('Create Sub-Space'), + ), content: Column( spacing: 12, mainAxisSize: MainAxisSize.min, @@ -96,6 +105,8 @@ class _SpaceSubSpacesDialogState extends State { SpaceDetailsActionButtons( onSave: _hasDuplicateNames ? null : _handleSave, onCancel: Navigator.of(context).pop, + saveButtonLabel: 'Save', + spacerFlex: 0, ) ], ); diff --git a/lib/pages/space_management_v2/modules/space_details/presentation/widgets/sub_spaces_input.dart b/lib/pages/space_management_v2/modules/space_details/presentation/widgets/sub_spaces_input.dart index dac52f93..96a1bdac 100644 --- a/lib/pages/space_management_v2/modules/space_details/presentation/widgets/sub_spaces_input.dart +++ b/lib/pages/space_management_v2/modules/space_details/presentation/widgets/sub_spaces_input.dart @@ -39,7 +39,7 @@ class _SubSpacesInputState extends State { @override Widget build(BuildContext context) { return Container( - width: context.screenWidth * 0.35, + width: context.screenWidth * 0.335, padding: const EdgeInsets.symmetric( vertical: 10, horizontal: 16, diff --git a/lib/pages/space_management_v2/modules/space_details/presentation/widgets/subspace_name_display_widget.dart b/lib/pages/space_management_v2/modules/space_details/presentation/widgets/subspace_name_display_widget.dart index 9096db27..88c3b639 100644 --- a/lib/pages/space_management_v2/modules/space_details/presentation/widgets/subspace_name_display_widget.dart +++ b/lib/pages/space_management_v2/modules/space_details/presentation/widgets/subspace_name_display_widget.dart @@ -124,16 +124,14 @@ class _SubspaceNameDisplayWidgetState extends State { children: [ SizedBox( width: context.screenWidth * 0.065, - height: context.screenHeight * 0.025, + height: context.screenHeight * 0.0135, child: TextField( focusNode: _focusNode, controller: _controller, style: textStyle?.copyWith( color: _hasDuplicateName ? Colors.red : null, ), - decoration: const InputDecoration.collapsed( - hintText: '', - ), + decoration: const InputDecoration.collapsed(hintText: ''), onChanged: _handleNameChange, onTapOutside: (_) => _tryToFinishEditing(), onSubmitted: _tryToSubmit,