🐛 Fix bottom sheet didn't avoid keyboard

This commit is contained in:
2025-08-04 17:36:04 +08:00
parent 92685d7410
commit 1aa45dd9f1
3 changed files with 121 additions and 139 deletions

View File

@@ -33,6 +33,7 @@ class SheetScaffold extends StatelessWidget {
);
return Container(
padding: MediaQuery.of(context).viewInsets,
constraints: BoxConstraints(
maxHeight: height ?? MediaQuery.of(context).size.height * heightFactor,
),

View File

@@ -864,22 +864,22 @@ class PostReplyPreview extends HookConsumerWidget {
: featuredReply!.when(
data:
(value) => Row(
crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
spacing: 8,
children: [
ProfilePictureWidget(
file: value!.publisher.picture,
file: value?.publisher.picture,
radius: 12,
).padding(top: 4),
if (value.content?.isNotEmpty ?? false)
if (value?.content?.isNotEmpty ?? false)
Expanded(
child: MarkdownTextContent(content: value.content!),
child: MarkdownTextContent(content: value!.content!),
)
else
Expanded(
child: Text(
'postHasAttachments',
).plural(value.attachments.length),
).plural(value?.attachments.length ?? 0),
),
],
),

View File

@@ -284,7 +284,7 @@ class _ShareSheetState extends ConsumerState<ShareSheet> {
// Send message to chat room
await apiClient.post(
'/chat/${chatRoom.id}/messages',
'/sphere/chat/${chatRoom.id}/messages',
data: {'content': content, 'attachments_id': attachmentIds, 'meta': {}},
);
@@ -328,12 +328,7 @@ class _ShareSheetState extends ConsumerState<ShareSheet> {
}
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Failed to share to chat: $e'),
backgroundColor: Theme.of(context).colorScheme.error,
),
);
showSnackBar('Failed to share to chat: $e');
}
} finally {
if (mounted) {
@@ -405,11 +400,6 @@ class _ShareSheetState extends ConsumerState<ShareSheet> {
children: [
// Share options with keyboard avoidance
Expanded(
child: AnimatedPadding(
duration: const Duration(milliseconds: 300),
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).viewInsets.bottom,
),
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -420,9 +410,7 @@ class _ShareSheetState extends ConsumerState<ShareSheet> {
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color:
Theme.of(
context,
).colorScheme.surfaceContainerHighest,
Theme.of(context).colorScheme.surfaceContainerHighest,
borderRadius: BorderRadius.circular(12),
),
child: Column(
@@ -434,9 +422,7 @@ class _ShareSheetState extends ConsumerState<ShareSheet> {
context,
).textTheme.labelMedium?.copyWith(
color:
Theme.of(
context,
).colorScheme.onSurfaceVariant,
Theme.of(context).colorScheme.onSurfaceVariant,
),
),
const SizedBox(height: 8),
@@ -456,9 +442,7 @@ class _ShareSheetState extends ConsumerState<ShareSheet> {
context,
).textTheme.titleSmall?.copyWith(
color:
Theme.of(
context,
).colorScheme.onSurfaceVariant,
Theme.of(context).colorScheme.onSurfaceVariant,
),
),
const SizedBox(height: 12),
@@ -507,9 +491,7 @@ class _ShareSheetState extends ConsumerState<ShareSheet> {
context,
).textTheme.titleSmall?.copyWith(
color:
Theme.of(
context,
).colorScheme.onSurfaceVariant,
Theme.of(context).colorScheme.onSurfaceVariant,
),
),
const SizedBox(height: 12),
@@ -552,7 +534,6 @@ class _ShareSheetState extends ConsumerState<ShareSheet> {
),
),
),
),
// Loading indicator and file upload progress
if (_isLoading)