🐛 Bug fixes
This commit is contained in:
@@ -9,12 +9,24 @@ export 'content/alert.native.dart'
|
||||
if (dart.library.html) 'content/alert.web.dart';
|
||||
|
||||
void showSnackBar(String message, {SnackBarAction? action}) {
|
||||
final context = globalOverlay.currentState!.context;
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
final padding = 40.0;
|
||||
final availableWidth = screenWidth - padding;
|
||||
|
||||
showTopSnackBar(
|
||||
globalOverlay.currentState!,
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 480),
|
||||
child: Center(
|
||||
child: Card(child: Text(message).padding(horizontal: 20, vertical: 16)),
|
||||
Center(
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
minWidth: availableWidth.clamp(0, 400),
|
||||
maxWidth: availableWidth.clamp(0, 600),
|
||||
),
|
||||
child: Card(
|
||||
elevation: 2,
|
||||
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||
child: Text(message).padding(horizontal: 20, vertical: 16),
|
||||
),
|
||||
),
|
||||
),
|
||||
snackBarPosition: SnackBarPosition.bottom,
|
||||
|
||||
@@ -22,23 +22,6 @@ class ComposeSubmitUtils {
|
||||
throw Exception('Already submitting');
|
||||
}
|
||||
|
||||
// Don't submit empty posts (no content and no attachments)
|
||||
final hasContent =
|
||||
state.titleController.text.trim().isNotEmpty ||
|
||||
state.descriptionController.text.trim().isNotEmpty ||
|
||||
state.contentController.text.trim().isNotEmpty;
|
||||
final hasAttachments = state.attachments.value.isNotEmpty;
|
||||
|
||||
if (!hasContent && !hasAttachments) {
|
||||
// Show error message if context is mounted
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text('postContentEmpty')));
|
||||
}
|
||||
throw Exception('Post content is empty'); // Don't submit empty posts
|
||||
}
|
||||
|
||||
try {
|
||||
state.submitting.value = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user