2024-12-05 09:11:48 -06:00
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
|
|
import 'package:immich_mobile/repositories/network.repository.dart';
|
|
|
|
import 'package:immich_mobile/repositories/permission.repository.dart';
|
|
|
|
|
|
|
|
final networkServiceProvider = Provider((ref) {
|
|
|
|
return NetworkService(
|
|
|
|
ref.watch(networkRepositoryProvider),
|
|
|
|
ref.watch(permissionRepositoryProvider),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
class NetworkService {
|
2025-06-20 09:11:03 -05:00
|
|
|
final NetworkRepository _repository;
|
2024-12-05 09:11:48 -06:00
|
|
|
final IPermissionRepository _permissionRepository;
|
|
|
|
|
2025-06-25 13:06:24 +05:30
|
|
|
const NetworkService(this._repository, this._permissionRepository);
|
2024-12-05 09:11:48 -06:00
|
|
|
|
|
|
|
Future<bool> getLocationWhenInUserPermission() {
|
|
|
|
return _permissionRepository.hasLocationWhenInUsePermission();
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<bool> requestLocationWhenInUsePermission() {
|
|
|
|
return _permissionRepository.requestLocationWhenInUsePermission();
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<bool> getLocationAlwaysPermission() {
|
|
|
|
return _permissionRepository.hasLocationAlwaysPermission();
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<bool> requestLocationAlwaysPermission() {
|
|
|
|
return _permissionRepository.requestLocationAlwaysPermission();
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<String?> getWifiName() async {
|
|
|
|
final canRead = await getLocationWhenInUserPermission();
|
|
|
|
if (!canRead) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return await _repository.getWifiName();
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<bool> openSettings() {
|
|
|
|
return _permissionRepository.openSettings();
|
|
|
|
}
|
|
|
|
}
|