Skip to content

Commit

Permalink
request app review after 5 launches
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonIT committed Nov 6, 2019
1 parent ac271e1 commit c27394c
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
40 changes: 40 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:async';

import 'package:app_review/app_review.dart';
import 'package:duration/duration.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
Expand Down Expand Up @@ -107,6 +108,44 @@ class _TimeTrackerState extends State<TimeTracker> {
SharedPreferences.getInstance().then((SharedPreferences prefs) {
this.prefs = prefs;
this.highlightBreaks = prefs.getBool("highlightBreaks") ?? false;
int appLaunches = prefs.getInt("appLaunches") ?? 0;
if (appLaunches > 4) {
Future.delayed(
const Duration(seconds: 10),
() => showCupertinoDialog(
context: context,
builder: (BuildContext context) => CupertinoAlertDialog(
title: const Text("Dir gefällt der TimeTracker?"),
content: const Text("Dann zeig es mir!"),
actions: [
CupertinoDialogAction(
isDefaultAction: true,
child: const Text("Ich lasse ein Bewertung da ⭐"),
onPressed: () {
Navigator.of(context, rootNavigator: true).pop("Rate");
AppReview.writeReview;
},
),
CupertinoDialogAction(
child: const Text("Ich kaufe dir etwas 🛒"),
onPressed: () {
Navigator.of(context, rootNavigator: true).pop("Buy");
_tabController.index = 3;
},
),
CupertinoDialogAction(
child: const Text("Alles erledigt 🎉"),
onPressed: () {
Navigator.of(context, rootNavigator: true).pop("Cancel");
prefs.setInt("appLaunches", -1);
},
),
],
),
));
} else if (appLaunches > -1) {
prefs.setInt("appLaunches", ++appLaunches);
}
});
}

Expand Down Expand Up @@ -692,6 +731,7 @@ class _TimeTrackerState extends State<TimeTracker> {

cs.addAll([
CSHeader("Weitere Infos"),
CSLink("Im Store Anzeigen", () => AppReview.storeListing),
CSLink("Quelltext", () => launch("https://github.com/SimonIT/timetracker")),
CSLink("Kontakt", () => launch("mailto:[email protected]")),
CSLink(
Expand Down
14 changes: 14 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.1"
app_review:
dependency: "direct main"
description:
name: app_review
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
archive:
dependency: transitive
description:
Expand Down Expand Up @@ -396,6 +403,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
package_info:
dependency: transitive
description:
name: package_info
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.0+10"
package_resolver:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ dependencies:
flutter_cupertino_settings: ^0.2.0
url_launcher: ^5.2.2
in_app_purchase: ^0.2.2+2
app_review: ^1.0.0

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit c27394c

Please sign in to comment.