fix: Open deep links
This commit is contained in:
parent
47ac9c8f97
commit
1e763f05f5
11 changed files with 37 additions and 72 deletions
|
|
@ -170,8 +170,14 @@ abstract class AppRoutes {
|
|||
),
|
||||
GoRoute(
|
||||
path: 'newprivatechat',
|
||||
pageBuilder: (context, state) =>
|
||||
defaultPageBuilder(context, state, const NewPrivateChat()),
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
state,
|
||||
NewPrivateChat(
|
||||
key: ValueKey('new_chat_${state.uri.query}'),
|
||||
deeplink: state.uri.queryParameters['deeplink'],
|
||||
),
|
||||
),
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
GoRoute(
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import 'dart:async';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'package:app_links/app_links.dart';
|
||||
import 'package:cross_file/cross_file.dart';
|
||||
import 'package:flutter_shortcuts_new/flutter_shortcuts_new.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
|
@ -11,6 +11,7 @@ import 'package:matrix/matrix.dart' as sdk;
|
|||
import 'package:matrix/matrix.dart';
|
||||
import 'package:receive_sharing_intent/receive_sharing_intent.dart';
|
||||
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pages/chat_list/chat_list_view.dart';
|
||||
import 'package:fluffychat/utils/localized_exception_extension.dart';
|
||||
|
|
@ -71,8 +72,6 @@ class ChatListController extends State<ChatList>
|
|||
|
||||
StreamSubscription? _intentFileStreamSubscription;
|
||||
|
||||
StreamSubscription? _intentUriStreamSubscription;
|
||||
|
||||
late ActiveFilter activeFilter;
|
||||
|
||||
String? _activeSpaceId;
|
||||
|
|
@ -308,6 +307,12 @@ class ChatListController extends State<ChatList>
|
|||
void _processIncomingSharedMedia(List<SharedMediaFile> files) {
|
||||
if (files.isEmpty) return;
|
||||
|
||||
if (files.singleOrNull?.path.startsWith(AppConfig.deepLinkPrefix) == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
inspect(files);
|
||||
|
||||
showScaffoldDialog(
|
||||
context: context,
|
||||
builder: (context) => ShareScaffoldDialog(
|
||||
|
|
@ -326,14 +331,6 @@ class ChatListController extends State<ChatList>
|
|||
);
|
||||
}
|
||||
|
||||
Future<void> _processIncomingUris(Uri? uri) async {
|
||||
if (uri == null) return;
|
||||
context.go('/rooms');
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
UrlLauncher(context, uri.toString()).openMatrixToUrl();
|
||||
});
|
||||
}
|
||||
|
||||
void _initReceiveSharingIntent() {
|
||||
if (!PlatformInfos.isMobile) return;
|
||||
|
||||
|
|
@ -347,11 +344,6 @@ class ChatListController extends State<ChatList>
|
|||
_processIncomingSharedMedia,
|
||||
);
|
||||
|
||||
// For receiving shared Uris
|
||||
_intentUriStreamSubscription = AppLinks().uriLinkStream.listen(
|
||||
_processIncomingUris,
|
||||
);
|
||||
|
||||
if (PlatformInfos.isAndroid) {
|
||||
final shortcuts = FlutterShortcuts();
|
||||
shortcuts.initialize().then(
|
||||
|
|
@ -394,7 +386,6 @@ class ChatListController extends State<ChatList>
|
|||
void dispose() {
|
||||
_intentDataStreamSubscription?.cancel();
|
||||
_intentFileStreamSubscription?.cancel();
|
||||
_intentUriStreamSubscription?.cancel();
|
||||
scrollController.removeListener(_onScroll);
|
||||
super.dispose();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@ import 'package:fluffychat/widgets/matrix.dart';
|
|||
import '../../widgets/adaptive_dialogs/user_dialog.dart';
|
||||
|
||||
class NewPrivateChat extends StatefulWidget {
|
||||
const NewPrivateChat({super.key});
|
||||
final String? deeplink;
|
||||
const NewPrivateChat({super.key, required this.deeplink});
|
||||
|
||||
@override
|
||||
NewPrivateChatController createState() => NewPrivateChatController();
|
||||
|
|
@ -33,6 +34,18 @@ class NewPrivateChatController extends State<NewPrivateChat> {
|
|||
|
||||
static const Duration _coolDown = Duration(milliseconds: 500);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
final deeplink = widget.deeplink;
|
||||
if (deeplink != null) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
UrlLauncher(context, deeplink).openMatrixToUrl();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> searchUsers([String? input]) async {
|
||||
final searchTerm = input ?? controller.text;
|
||||
if (searchTerm.isEmpty) {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import 'package:go_router/go_router.dart';
|
|||
import 'package:matrix/matrix.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/config/routes.dart';
|
||||
import 'package:fluffychat/config/setting_keys.dart';
|
||||
import 'package:fluffychat/config/themes.dart';
|
||||
|
|
@ -37,6 +38,12 @@ class FluffyChatApp extends StatelessWidget {
|
|||
static final GoRouter router = GoRouter(
|
||||
routes: AppRoutes.routes,
|
||||
debugLogDiagnostics: true,
|
||||
redirect: (context, state) {
|
||||
if (state.uri.toString().startsWith(AppConfig.deepLinkPrefix)) {
|
||||
return '/rooms/newprivatechat?deeplink=${state.uri}';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
);
|
||||
|
||||
@override
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
#include <file_selector_linux/file_selector_plugin.h>
|
||||
#include <flutter_secure_storage_linux/flutter_secure_storage_linux_plugin.h>
|
||||
#include <flutter_webrtc/flutter_web_r_t_c_plugin.h>
|
||||
#include <gtk/gtk_plugin.h>
|
||||
#include <handy_window/handy_window_plugin.h>
|
||||
#include <record_linux/record_linux_plugin.h>
|
||||
#include <screen_retriever_linux/screen_retriever_linux_plugin.h>
|
||||
|
|
@ -45,9 +44,6 @@ void fl_register_plugins(FlPluginRegistry* registry) {
|
|||
g_autoptr(FlPluginRegistrar) flutter_webrtc_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterWebRTCPlugin");
|
||||
flutter_web_r_t_c_plugin_register_with_registrar(flutter_webrtc_registrar);
|
||||
g_autoptr(FlPluginRegistrar) gtk_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "GtkPlugin");
|
||||
gtk_plugin_register_with_registrar(gtk_registrar);
|
||||
g_autoptr(FlPluginRegistrar) handy_window_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "HandyWindowPlugin");
|
||||
handy_window_plugin_register_with_registrar(handy_window_registrar);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ list(APPEND FLUTTER_PLUGIN_LIST
|
|||
file_selector_linux
|
||||
flutter_secure_storage_linux
|
||||
flutter_webrtc
|
||||
gtk
|
||||
handy_window
|
||||
record_linux
|
||||
screen_retriever_linux
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
import FlutterMacOS
|
||||
import Foundation
|
||||
|
||||
import app_links
|
||||
import audio_session
|
||||
import desktop_drop
|
||||
import desktop_webview_window
|
||||
|
|
@ -36,7 +35,6 @@ import window_manager
|
|||
import window_to_front
|
||||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
AppLinksMacosPlugin.register(with: registry.registrar(forPlugin: "AppLinksMacosPlugin"))
|
||||
AudioSessionPlugin.register(with: registry.registrar(forPlugin: "AudioSessionPlugin"))
|
||||
DesktopDropPlugin.register(with: registry.registrar(forPlugin: "DesktopDropPlugin"))
|
||||
DesktopWebviewWindowPlugin.register(with: registry.registrar(forPlugin: "DesktopWebviewWindowPlugin"))
|
||||
|
|
|
|||
40
pubspec.lock
40
pubspec.lock
|
|
@ -41,38 +41,6 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.3"
|
||||
app_links:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: app_links
|
||||
sha256: "5f88447519add627fe1cbcab4fd1da3d4fed15b9baf29f28b22535c95ecee3e8"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.4.1"
|
||||
app_links_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: app_links_linux
|
||||
sha256: f5f7173a78609f3dfd4c2ff2c95bd559ab43c80a87dc6a095921d96c05688c81
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.3"
|
||||
app_links_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: app_links_platform_interface
|
||||
sha256: "05f5379577c513b534a29ddea68176a4d4802c46180ee8e2e966257158772a3f"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.2"
|
||||
app_links_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: app_links_web
|
||||
sha256: af060ed76183f9e2b87510a9480e56a5352b6c249778d07bd2c95fc35632a555
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
archive:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
@ -807,14 +775,6 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.8"
|
||||
gtk:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: gtk
|
||||
sha256: e8ce9ca4b1df106e4d72dad201d345ea1a036cc12c360f1a7d5a758f78ffa42c
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
handy_window:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ environment:
|
|||
|
||||
dependencies:
|
||||
animations: ^2.1.1
|
||||
app_links: ^6.4.1
|
||||
archive: ^4.0.7
|
||||
async: ^2.11.0
|
||||
badges: ^3.1.2
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <app_links/app_links_plugin_c_api.h>
|
||||
#include <desktop_drop/desktop_drop_plugin.h>
|
||||
#include <desktop_webview_window/desktop_webview_window_plugin.h>
|
||||
#include <dynamic_color/dynamic_color_plugin_c_api.h>
|
||||
|
|
@ -26,8 +25,6 @@
|
|||
#include <window_to_front/window_to_front_plugin.h>
|
||||
|
||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
AppLinksPluginCApiRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("AppLinksPluginCApi"));
|
||||
DesktopDropPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("DesktopDropPlugin"));
|
||||
DesktopWebviewWindowPluginRegisterWithRegistrar(
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
app_links
|
||||
desktop_drop
|
||||
desktop_webview_window
|
||||
dynamic_color
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue