mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-08-25 17:09:40 +00:00
Rework fixes.
This commit is contained in:
@ -1,12 +1,29 @@
|
|||||||
import 'package:flutter/material.dart';
|
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/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/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/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 {
|
abstract final class SpaceManagementCommunityDialogHelper {
|
||||||
static void showCreateDialog(BuildContext context) => showDialog<void>(
|
static void showCreateDialog(BuildContext context) => showDialog<void>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (_) => const CreateCommunityDialog(),
|
builder: (_) => CreateCommunityDialog(
|
||||||
|
onSuccess: (community) {
|
||||||
|
context.showSuccessSnackbar(
|
||||||
|
'${community.name} community created successfully',
|
||||||
|
);
|
||||||
|
context.read<CommunitiesBloc>().add(
|
||||||
|
InsertCommunity(community),
|
||||||
|
);
|
||||||
|
|
||||||
|
context.read<CommunitiesTreeSelectionBloc>().add(
|
||||||
|
SelectCommunityEvent(community: community),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
static void showEditDialog(
|
static void showEditDialog(
|
||||||
|
@ -23,62 +23,55 @@ class _CreateSpaceButtonState extends State<CreateSpaceButton> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Tooltip(
|
return InkWell(
|
||||||
margin: const EdgeInsets.symmetric(vertical: 24),
|
onTap: () => SpaceDetailsDialogHelper.showCreate(
|
||||||
message: 'Create a new space',
|
context,
|
||||||
child: InkWell(
|
communityUuid: widget.community.uuid,
|
||||||
onTap: () => SpaceDetailsDialogHelper.showCreate(
|
onSuccess: (updatedSpaceModel) {
|
||||||
context,
|
final newCommunity = widget.community.copyWith(
|
||||||
communityUuid: widget.community.uuid,
|
spaces: [...widget.community.spaces, updatedSpaceModel],
|
||||||
onSuccess: (updatedSpaceModel) {
|
);
|
||||||
final newCommunity = widget.community.copyWith(
|
context.read<CommunitiesBloc>().add(
|
||||||
spaces: [...widget.community.spaces, updatedSpaceModel],
|
CommunitiesUpdateCommunity(newCommunity),
|
||||||
);
|
);
|
||||||
context.read<CommunitiesBloc>().add(
|
context.read<CommunitiesTreeSelectionBloc>().add(
|
||||||
CommunitiesUpdateCommunity(newCommunity),
|
SelectSpaceEvent(
|
||||||
);
|
space: updatedSpaceModel,
|
||||||
context.read<CommunitiesTreeSelectionBloc>().add(
|
community: newCommunity,
|
||||||
SelectSpaceEvent(
|
),
|
||||||
space: updatedSpaceModel,
|
);
|
||||||
community: newCommunity,
|
},
|
||||||
),
|
),
|
||||||
);
|
child: MouseRegion(
|
||||||
},
|
onEnter: (_) => setState(() => _isHovered = true),
|
||||||
),
|
onExit: (_) => setState(() => _isHovered = false),
|
||||||
child: MouseRegion(
|
child: AnimatedOpacity(
|
||||||
onEnter: (_) => setState(() => _isHovered = true),
|
duration: const Duration(milliseconds: 100),
|
||||||
onExit: (_) => setState(() => _isHovered = false),
|
opacity: _isHovered ? 1.0 : 0.45,
|
||||||
child: AnimatedOpacity(
|
child: Container(
|
||||||
duration: const Duration(milliseconds: 100),
|
width: 150,
|
||||||
opacity: _isHovered ? 1.0 : 0.45,
|
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(
|
child: Container(
|
||||||
width: 150,
|
margin: const EdgeInsets.symmetric(vertical: 20),
|
||||||
height: 90,
|
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
border: Border.all(color: ColorsManager.borderColor, width: 2),
|
||||||
borderRadius: BorderRadius.circular(20),
|
color: ColorsManager.boxColor,
|
||||||
boxShadow: [
|
shape: BoxShape.circle,
|
||||||
BoxShadow(
|
|
||||||
color: Colors.grey.withValues(alpha: 0.2),
|
|
||||||
spreadRadius: 3,
|
|
||||||
blurRadius: 8,
|
|
||||||
offset: const Offset(0, 4),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
child: Container(
|
child: const Center(
|
||||||
margin: const EdgeInsets.symmetric(vertical: 20),
|
child: Icon(Icons.add, color: ColorsManager.vividBlue),
|
||||||
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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -2,15 +2,19 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.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/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/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/domain/models/community_model.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/data/services/remote_create_community_service.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/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/pages/space_management_v2/modules/create_community/presentation/bloc/create_community_bloc.dart';
|
||||||
import 'package:syncrow_web/services/api/http_service.dart';
|
import 'package:syncrow_web/services/api/http_service.dart';
|
||||||
|
|
||||||
class CreateCommunityDialog extends StatelessWidget {
|
class CreateCommunityDialog extends StatelessWidget {
|
||||||
const CreateCommunityDialog({super.key});
|
const CreateCommunityDialog({
|
||||||
|
required this.onSuccess,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
|
final void Function(CommunityModel community) onSuccess;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -27,23 +31,14 @@ class CreateCommunityDialog extends StatelessWidget {
|
|||||||
case CreateCommunitySuccess(:final community):
|
case CreateCommunitySuccess(:final community):
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
SpaceManagementCommunityDialogHelper.showSuccessSnackBar(
|
onSuccess(community);
|
||||||
context,
|
|
||||||
'${community.name} community created successfully',
|
|
||||||
);
|
|
||||||
context.read<CommunitiesBloc>().add(
|
|
||||||
InsertCommunity(community),
|
|
||||||
);
|
|
||||||
context.read<CommunitiesTreeSelectionBloc>().add(
|
|
||||||
SelectCommunityEvent(community: community),
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case CreateCommunityFailure():
|
case CreateCommunityFailure():
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
builder: (BuildContext context, CreateCommunityState state) {
|
builder: (context, state) {
|
||||||
return CommunityDialog(
|
return CommunityDialog(
|
||||||
title: const Text('Create Community'),
|
title: const Text('Create Community'),
|
||||||
initialName: null,
|
initialName: null,
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import 'package:flutter/material.dart';
|
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';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
|
||||||
class SpaceDetailsActionButtons extends StatelessWidget {
|
class SpaceDetailsActionButtons extends StatelessWidget {
|
||||||
@ -10,12 +8,14 @@ class SpaceDetailsActionButtons extends StatelessWidget {
|
|||||||
required this.onCancel,
|
required this.onCancel,
|
||||||
this.saveButtonLabel = 'OK',
|
this.saveButtonLabel = 'OK',
|
||||||
this.cancelButtonLabel = 'Cancel',
|
this.cancelButtonLabel = 'Cancel',
|
||||||
|
this.spacerFlex = 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
final VoidCallback onCancel;
|
final VoidCallback onCancel;
|
||||||
final VoidCallback? onSave;
|
final VoidCallback? onSave;
|
||||||
final String saveButtonLabel;
|
final String saveButtonLabel;
|
||||||
final String cancelButtonLabel;
|
final String cancelButtonLabel;
|
||||||
|
final int spacerFlex;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -24,24 +24,40 @@ class SpaceDetailsActionButtons extends StatelessWidget {
|
|||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
spacing: 10,
|
spacing: 10,
|
||||||
children: [
|
children: [
|
||||||
const Spacer(),
|
if (spacerFlex > 0) Spacer(flex: spacerFlex),
|
||||||
Expanded(flex: 2, child: _buildCancelButton(context)),
|
Expanded(flex: 2, child: _buildCancelButton(context)),
|
||||||
Expanded(flex: 2, child: _buildSaveButton()),
|
Expanded(flex: 2, child: _buildSaveButton()),
|
||||||
const Spacer(),
|
if (spacerFlex > 0) Spacer(flex: spacerFlex),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildCancelButton(BuildContext context) {
|
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() {
|
Widget _buildSaveButton() {
|
||||||
return DefaultButton(
|
return ElevatedButton(
|
||||||
onPressed: onSave,
|
onPressed: onSave,
|
||||||
borderRadius: 10,
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: ColorsManager.secondaryColor,
|
elevation: 4,
|
||||||
foregroundColor: ColorsManager.white,
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
|
backgroundColor: ColorsManager.secondaryColor,
|
||||||
|
foregroundColor: ColorsManager.white,
|
||||||
|
),
|
||||||
child: Text(saveButtonLabel),
|
child: Text(saveButtonLabel),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -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/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/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/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';
|
import 'package:uuid/uuid.dart';
|
||||||
|
|
||||||
class SpaceSubSpacesDialog extends StatefulWidget {
|
class SpaceSubSpacesDialog extends StatefulWidget {
|
||||||
@ -68,7 +70,14 @@ class _SpaceSubSpacesDialogState extends State<SpaceSubSpacesDialog> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return AlertDialog(
|
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(
|
content: Column(
|
||||||
spacing: 12,
|
spacing: 12,
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
@ -96,6 +105,8 @@ class _SpaceSubSpacesDialogState extends State<SpaceSubSpacesDialog> {
|
|||||||
SpaceDetailsActionButtons(
|
SpaceDetailsActionButtons(
|
||||||
onSave: _hasDuplicateNames ? null : _handleSave,
|
onSave: _hasDuplicateNames ? null : _handleSave,
|
||||||
onCancel: Navigator.of(context).pop,
|
onCancel: Navigator.of(context).pop,
|
||||||
|
saveButtonLabel: 'Save',
|
||||||
|
spacerFlex: 0,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
@ -39,7 +39,7 @@ class _SubSpacesInputState extends State<SubSpacesInput> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
width: context.screenWidth * 0.35,
|
width: context.screenWidth * 0.335,
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
vertical: 10,
|
vertical: 10,
|
||||||
horizontal: 16,
|
horizontal: 16,
|
||||||
|
@ -124,16 +124,14 @@ class _SubspaceNameDisplayWidgetState extends State<SubspaceNameDisplayWidget> {
|
|||||||
children: [
|
children: [
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: context.screenWidth * 0.065,
|
width: context.screenWidth * 0.065,
|
||||||
height: context.screenHeight * 0.025,
|
height: context.screenHeight * 0.0135,
|
||||||
child: TextField(
|
child: TextField(
|
||||||
focusNode: _focusNode,
|
focusNode: _focusNode,
|
||||||
controller: _controller,
|
controller: _controller,
|
||||||
style: textStyle?.copyWith(
|
style: textStyle?.copyWith(
|
||||||
color: _hasDuplicateName ? Colors.red : null,
|
color: _hasDuplicateName ? Colors.red : null,
|
||||||
),
|
),
|
||||||
decoration: const InputDecoration.collapsed(
|
decoration: const InputDecoration.collapsed(hintText: ''),
|
||||||
hintText: '',
|
|
||||||
),
|
|
||||||
onChanged: _handleNameChange,
|
onChanged: _handleNameChange,
|
||||||
onTapOutside: (_) => _tryToFinishEditing(),
|
onTapOutside: (_) => _tryToFinishEditing(),
|
||||||
onSubmitted: _tryToSubmit,
|
onSubmitted: _tryToSubmit,
|
||||||
|
Reference in New Issue
Block a user