diff --git a/app/lib/ui/flow/permission/enable_permission_view.dart b/app/lib/ui/flow/permission/enable_permission_view.dart index 7719bf4f..3b61942d 100644 --- a/app/lib/ui/flow/permission/enable_permission_view.dart +++ b/app/lib/ui/flow/permission/enable_permission_view.dart @@ -73,22 +73,22 @@ class _EnablePermissionViewState extends ConsumerState _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), ], @@ -112,8 +112,8 @@ class _EnablePermissionViewState extends ConsumerState 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, @@ -121,12 +121,13 @@ class _EnablePermissionViewState extends ConsumerState 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(); + } }, ), ), @@ -135,8 +136,8 @@ class _EnablePermissionViewState extends ConsumerState child: InkWell( splashColor: Colors.transparent, onTap: () { - if (!buttonValue) { - onTapRadio(); + if (!isChecked) { + onChanged(); } }, child: Column( diff --git a/app/lib/ui/flow/permission/enable_permission_view_model.dart b/app/lib/ui/flow/permission/enable_permission_view_model.dart index fc01e06e..8031d4f7 100644 --- a/app/lib/ui/flow/permission/enable_permission_view_model.dart +++ b/app/lib/ui/flow/permission/enable_permission_view_model.dart @@ -39,9 +39,11 @@ class PermissionViewNotifier extends StateNotifier { } Future 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()); } diff --git a/data/lib/service/permission_service.dart b/data/lib/service/permission_service.dart index a6c9ee03..064555c5 100644 --- a/data/lib/service/permission_service.dart +++ b/data/lib/service/permission_service.dart @@ -16,6 +16,9 @@ class PermissionService { Future requestLocationPermission() async { return await Permission.location.request(); } + Future requestLocationPermissionStatus() async { + return await Permission.location.status; + } Future isBackgroundLocationPermissionGranted() async { return await Permission.locationAlways.isGranted;