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