Skip to content

Commit

Permalink
[imp] in app review & in app update
Browse files Browse the repository at this point in the history
  • Loading branch information
hizurk1 committed Mar 20, 2024
1 parent e5215eb commit 809e947
Show file tree
Hide file tree
Showing 15 changed files with 112 additions and 34 deletions.
4 changes: 3 additions & 1 deletion assets/translations/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@
"new_word_today": "New word today: {}.\\nDefinition: {}",
"remind_at": "Remind at: {}",
"notification_set_to": "Notification will show at {} every day.",
"cancel_all_noti": "Canceled all notifications."
"cancel_all_noti": "Canceled all notifications.",
"no_update_available": "There are no updates available for your app.",
"update_success_please_restart": "Update successful. Please restart the app."
},
"favourite": {
"add_to_favourite": "Added \"{}\" into your favourite list.",
Expand Down
4 changes: 3 additions & 1 deletion assets/translations/vi-VN.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@
"new_word_today": "Từ mới hôm nay: {}.\\nĐịnh nghĩa: {}",
"remind_at": "Nhắc nhở lúc: {}",
"notification_set_to": "Thông báo sẽ hiển thị lúc {} mỗi ngày.",
"cancel_all_noti": "Huỷ tất cả thông báo."
"cancel_all_noti": "Huỷ tất cả thông báo.",
"no_update_available": "Không có bản cập nhật mới cho ứng dụng.",
"update_success_please_restart": "Cập nhật thành công. Hãy khởi động lại ứng dụng."
},
"favourite": {
"add_to_favourite": "Đã thêm \"{}\" vào danh sách yêu thích của bạn.",
Expand Down
3 changes: 2 additions & 1 deletion lib/app/screens/setting/setting_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_svg/svg.dart';
import 'package:in_app_review/in_app_review.dart';
import 'package:in_app_update/in_app_update.dart';

import '../../../config/app_logger.dart';
import '../../../core/extensions/build_context.dart';
import '../../../core/extensions/date_time.dart';
import '../../../features/authentication/presentation/widgets/setting_delete_account_bottom_sheet.dart';
Expand Down
6 changes: 3 additions & 3 deletions lib/app/screens/setting/widgets/setting_about_us.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class _SettingAboutUs extends StatelessWidget {
padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 18.h),
leading: SvgPicture.asset(
Assets.icons.aboutUs,
height: 25.h,
width: 25.w,
height: 25.r,
width: 25.r,
colorFilter: ColorFilter.mode(context.bwColor, BlendMode.srcIn),
),
titlePadding: EdgeInsets.symmetric(horizontal: 20.w),
Expand All @@ -23,7 +23,7 @@ class _SettingAboutUs extends StatelessWidget {
trailing: Icon(
Icons.arrow_forward_ios_rounded,
color: context.greyColor,
size: 18,
size: 18.r,
),
),
);
Expand Down
54 changes: 45 additions & 9 deletions lib/app/screens/setting/widgets/setting_check_for_update.dart
Original file line number Diff line number Diff line change
@@ -1,31 +1,67 @@
part of '../setting_page.dart';

