Toggle either bike id input controls and lock management view implemented.

This commit is contained in:
Oliver Hauff 2021-07-14 22:39:31 +02:00
parent 892563ac0f
commit 0c0baf1b10
3 changed files with 33 additions and 6 deletions

View file

@ -12,11 +12,14 @@
<Frame>
<StackLayout>
<Entry
Placeholder="Bike id hier eingeben"
Placeholder="Fahrrad-Nummer bitte hier eingeben"
IsVisible="{Binding IsSelectBikeVisible}"
Text="{Binding BikeIdUserInput}">
</Entry>
<Button
Text="Wählen"
<Button
Text="Rad Wählen"
IsEnabled="{Binding IsSelectBikeEnabled}"
IsVisible="{Binding IsSelectBikeVisible}"
Command="{Binding OnSelectBikeRequest}">
</Button>
<ListView

View file

@ -27,7 +27,7 @@ namespace TINK.View.Settings
/// <returns>Boolean value indicating whether object is visible or not.</returns>
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return ((Permissions)(value)).HasFlag(VisibleFlag);
return ((Permissions)value).HasFlag(VisibleFlag);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)

View file

@ -29,13 +29,33 @@ namespace TINK.ViewModel.FindBike
{
public class FindBikePageViewModel : BikesViewModel, INotifyCollectionChanged, INotifyPropertyChanged
{
private string bikeIdUserInput = string.Empty;
/// <summary> Text entered by user to specify a bike.</summary>
public string BikeIdUserInput { get; set; }
public string BikeIdUserInput
{
get => bikeIdUserInput;
set
{
if (value == bikeIdUserInput)
{
return;
}
bikeIdUserInput = value;
base.OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsSelectBikeEnabled)));
}
}
/// <summary> Holds all bikes available.</summary>
public BikeCollection Bikes { get; set; }
/// <summary> Do not allow to select bike if id is not set.</summary>
public bool IsSelectBikeEnabled => BikeIdUserInput != null && BikeIdUserInput.Length > 0;
/// <summary> Hide id input fields as soon as bike is found.</summary>
public bool IsSelectBikeVisible => BikeCollection != null && BikeCollection.Count == 0;
/// <summary>
/// Constructs bike collection view model in case information about occupied bikes is available.
/// </summary>
@ -65,6 +85,10 @@ namespace TINK.ViewModel.FindBike
ISmartDevice smartDevice,
IViewService viewService) : base(p_oUser, permissions, bluetoothLE, runtimPlatform, isConnectedDelegate, connectorFactory, geolocation, lockService, polling, postAction, smartDevice, viewService, () => new MyBikeInUseStateInfoProvider())
{
CollectionChanged += (sender, eventargs) =>
{
OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsSelectBikeVisible)));
};
}
/// <summary>
@ -87,7 +111,7 @@ namespace TINK.ViewModel.FindBike
}
/// <summary> Command object to bind select bike button to view model. </summary>
public System.Windows.Input.ICommand OnSelectBikeRequest => new Xamarin.Forms.Command(async () => await SelectBike());
public System.Windows.Input.ICommand OnSelectBikeRequest => new Xamarin.Forms.Command(async () => await SelectBike(), () => IsSelectBikeEnabled);
/// <summary> Select a bike by ID</summary>
public async Task SelectBike()