diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist
index 03a9e9a..14c2504 100644
--- a/ios/Runner/Info.plist
+++ b/ios/Runner/Info.plist
@@ -15,7 +15,7 @@
CFBundleLocalizations
en
- nb
+ tr
CFBundleName
todo_app
diff --git a/lib/Pages/home_page.dart b/lib/Pages/home_page.dart
index fc4fbf9..4582472 100644
--- a/lib/Pages/home_page.dart
+++ b/lib/Pages/home_page.dart
@@ -18,6 +18,7 @@ class HomePage extends StatefulWidget {
class _HomePageState extends State {
late int badgeValue;
+
@override
void initState() {
super.initState();
diff --git a/lib/Pages/main_screen.dart b/lib/Pages/main_screen.dart
index da603f9..6d7969e 100644
--- a/lib/Pages/main_screen.dart
+++ b/lib/Pages/main_screen.dart
@@ -1,3 +1,5 @@
+import 'dart:async';
+
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:hexcolor/hexcolor.dart';
@@ -6,6 +8,7 @@ import 'package:provider/provider.dart';
import 'package:todo_app/Pages/profile_page.dart';
import 'package:todo_app/provider/todos_provider.dart';
+import '../Review/review_service.dart';
import 'add_todo.dart';
import 'calendar_page.dart';
import 'dashboard_page.dart';
@@ -30,6 +33,7 @@ class _MainScreenState extends State {
];
late int badgeValue;
+ final ReviewService _reviewService = ReviewService();
@override
void initState() {
@@ -45,6 +49,15 @@ class _MainScreenState extends State {
DateTime.fromMillisecondsSinceEpoch(Todo.dateMilliseconds).year ==
DateTime.now().year;
}).length;
+
+ // App Review
+ Timer(const Duration(seconds: 2), () {
+ _reviewService.isSecondTimeOpen().then((secondOpen) {
+ if (secondOpen) {
+ _reviewService.showRating();
+ }
+ });
+ });
}
final PageStorageBucket bucket = PageStorageBucket();
diff --git a/lib/Review/review_service.dart b/lib/Review/review_service.dart
new file mode 100644
index 0000000..a47e836
--- /dev/null
+++ b/lib/Review/review_service.dart
@@ -0,0 +1,64 @@
+import 'package:in_app_review/in_app_review.dart';
+import 'package:shared_preferences/shared_preferences.dart';
+import 'package:todo_app/provider/shared_prefences_helper.dart';
+
+const KEY = 'FIRST_TIME_OPEN';
+const COUNTER = 'OPEN_COUNTER';
+
+class ReviewService {
+ late SharedPreferences _sharedPreferences;
+ late int openCounter;
+
+ final InAppReview _inAppReview = InAppReview.instance;
+ Future isSecondTimeOpen() async {
+ _sharedPreferences = await SharedPreferencesHelper.instance;
+ openCounter = _sharedPreferences.getInt(COUNTER) ?? 1;
+ try {
+ dynamic isSecondTime = _sharedPreferences.getBool(KEY);
+ if (openCounter == 3) {
+ _sharedPreferences.setBool(KEY, true);
+ openCounter += 1;
+ _sharedPreferences.setInt(COUNTER, openCounter);
+ return true;
+ } else if (openCounter == 15) {
+ _sharedPreferences.setBool(KEY, true);
+ openCounter += 1;
+ _sharedPreferences.setInt(COUNTER, openCounter);
+ return true;
+ } else if (openCounter == 150) {
+ _sharedPreferences.setBool(KEY, true);
+ openCounter += 1;
+ _sharedPreferences.setInt(COUNTER, openCounter);
+ return true;
+ } else if (openCounter == 400) {
+ _sharedPreferences.setBool(KEY, true);
+ openCounter += 1;
+ _sharedPreferences.setInt(COUNTER, openCounter);
+ return true;
+ } else {
+ _sharedPreferences.setBool(KEY, false);
+ openCounter += 1;
+ _sharedPreferences.setInt(COUNTER, openCounter);
+ return false;
+ }
+ } catch (e) {
+ return false;
+ }
+ }
+
+ Future showRating() async {
+ try {
+ final available = await _inAppReview.isAvailable();
+ if (available) {
+ _inAppReview.requestReview();
+ } else {
+ _inAppReview.openStoreListing(
+ appStoreId: 'com.yagizdokumaci.todomoon',
+ );
+ }
+ return true;
+ } catch (e) {
+ return false;
+ }
+ }
+}
diff --git a/pubspec.yaml b/pubspec.yaml
index f02c1fe..ffcec7f 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -53,6 +53,7 @@ dependencies:
adaptive_dialog: ^1.4.0
easy_localization: ^3.0.0
flutter_app_badger: ^1.4.0
+ in_app_review: ^2.0.4
dev_dependencies:
flutter_test: