An open-source cross-platform alternative to AirDrop
feat: bind ESC globally (#543)
Tien Do Namcb7b51e66320
diff --git a/assets/CHANGELOG.md b/assets/CHANGELOG.mdindex 8c0234dd..18dc215b 100644--- a/assets/CHANGELOG.md+++ b/assets/CHANGELOG.md@@ -1,5 +1,6 @@## 1.11.0 (2023-)+- feat(desktop): bind "ESC" key to go the previous page- feat(android, ios): open link in new browser tab (@Tienisto)## 1.10.0 (2023-06-02)diff --git a/lib/pages/about_page.dart b/lib/pages/about_page.dartindex 8a726200..bd9da026 100644--- a/lib/pages/about_page.dart+++ b/lib/pages/about_page.dart@@ -1,7 +1,6 @@import 'package:flutter/material.dart';import 'package:localsend_app/gen/strings.g.dart';import 'package:localsend_app/pages/debug/debug_page.dart';-import 'package:localsend_app/util/shortcut_warpper.dart';import 'package:localsend_app/widget/local_send_logo.dart';import 'package:localsend_app/widget/responsive_list_view.dart';import 'package:routerino/routerino.dart';@@ -27,71 +26,66 @@ class AboutPage extends StatelessWidget {@overrideWidget build(BuildContext context) {- return ShortcutWrapper(- child: Scaffold(- appBar: AppBar(- title: Text(t.aboutPage.title),- ),- body: ResponsiveListView(- padding: const EdgeInsets.symmetric(horizontal: 15),- children: [- const SizedBox(height: 20),- const LocalSendLogo(withText: true),- Text(- '© ${DateTime.now().year} Tien Do Nam',- textAlign: TextAlign.center,+ return Scaffold(+ appBar: AppBar(+ title: Text(t.aboutPage.title),+ ),+ body: ResponsiveListView(+ padding: const EdgeInsets.symmetric(horizontal: 15),+ children: [+ const SizedBox(height: 20),+ const LocalSendLogo(withText: true),+ Text(+ '© ${DateTime.now().year} Tien Do Nam',+ textAlign: TextAlign.center,+ ),+ const SizedBox(height: 10),+ Center(+ child: TextButton(+ onPressed: () async {+ await launchUrl(Uri.parse('https://localsend.org'));+ },+ child: const Text('localsend.org'),),- const SizedBox(height: 10),- Center(- child: TextButton(+ ),+ Text(_body),+ Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ TextButton(onPressed: () async {await launchUrl(Uri.parse('https://localsend.org'));},- child: const Text('localsend.org'),+ child: const Text('Homepage'),),- ),- Text(_body),- Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- TextButton(- onPressed: () async {- await launchUrl(Uri.parse('https://localsend.org'));- },- child: const Text('Homepage'),- ),- TextButton(- onPressed: () async {- await launchUrl(- Uri.parse('https://github.com/localsend/localsend'),- mode: LaunchMode.externalApplication);- },- child: const Text('Source Code (Github)'),- ),- TextButton(- onPressed: () async {- await launchUrl(- Uri.parse('https://opensource.org/licenses/MIT'));- },- child: const Text('MIT License'),- ),- TextButton(- onPressed: () async {- await context.push(() => const LicensePage());- },- child: const Text('License Notices'),- ),- TextButton(- onPressed: () async {- await context.push(() => const DebugPage());- },- child: const Text('Debugging'),- ),- ],- ),- const SizedBox(height: 50),- ],- ),+ TextButton(+ onPressed: () async {+ await launchUrl(Uri.parse('https://github.com/localsend/localsend'), mode: LaunchMode.externalApplication);+ },+ child: const Text('Source Code (Github)'),+ ),+ TextButton(+ onPressed: () async {+ await launchUrl(Uri.parse('https://opensource.org/licenses/MIT'));+ },+ child: const Text('MIT License'),+ ),+ TextButton(+ onPressed: () async {+ await context.push(() => const LicensePage());+ },+ child: const Text('License Notices'),+ ),+ TextButton(+ onPressed: () async {+ await context.push(() => const DebugPage());+ },+ child: const Text('Debugging'),+ ),+ ],+ ),+ const SizedBox(height: 50),+ ],),);}diff --git a/lib/pages/changelog_page.dart b/lib/pages/changelog_page.dartindex 132fdfdd..e6d4acd3 100644--- a/lib/pages/changelog_page.dart+++ b/lib/pages/changelog_page.dart@@ -3,7 +3,6 @@ import 'package:flutter/services.dart' show rootBundle;import 'package:flutter_markdown/flutter_markdown.dart';import 'package:localsend_app/gen/assets.gen.dart';import 'package:localsend_app/gen/strings.g.dart';-import 'package:localsend_app/util/shortcut_warpper.dart';import 'package:localsend_app/util/ui/nav_bar_padding.dart';class ChangelogPage extends StatelessWidget {@@ -11,29 +10,26 @@ class ChangelogPage extends StatelessWidget {@overrideWidget build(BuildContext context) {- return ShortcutWrapper(- child: Scaffold(- appBar: AppBar(- title: Text(t.changelogPage.title),- ),- body: FutureBuilder(- future: rootBundle- .loadString(Assets.changelog), // ignore: discarded_futures- builder: (context, data) {- if (!data.hasData) {- return Container();- }- return Markdown(- padding: EdgeInsets.only(- left: 15,- right: 15,- top: 15,- bottom: 15 + getNavBarPadding(context),- ),- data: data.data!,- );- },- ),+ return Scaffold(+ appBar: AppBar(+ title: Text(t.changelogPage.title),+ ),+ body: FutureBuilder(+ future: rootBundle.loadString(Assets.changelog), // ignore: discarded_futures+ builder: (context, data) {+ if (!data.hasData) {+ return Container();+ }+ return Markdown(+ padding: EdgeInsets.only(+ left: 15,+ right: 15,+ top: 15,+ bottom: 15 + getNavBarPadding(context),+ ),+ data: data.data!,+ );+ },),);}diff --git a/lib/util/shortcut_warpper.dart b/lib/util/shortcut_warpper.dartdeleted file mode 100644index fcee3ba4..00000000--- a/lib/util/shortcut_warpper.dart+++ /dev/null@@ -1,35 +0,0 @@-import 'package:flutter/material.dart';-import 'package:flutter/services.dart';--class ShortcutWrapper extends StatelessWidget {- final Widget child;- final Map<LogicalKeySet, Intent> additionalShortcuts;-- ShortcutWrapper({- required this.child,- this.additionalShortcuts = const {},- });-- @override- Widget build(BuildContext context) {- final shortcuts = {- LogicalKeySet(LogicalKeyboardKey.escape): ActivateIntent(),- ...additionalShortcuts,- };-- return Shortcuts(- shortcuts: shortcuts,- child: Actions(- actions: {- ActivateIntent: CallbackAction<ActivateIntent>(- onInvoke: (ActivateIntent intent) => Navigator.pop(context),- ),- },- child: Focus(- autofocus: true,- child: child,- ),- ),- );- }-}diff --git a/lib/widget/watcher/shortcut_watcher.dart b/lib/widget/watcher/shortcut_watcher.dartindex 71ad5c89..2ad6da34 100644--- a/lib/widget/watcher/shortcut_watcher.dart+++ b/lib/widget/watcher/shortcut_watcher.dart@@ -3,6 +3,7 @@ import 'dart:io';import 'package:flutter/material.dart';import 'package:flutter/services.dart';import 'package:localsend_app/util/native/platform_check.dart';+import 'package:routerino/routerino.dart';class ShortcutWatcher extends StatelessWidget {final Widget child;@@ -19,10 +20,13 @@ class ShortcutWatcher extends StatelessWidget {// Add Control+Q binding for Linux// https://github.com/localsend/localsend/issues/194if (checkPlatform([TargetPlatform.linux])) LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.keyQ): _ExitAppIntent(),++ LogicalKeySet(LogicalKeyboardKey.escape): _PopPageIntent(),},child: Actions(actions: {_ExitAppIntent: CallbackAction(onInvoke: (_) => exit(0)),+ _PopPageIntent: CallbackAction(onInvoke: (_) async => Navigator.of(Routerino.context).maybePop()),},child: child,),@@ -31,3 +35,5 @@ class ShortcutWatcher extends StatelessWidget {}class _ExitAppIntent extends Intent {}++class _PopPageIntent extends Intent {}