Skip to content

Commit

Permalink
Fix app rejection (#167)
Browse files Browse the repository at this point in the history
* update radio button with checkbox

* do not show custom prompt of navigating to setting if user don't allow location permission
  • Loading branch information
cp-ishita-g authored Dec 20, 2024
1 parent ba776f9 commit 59a4eb1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
29 changes: 15 additions & 14 deletions app/lib/ui/flow/permission/enable_permission_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,22 @@ class _EnablePermissionViewState extends ConsumerState<EnablePermissionView>
_permissionView(
title: context.l10n.enable_location_access_title,
subTitle: context.l10n.enable_location_access_sub_title,
buttonValue: state.isLocationGranted,
onTapRadio: notifier.requestLocationPermission,
isChecked: state.isLocationGranted,
onChanged: notifier.requestLocationPermission,
),
const SizedBox(height: 24),
_permissionView(
title: context.l10n.enable_background_location_access_title,
subTitle: context.l10n.enable_background_location_access_sub_title,
buttonValue: state.isBackGroundLocationGranted,
onTapRadio: notifier.requestBackgroundLocationPermission,
isChecked: state.isBackGroundLocationGranted,
onChanged: notifier.requestBackgroundLocationPermission,
),
const SizedBox(height: 24),
_permissionView(
title: context.l10n.enable_notification_access_title,
subTitle: context.l10n.enable_notification_access_sun_title,
buttonValue: state.isNotificationGranted,
onTapRadio: notifier.requestNotificationPermission,
isChecked: state.isNotificationGranted,
onChanged: notifier.requestNotificationPermission,
),
const SizedBox(height: 64),
],
Expand All @@ -112,21 +112,22 @@ class _EnablePermissionViewState extends ConsumerState<EnablePermissionView>
Widget _permissionView({
required String title,
required String subTitle,
required bool buttonValue,
required VoidCallback onTapRadio,
required bool isChecked,
required VoidCallback onChanged,
}) {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
width: 24,
height: 24,
child: Radio(
value: true,
groupValue: buttonValue,
child: Checkbox(
value: isChecked,
activeColor: context.colorScheme.primary,
onChanged: (value) {
onTapRadio();
if (value == true) {
onChanged();
}
},
),
),
Expand All @@ -135,8 +136,8 @@ class _EnablePermissionViewState extends ConsumerState<EnablePermissionView>
child: InkWell(
splashColor: Colors.transparent,
onTap: () {
if (!buttonValue) {
onTapRadio();
if (!isChecked) {
onChanged();
}
},
child: Column(
Expand Down
4 changes: 3 additions & 1 deletion app/lib/ui/flow/permission/enable_permission_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ class PermissionViewNotifier extends StateNotifier<PermissionViewState> {
}

Future<void> requestLocationPermission() async {
final permissionState = await permissionService.requestLocationPermission();
final permissionState = await permissionService.requestLocationPermissionStatus();
if (permissionState.isGranted) {
state = state.copyWith(isLocationGranted: true);
} else if (permissionState.isDenied) {
await permissionService.requestLocationPermission();
} else {
state = state.copyWith(showLocationPrompt: DateTime.now());
}
Expand Down
3 changes: 3 additions & 0 deletions data/lib/service/permission_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class PermissionService {
Future<PermissionStatus> requestLocationPermission() async {
return await Permission.location.request();
}
Future<PermissionStatus> requestLocationPermissionStatus() async {
return await Permission.location.status;
}

Future<bool> isBackgroundLocationPermissionGranted() async {
return await Permission.locationAlways.isGranted;
Expand Down

0 comments on commit 59a4eb1

Please sign in to comment.