Workforce rotation settings and location permission handling

This commit is contained in:
2026-03-08 17:31:39 +08:00
parent ce82a88e04
commit 8bf0dc13d7
8 changed files with 1200 additions and 26 deletions
+32
View File
@@ -0,0 +1,32 @@
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:permission_handler/permission_handler.dart';
import '../services/permission_service.dart';
/// Helpers for requesting and checking the platform location permission.
///
/// Mirrors the pattern in [notification_permission.dart] so that location
/// can be requested at app launch and before location-dependent actions.
Future<PermissionStatus> requestLocationPermission() async {
if (kIsWeb) {
return PermissionStatus.granted;
}
return requestPermission(Permission.location);
}
/// Ensures location permission is granted. Returns `true` if granted.
///
/// Call on app launch and before check-in, check-out, or toggling location
/// tracking so the user always has the opportunity to grant permission.
Future<bool> ensureLocationPermission() async {
if (kIsWeb) return true;
final status = await Permission.location.status;
if (status.isGranted) return true;
if (status.isDenied || status.isRestricted || status.isLimited) {
final newStatus = await requestLocationPermission();
return newStatus.isGranted;
}
// permanently denied user must open settings
return false;
}