diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index ed33b49..6839021 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -1,44 +1,53 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/gopher_browser.dart b/lib/gopher_browser.dart
index 7fd495f..e083c32 100644
--- a/lib/gopher_browser.dart
+++ b/lib/gopher_browser.dart
@@ -21,6 +21,7 @@ class _GopherBrowserState extends State {
@override
void initState() {
super.initState();
+ print("Started with: ${widget.initialUrl}");
_currentItem = ParsedGopherItem.parseUrl(widget.initialUrl);
}
diff --git a/lib/main.dart b/lib/main.dart
index f5e2f53..882e338 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -2,8 +2,10 @@
// once it will matter
// ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables
+import 'dart:async';
+
import 'package:flutter/material.dart';
-import 'dart:io';
+import 'package:app_links/app_links.dart';
import 'package:gophershy/gopher_browser.dart';
@@ -11,13 +13,45 @@ void main() {
runApp(const GopherShy());
}
-class GopherShy extends StatelessWidget {
- const GopherShy({super.key});
+class _GopherShyState extends State {
+ late final AppLinks _appLinks;
+ final _navigatorKey = GlobalKey();
+ StreamSubscription? _linkSubscription;
+
+ @override
+ void initState() {
+ super.initState();
+ _appLinks = AppLinks();
+ _initDeepLinks();
+ print("Launching bcs: ${widget.fromIntentLink}");
+ }
+
+ @override
+ void dispose() {
+ _linkSubscription?.cancel();
+ super.dispose();
+ }
+
+ Future _initDeepLinks() async {
+ // Handle links
+ _linkSubscription = _appLinks.uriLinkStream.listen((uri) {
+ debugPrint('GopherShy: onAppLink: $uri');
+ _openAppLink(uri);
+ });
+ }
+
+ void _openAppLink(Uri uri) {
+ _navigatorKey.currentState?.push(MaterialPageRoute(
+ builder: (BuildContext context) {
+ return GopherShy(fromIntentLink: uri.toString());
+ },
+ ));
+ }
- // This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
+ navigatorKey: _navigatorKey,
title: 'GopherShy',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
@@ -28,13 +62,22 @@ class GopherShy extends StatelessWidget {
appBar: PreferredSize(
preferredSize: Size.fromHeight(50),
child: Text(
- "Whoaaaaa",
+ "${widget.fromIntentLink} Whoaaaaa",
style: TextStyle(fontSize: 50),
),
),
// In future replace with bookmark view
- body: GopherBrowser(initialUrl: "gopher://treebrary.org"),
+ body: GopherBrowser(
+ initialUrl: widget.fromIntentLink ?? "gopher://treebrary.org"),
)),
);
}
}
+
+class GopherShy extends StatefulWidget {
+ const GopherShy({super.key, this.fromIntentLink});
+
+ final String? fromIntentLink;
+ @override
+ State createState() => _GopherShyState();
+}
diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc
index e71a16d..1ea3346 100644
--- a/linux/flutter/generated_plugin_registrant.cc
+++ b/linux/flutter/generated_plugin_registrant.cc
@@ -6,6 +6,10 @@
#include "generated_plugin_registrant.h"
+#include
void fl_register_plugins(FlPluginRegistry* registry) {
+ g_autoptr(FlPluginRegistrar) gtk_registrar =
+ fl_plugin_registry_get_registrar_for_plugin(registry, "GtkPlugin");
+ gtk_plugin_register_with_registrar(gtk_registrar);
}
diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake
index 2e1de87..2ee43a9 100644
--- a/linux/flutter/generated_plugins.cmake
+++ b/linux/flutter/generated_plugins.cmake
@@ -3,6 +3,7 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
+ gtk
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST
diff --git a/pubspec.lock b/pubspec.lock
index e8aa334..1a0a514 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -1,6 +1,38 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
+ app_links:
+ dependency: "direct main"
+ description:
+ name: app_links
+ sha256: ad1a6d598e7e39b46a34f746f9a8b011ee147e4c275d407fa457e7a62f84dd99
+ url: "https://pub.dev"
+ source: hosted
+ version: "6.3.2"
+ 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"
async:
dependency: transitive
description:
@@ -88,6 +120,14 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
+ gtk:
+ dependency: transitive
+ description:
+ name: gtk
+ sha256: e8ce9ca4b1df106e4d72dad201d345ea1a036cc12c360f1a7d5a758f78ffa42c
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.1.0"
leak_tracker:
dependency: transitive
description:
diff --git a/pubspec.yaml b/pubspec.yaml
index be65b97..30f680b 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -25,6 +25,7 @@ environment:
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
+ app_links: ^6.3.2
flutter:
sdk: flutter
shared_preferences: ^2.2.3
diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc
index 8b6d468..2667145 100644
--- a/windows/flutter/generated_plugin_registrant.cc
+++ b/windows/flutter/generated_plugin_registrant.cc
@@ -6,6 +6,9 @@
#include "generated_plugin_registrant.h"
+#include
void RegisterPlugins(flutter::PluginRegistry* registry) {
+ AppLinksPluginCApiRegisterWithRegistrar(
+ registry->GetRegistrarForPlugin("AppLinksPluginCApi"));
}
diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake
index b93c4c3..455e0df 100644
--- a/windows/flutter/generated_plugins.cmake
+++ b/windows/flutter/generated_plugins.cmake
@@ -3,6 +3,7 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
+ app_links
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST