Skip to content

Commit

Permalink
Implement rate us (#73)
Browse files Browse the repository at this point in the history
* Implement rate us

* Implement clear cache

* Resolve conflict

* Format code
  • Loading branch information
cp-pratik-k authored Dec 17, 2024
1 parent ac8c3d3 commit 56d2a3c
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/assets/images/ic_notification.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions app/assets/locales/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@
"version_title": "Version",
"sign_in_with_google_drive_title": "Sign in with Google Drive",
"sign_in_with_dropbox_title": "Sign in with Dropbox",
"rate_us_title": "Rate us",
"clear_cache_title": "Clear cache",

"@_UPLOAD_ITEM":{},
"upload_status_waiting": "Upload is in the queue",
Expand Down
4 changes: 4 additions & 0 deletions app/lib/gen/assets.gen.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions app/lib/ui/flow/accounts/accounts_screen_view_model.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:io';
import 'package:data/models/media_process/media_process.dart';
import 'package:data/repositories/media_process_repository.dart';
import 'package:data/services/auth_service.dart';
Expand All @@ -8,6 +9,7 @@ import 'package:data/storage/provider/preferences_provider.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:path_provider/path_provider.dart';
import 'package:permission_handler/permission_handler.dart';

part 'accounts_screen_view_model.freezed.dart';
Expand Down Expand Up @@ -63,6 +65,30 @@ class AccountsStateNotifier extends StateNotifier<AccountsState> {
state = state.copyWith(notificationsPermissionStatus: status.isGranted);
}

Future<void> clearCache() async {
try {
final cacheDirectory = await getApplicationDocumentsDirectory();
if (await cacheDirectory.exists()) {
final files = cacheDirectory.listSync().where(
(file) => file is File && file.path.contains('thumbnail_'),
);
for (var file in files) {
await file.delete();
}
}
} catch (e) {
state = state.copyWith(error: e);
}
}

Future<void> rateUs() async {
try {
await _deviceService.rateApp();
} catch (e) {
state = state.copyWith(error: e);
}
}

void updateUser(GoogleSignInAccount? account) {
state = state.copyWith(googleAccount: account);
}
Expand Down
8 changes: 8 additions & 0 deletions app/lib/ui/flow/accounts/components/settings_action_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ class _SettingsActionListState extends ConsumerState<SettingsActionList>
},
),
),
ActionListButton(
title: context.l10n.rate_us_title,
onPressed: notifier.rateUs,
),
ActionListButton(
title: context.l10n.clear_cache_title,
onPressed: notifier.clearCache,
),
ActionListButton(
title: context.l10n.term_and_condition_title,
onPressed: () {
Expand Down
Loading

0 comments on commit 56d2a3c

Please sign in to comment.