🐛 Fix share sheet

This commit is contained in:
LittleSheep 2025-06-26 14:45:44 +08:00
parent f2829b2012
commit e90b35f19f
2 changed files with 153 additions and 130 deletions

View File

@ -587,6 +587,11 @@
"addAdditionalMessage": "Add additional message...", "addAdditionalMessage": "Add additional message...",
"uploadingFiles": "Uploading files...", "uploadingFiles": "Uploading files...",
"sharedSuccessfully": "Shared successfully!", "sharedSuccessfully": "Shared successfully!",
"shareSuccess": "Shared successfully!",
"shareToSpecificChatSuccess": "Shared to {} successfully!",
"wouldYouLikeToGoToChat": "Would you like to go to the chat?",
"no": "No",
"yes": "Yes",
"navigateToChat": "Navigate to Chat", "navigateToChat": "Navigate to Chat",
"wouldYouLikeToNavigateToChat": "Would you like to navigate to the chat?", "wouldYouLikeToNavigateToChat": "Would you like to navigate to the chat?",
"abuseReport": "Report", "abuseReport": "Report",

View File

@ -403,13 +403,27 @@ class _ShareSheetState extends ConsumerState<ShareSheet> {
titleText: widget.title ?? 'share'.tr(), titleText: widget.title ?? 'share'.tr(),
heightFactor: 0.75, heightFactor: 0.75,
child: Column( child: Column(
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,
children: [ children: [
// Content preview // Content preview
Container( Container(
margin: const EdgeInsets.all(16), margin: const EdgeInsets.all(16),
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surfaceContainerHighest, color:
Theme.of(
context,
).colorScheme.surfaceContainerHighest,
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
), ),
child: Column( child: Column(
@ -417,8 +431,13 @@ class _ShareSheetState extends ConsumerState<ShareSheet> {
children: [ children: [
Text( Text(
'contentToShare'.tr(), 'contentToShare'.tr(),
style: Theme.of(context).textTheme.labelMedium?.copyWith( style: Theme.of(
color: Theme.of(context).colorScheme.onSurfaceVariant, context,
).textTheme.labelMedium?.copyWith(
color:
Theme.of(
context,
).colorScheme.onSurfaceVariant,
), ),
), ),
const SizedBox(height: 8), const SizedBox(height: 8),
@ -426,13 +445,6 @@ class _ShareSheetState extends ConsumerState<ShareSheet> {
], ],
), ),
), ),
// Share options
Expanded(
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Quick actions row (horizontally scrollable) // Quick actions row (horizontally scrollable)
Padding( Padding(
padding: const EdgeInsets.symmetric(horizontal: 16), padding: const EdgeInsets.symmetric(horizontal: 16),
@ -445,7 +457,9 @@ class _ShareSheetState extends ConsumerState<ShareSheet> {
context, context,
).textTheme.titleSmall?.copyWith( ).textTheme.titleSmall?.copyWith(
color: color:
Theme.of(context).colorScheme.onSurfaceVariant, Theme.of(
context,
).colorScheme.onSurfaceVariant,
), ),
), ),
const SizedBox(height: 12), const SizedBox(height: 12),
@ -494,7 +508,9 @@ class _ShareSheetState extends ConsumerState<ShareSheet> {
context, context,
).textTheme.titleSmall?.copyWith( ).textTheme.titleSmall?.copyWith(
color: color:
Theme.of(context).colorScheme.onSurfaceVariant, Theme.of(
context,
).colorScheme.onSurfaceVariant,
), ),
), ),
const SizedBox(height: 12), const SizedBox(height: 12),
@ -514,6 +530,10 @@ class _ShareSheetState extends ConsumerState<ShareSheet> {
vertical: 12, vertical: 12,
), ),
), ),
onTapOutside:
(_) =>
FocusManager.instance.primaryFocus
?.unfocus(),
maxLines: 3, maxLines: 3,
minLines: 1, minLines: 1,
enabled: !_isLoading, enabled: !_isLoading,
@ -533,6 +553,7 @@ class _ShareSheetState extends ConsumerState<ShareSheet> {
), ),
), ),
), ),
),
// Loading indicator and file upload progress // Loading indicator and file upload progress
if (_isLoading) if (_isLoading)
@ -829,9 +850,7 @@ class _TextPreview extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
constraints: const BoxConstraints(maxHeight: kPreviewMaxHeight), constraints: const BoxConstraints(maxHeight: kPreviewMaxHeight),
child: SingleChildScrollView(
child: Text(text, style: Theme.of(context).textTheme.bodyMedium), child: Text(text, style: Theme.of(context).textTheme.bodyMedium),
),
); );
} }
} }
@ -1000,7 +1019,6 @@ class _LinkPreview extends ConsumerWidget {
), ),
const SizedBox(height: 8), const SizedBox(height: 8),
Expanded( Expanded(
child: SingleChildScrollView(
child: SelectableText( child: SelectableText(
link, link,
style: Theme.of(context).textTheme.bodyMedium?.copyWith( style: Theme.of(context).textTheme.bodyMedium?.copyWith(
@ -1009,7 +1027,6 @@ class _LinkPreview extends ConsumerWidget {
), ),
), ),
), ),
),
], ],
), ),
); );
@ -1235,6 +1252,7 @@ void showShareSheet({
showModalBottomSheet( showModalBottomSheet(
context: context, context: context,
isScrollControlled: true, isScrollControlled: true,
useRootNavigator: true,
builder: builder:
(context) => ShareSheet( (context) => ShareSheet(
content: content, content: content,