postit: persist settings save and apply ApiUrl changes without restart #51
3 changed files with 37 additions and 2 deletions
postit: cache rdv reverse geocoding results
commit
bc162b8a05
|
|
@ -20,6 +20,9 @@ public partial class RdvViewModel : BillingCommandPageViewModel
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
public partial string SuggestedAddress { get; set; } = string.Empty;
|
public partial string SuggestedAddress { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
public partial bool IsResolvingAddress { get; set; }
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
public partial double? Latitude { get; set; }
|
public partial double? Latitude { get; set; }
|
||||||
|
|
||||||
|
|
@ -37,6 +40,7 @@ public partial class RdvViewModel : BillingCommandPageViewModel
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HasSuggestedAddress => !string.IsNullOrWhiteSpace(SuggestedAddress);
|
public bool HasSuggestedAddress => !string.IsNullOrWhiteSpace(SuggestedAddress);
|
||||||
|
public bool HasSuggestedAddressPanel => HasSuggestedAddress || IsResolvingAddress;
|
||||||
|
|
||||||
protected override void ApplyExistingQuery(BillingQueryDetailsDto existingQuery)
|
protected override void ApplyExistingQuery(BillingQueryDetailsDto existingQuery)
|
||||||
{
|
{
|
||||||
|
|
@ -135,6 +139,7 @@ public partial class RdvViewModel : BillingCommandPageViewModel
|
||||||
|
|
||||||
public void NotifyReverseGeocodingStarted()
|
public void NotifyReverseGeocodingStarted()
|
||||||
{
|
{
|
||||||
|
IsResolvingAddress = true;
|
||||||
this.SetInfoStatus(string.IsNullOrWhiteSpace(Address)
|
this.SetInfoStatus(string.IsNullOrWhiteSpace(Address)
|
||||||
? "Recherche de l'adresse depuis la carte..."
|
? "Recherche de l'adresse depuis la carte..."
|
||||||
: "Recherche d'une adresse suggérée..."
|
: "Recherche d'une adresse suggérée..."
|
||||||
|
|
@ -143,6 +148,7 @@ public partial class RdvViewModel : BillingCommandPageViewModel
|
||||||
|
|
||||||
public void NotifyReverseGeocodingUnavailable()
|
public void NotifyReverseGeocodingUnavailable()
|
||||||
{
|
{
|
||||||
|
IsResolvingAddress = false;
|
||||||
if (HasSuggestedAddress || !string.IsNullOrWhiteSpace(Address))
|
if (HasSuggestedAddress || !string.IsNullOrWhiteSpace(Address))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -159,6 +165,7 @@ public partial class RdvViewModel : BillingCommandPageViewModel
|
||||||
{
|
{
|
||||||
Address = trimmedAddress;
|
Address = trimmedAddress;
|
||||||
SuggestedAddress = string.Empty;
|
SuggestedAddress = string.Empty;
|
||||||
|
IsResolvingAddress = false;
|
||||||
this.SetInfoStatus("Adresse mise à jour depuis la carte.");
|
this.SetInfoStatus("Adresse mise à jour depuis la carte.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -166,10 +173,12 @@ public partial class RdvViewModel : BillingCommandPageViewModel
|
||||||
if (string.Equals(Address.Trim(), trimmedAddress, StringComparison.Ordinal))
|
if (string.Equals(Address.Trim(), trimmedAddress, StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
SuggestedAddress = string.Empty;
|
SuggestedAddress = string.Empty;
|
||||||
|
IsResolvingAddress = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SuggestedAddress = trimmedAddress;
|
SuggestedAddress = trimmedAddress;
|
||||||
|
IsResolvingAddress = false;
|
||||||
this.SetInfoStatus("Adresse suggérée depuis la carte. Appliquez-la si besoin.");
|
this.SetInfoStatus("Adresse suggérée depuis la carte. Appliquez-la si besoin.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -181,15 +190,22 @@ public partial class RdvViewModel : BillingCommandPageViewModel
|
||||||
|
|
||||||
Address = SuggestedAddress.Trim();
|
Address = SuggestedAddress.Trim();
|
||||||
SuggestedAddress = string.Empty;
|
SuggestedAddress = string.Empty;
|
||||||
|
IsResolvingAddress = false;
|
||||||
this.SetInfoStatus("Adresse suggérée appliquée.");
|
this.SetInfoStatus("Adresse suggérée appliquée.");
|
||||||
}
|
}
|
||||||
|
|
||||||
partial void OnSuggestedAddressChanged(string value)
|
partial void OnSuggestedAddressChanged(string value)
|
||||||
{
|
{
|
||||||
OnPropertyChanged(nameof(HasSuggestedAddress));
|
OnPropertyChanged(nameof(HasSuggestedAddress));
|
||||||
|
OnPropertyChanged(nameof(HasSuggestedAddressPanel));
|
||||||
ApplySuggestedAddressCommand.NotifyCanExecuteChanged();
|
ApplySuggestedAddressCommand.NotifyCanExecuteChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
partial void OnIsResolvingAddressChanged(bool value)
|
||||||
|
{
|
||||||
|
OnPropertyChanged(nameof(HasSuggestedAddressPanel));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected override async Task SubmitAsync()
|
protected override async Task SubmitAsync()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -42,9 +42,9 @@
|
||||||
|
|
||||||
<Grid Grid.Row="7"
|
<Grid Grid.Row="7"
|
||||||
Grid.ColumnSpan="2"
|
Grid.ColumnSpan="2"
|
||||||
ColumnDefinitions="*,12,Auto"
|
ColumnDefinitions="*,12,Auto,12,Auto"
|
||||||
Margin="0,0,0,8"
|
Margin="0,0,0,8"
|
||||||
IsVisible="{Binding HasSuggestedAddress}">
|
IsVisible="{Binding HasSuggestedAddressPanel}">
|
||||||
<TextBlock Grid.Column="0"
|
<TextBlock Grid.Column="0"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="{Binding SuggestedAddress, StringFormat='Adresse suggérée: {0}'}"
|
Text="{Binding SuggestedAddress, StringFormat='Adresse suggérée: {0}'}"
|
||||||
|
|
@ -53,6 +53,10 @@
|
||||||
<Button Grid.Column="2"
|
<Button Grid.Column="2"
|
||||||
Content="Utiliser"
|
Content="Utiliser"
|
||||||
Command="{Binding ApplySuggestedAddressCommand}" />
|
Command="{Binding ApplySuggestedAddressCommand}" />
|
||||||
|
<ProgressBar Grid.Column="4"
|
||||||
|
Width="80"
|
||||||
|
IsIndeterminate="True"
|
||||||
|
IsVisible="{Binding IsResolvingAddress}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid Grid.Row="8"
|
<Grid Grid.Row="8"
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@ public partial class RdvPage : ContentPage
|
||||||
private RdvViewModel? _currentViewModel;
|
private RdvViewModel? _currentViewModel;
|
||||||
private readonly IReverseGeocodingService _reverseGeocodingService;
|
private readonly IReverseGeocodingService _reverseGeocodingService;
|
||||||
private CancellationTokenSource? _reverseGeocodeCts;
|
private CancellationTokenSource? _reverseGeocodeCts;
|
||||||
|
private double? _lastResolvedLatitude;
|
||||||
|
private double? _lastResolvedLongitude;
|
||||||
|
private string? _lastResolvedAddress;
|
||||||
|
|
||||||
public RdvPage()
|
public RdvPage()
|
||||||
: this(null)
|
: this(null)
|
||||||
|
|
@ -180,6 +183,14 @@ public partial class RdvPage : ContentPage
|
||||||
|
|
||||||
private async Task TryResolveAddressAsync(RdvViewModel vm, double latitude, double longitude)
|
private async Task TryResolveAddressAsync(RdvViewModel vm, double latitude, double longitude)
|
||||||
{
|
{
|
||||||
|
if (_lastResolvedLatitude == latitude
|
||||||
|
&& _lastResolvedLongitude == longitude
|
||||||
|
&& !string.IsNullOrWhiteSpace(_lastResolvedAddress))
|
||||||
|
{
|
||||||
|
vm.ApplyResolvedAddress(_lastResolvedAddress);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_reverseGeocodeCts?.Cancel();
|
_reverseGeocodeCts?.Cancel();
|
||||||
_reverseGeocodeCts?.Dispose();
|
_reverseGeocodeCts?.Dispose();
|
||||||
_reverseGeocodeCts = new CancellationTokenSource();
|
_reverseGeocodeCts = new CancellationTokenSource();
|
||||||
|
|
@ -196,6 +207,9 @@ public partial class RdvPage : ContentPage
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(resolved))
|
if (!string.IsNullOrWhiteSpace(resolved))
|
||||||
{
|
{
|
||||||
|
_lastResolvedLatitude = latitude;
|
||||||
|
_lastResolvedLongitude = longitude;
|
||||||
|
_lastResolvedAddress = resolved;
|
||||||
vm.ApplyResolvedAddress(resolved);
|
vm.ApplyResolvedAddress(resolved);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -204,6 +218,7 @@ public partial class RdvPage : ContentPage
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException)
|
catch (OperationCanceledException)
|
||||||
{
|
{
|
||||||
|
vm.IsResolvingAddress = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue