mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-05 10:36:30 +01:00
88 lines
3.5 KiB
C#
88 lines
3.5 KiB
C#
|
|
using Serilog;
|
|
using System;
|
|
using System.Collections.Specialized;
|
|
using System.ComponentModel;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using TINK.Model.Bike;
|
|
using TINK.Model.Connector;
|
|
using TINK.Model.User;
|
|
using TINK.View;
|
|
using TINK.Settings;
|
|
using TINK.Model.Bike.BluetoothLock;
|
|
using System.Collections.Generic;
|
|
using TINK.Services.BluetoothLock;
|
|
using TINK.Model.Services.Geolocation;
|
|
using System.Linq;
|
|
using TINK.Model;
|
|
using Xamarin.Forms;
|
|
using TINK.ViewModel.Bikes;
|
|
using TINK.Services.BluetoothLock.Tdo;
|
|
using Plugin.Permissions;
|
|
using Plugin.Permissions.Abstractions;
|
|
using Plugin.BLE.Abstractions.Contracts;
|
|
using TINK.MultilingualResources;
|
|
using TINK.Model.Device;
|
|
|
|
namespace TINK.ViewModel.FindBike
|
|
{
|
|
public class FindBikePageViewModel : BikesViewModel, INotifyCollectionChanged, INotifyPropertyChanged
|
|
{
|
|
/// <summary>
|
|
/// Constructs bike collection view model in case information about occupied bikes is available.
|
|
/// </summary>
|
|
/// <param name="p_oUser">Mail address of active user.</param>
|
|
/// <param name="isReportLevelVerbose">True if report level is verbose, false if not.</param>
|
|
/// <param name="permissions">Holds object to query location permisions.</param>
|
|
/// <param name="bluetoothLE">Holds object to query bluetooth state.</param>
|
|
/// <param name="runtimPlatform">Specifies on which platform code is run.</param>
|
|
/// <param name="isConnectedDelegate">Returns if mobile is connected to web or not.</param>
|
|
/// <param name="connectorFactory">Connects system to copri.</param>
|
|
/// <param name="lockService">Service to control lock retrieve info.</param>
|
|
/// <param name="polling"> Holds whether to poll or not and the periode leght is polling is on. </param>
|
|
/// <param name="postAction">Executes actions on GUI thread.</param>
|
|
/// <param name="smartDevice">Provides info about the smart device (phone, tablet, ...).</param>
|
|
/// <param name="viewService">Interface to actuate methodes on GUI.</param>
|
|
public FindBikePageViewModel(
|
|
User p_oUser,
|
|
IPermissions permissions,
|
|
IBluetoothLE bluetoothLE,
|
|
string runtimPlatform,
|
|
Func<bool> isConnectedDelegate,
|
|
Func<bool, IConnector> connectorFactory,
|
|
IGeolocation geolocation,
|
|
ILocksService lockService,
|
|
PollingParameters polling,
|
|
Action<SendOrPostCallback, object> postAction,
|
|
ISmartDevice smartDevice,
|
|
IViewService viewService) : base(p_oUser, permissions, bluetoothLE, runtimPlatform, isConnectedDelegate, connectorFactory, geolocation, lockService, polling, postAction, smartDevice, viewService, () => new MyBikeInUseStateInfoProvider())
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Invoked when page is shown.
|
|
/// Starts update process.
|
|
/// </summary>
|
|
public async Task OnAppearing()
|
|
{
|
|
// Get my bikes from COPRI
|
|
Log.ForContext<FindBikePageViewModel>().Information("User request to show page MyBikes/ page re-appearing");
|
|
|
|
ActionText = AppResources.ActivityTextMyBikesLoadingBikes;
|
|
|
|
var bikes = await ConnectorFactory(IsConnected).Query.GetBikesAsync();
|
|
|
|
Exception = bikes.Exception; // Update communication error from query for bikes occupied.
|
|
|
|
BikeIds = bikes.Response.Select(x => x.Id);
|
|
|
|
ActionText = "";
|
|
IsIdle = true;
|
|
}
|
|
|
|
|
|
public IEnumerable<string> BikeIds { get; set; }
|
|
|
|
}
|
|
}
|