✨ Receving share from system
This commit is contained in:
parent
a7c9a2281c
commit
0062d3baf0
@ -846,6 +846,7 @@
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CODE_SIGN_ENTITLEMENTS = SolianShareExtension/SolianShareExtension.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
CUSTOM_GROUP_ID = group.solsynth.solian;
|
||||
@ -888,6 +889,7 @@
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CODE_SIGN_ENTITLEMENTS = SolianShareExtension/SolianShareExtension.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
CUSTOM_GROUP_ID = group.solsynth.solian;
|
||||
@ -927,6 +929,7 @@
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CODE_SIGN_ENTITLEMENTS = SolianShareExtension/SolianShareExtension.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
CUSTOM_GROUP_ID = group.solsynth.solian;
|
||||
@ -966,6 +969,7 @@
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CODE_SIGN_ENTITLEMENTS = SolianNotificationService/SolianNotificationService.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_TEAM = W7HPZ53V6B;
|
||||
@ -1007,6 +1011,7 @@
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CODE_SIGN_ENTITLEMENTS = SolianNotificationService/SolianNotificationService.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_TEAM = W7HPZ53V6B;
|
||||
@ -1045,6 +1050,7 @@
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CODE_SIGN_ENTITLEMENTS = SolianNotificationService/SolianNotificationService.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_TEAM = W7HPZ53V6B;
|
||||
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.application-groups</key>
|
||||
<array>
|
||||
<string>group.solsynth.solian</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
10
ios/SolianShareExtension/SolianShareExtension.entitlements
Normal file
10
ios/SolianShareExtension/SolianShareExtension.entitlements
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.application-groups</key>
|
||||
<array>
|
||||
<string>group.solsynth.solian</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
@ -19,6 +19,7 @@ import 'package:island/pods/userinfo.dart';
|
||||
import 'package:island/pods/websocket.dart';
|
||||
import 'package:island/route.dart';
|
||||
import 'package:island/services/notify.dart';
|
||||
import 'package:island/widgets/app_wrapper.dart';
|
||||
import 'package:island/services/timezone.dart';
|
||||
import 'package:island/widgets/alert.dart';
|
||||
import 'package:island/widgets/app_scaffold.dart';
|
||||
@ -60,11 +61,11 @@ void main() async {
|
||||
if (!kIsWeb && (Platform.isMacOS || Platform.isLinux || Platform.isWindows)) {
|
||||
doWhenWindowReady(() {
|
||||
const defaultSize = Size(360, 640);
|
||||
|
||||
|
||||
// Get saved window size from preferences
|
||||
final savedSizeString = prefs.getString(kAppWindowSize);
|
||||
Size initialSize = defaultSize;
|
||||
|
||||
|
||||
if (savedSizeString != null) {
|
||||
try {
|
||||
final parts = savedSizeString.split(',');
|
||||
@ -78,12 +79,14 @@ void main() async {
|
||||
initialSize = defaultSize;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
appWindow.minSize = defaultSize;
|
||||
appWindow.size = initialSize;
|
||||
appWindow.alignment = Alignment.center;
|
||||
appWindow.show();
|
||||
log("[SplashScreen] Desktop window is ready with size: ${initialSize.width}x${initialSize.height}");
|
||||
log(
|
||||
"[SplashScreen] Desktop window is ready with size: ${initialSize.width}x${initialSize.height}",
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -8,13 +8,17 @@ class AppRouter extends RootStackRouter {
|
||||
|
||||
@override
|
||||
List<AutoRoute> get routes => [
|
||||
AutoRoute(page: PostComposeRoute.page, path: '/posts/compose'),
|
||||
AutoRoute(page: PostEditRoute.page, path: '/posts/:id/edit'),
|
||||
AutoRoute(page: CallRoute.page, path: '/chat/:id/call'),
|
||||
AutoRoute(page: EventCalanderRoute.page, path: '/account/:name/calendar'),
|
||||
AutoRoute(path: '/', page: AppWrapper.page, children: _appRoutes),
|
||||
];
|
||||
|
||||
List<AutoRoute> get _appRoutes => [
|
||||
AutoRoute(page: PostComposeRoute.page, path: 'posts/compose'),
|
||||
AutoRoute(page: PostEditRoute.page, path: 'posts/:id/edit'),
|
||||
AutoRoute(page: CallRoute.page, path: 'chat/:id/call'),
|
||||
AutoRoute(page: EventCalanderRoute.page, path: 'account/:name/calendar'),
|
||||
AutoRoute(
|
||||
page: TabsRoute.page,
|
||||
path: '/',
|
||||
path: '',
|
||||
children: [
|
||||
AutoRoute(
|
||||
page: ExploreShellRoute.page,
|
||||
@ -58,7 +62,7 @@ class AppRouter extends RootStackRouter {
|
||||
),
|
||||
AutoRoute(
|
||||
page: CreatorHubShellRoute.page,
|
||||
path: '/creators',
|
||||
path: 'creators',
|
||||
children: [
|
||||
AutoRoute(page: CreatorHubRoute.page, path: ''),
|
||||
AutoRoute(page: CreatorPostListRoute.page, path: ':name/posts'),
|
||||
@ -81,11 +85,11 @@ class AppRouter extends RootStackRouter {
|
||||
AutoRoute(page: EditPublisherRoute.page, path: ':name/edit'),
|
||||
],
|
||||
),
|
||||
AutoRoute(page: LoginRoute.page, path: '/auth/login'),
|
||||
AutoRoute(page: CreateAccountRoute.page, path: '/auth/create-account'),
|
||||
AutoRoute(page: SettingsRoute.page, path: '/settings'),
|
||||
AutoRoute(page: NewRealmRoute.page, path: '/realms/new'),
|
||||
AutoRoute(page: RealmDetailRoute.page, path: '/realms/:slug'),
|
||||
AutoRoute(page: EditRealmRoute.page, path: '/realms/:slug/edit'),
|
||||
AutoRoute(page: LoginRoute.page, path: 'auth/login'),
|
||||
AutoRoute(page: CreateAccountRoute.page, path: 'auth/create-account'),
|
||||
AutoRoute(page: SettingsRoute.page, path: 'settings'),
|
||||
AutoRoute(page: NewRealmRoute.page, path: 'realms/new'),
|
||||
AutoRoute(page: RealmDetailRoute.page, path: 'realms/:slug'),
|
||||
AutoRoute(page: EditRealmRoute.page, path: 'realms/:slug/edit'),
|
||||
];
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -7,7 +7,7 @@ part of 'compose_storage_db.dart';
|
||||
// **************************************************************************
|
||||
|
||||
String _$composeStorageNotifierHash() =>
|
||||
r'3de7a01a93d999d45a32fb68617b77f194589686';
|
||||
r'4ab4dce85d0a961f096dc3b11505f8f0964dee9d';
|
||||
|
||||
/// See also [ComposeStorageNotifier].
|
||||
@ProviderFor(ComposeStorageNotifier)
|
||||
|
91
lib/services/sharing_intent.dart
Normal file
91
lib/services/sharing_intent.dart
Normal file
@ -0,0 +1,91 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:receive_sharing_intent/receive_sharing_intent.dart';
|
||||
import 'package:island/widgets/share/share_sheet.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
|
||||
class SharingIntentService {
|
||||
static final SharingIntentService _instance =
|
||||
SharingIntentService._internal();
|
||||
factory SharingIntentService() => _instance;
|
||||
SharingIntentService._internal();
|
||||
|
||||
StreamSubscription<List<SharedMediaFile>>? _intentSub;
|
||||
BuildContext? _context;
|
||||
|
||||
/// Initialize the sharing intent service
|
||||
void initialize(BuildContext context) {
|
||||
debugPrint("SharingIntentService: Initializing with context");
|
||||
_context = context;
|
||||
_setupSharingListeners();
|
||||
}
|
||||
|
||||
/// Setup listeners for sharing intents
|
||||
void _setupSharingListeners() {
|
||||
debugPrint("SharingIntentService: Setting up sharing listeners");
|
||||
|
||||
// Listen to media sharing coming from outside the app while the app is in memory
|
||||
_intentSub = ReceiveSharingIntent.instance.getMediaStream().listen(
|
||||
(List<SharedMediaFile> value) {
|
||||
debugPrint(
|
||||
"SharingIntentService: Media stream received ${value.length} files",
|
||||
);
|
||||
if (value.isNotEmpty) {
|
||||
_handleSharedContent(value);
|
||||
}
|
||||
},
|
||||
onError: (err) {
|
||||
debugPrint("SharingIntentService: Stream error: $err");
|
||||
},
|
||||
);
|
||||
|
||||
// Get the media sharing coming from outside the app while the app is closed
|
||||
ReceiveSharingIntent.instance.getInitialMedia().then((
|
||||
List<SharedMediaFile> value,
|
||||
) {
|
||||
debugPrint(
|
||||
"SharingIntentService: Initial media received ${value.length} files",
|
||||
);
|
||||
if (value.isNotEmpty) {
|
||||
_handleSharedContent(value);
|
||||
// Tell the library that we are done processing the intent
|
||||
ReceiveSharingIntent.instance.reset();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// Handle shared media files
|
||||
void _handleSharedContent(List<SharedMediaFile> sharedFiles) {
|
||||
if (_context == null) {
|
||||
debugPrint(
|
||||
"SharingIntentService: Context is null, cannot handle shared content",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
debugPrint(
|
||||
"SharingIntentService: Received ${sharedFiles.length} shared files",
|
||||
);
|
||||
for (final file in sharedFiles) {
|
||||
debugPrint(
|
||||
"SharingIntentService: File path: ${file.path}, type: ${file.type}",
|
||||
);
|
||||
}
|
||||
|
||||
// Convert SharedMediaFile to XFile
|
||||
final List<XFile> files =
|
||||
sharedFiles
|
||||
.map((file) => XFile(file.path, name: file.path.split('/').last))
|
||||
.toList();
|
||||
|
||||
// Show ShareSheet with the shared files
|
||||
showShareSheet(context: _context!, content: ShareContent.files(files));
|
||||
}
|
||||
|
||||
/// Dispose of resources
|
||||
void dispose() {
|
||||
_intentSub?.cancel();
|
||||
_context = null;
|
||||
}
|
||||
}
|
23
lib/widgets/app_wrapper.dart
Normal file
23
lib/widgets/app_wrapper.dart
Normal file
@ -0,0 +1,23 @@
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:island/services/sharing_intent.dart';
|
||||
|
||||
@RoutePage()
|
||||
class AppWrapper extends HookConsumerWidget {
|
||||
const AppWrapper({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
useEffect(() {
|
||||
final sharingService = SharingIntentService();
|
||||
sharingService.initialize(context);
|
||||
return () {
|
||||
sharingService.dispose();
|
||||
};
|
||||
}, const []);
|
||||
|
||||
return AutoRouter();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user