integrated link sharing and clipboard options directly into QR view and simplified sharing flow by removing intermediate selection dialog
This commit is contained in:
@@ -1,8 +1,15 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:screen_brightness/screen_brightness.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';
|
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 {
|
class QrShareView extends StatefulWidget {
|
||||||
const QrShareView({super.key});
|
const QrShareView({super.key});
|
||||||
|
|
||||||
@@ -23,6 +30,20 @@ class _QrShareViewState extends State<QrShareView> {
|
|||||||
super.dispose();
|
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
|
@override
|
||||||
Widget build(BuildContext context) => DefaultTabController(
|
Widget build(BuildContext context) => DefaultTabController(
|
||||||
length: 2,
|
length: 2,
|
||||||
@@ -38,16 +59,41 @@ class _QrShareViewState extends State<QrShareView> {
|
|||||||
),
|
),
|
||||||
body: const TabBarView(
|
body: const TabBarView(
|
||||||
children: [
|
children: [
|
||||||
AppSharePlatformView(
|
AppSharePlatformView('Für Android', _androidUrl),
|
||||||
'Für Android',
|
AppSharePlatformView('Für iOS & iPad', _iosUrl),
|
||||||
'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',
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
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),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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<ShareTargetType?> showSelectShareTypeSheet(BuildContext context) {
|
|
||||||
return showModalBottomSheet<ShareTargetType>(
|
|
||||||
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ß!',
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -8,7 +8,6 @@ import '../../routing/app_routes.dart';
|
|||||||
import '../../state/app/modules/app_modules.dart';
|
import '../../state/app/modules/app_modules.dart';
|
||||||
import '../../widget/centered_leading.dart';
|
import '../../widget/centered_leading.dart';
|
||||||
import '../../widget/info_dialog.dart';
|
import '../../widget/info_dialog.dart';
|
||||||
import 'more/share/select_share_type_dialog.dart';
|
|
||||||
|
|
||||||
class Overhang extends StatefulWidget {
|
class Overhang extends StatefulWidget {
|
||||||
const Overhang({super.key});
|
const Overhang({super.key});
|
||||||
@@ -45,11 +44,7 @@ class _OverhangState extends State<Overhang> {
|
|||||||
title: const Text('Teile die App'),
|
title: const Text('Teile die App'),
|
||||||
subtitle: const Text('Mit Freunden und deiner Klasse teilen'),
|
subtitle: const Text('Mit Freunden und deiner Klasse teilen'),
|
||||||
trailing: const Icon(Icons.arrow_right),
|
trailing: const Icon(Icons.arrow_right),
|
||||||
onTap: () async {
|
onTap: () => AppRoutes.openQrShare(context),
|
||||||
final result = await showSelectShareTypeSheet(context);
|
|
||||||
if (!mounted || result != ShareTargetType.qr) return;
|
|
||||||
if (context.mounted) AppRoutes.openQrShare(context);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
FutureBuilder(
|
FutureBuilder(
|
||||||
future: InAppReview.instance.isAvailable(),
|
future: InAppReview.instance.isAvailable(),
|
||||||
|
|||||||
Reference in New Issue
Block a user