Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"@pleaseAllowNotifications": {
"description": "Title asking the user to allow notifications"
},
"notificationPermissionDescription": "OnTime needs notifications to help you get ready",
"notificationPermissionDescription": "OnTime sends schedule preparation reminders so you can get ready on time.",
"@notificationPermissionDescription": {
"description": "Description explaining why notification permission is needed"
},
Expand Down Expand Up @@ -464,15 +464,15 @@
"@notificationAlreadyEnabled": {
"description": "Dialog title when notification is already enabled"
},
"notificationAlreadyEnabledDescription": "App notifications are currently active.",
"notificationAlreadyEnabledDescription": "Schedule preparation reminders are currently active.",
"@notificationAlreadyEnabledDescription": {
"description": "Dialog content when notification is already enabled"
},
"notificationPermissionRequired": "Notification Permission Required",
"@notificationPermissionRequired": {
"description": "Dialog title when requesting notification permission"
},
"notificationPermissionRequiredDescription": "We'll send you notifications so you don't miss your appointments.\nWould you like to allow notifications?",
"notificationPermissionRequiredDescription": "OnTime uses notifications for schedule preparation reminders and appointment alerts.\nWould you like to allow notifications?",
"@notificationPermissionRequiredDescription": {
"description": "Dialog content when requesting notification permission"
},
Expand All @@ -484,15 +484,15 @@
"@notificationPermissionGranted": {
"description": "Dialog title when notification permission is granted"
},
"notificationPermissionGrantedDescription": "Notifications have been successfully activated.",
"notificationPermissionGrantedDescription": "Schedule preparation reminders are now active.",
"@notificationPermissionGrantedDescription": {
"description": "Dialog content when notification permission is granted"
},
"openNotificationSettings": "Allow Notifications in Settings",
"@openNotificationSettings": {
"description": "Dialog title to open notification settings"
},
"openNotificationSettingsDescription": "Notification permission was denied.\nPlease allow notifications in Settings.",
"openNotificationSettingsDescription": "Notification permission was denied.\nTo receive schedule preparation reminders, please allow notifications in Settings.",
"@openNotificationSettingsDescription": {
"description": "Dialog content to open notification settings"
},
Expand Down
10 changes: 5 additions & 5 deletions lib/l10n/app_ko.arb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"allowNotifications": "알림 허용하기",
"doItLater": "나중에 할게요.",
"pleaseAllowNotifications": "알림을 허용해주세요",
"notificationPermissionDescription": "알림을 허용해야 온타임이 준비를 \n도와드릴 수 있어요",
"notificationPermissionDescription": "약속 준비 리마인더를 보내\n제시간에 준비할 수 있게 도와드려요.",
"late": " 지각했어요",
"early": " 일찍 준비했어요",
"letsGo": "까먹지 않고 출발",
Expand Down Expand Up @@ -157,13 +157,13 @@
"description": "Notification body text for continuing preparation"
},
"notificationAlreadyEnabled": "알림이 이미 허용됨",
"notificationAlreadyEnabledDescription": "현재 앱 알림이 활성화되어 있습니다.",
"notificationAlreadyEnabledDescription": "약속 준비 리마인더가 현재 활성화되어 있습니다.",
"notificationPermissionRequired": "알림 권한 필요",
"notificationPermissionRequiredDescription": "약속 시간을 놓치지 않도록 알림을 보내드립니다.\n알림을 허용하시겠습니까?",
"notificationPermissionRequiredDescription": "온타임은 약속 준비 리마인더와 약속 알림을 보내기 위해 알림을 사용합니다.\n알림을 허용하시겠습니까?",
"allow": "허용",
"notificationPermissionGranted": "알림 허용 완료",
"notificationPermissionGrantedDescription": "알림이 성공적으로 활성화되었습니다.",
"notificationPermissionGrantedDescription": "약속 준비 리마인더가 활성화되었습니다.",
"openNotificationSettings": "설정에서 알림 허용",
"openNotificationSettingsDescription": "알림 권한이 거부되었습니다.\n설정에서 직접 알림을 허용해주세요.",
"openNotificationSettingsDescription": "알림 권한이 거부되었습니다.\n약속 준비 리마인더를 받으려면 설정에서 알림을 허용해주세요.",
"openSettings": "설정 열기"
}
10 changes: 5 additions & 5 deletions lib/l10n/app_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ abstract class AppLocalizations {
/// Description explaining why notification permission is needed
///
/// In en, this message translates to:
/// **'OnTime needs notifications to help you get ready'**
/// **'OnTime sends schedule preparation reminders so you can get ready on time.'**
String get notificationPermissionDescription;

/// Appended to the time when the user is late
Expand Down Expand Up @@ -725,7 +725,7 @@ abstract class AppLocalizations {
/// Dialog content when notification is already enabled
///
/// In en, this message translates to:
/// **'App notifications are currently active.'**
/// **'Schedule preparation reminders are currently active.'**
String get notificationAlreadyEnabledDescription;

/// Dialog title when requesting notification permission
Expand All @@ -737,7 +737,7 @@ abstract class AppLocalizations {
/// Dialog content when requesting notification permission
///
/// In en, this message translates to:
/// **'We\'ll send you notifications so you don\'t miss your appointments.\nWould you like to allow notifications?'**
/// **'OnTime uses notifications for schedule preparation reminders and appointment alerts.\nWould you like to allow notifications?'**
String get notificationPermissionRequiredDescription;

/// Button text to allow permission
Expand All @@ -755,7 +755,7 @@ abstract class AppLocalizations {
/// Dialog content when notification permission is granted
///
/// In en, this message translates to:
/// **'Notifications have been successfully activated.'**
/// **'Schedule preparation reminders are now active.'**
String get notificationPermissionGrantedDescription;

/// Dialog title to open notification settings
Expand All @@ -767,7 +767,7 @@ abstract class AppLocalizations {
/// Dialog content to open notification settings
///
/// In en, this message translates to:
/// **'Notification permission was denied.\nPlease allow notifications in Settings.'**
/// **'Notification permission was denied.\nTo receive schedule preparation reminders, please allow notifications in Settings.'**
String get openNotificationSettingsDescription;

/// Button text to open app settings
Expand Down
10 changes: 5 additions & 5 deletions lib/l10n/app_localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class AppLocalizationsEn extends AppLocalizations {

@override
String get notificationPermissionDescription =>
'OnTime needs notifications to help you get ready';
'OnTime sends schedule preparation reminders so you can get ready on time.';

@override
String get late => ' late';
Expand Down Expand Up @@ -370,15 +370,15 @@ class AppLocalizationsEn extends AppLocalizations {

@override
String get notificationAlreadyEnabledDescription =>
'App notifications are currently active.';
'Schedule preparation reminders are currently active.';

@override
String get notificationPermissionRequired =>
'Notification Permission Required';

@override
String get notificationPermissionRequiredDescription =>
'We\'ll send you notifications so you don\'t miss your appointments.\nWould you like to allow notifications?';
'OnTime uses notifications for schedule preparation reminders and appointment alerts.\nWould you like to allow notifications?';

@override
String get allow => 'Allow';
Expand All @@ -388,14 +388,14 @@ class AppLocalizationsEn extends AppLocalizations {

@override
String get notificationPermissionGrantedDescription =>
'Notifications have been successfully activated.';
'Schedule preparation reminders are now active.';

@override
String get openNotificationSettings => 'Allow Notifications in Settings';

@override
String get openNotificationSettingsDescription =>
'Notification permission was denied.\nPlease allow notifications in Settings.';
'Notification permission was denied.\nTo receive schedule preparation reminders, please allow notifications in Settings.';

@override
String get openSettings => 'Open Settings';
Expand Down
12 changes: 7 additions & 5 deletions lib/l10n/app_localizations_ko.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class AppLocalizationsKo extends AppLocalizations {

@override
String get notificationPermissionDescription =>
'알림을 허용해야 온타임이 준비를 \n도와드릴 수 있어요';
'약속 준비 리마인더를 보내\n제시간에 준비할 수 있게 도와드려요.';

@override
String get late => ' 지각했어요';
Expand Down Expand Up @@ -345,14 +345,15 @@ class AppLocalizationsKo extends AppLocalizations {
String get notificationAlreadyEnabled => '알림이 이미 허용됨';

@override
String get notificationAlreadyEnabledDescription => '현재 앱 알림이 활성화되어 있습니다.';
String get notificationAlreadyEnabledDescription =>
'약속 준비 리마인더가 현재 활성화되어 있습니다.';

@override
String get notificationPermissionRequired => '알림 권한 필요';

@override
String get notificationPermissionRequiredDescription =>
'약속 시간을 놓치지 않도록 알림을 보내드립니다.\n알림을 허용하시겠습니까?';
'온타임은 약속 준비 리마인더와 약속 알림을 보내기 위해 알림을 사용합니다.\n알림을 허용하시겠습니까?';

@override
String get allow => '허용';
Expand All @@ -361,14 +362,15 @@ class AppLocalizationsKo extends AppLocalizations {
String get notificationPermissionGranted => '알림 허용 완료';

@override
String get notificationPermissionGrantedDescription => '알림이 성공적으로 활성화되었습니다.';
String get notificationPermissionGrantedDescription =>
'약속 준비 리마인더가 활성화되었습니다.';

@override
String get openNotificationSettings => '설정에서 알림 허용';

@override
String get openNotificationSettingsDescription =>
'알림 권한이 거부되었습니다.\n설정에서 직접 알림을 허용해주세요.';
'알림 권한이 거부되었습니다.\n약속 준비 리마인더를 받으려면 설정에서 알림을 허용해주세요.';

@override
String get openSettings => '설정 열기';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,41 @@ import 'package:on_time_front/presentation/shared/components/modal_wide_button.d
import 'package:on_time_front/presentation/shared/components/two_action_dialog.dart';
import 'package:on_time_front/presentation/shared/constants/app_colors.dart';

abstract interface class NotificationPermissionGateway {
Future<AuthorizationStatus> checkNotificationPermission();

Future<AuthorizationStatus> requestPermission();

Future<bool> openNotificationSettings();
}

class NotificationServicePermissionGateway
implements NotificationPermissionGateway {
const NotificationServicePermissionGateway();

@override
Future<AuthorizationStatus> checkNotificationPermission() {
return NotificationService.instance.checkNotificationPermission();
}

@override
Future<bool> openNotificationSettings() {
return NotificationService.instance.openNotificationSettings();
}

@override
Future<AuthorizationStatus> requestPermission() {
return NotificationService.instance.requestPermission();
}
}

class NotificationAllowScreen extends StatelessWidget {
const NotificationAllowScreen({super.key});
const NotificationAllowScreen({
super.key,
this.permissionGateway = const NotificationServicePermissionGateway(),
});

final NotificationPermissionGateway permissionGateway;

@override
Widget build(BuildContext context) {
Expand All @@ -31,14 +64,11 @@ class NotificationAllowScreen extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
spacing: 40,
children: [
_Image(),
_Title(),
],
children: [_Image(), _Title()],
),
),
),
_Buttons(),
_Buttons(permissionGateway: permissionGateway),
],
),
),
Expand All @@ -47,7 +77,10 @@ class NotificationAllowScreen extends StatelessWidget {
}

class _Buttons extends StatelessWidget {
const _Buttons();
const _Buttons({required this.permissionGateway});

final NotificationPermissionGateway permissionGateway;

@override
Widget build(BuildContext context) {
final textTheme = Theme.of(context).textTheme;
Expand All @@ -60,7 +93,7 @@ class _Buttons extends StatelessWidget {
children: [
FilledButton(
onPressed: () async {
await _handleNotificationPermission(context);
await _handleNotificationPermission(context, permissionGateway);
},
child: Text(
AppLocalizations.of(context)!.allowNotifications,
Expand Down Expand Up @@ -110,18 +143,14 @@ class _Title extends StatelessWidget {
Text(
AppLocalizations.of(context)!.pleaseAllowNotifications,
textAlign: TextAlign.center,
style: textTheme.headlineMedium?.copyWith(
color: colorScheme.primary,
),
style: textTheme.headlineMedium?.copyWith(color: colorScheme.primary),
),
SizedBox(
width: 282,
child: Text(
AppLocalizations.of(context)!.notificationPermissionDescription,
textAlign: TextAlign.center,
style: textTheme.titleMedium?.copyWith(
color: colorScheme.outline,
),
style: textTheme.titleMedium?.copyWith(color: colorScheme.outline),
),
),
],
Expand All @@ -141,25 +170,22 @@ class _Image extends StatelessWidget {
padding: const EdgeInsets.all(17.50),
decoration: ShapeDecoration(
color: colorScheme.primaryContainer,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(35),
),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(35)),
),
child: SvgPicture.asset(
'bell-ringing.svg',
package: 'assets',
colorFilter: ColorFilter.mode(
colorScheme.primary,
BlendMode.srcIn,
),
colorFilter: ColorFilter.mode(colorScheme.primary, BlendMode.srcIn),
),
);
}
}

Future<void> _handleNotificationPermission(BuildContext context) async {
final notificationService = NotificationService.instance;
final currentStatus = await notificationService.checkNotificationPermission();
Future<void> _handleNotificationPermission(
BuildContext context,
NotificationPermissionGateway permissionGateway,
) async {
final currentStatus = await permissionGateway.checkNotificationPermission();

if (!context.mounted) return;

Expand All @@ -171,15 +197,15 @@ Future<void> _handleNotificationPermission(BuildContext context) async {
} else if (currentStatus == AuthorizationStatus.denied) {
final shouldOpenSettings = await _showGoToSettingsDialog(context);
if (shouldOpenSettings == true) {
await notificationService.openNotificationSettings();
await permissionGateway.openNotificationSettings();
} else if (context.mounted) {
await context.read<NotificationGateCubit>().dismissPrompt();
if (context.mounted) {
context.go('/home');
}
}
} else if (currentStatus == AuthorizationStatus.notDetermined) {
final newStatus = await notificationService.requestPermission();
final newStatus = await permissionGateway.requestPermission();

if (!context.mounted) return;

Expand All @@ -191,7 +217,7 @@ Future<void> _handleNotificationPermission(BuildContext context) async {
} else if (newStatus == AuthorizationStatus.denied) {
final shouldOpenSettings = await _showGoToSettingsDialog(context);
if (shouldOpenSettings == true) {
await notificationService.openNotificationSettings();
await permissionGateway.openNotificationSettings();
} else if (context.mounted) {
await context.read<NotificationGateCubit>().dismissPrompt();
if (context.mounted) {
Expand All @@ -202,7 +228,7 @@ Future<void> _handleNotificationPermission(BuildContext context) async {
} else {
final shouldOpenSettings = await _showGoToSettingsDialog(context);
if (shouldOpenSettings == true) {
await notificationService.openNotificationSettings();
await permissionGateway.openNotificationSettings();
} else if (context.mounted) {
await context.read<NotificationGateCubit>().dismissPrompt();
if (context.mounted) {
Expand Down
Loading
Loading