🐛 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( return Container(
padding: MediaQuery.of(context).viewInsets,
constraints: BoxConstraints( constraints: BoxConstraints(
maxHeight: height ?? MediaQuery.of(context).size.height * heightFactor, maxHeight: height ?? MediaQuery.of(context).size.height * heightFactor,
), ),

View File

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