mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-08-24 23:32:27 +00:00
Refactor SpaceDetailsDialog to improve title handling and loading/error dialogs
This commit is contained in:
@ -43,12 +43,23 @@ class _SpaceDetailsDialogState extends State<SpaceDetailsDialog> {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
Widget _buildTitle(BuildContext context) {
|
||||
return DefaultTextStyle(
|
||||
style: context.textTheme.titleLarge!.copyWith(
|
||||
fontSize: 30,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: ColorsManager.blackColor,
|
||||
),
|
||||
child: widget.title,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final isCreateMode = widget.spaceModel.uuid.isEmpty;
|
||||
if (isCreateMode) {
|
||||
return SpaceDetailsForm(
|
||||
title: widget.title,
|
||||
title: _buildTitle(context),
|
||||
space: SpaceDetailsModel.empty(),
|
||||
onSave: widget.onSave,
|
||||
);
|
||||
@ -57,23 +68,23 @@ class _SpaceDetailsDialogState extends State<SpaceDetailsDialog> {
|
||||
return BlocBuilder<SpaceDetailsBloc, SpaceDetailsState>(
|
||||
bloc: widget.context.read<SpaceDetailsBloc>(),
|
||||
builder: (context, state) => switch (state) {
|
||||
SpaceDetailsInitial() => _buildLoadingDialog(),
|
||||
SpaceDetailsLoading() => _buildLoadingDialog(),
|
||||
SpaceDetailsInitial() => buildLoadingDialog(),
|
||||
SpaceDetailsLoading() => buildLoadingDialog(),
|
||||
SpaceDetailsLoaded(:final spaceDetails) => SpaceDetailsForm(
|
||||
title: widget.title,
|
||||
title: _buildTitle(context),
|
||||
space: spaceDetails,
|
||||
onSave: widget.onSave,
|
||||
),
|
||||
SpaceDetailsFailure(:final errorMessage) => _buildErrorDialog(
|
||||
SpaceDetailsFailure(:final errorMessage) => buildErrorDialog(
|
||||
errorMessage,
|
||||
),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLoadingDialog() {
|
||||
Widget buildLoadingDialog() {
|
||||
return AlertDialog(
|
||||
title: widget.title,
|
||||
title: _buildTitle(context),
|
||||
backgroundColor: ColorsManager.white,
|
||||
content: SizedBox(
|
||||
height: context.screenHeight * 0.3,
|
||||
@ -83,18 +94,17 @@ class _SpaceDetailsDialogState extends State<SpaceDetailsDialog> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildErrorDialog(String errorMessage) {
|
||||
Widget buildErrorDialog(String errorMessage) {
|
||||
return AlertDialog(
|
||||
title: widget.title,
|
||||
title: _buildTitle(context),
|
||||
backgroundColor: ColorsManager.white,
|
||||
content: Center(
|
||||
child: SelectableText(
|
||||
errorMessage,
|
||||
style: context.textTheme.bodyLarge?.copyWith(
|
||||
color: ColorsManager.red,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 18,
|
||||
),
|
||||
content: SelectableText(
|
||||
errorMessage,
|
||||
textAlign: TextAlign.center,
|
||||
style: context.textTheme.bodyLarge?.copyWith(
|
||||
color: ColorsManager.red,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
Reference in New Issue
Block a user