diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index aede704..2c92c16 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -11,6 +11,7 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/SolarShare/Info.plist b/ios/SolarShare/Info.plist new file mode 100644 index 0000000..b256dc6 --- /dev/null +++ b/ios/SolarShare/Info.plist @@ -0,0 +1,36 @@ + + + + + PHSupportedMediaTypes + + Video + Image + + NSExtensionActivationRule + + NSExtensionActivationSupportsText + + NSExtensionActivationSupportsWebURLWithMaxCount + 1 + NSExtensionActivationSupportsImageWithMaxCount + 100 + NSExtensionActivationSupportsMovieWithMaxCount + 100 + NSExtensionActivationSupportsFileWithMaxCount + 100 + + NSExtension + + NSExtensionAttributes + + NSExtensionActivationRule + TRUEPREDICATE + + NSExtensionMainStoryboard + MainInterface + NSExtensionPointIdentifier + com.apple.share-services + + + diff --git a/ios/SolarShare/ShareViewController.swift b/ios/SolarShare/ShareViewController.swift new file mode 100644 index 0000000..6390bbe --- /dev/null +++ b/ios/SolarShare/ShareViewController.swift @@ -0,0 +1,18 @@ +// +// ShareViewController.swift +// SolarShare +// +// Created by LittleSheep on 2024/12/15. +// + +import receive_sharing_intent + +class ShareViewController: RSIShareViewController { + + // Use this method to return false if you don't want to redirect to host app automatically. + // Default is true + override func shouldAutoRedirect() -> Bool { + return true + } + +} diff --git a/ios/SolarShare/SolarShare.entitlements b/ios/SolarShare/SolarShare.entitlements new file mode 100644 index 0000000..7121c32 --- /dev/null +++ b/ios/SolarShare/SolarShare.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.application-groups + + group.solsynth.solian + + + diff --git a/lib/main.dart b/lib/main.dart index 7a4f99a..f4d8184 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,3 +1,5 @@ +import 'dart:async'; +import 'dart:developer'; import 'dart:io'; import 'package:bitsdojo_window/bitsdojo_window.dart'; @@ -12,6 +14,7 @@ import 'package:go_router/go_router.dart'; import 'package:hive_flutter/hive_flutter.dart'; import 'package:home_widget/home_widget.dart'; import 'package:provider/provider.dart'; +import 'package:receive_sharing_intent/receive_sharing_intent.dart'; import 'package:relative_time/relative_time.dart'; import 'package:responsive_framework/responsive_framework.dart'; import 'package:styled_widget/styled_widget.dart'; @@ -162,6 +165,8 @@ class _AppSplashScreen extends StatefulWidget { class _AppSplashScreenState extends State<_AppSplashScreen> { bool _isReady = false; + late StreamSubscription _shareIntentSubscription; + Future _initialize() async { try { final home = context.read(); @@ -186,10 +191,17 @@ class _AppSplashScreenState extends State<_AppSplashScreen> { } } + void _listenShareIntent() async { + _shareIntentSubscription = ReceiveSharingIntent.instance.getMediaStream().listen((value) {}, onError: (err) { + log("[ShareIntent] Unable to subscribe: $err"); + }); + } + @override void initState() { super.initState(); _initialize(); + _listenShareIntent(); } @override diff --git a/lib/screens/home.dart b/lib/screens/home.dart index c4a99f0..b07b621 100644 --- a/lib/screens/home.dart +++ b/lib/screens/home.dart @@ -177,7 +177,7 @@ class _HomeDashCheckInWidgetState extends State<_HomeDashCheckInWidget> { Text( prefix.tr(args: ['$prefix$pos'.tr()]), style: Theme.of(context).textTheme.titleMedium!.copyWith(fontWeight: FontWeight.bold), - ).tr(), + ), Text( '$prefix${pos}Description', style: Theme.of(context).textTheme.bodyMedium, diff --git a/pubspec.lock b/pubspec.lock index 818cbbb..0da67ed 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1474,6 +1474,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.1.0" + receive_sharing_intent: + dependency: "direct main" + description: + name: receive_sharing_intent + sha256: ec76056e4d258ad708e76d85591d933678625318e411564dcb9059048ca3a593 + url: "https://pub.dev" + source: hosted + version: "1.8.1" relative_time: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index d7e1b17..2903e95 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -105,6 +105,7 @@ dependencies: marquee: ^2.3.0 flutter_svg: ^2.0.16 home_widget: ^0.7.0 + receive_sharing_intent: ^1.8.1 dev_dependencies: flutter_test: