94 lines
3.1 KiB
Dart
94 lines
3.1 KiB
Dart
|
|
import 'dart:io';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:in_app_review/in_app_review.dart';
|
|
|
|
import '../../extensions/render_not_null.dart';
|
|
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});
|
|
|
|
@override
|
|
State<Overhang> createState() => _OverhangState();
|
|
}
|
|
|
|
class _OverhangState extends State<Overhang> {
|
|
@override
|
|
Widget build(BuildContext context) => Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('Mehr'),
|
|
actions: [
|
|
IconButton(onPressed: () => AppRoutes.openSettings(context), icon: const Icon(Icons.settings)),
|
|
],
|
|
),
|
|
body: _overhang(),
|
|
);
|
|
|
|
Widget _overhang() => ListView(
|
|
children: [
|
|
...AppModule.getOverhangModules(context).map((e) => e.toListTile(context)),
|
|
|
|
const Divider(),
|
|
|
|
ListTile(
|
|
leading: const Icon(Icons.share_outlined),
|
|
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 showDialog<ShareTargetType>(
|
|
context: context,
|
|
builder: (_) => const SelectShareTypeDialog(),
|
|
);
|
|
if (!mounted || result != ShareTargetType.qr) return;
|
|
if (context.mounted) AppRoutes.openQrShare(context);
|
|
},
|
|
),
|
|
FutureBuilder(
|
|
future: InAppReview.instance.isAvailable(),
|
|
builder: (context, snapshot) {
|
|
if(!snapshot.hasData) return const SizedBox.shrink();
|
|
|
|
String? getPlatformStoreName() {
|
|
if(Platform.isAndroid) return 'Play store';
|
|
if(Platform.isIOS) return 'App store';
|
|
return null;
|
|
}
|
|
|
|
return ListTile(
|
|
leading: const CenteredLeading(Icon(Icons.star_rate_outlined)),
|
|
title: const Text('App bewerten'),
|
|
subtitle: getPlatformStoreName().wrapNullable((data) => Text('Im $data')),
|
|
trailing: const Icon(Icons.arrow_right),
|
|
onTap: () {
|
|
InAppReview.instance.openStoreListing(appStoreId: '6458789560').then(
|
|
(value) {
|
|
if (!context.mounted) return;
|
|
InfoDialog.show(context, 'Vielen Dank!');
|
|
},
|
|
onError: (error) {
|
|
if (!context.mounted) return;
|
|
InfoDialog.show(context, error.toString(), copyable: true, title: 'Fehler');
|
|
},
|
|
);
|
|
},
|
|
);
|
|
},
|
|
),
|
|
ListTile(
|
|
leading: const CenteredLeading(Icon(Icons.feedback_outlined)),
|
|
title: const Text('Du hast eine Idee?'),
|
|
subtitle: const Text('Fehler und Verbessungsvorschläge'),
|
|
trailing: const Icon(Icons.arrow_right),
|
|
onTap: () => AppRoutes.openFeedback(context),
|
|
),
|
|
],
|
|
);
|
|
}
|