using System;
using System.Threading;
using System.Threading.Tasks;
using TINK.Model.Device;
using Xamarin.Essentials;
namespace TINK.Services.Geolocation
{
public class SimulatedGeolocationService : IGeolocationService
{
private IGeolodationDependent Dependent { get; }
public SimulatedGeolocationService(IGeolodationDependent dependent)
{
Dependent = dependent;
}
/// Gets the current location.
/// Token to cancel request for geolocation.
/// Time when geolocation is of interest. Is used to determine whether cached geolocation can be used or not.
public async Task GetAsync(CancellationToken? cancelToken = null, DateTime? timeStamp = null)
{
return await Task.FromResult(new Geolocation.Builder {
Latitude = 47.976634,
Longitude = 7.825490,
Accuracy = 0,
Timestamp = timeStamp ?? DateTime.Now }.Build()); ;
}
/// If true location data returned is simulated.
public bool IsSimulation { get => true; }
public bool IsGeolcationEnabled => Dependent.IsGeolcationEnabled;
}
}