class _SettingCheckUpdate extends StatelessWidget {
final ValueNotifier<bool> updatingNotifier = ValueNotifier(false);

Future<void> _checkForUpdate() async {
updatingNotifier.value = true;
final updateInfo = await InAppUpdate.checkForUpdate();
updatingNotifier.value = false;
if (updateInfo.updateAvailability == UpdateAvailability.updateAvailable) {
// Perform immediate update
final result = await InAppUpdate.performImmediateUpdate();
if (result == AppUpdateResult.success) {
//App Update successful
Navigators().showDialogWithButton(
dissmisable: false,
iconData: Icons.check,
title: LocaleKeys.setting_update_success_please_restart.tr(),
maxLinesTitle: 3,
showAccept: false,
showCancel: false,
);
}
} else {
Navigators().showMessage(
LocaleKeys.setting_no_update_available.tr(),
type: MessageType.info,
);
}
}

@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
logger.d("Check update");
},
onTap: () => _checkForUpdate(),
child: ListTileCustom(
minHeight: 60.h,
width: context.screenWidth,
padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 18.h),
leading: SvgPicture.asset(
Assets.icons.checkUpdate,
height: 25.h,
width: 25.w,
height: 25.r,
width: 25.r,
colorFilter: ColorFilter.mode(context.bwColor, BlendMode.srcIn),
),
titlePadding: EdgeInsets.symmetric(horizontal: 20.w),
title: TextCustom(
LocaleKeys.setting_check_for_update.tr(),
style: context.textStyle.bodyS.bw,
),
trailing: Icon(
Icons.arrow_forward_ios_rounded,
color: context.greyColor,
size: 18,
trailing: ValueListenableBuilder(
valueListenable: updatingNotifier,
builder: (context, bool updating, _) {
return updating
? LoadingIndicatorWidget(
color: context.greyColor,
size: Size.square(18.r),
)
: Icon(
Icons.arrow_forward_ios_rounded,
color: context.greyColor,
size: 18.r,
);
},
),
),
);
Expand Down
6 changes: 3 additions & 3 deletions lib/app/screens/setting/widgets/setting_delete_acc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class _SettingDeleteAcc extends StatelessWidget {
padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 18.h),
leading: SvgPicture.asset(
Assets.icons.deleteAcc,
height: 25.h,
width: 25.w,
height: 25.r,
width: 25.r,
colorFilter: ColorFilter.mode(context.bwColor, BlendMode.srcIn),
),
titlePadding: EdgeInsets.symmetric(horizontal: 20.w),
Expand All @@ -29,7 +29,7 @@ class _SettingDeleteAcc extends StatelessWidget {
trailing: Icon(
Icons.arrow_forward_ios_rounded,
color: context.greyColor,
size: 18,
size: 18.r,
),
),
);
Expand Down
4 changes: 2 additions & 2 deletions lib/app/screens/setting/widgets/setting_language.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class _SettingLanguage extends StatelessWidget {
padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 6.h),
leading: SvgPicture.asset(
Assets.icons.language,
height: 25.h,
width: 25.w,
height: 25.r,
width: 25.r,
colorFilter: ColorFilter.mode(context.bwColor, BlendMode.srcIn),
),
titlePadding: EdgeInsets.symmetric(horizontal: 20.w),
Expand Down
4 changes: 2 additions & 2 deletions lib/app/screens/setting/widgets/setting_notification.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ class _SettingNotificationState extends State<_SettingNotification> {
padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 6.h),
leading: SvgPicture.asset(
Assets.icons.notification2,
height: 25.h,
width: 25.w,
height: 25.r,
width: 25.r,
colorFilter: ColorFilter.mode(context.bwColor, BlendMode.srcIn),
),
titlePadding: EdgeInsets.symmetric(horizontal: 20.w),
Expand Down
6 changes: 3 additions & 3 deletions lib/app/screens/setting/widgets/setting_privacy_policy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class _SettingPrivacyPolicy extends StatelessWidget {
padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 18.h),
leading: SvgPicture.asset(
Assets.icons.privacy,
height: 25.h,
width: 25.w,
height: 25.r,
width: 25.r,
colorFilter: ColorFilter.mode(context.bwColor, BlendMode.srcIn),
),
titlePadding: EdgeInsets.symmetric(horizontal: 20.w),
Expand All @@ -23,7 +23,7 @@ class _SettingPrivacyPolicy extends StatelessWidget {
trailing: Icon(
Icons.arrow_forward_ios_rounded,
color: context.greyColor,
size: 18,
size: 18.r,
),
),
);
Expand Down
17 changes: 11 additions & 6 deletions lib/app/screens/setting/widgets/setting_rate_app.dart
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
part of '../setting_page.dart';

