From 5c25bc54ecd6834f885ae3388e701e5cab6b9c6a Mon Sep 17 00:00:00 2001 From: Chen Peng Date: Sat, 11 May 2024 18:26:37 +0800 Subject: [PATCH] add github link --- notes/flutter_web/lib/routes/layout.dart | 17 +++++++++++++++-- .../Flutter/GeneratedPluginRegistrant.swift | 2 ++ notes/flutter_web/macos/Podfile.lock | 6 ++++++ notes/flutter_web/pubspec.yaml | 1 + 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/notes/flutter_web/lib/routes/layout.dart b/notes/flutter_web/lib/routes/layout.dart index a1a0a0c3..05b9e4d6 100644 --- a/notes/flutter_web/lib/routes/layout.dart +++ b/notes/flutter_web/lib/routes/layout.dart @@ -4,6 +4,7 @@ import 'package:you_flutter/better_ui.dart'; import 'package:you_flutter/note.dart'; import 'package:you_flutter/router.dart'; import 'package:you_flutter/state.dart'; +import 'package:url_launcher/url_launcher.dart'; /// [LayoutBuilder] Widget build(BuildContext context, Widget child) { @@ -40,7 +41,13 @@ class RootLayoutState extends State { return Scaffold( primary: true, - appBar: AppBar(toolbarHeight: 38, title: Text("location: ${route.uri}"), foregroundColor: colors.primaryFixed, backgroundColor: colors.onPrimaryFixed), + appBar: AppBar(toolbarHeight: 38, title: Text("location: ${route.uri}"), foregroundColor: colors.primaryFixed, backgroundColor: colors.onPrimaryFixed, actions: [ + TextButton.icon( + onPressed: () => _launchUrl(Uri.parse("https://github.com/chen56/you")), + icon: const Icon(Icons.link), + label: const Text('github'), + ), + ]), body: SafeArea( child: SelectionArea( child: Row( @@ -72,7 +79,7 @@ class RootLayoutState extends State { const _NoteTree().flexible$(), SingleChildScrollView( // children: [widget.child.align$(alignment: Alignment.topLeft)], - child:widget.child, + child: widget.child, ).expanded$(), ], ), @@ -191,3 +198,9 @@ extension _NoteTreeNode on To { } } } + +Future _launchUrl(Uri url) async { + if (!await launchUrl(url)) { + throw Exception('Could not launch $url'); + } +} diff --git a/notes/flutter_web/macos/Flutter/GeneratedPluginRegistrant.swift b/notes/flutter_web/macos/Flutter/GeneratedPluginRegistrant.swift index 724bb2ac..997e35da 100644 --- a/notes/flutter_web/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/notes/flutter_web/macos/Flutter/GeneratedPluginRegistrant.swift @@ -6,7 +6,9 @@ import FlutterMacOS import Foundation import shared_preferences_foundation +import url_launcher_macos func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) + UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) } diff --git a/notes/flutter_web/macos/Podfile.lock b/notes/flutter_web/macos/Podfile.lock index c3e7765c..5d90d17e 100644 --- a/notes/flutter_web/macos/Podfile.lock +++ b/notes/flutter_web/macos/Podfile.lock @@ -3,20 +3,26 @@ PODS: - shared_preferences_foundation (0.0.1): - Flutter - FlutterMacOS + - url_launcher_macos (0.0.1): + - FlutterMacOS DEPENDENCIES: - FlutterMacOS (from `Flutter/ephemeral`) - shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`) + - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) EXTERNAL SOURCES: FlutterMacOS: :path: Flutter/ephemeral shared_preferences_foundation: :path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin + url_launcher_macos: + :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos SPEC CHECKSUMS: FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695 + url_launcher_macos: 5f437abeda8c85500ceb03f5c1938a8c5a705399 PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367 diff --git a/notes/flutter_web/pubspec.yaml b/notes/flutter_web/pubspec.yaml index 3ebf06f9..c2153455 100644 --- a/notes/flutter_web/pubspec.yaml +++ b/notes/flutter_web/pubspec.yaml @@ -36,6 +36,7 @@ dependencies: # you_* you_dart: ^0.0.4 you_flutter: ^0.0.4 + url_launcher: ^6.2.6 dev_dependencies: