mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-08-25 22:09:40 +00:00
Rework fixes.
This commit is contained in:
@ -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<CommunitiesBloc>().add(
|
||||
InsertCommunity(community),
|
||||
);
|
||||
context.read<CommunitiesTreeSelectionBloc>().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,
|
||||
|
@ -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),
|
||||
);
|
||||
}
|
||||
|
@ -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<SpaceSubSpacesDialog> {
|
||||
@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<SpaceSubSpacesDialog> {
|
||||
SpaceDetailsActionButtons(
|
||||
onSave: _hasDuplicateNames ? null : _handleSave,
|
||||
onCancel: Navigator.of(context).pop,
|
||||
saveButtonLabel: 'Save',
|
||||
spacerFlex: 0,
|
||||
)
|
||||
],
|
||||
);
|
||||
|
@ -39,7 +39,7 @@ class _SubSpacesInputState extends State<SubSpacesInput> {
|
||||
@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,
|
||||
|
@ -124,16 +124,14 @@ class _SubspaceNameDisplayWidgetState extends State<SubspaceNameDisplayWidget> {
|
||||
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,
|
||||
|
Reference in New Issue
Block a user