2023-04-05 15:02:10 +02:00
|
|
|
using System;
|
2024-04-09 12:53:23 +02:00
|
|
|
using ShareeBike.Model.Connector;
|
|
|
|
using ShareeBike.Model.Device;
|
|
|
|
using ShareeBike.Model.User;
|
|
|
|
using ShareeBike.Services.BluetoothLock;
|
|
|
|
using ShareeBike.Services.Geolocation;
|
|
|
|
using ShareeBike.View;
|
2021-05-13 20:03:07 +02:00
|
|
|
|
2024-04-09 12:53:23 +02:00
|
|
|
namespace ShareeBike.ViewModel.Bikes.Bike
|
2021-05-13 20:03:07 +02:00
|
|
|
{
|
2022-09-06 16:08:19 +02:00
|
|
|
public static class BikeViewModelFactory
|
|
|
|
{
|
|
|
|
/// <param name="smartDevice">Provides info about the smart device (phone, tablet, ...).</param>
|
2023-07-04 11:06:38 +02:00
|
|
|
/// <param name="viewContext"> Holds the view context in which bike view model is used.</param>
|
2022-09-06 16:08:19 +02:00
|
|
|
/// <param name="stateInfoProvider">Provides in use state information.</param>
|
|
|
|
/// <param name="bikesViewModel">View model to be used for progress report and unlocking/ locking view.</param>
|
|
|
|
/// <param name="openUrlInBrowser">Delegate to open browser.</param>
|
|
|
|
public static BikeViewModelBase Create(
|
|
|
|
Func<bool> isConnectedDelegate,
|
|
|
|
Func<bool, IConnector> connectorFactory,
|
2023-04-05 15:02:10 +02:00
|
|
|
IGeolocationService geolocationService,
|
2022-09-06 16:08:19 +02:00
|
|
|
ILocksService lockService,
|
|
|
|
Action<string> bikeRemoveDelegate,
|
|
|
|
Func<IPollingUpdateTaskManager> viewUpdateManager,
|
|
|
|
ISmartDevice smartDevice,
|
|
|
|
IViewService viewService,
|
|
|
|
Model.Bikes.BikeInfoNS.BC.BikeInfoMutable bikeInfo,
|
|
|
|
IUser activeUser,
|
2023-07-04 11:06:38 +02:00
|
|
|
ViewContext viewContext,
|
2022-09-06 16:08:19 +02:00
|
|
|
IInUseStateInfoProvider stateInfoProvider,
|
|
|
|
IBikesViewModel bikesViewModel,
|
|
|
|
Action<string> openUrlInBrowser)
|
|
|
|
{
|
|
|
|
if (bikeInfo is Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfoMutable)
|
|
|
|
{
|
|
|
|
return new BluetoothLock.BikeViewModel(
|
|
|
|
isConnectedDelegate,
|
|
|
|
connectorFactory,
|
2023-04-05 15:02:10 +02:00
|
|
|
geolocationService,
|
2022-09-06 16:08:19 +02:00
|
|
|
lockService,
|
|
|
|
bikeRemoveDelegate,
|
|
|
|
viewUpdateManager,
|
|
|
|
smartDevice,
|
|
|
|
viewService,
|
|
|
|
bikeInfo as Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfoMutable,
|
|
|
|
activeUser,
|
2023-07-04 11:06:38 +02:00
|
|
|
viewContext,
|
2022-09-06 16:08:19 +02:00
|
|
|
stateInfoProvider,
|
|
|
|
bikesViewModel,
|
|
|
|
openUrlInBrowser);
|
|
|
|
}
|
|
|
|
if (bikeInfo is Model.Bikes.BikeInfoNS.CopriLock.BikeInfoMutable)
|
|
|
|
{
|
|
|
|
return new CopriLock.BikeViewModel(
|
|
|
|
isConnectedDelegate,
|
|
|
|
connectorFactory,
|
|
|
|
bikeRemoveDelegate,
|
|
|
|
viewUpdateManager,
|
|
|
|
smartDevice,
|
|
|
|
viewService,
|
|
|
|
bikeInfo,
|
|
|
|
activeUser,
|
2023-07-04 11:06:38 +02:00
|
|
|
viewContext,
|
2022-09-06 16:08:19 +02:00
|
|
|
stateInfoProvider,
|
|
|
|
bikesViewModel,
|
|
|
|
openUrlInBrowser);
|
|
|
|
}
|
2022-04-25 22:15:15 +02:00
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
2021-05-13 20:03:07 +02:00
|
|
|
}
|