class _SettingRateApp extends StatelessWidget {
Future<void> _inAppReview() async {
final InAppReview inAppReview = InAppReview.instance;
if (await inAppReview.isAvailable()) {
await inAppReview.requestReview();
}
}

@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
logger.d("Rate this app");
},
onTap: () => _inAppReview(),
child: ListTileCustom(
minHeight: 60.h,
width: context.screenWidth,
padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 18.h),
leading: SvgPicture.asset(
Assets.icons.rateApp,
height: 25.h,
width: 25.w,
height: 25.r,
width: 25.r,
colorFilter: ColorFilter.mode(context.bwColor, BlendMode.srcIn),
),
titlePadding: EdgeInsets.symmetric(horizontal: 20.w),
Expand All @@ -25,7 +30,7 @@ class _SettingRateApp extends StatelessWidget {
trailing: Icon(
Icons.arrow_forward_ios_rounded,
color: context.greyColor,
size: 18,
size: 18.r,
),
),
);
Expand Down
8 changes: 6 additions & 2 deletions lib/app/translations/codegen_loader.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ class CodegenLoader extends AssetLoader{
"new_word_today": "New word today: {}.\\nDefinition: {}",
"remind_at": "Remind at: {}",
"notification_set_to": "Notification will show at {} every day.",
"cancel_all_noti": "Canceled all notifications."
"cancel_all_noti": "Canceled all notifications.",
"no_update_available": "There are no updates available for your app.",
"update_success_please_restart": "Update successful. Please restart the app."
},
"favourite": {
"add_to_favourite": "Added \"{}\" into your favourite list.",
Expand Down Expand Up @@ -484,7 +486,9 @@ static const Map<String,dynamic> vi_VN = {
"new_word_today": "Từ mới hôm nay: {}.\\nĐịnh nghĩa: {}",
"remind_at": "Nhắc nhở lúc: {}",
"notification_set_to": "Thông báo sẽ hiển thị lúc {} mỗi ngày.",
"cancel_all_noti": "Huỷ tất cả thông báo."
"cancel_all_noti": "Huỷ tất cả thông báo.",
"no_update_available": "Không có bản cập nhật mới cho ứng dụng.",
"update_success_please_restart": "Cập nhật thành công. Hãy khởi động lại ứng dụng."
},
"favourite": {
"add_to_favourite": "Đã thêm \"{}\" vào danh sách yêu thích của bạn.",
Expand Down
2 changes: 2 additions & 0 deletions lib/app/translations/locale_keys.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ abstract class LocaleKeys {
static const setting_remind_at = 'setting.remind_at';
static const setting_notification_set_to = 'setting.notification_set_to';
static const setting_cancel_all_noti = 'setting.cancel_all_noti';
static const setting_no_update_available = 'setting.no_update_available';
static const setting_update_success_please_restart = 'setting.update_success_please_restart';
static const favourite_add_to_favourite = 'favourite.add_to_favourite';
static const favourite_remove_from_favourite = 'favourite.remove_from_favourite';
static const favourite_favourites = 'favourite.favourites';
Expand Down
2 changes: 1 addition & 1 deletion lib/app/widgets/loading_indicator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class LoadingIndicatorWidget extends StatelessWidget {
width: size?.width.r ?? 25.r,
child: CircularProgressIndicator(
strokeWidth: 2.5,
color: context.theme.primaryColor,
color: color ?? context.theme.primaryColor,
),
);
}
Expand Down
24 changes: 24 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,30 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.2.1+1"
in_app_review:
dependency: "direct main"
description:
name: in_app_review
sha256: "99869244d09adc76af16bf8fd731dd13cef58ecafd5917847589c49f378cbb30"
url: "https://pub.dev"
source: hosted
version: "2.0.9"
in_app_review_platform_interface:
dependency: transitive
description:
name: in_app_review_platform_interface
sha256: fed2c755f2125caa9ae10495a3c163aa7fab5af3585a9c62ef4a6920c5b45f10
url: "https://pub.dev"
source: hosted
version: "2.0.5"
in_app_update:
dependency: "direct main"
description:
name: in_app_update
sha256: b6ccb757281a96a4b18536f68fe2567aeca865134218719364212da8fe94615c
url: "https://pub.dev"
source: hosted
version: "4.2.2"
intl:
dependency: "direct main"
description:
Expand Down
2 changes: 2 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ dependencies:
google_fonts: ^6.1.0
google_sign_in: ^6.2.1
image_picker: ^1.0.4
in_app_review: ^2.0.9
in_app_update: ^4.2.2
intl: ^0.18.1
like_button: ^2.0.5
logger: ^2.0.2+1
Expand Down

0 comments on commit 809e947

Please sign in to comment.