diff --git a/lib/view/pages/more/share/qr_share_view.dart b/lib/view/pages/more/share/qr_share_view.dart index d3482ca..fbbe2f7 100644 --- a/lib/view/pages/more/share/qr_share_view.dart +++ b/lib/view/pages/more/share/qr_share_view.dart @@ -1,8 +1,15 @@ import 'package:flutter/material.dart'; import 'package:screen_brightness/screen_brightness.dart'; +import 'package:share_plus/share_plus.dart'; +import '../../../../utils/clipboard_helper.dart'; +import '../../../../widget/share_position_origin.dart'; import 'app_share_platform_view.dart'; +const _androidUrl = + 'https://play.google.com/store/apps/details?id=eu.mhsl.marianum.mobile.client'; +const _iosUrl = 'https://apps.apple.com/us/app/marianum-fulda/id6458789560'; + class QrShareView extends StatefulWidget { const QrShareView({super.key}); @@ -23,6 +30,20 @@ class _QrShareViewState extends State { super.dispose(); } + void _shareLink(BuildContext context) { + SharePlus.instance.share( + ShareParams( + sharePositionOrigin: SharePositionOrigin.get(context), + subject: 'App Teilen', + text: + 'Hol dir die für das Marianum maßgeschneiderte App:' + '\n\nAndroid: $_androidUrl ' + '\niOS: $_iosUrl ' + '\n\nViel Spaß!', + ), + ); + } + @override Widget build(BuildContext context) => DefaultTabController( length: 2, @@ -38,16 +59,41 @@ class _QrShareViewState extends State { ), body: const TabBarView( children: [ - AppSharePlatformView( - 'Für Android', - 'https://play.google.com/store/apps/details?id=eu.mhsl.marianum.mobile.client', - ), - AppSharePlatformView( - 'Für iOS & iPad', - 'https://apps.apple.com/us/app/marianum-fulda/id6458789560', - ), + AppSharePlatformView('Für Android', _androidUrl), + AppSharePlatformView('Für iOS & iPad', _iosUrl), ], ), + bottomNavigationBar: SafeArea( + child: Material( + color: Theme.of(context).colorScheme.surface, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Divider(height: 1), + Builder( + builder: (innerCtx) => ListTile( + leading: const Icon(Icons.share_outlined), + title: const Text('Per Link teilen'), + trailing: const Icon(Icons.arrow_right), + onTap: () => _shareLink(innerCtx), + ), + ), + ListTile( + leading: const Icon(Icons.android_outlined), + title: const Text('Android-Link kopieren'), + trailing: const Icon(Icons.copy), + onTap: () => copyToClipboard(context, _androidUrl), + ), + ListTile( + leading: const Icon(Icons.apple_outlined), + title: const Text('iOS-Link kopieren'), + trailing: const Icon(Icons.copy), + onTap: () => copyToClipboard(context, _iosUrl), + ), + ], + ), + ), + ), ), ); } diff --git a/lib/view/pages/more/share/select_share_type_dialog.dart b/lib/view/pages/more/share/select_share_type_dialog.dart deleted file mode 100644 index 61dc782..0000000 --- a/lib/view/pages/more/share/select_share_type_dialog.dart +++ /dev/null @@ -1,50 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:share_plus/share_plus.dart'; - -import '../../../../widget/share_position_origin.dart'; - -enum ShareTargetType { qr } - -/// Bottom sheet that lets the user pick how they want to share the app. -/// Resolves with [ShareTargetType.qr] for the QR option, or `null` when the -/// sheet is dismissed (link sharing fires immediately and resolves null). -Future showSelectShareTypeSheet(BuildContext context) { - return showModalBottomSheet( - context: context, - isScrollControlled: true, - showDragHandle: true, - useSafeArea: true, - builder: (sheetCtx) => SafeArea( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - ListTile( - leading: const Icon(Icons.qr_code_2_outlined), - title: const Text('Per QR-Code'), - trailing: const Icon(Icons.arrow_right), - onTap: () => Navigator.of(sheetCtx).pop(ShareTargetType.qr), - ), - ListTile( - leading: const Icon(Icons.link_outlined), - title: const Text('Per Link teilen'), - trailing: const Icon(Icons.arrow_right), - onTap: () { - Navigator.of(sheetCtx).pop(); - SharePlus.instance.share( - ShareParams( - sharePositionOrigin: SharePositionOrigin.get(sheetCtx), - subject: 'App Teilen', - text: - 'Hol dir die für das Marianum maßgeschneiderte App:' - '\n\nAndroid: https://play.google.com/store/apps/details?id=eu.mhsl.marianum.mobile.client ' - '\niOS: https://apps.apple.com/us/app/marianum-fulda/id6458789560 ' - '\n\nViel Spaß!', - ), - ); - }, - ), - ], - ), - ), - ); -} diff --git a/lib/view/pages/overhang.dart b/lib/view/pages/overhang.dart index 889eeca..fbdf8a4 100644 --- a/lib/view/pages/overhang.dart +++ b/lib/view/pages/overhang.dart @@ -8,7 +8,6 @@ import '../../routing/app_routes.dart'; import '../../state/app/modules/app_modules.dart'; import '../../widget/centered_leading.dart'; import '../../widget/info_dialog.dart'; -import 'more/share/select_share_type_dialog.dart'; class Overhang extends StatefulWidget { const Overhang({super.key}); @@ -45,11 +44,7 @@ class _OverhangState extends State { title: const Text('Teile die App'), subtitle: const Text('Mit Freunden und deiner Klasse teilen'), trailing: const Icon(Icons.arrow_right), - onTap: () async { - final result = await showSelectShareTypeSheet(context); - if (!mounted || result != ShareTargetType.qr) return; - if (context.mounted) AppRoutes.openQrShare(context); - }, + onTap: () => AppRoutes.openQrShare(context), ), FutureBuilder( future: InAppReview.instance.isAvailable(),