feat: implement mobile UI, Android build configuration, and share intent handling using share_handler
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:share_handler/share_handler.dart';
|
||||
import 'sender_providers.dart';
|
||||
|
||||
final shareHandlerProvider = Provider<void>((ref) {
|
||||
final handler = ShareHandler.instance;
|
||||
|
||||
// Listen for background shares
|
||||
handler.sharedMediaStream.listen((SharedMedia media) {
|
||||
_handleMedia(media, ref);
|
||||
});
|
||||
|
||||
// Check for initial share (app opened via share)
|
||||
handler.getInitialSharedMedia().then((media) {
|
||||
if (media != null) {
|
||||
_handleMedia(media, ref);
|
||||
}
|
||||
});
|
||||
|
||||
return;
|
||||
});
|
||||
|
||||
void _handleMedia(SharedMedia media, Ref ref) {
|
||||
final content = media.content;
|
||||
if (content != null && content.isNotEmpty) {
|
||||
// If it's a URL or contains a URL, send it
|
||||
if (content.startsWith('http')) {
|
||||
ref.read(senderProvider.notifier).sendLink(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user