An open-source cross-platform alternative to AirDrop
#1274 Make share larger (#1283)
David Greengas603c8f9625ee
diff --git a/app/assets/i18n/strings.i18n.json b/app/assets/i18n/strings.i18n.jsonindex b6944ebe..e1671832 100644--- a/app/assets/i18n/strings.i18n.json+++ b/app/assets/i18n/strings.i18n.json@@ -402,6 +402,9 @@"qr": {"title": "QR Code"},+ "zoom": {+ "title": "URL"+ },"quickActions": {"title": "Quick Actions","counter": "Counter",@@ -464,4 +467,4 @@"sNameDurationLabel": "duration","sUnitAssetCountLabel": "count"}-}+}\ No newline at end of filediff --git a/app/lib/pages/web_send_page.dart b/app/lib/pages/web_send_page.dartindex ddd1fe3d..7bd4e162 100644--- a/app/lib/pages/web_send_page.dart+++ b/app/lib/pages/web_send_page.dart@@ -10,6 +10,7 @@ import 'package:localsend_app/util/native/platform_check.dart';import 'package:localsend_app/util/sleep.dart';import 'package:localsend_app/util/ui/snackbar.dart';import 'package:localsend_app/widget/dialogs/qr_dialog.dart';+import 'package:localsend_app/widget/dialogs/zoom_dialog.dart';import 'package:localsend_app/widget/responsive_list_view.dart';import 'package:refena_flutter/refena_flutter.dart';@@ -94,24 +95,30 @@ class _WebSendPageState extends State<WebSendPage> with Refena {mainAxisAlignment: MainAxisAlignment.center,crossAxisAlignment: CrossAxisAlignment.center,children: [- if (_stateEnum == _ServerState.initializing || _stateEnum == _ServerState.stopping) ...[+ if (_stateEnum == _ServerState.initializing ||+ _stateEnum == _ServerState.stopping) ...[const CircularProgressIndicator(),const SizedBox(height: 20),Center(child: Text(- _stateEnum == _ServerState.initializing ? t.webSharePage.loading : t.webSharePage.stopping,+ _stateEnum == _ServerState.initializing+ ? t.webSharePage.loading+ : t.webSharePage.stopping,style: Theme.of(context).textTheme.titleLarge,),),] else if (_initializedError != null) ...[- const Icon(Icons.error_outline, size: 48, color: Colors.red),+ const Icon(Icons.error_outline,+ size: 48, color: Colors.red),const SizedBox(height: 10),Center(- child: Text(t.webSharePage.error, style: Theme.of(context).textTheme.titleLarge),+ child: Text(t.webSharePage.error,+ style: Theme.of(context).textTheme.titleLarge),),const SizedBox(height: 10),Center(- child: SelectableText(_initializedError!, style: Theme.of(context).textTheme.bodyMedium),+ child: SelectableText(_initializedError!,+ style: Theme.of(context).textTheme.bodyMedium),),],],@@ -125,7 +132,8 @@ class _WebSendPageState extends State<WebSendPage> with Refena {return ResponsiveListView(padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 20),children: [- Text(t.webSharePage.openLink(n: networkState.localIps.length), style: Theme.of(context).textTheme.titleMedium),+ Text(t.webSharePage.openLink(n: networkState.localIps.length),+ style: Theme.of(context).textTheme.titleMedium),const SizedBox(height: 10),Card(color: Theme.of(context).colorScheme.secondaryContainer,@@ -135,7 +143,8 @@ class _WebSendPageState extends State<WebSendPage> with Refena {crossAxisAlignment: CrossAxisAlignment.start,children: [...networkState.localIps.map((ip) {- final url = '${_encrypted ? 'https' : 'http'}://$ip:${serverState.port}';+ final url =+ '${_encrypted ? 'https' : 'http'}://$ip:${serverState.port}';return Padding(padding: const EdgeInsets.all(5),child: Row(@@ -147,13 +156,16 @@ class _WebSendPageState extends State<WebSendPage> with Refena {const SizedBox(width: 5),InkWell(onTap: () async {- await Clipboard.setData(ClipboardData(text: url));+ await Clipboard.setData(+ ClipboardData(text: url));if (mounted && checkPlatformIsDesktop()) {- context.showSnackBar(t.general.copiedToClipboard);+ context.showSnackBar(+ t.general.copiedToClipboard);}},child: const Padding(- padding: EdgeInsets.symmetric(horizontal: 8, vertical: 2),+ padding: EdgeInsets.symmetric(+ horizontal: 8, vertical: 2),child: Icon(Icons.content_copy, size: 16),),),@@ -168,10 +180,27 @@ class _WebSendPageState extends State<WebSendPage> with Refena {);},child: const Padding(- padding: EdgeInsets.symmetric(horizontal: 8, vertical: 2),+ padding: EdgeInsets.symmetric(+ horizontal: 8, vertical: 2),child: Icon(Icons.qr_code, size: 16),),),+ InkWell(+ onTap: () async {+ await showDialog(+ context: context,+ builder: (_) => ZoomDialog(+ data: url,+ listenIncomingWebSendRequests: true,+ ),+ );+ },+ child: const Padding(+ padding: EdgeInsets.symmetric(+ horizontal: 8, vertical: 2),+ child: Icon(Icons.zoom_in_map, size: 16),+ ),+ ),],),);@@ -181,7 +210,8 @@ class _WebSendPageState extends State<WebSendPage> with Refena {),),const SizedBox(height: 20),- Text(t.webSharePage.requests, style: Theme.of(context).textTheme.titleMedium),+ Text(t.webSharePage.requests,+ style: Theme.of(context).textTheme.titleMedium),const SizedBox(height: 10),if (webSendState.sessions.isEmpty)Padding(@@ -203,41 +233,64 @@ class _WebSendPageState extends State<WebSendPage> with Refena {children: [Text(session.deviceInfo,- style: Theme.of(context).textTheme.bodyLarge!.copyWith(- color: session.responseHandler != null ? Theme.of(context).colorScheme.warning : null,+ style: Theme.of(context)+ .textTheme+ .bodyLarge!+ .copyWith(+ color: session.responseHandler != null+ ? Theme.of(context)+ .colorScheme+ .warning+ : null,),),const SizedBox(height: 5),- Text(session.ip, style: Theme.of(context).textTheme.bodyMedium!.copyWith(color: Colors.grey)),+ Text(session.ip,+ style: Theme.of(context)+ .textTheme+ .bodyMedium!+ .copyWith(color: Colors.grey)),],),),if (session.responseHandler != null) ...[TextButton(onPressed: () {- ref.notifier(serverProvider).declineWebSendRequest(session.sessionId);+ ref+ .notifier(serverProvider)+ .declineWebSendRequest(session.sessionId);},style: TextButton.styleFrom(- foregroundColor: Theme.of(context).colorScheme.onSurface,+ foregroundColor:+ Theme.of(context).colorScheme.onSurface,),child: const Icon(Icons.close),),TextButton(onPressed: () {- ref.notifier(serverProvider).acceptWebSendRequest(session.sessionId);+ ref+ .notifier(serverProvider)+ .acceptWebSendRequest(session.sessionId);},style: TextButton.styleFrom(- foregroundColor: Theme.of(context).colorScheme.onSurface,+ foregroundColor:+ Theme.of(context).colorScheme.onSurface,),child: const Icon(Icons.check_circle),),] elsePadding(- padding: const EdgeInsets.symmetric(horizontal: 20),+ padding:+ const EdgeInsets.symmetric(horizontal: 20),child: Text(t.general.accepted,- style: Theme.of(context).textTheme.bodyMedium!.copyWith(- color: Theme.of(context).colorScheme.onSecondaryContainer,+ style: Theme.of(context)+ .textTheme+ .bodyMedium!+ .copyWith(+ color: Theme.of(context)+ .colorScheme+ .onSecondaryContainer,),),),@@ -250,7 +303,8 @@ class _WebSendPageState extends State<WebSendPage> with Refena {Row(crossAxisAlignment: CrossAxisAlignment.center,children: [- Text(t.webSharePage.encryption, style: Theme.of(context).textTheme.titleMedium),+ Text(t.webSharePage.encryption,+ style: Theme.of(context).textTheme.titleMedium),const SizedBox(width: 10),Checkbox(value: _encrypted,@@ -263,17 +317,23 @@ class _WebSendPageState extends State<WebSendPage> with Refena {if (_encrypted)Text(t.webSharePage.encryptionHint,- style: Theme.of(context).textTheme.bodyMedium!.copyWith(color: Theme.of(context).colorScheme.warning),+ style: Theme.of(context)+ .textTheme+ .bodyMedium!+ .copyWith(color: Theme.of(context).colorScheme.warning),),Row(crossAxisAlignment: CrossAxisAlignment.center,children: [- Text(t.webSharePage.autoAccept, style: Theme.of(context).textTheme.titleMedium),+ Text(t.webSharePage.autoAccept,+ style: Theme.of(context).textTheme.titleMedium),const SizedBox(width: 10),Checkbox(value: webSendState.autoAccept,onChanged: (value) {- ref.notifier(serverProvider).setWebSendAutoAccept(value == true);+ ref+ .notifier(serverProvider)+ .setWebSendAutoAccept(value == true);},),],diff --git a/app/lib/widget/dialogs/zoom_dialog.dart b/app/lib/widget/dialogs/zoom_dialog.dartnew file mode 100644index 00000000..8c657d53--- /dev/null+++ b/app/lib/widget/dialogs/zoom_dialog.dart@@ -0,0 +1,81 @@+import 'package:flutter/material.dart';+import 'package:localsend_app/gen/strings.g.dart';+import 'package:localsend_app/model/state/send/web/web_send_state.dart';+import 'package:localsend_app/provider/network/server/server_provider.dart';+import 'package:localsend_app/theme.dart';++import 'package:refena_flutter/refena_flutter.dart';+import 'package:routerino/routerino.dart';++class ZoomDialog extends StatelessWidget {+ final String data;+ final bool listenIncomingWebSendRequests;++ const ZoomDialog({+ required this.data,+ this.listenIncomingWebSendRequests = false,+ });++ @override+ Widget build(BuildContext context) {+ final width = MediaQuery.of(context).size.width * .80;+ final fontSize = width / 400 * 48;++ final WebSendState? webSendState;+ if (listenIncomingWebSendRequests) {+ webSendState =+ context.ref.watch(serverProvider.select((s) => s?.webSendState));+ } else {+ webSendState = null;+ }++ return AlertDialog(+ title: Text(t.dialogs.zoom.title),+ content: Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ Padding(+ padding: const EdgeInsets.all(8.0),+ child: FittedBox(+ fit: BoxFit.fill,+ clipBehavior: Clip.antiAlias,+ child: Text(data,+ textAlign: TextAlign.center,+ style: TextStyle(fontSize: fontSize)),+ ),+ ),+ const SizedBox(height: 10),+ if (listenIncomingWebSendRequests && webSendState != null)+ Builder(+ builder: (context) {+ final pending = webSendState?.sessions.values.fold<int>(+ 0,+ (prev, curr) =>+ prev + (curr.responseHandler != null ? 1 : 0)) ??+ 0;+ if (pending != 0) {+ return Padding(+ padding: const EdgeInsets.only(top: 5),+ child: Text(+ t.webSharePage.pendingRequests(n: pending),+ style: TextStyle(+ color: Theme.of(context).colorScheme.warning),+ textAlign: TextAlign.center,+ ),+ );+ } else {+ return Container();+ }+ },+ ),+ ],+ ),+ actions: [+ TextButton(+ onPressed: () => context.pop(),+ child: Text(t.general.close),+ )+ ],+ );+ }+}