mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
Refactor CommunityDialog: Extract error message display into a separate method _buildErrorMessage
for improved readability and maintainability. This change enhances the structure of the dialog while ensuring consistent error handling.
This commit is contained in:
@ -3,6 +3,7 @@ import 'package:syncrow_web/pages/common/buttons/cancel_button.dart';
|
||||
import 'package:syncrow_web/pages/common/buttons/default_button.dart';
|
||||
import 'package:syncrow_web/pages/space_management_v2/modules/create_community/presentation/create_community_name_text_field.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||
|
||||
class CommunityDialog extends StatefulWidget {
|
||||
final String? initialName;
|
||||
@ -72,19 +73,8 @@ class _CommunityDialogState extends State<CommunityDialog> {
|
||||
child: widget.title,
|
||||
),
|
||||
const SizedBox(height: 18),
|
||||
CreateCommunityNameTextField(
|
||||
nameController: _nameController,
|
||||
),
|
||||
if (widget.errorMessage != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 18),
|
||||
child: SelectableText(
|
||||
'* ${widget.errorMessage}',
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
),
|
||||
),
|
||||
CreateCommunityNameTextField(nameController: _nameController),
|
||||
_buildErrorMessage(),
|
||||
const SizedBox(height: 24),
|
||||
_buildActionButtons(context),
|
||||
],
|
||||
@ -131,4 +121,19 @@ class _CommunityDialogState extends State<CommunityDialog> {
|
||||
widget.onSubmit.call(_nameController.text.trim());
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildErrorMessage() {
|
||||
return Visibility(
|
||||
visible: widget.errorMessage != null,
|
||||
child: Padding(
|
||||
padding: const EdgeInsetsDirectional.symmetric(vertical: 18),
|
||||
child: SelectableText(
|
||||
'* ${widget.errorMessage}',
|
||||
style: context.textTheme.bodyMedium?.copyWith(
|
||||
color: context.theme.colorScheme.error,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user