Skip to content

Commit

Permalink
App review is back (#6367)
Browse files Browse the repository at this point in the history
  • Loading branch information
g123k authored Feb 11, 2025
1 parent 4adbd94 commit 8681098
Show file tree
Hide file tree
Showing 18 changed files with 1,265 additions and 899 deletions.
18 changes: 18 additions & 0 deletions packages/smooth_app/assets/misc/tagline_0.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions packages/smooth_app/assets/misc/tagline_1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions packages/smooth_app/assets/misc/tagline_2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 14 additions & 1 deletion packages/smooth_app/lib/helpers/analytics_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ enum AnalyticsCategory {
robotoff(tag: 'robotoff'),
list(tag: 'list'),
deepLink(tag: 'deep link'),
hungerGame(tag: 'hunger game');
hungerGame(tag: 'hunger game'),
appRating(tag: 'app rating');

const AnalyticsCategory({required this.tag});

Expand Down Expand Up @@ -147,6 +148,18 @@ enum AnalyticsEvent {
hungerGameOpened(
tag: 'hunger game opened',
category: AnalyticsCategory.hungerGame,
),
appRatingSatisfied(
tag: 'satisfied',
category: AnalyticsCategory.appRating,
),
appRatingNeutral(
tag: 'neutral',
category: AnalyticsCategory.appRating,
),
appRatingNotSatisfied(
tag: 'not satisfied',
category: AnalyticsCategory.appRating,
);

const AnalyticsEvent({required this.tag, required this.category});
Expand Down
40 changes: 32 additions & 8 deletions packages/smooth_app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -3268,14 +3268,6 @@
"@show_password": {
"description": "Show hidden password in password field"
},
"rate_app": "Rate the app",
"app_rating_dialog_title": "Great! Let others know what you think of this app!",
"app_rating_dialog_positive_action": "Rate the app",
"app_rating_dialog_negative_action": "Later",
"app_rating_dialog_title_enjoying_app": "Are you enjoying this app?",
"app_rating_dialog_title_enjoying_positive_actions": "Yeah!",
"not_really": "Not really",
"app_rating_dialog_title_not_enjoying_app": "We are so sorry to hear that! Could you tell us what happened?",
"owner_field_info_title": "Producer provided values",
"@owner_field_info_title": {
"description": "Title of the 'producer provided' info list-tile"
Expand Down Expand Up @@ -4107,5 +4099,37 @@
"type": "int"
}
}
},
"app_review_title": "Are you enjoying this app?",
"@app_review_title": {
"description": "Title for the app review card in the tagline"
},
"app_review_low": "Could do better",
"@app_review_low": {
"description": "Item in the app review card with the lowest rating"
},
"app_review_medium": "Not bad",
"@app_review_medium": {
"description": "Item in the app review card with an average rating"
},
"app_review_high": "I love it!",
"@app_review_high": {
"description": "Item in the app review card with the highest rating"
},
"app_review_feedback_modal_title": "Help us improve our application",
"@app_review_feedback_modal_title": {
"description": "Title of the modal sheet displayed when the user has not selected the highest value"
},
"app_review_feedback_modal_content": "If you have a few minutes, could you answer this form so that **we can improve in future updates**:",
"@app_review_feedback_modal_content": {
"description": "Content of the modal sheet displayed when the user has not selected the highest value"
},
"app_review_feedback_modal_open_form": "Answer the form",
"@app_review_feedback_modal_open_form": {
"description": "Answer the form button"
},
"app_review_feedback_modal_later": "Ask me later",
"@app_review_feedback_modal_later": {
"description": "Ask me later button"
}
}
4 changes: 4 additions & 0 deletions packages/smooth_app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import 'package:smooth_app/helpers/entry_points_helper.dart';
import 'package:smooth_app/helpers/global_vars.dart';
import 'package:smooth_app/helpers/network_config.dart';
import 'package:smooth_app/helpers/permission_helper.dart';
import 'package:smooth_app/pages/app_review.dart';
import 'package:smooth_app/pages/navigator/app_navigator.dart';
import 'package:smooth_app/pages/onboarding/onboarding_flow_navigator.dart';
import 'package:smooth_app/query/product_query.dart';
Expand Down Expand Up @@ -237,6 +238,9 @@ class _SmoothAppState extends State<SmoothApp> {
_lazyProvide<AppNewsProvider>(
(_) => AppNewsProvider(_userPreferences),
),
_lazyProvide<AppReviewProvider>(
(_) => AppReviewProvider(_userPreferences),
),
],
child: AnimationsLoader(
child: AppNavigator(
Expand Down
59 changes: 59 additions & 0 deletions packages/smooth_app/lib/pages/app_review.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import 'package:flutter/cupertino.dart';
import 'package:smooth_app/data_models/preferences/user_preferences.dart';
import 'package:smooth_app/helpers/analytics_helper.dart';

class AppReviewProvider extends ValueNotifier<AppReviewState> {
AppReviewProvider(this.userPreferences) : super(AppReviewState.checking) {
check();
}

final UserPreferences userPreferences;

static const int _APP_MIN_LAUNCHES = 5; // wait for 5 launches
static const int _APP_REVIEW_FREQUENCY = 4; // then every 4 launches

Future<void> check() async {
final bool hasAlreadyReviewed = userPreferences.inAppReviewAlreadyAsked;

if (hasAlreadyReviewed) {
value = AppReviewState.ignore;
return;
}

final int appLaunches = userPreferences.appLaunches;
if (appLaunches > _APP_MIN_LAUNCHES &&
(appLaunches - _APP_MIN_LAUNCHES) % _APP_REVIEW_FREQUENCY == 0) {
value = AppReviewState.askForReview;
return;
}

value = AppReviewState.ignore;
}

void hide() {
value = AppReviewState.ignore;
}

void markAsReviewed(AppReviewResult result) {
userPreferences.markInAppReviewAsShown();
value = AppReviewState.ignore;

AnalyticsHelper.trackEvent(switch (result) {
AppReviewResult.satisfied => AnalyticsEvent.appRatingSatisfied,
AppReviewResult.neutral => AnalyticsEvent.appRatingNeutral,
AppReviewResult.unsatisfied => AnalyticsEvent.appRatingNotSatisfied,
});
}
}

enum AppReviewState {
checking,
askForReview,
ignore,
}

enum AppReviewResult {
satisfied,
neutral,
unsatisfied,
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import 'package:smooth_app/pages/preferences/user_preferences_image_source.dart'
import 'package:smooth_app/pages/preferences/user_preferences_item.dart';
import 'package:smooth_app/pages/preferences/user_preferences_language_selector.dart';
import 'package:smooth_app/pages/preferences/user_preferences_page.dart';
import 'package:smooth_app/pages/preferences/user_preferences_rate_us.dart';
import 'package:smooth_app/pages/preferences/user_preferences_share_with_friends.dart';
import 'package:smooth_app/pages/preferences/user_preferences_widgets.dart';
import 'package:smooth_app/themes/theme_provider.dart';
Expand Down Expand Up @@ -131,7 +130,6 @@ class UserPreferencesSettings extends AbstractUserPreferences {
_getDivider(),
UserPreferencesAdvancedSettings.getUserPreferencesItem(context),
_getDivider(),
UserPreferencesRateUs.getUserPreferencesItem(context),
UserPreferencesShareWithFriends.getUserPreferencesItem(context),
];
}
Expand Down
Loading

0 comments on commit 8681098

Please sign in to comment.