Contact page shows operator specific info

This commit is contained in:
Oliver Hauff 2021-07-20 23:06:09 +02:00
parent e436e83c1d
commit a58c33f005
51 changed files with 948 additions and 221 deletions

View file

@ -28,7 +28,7 @@ namespace TINK.Model.Connector
/// </summary>
/// <param name="p_oStationInfo">Object to get information from.</param>
/// <returns>Position information.</returns>
public static Station.Position GetPosition(this StationsAllResponse.StationInfo p_oStationInfo)
public static Station.Position GetPosition(this StationsAvailableResponse.StationInfo p_oStationInfo)
{
return GetPosition(p_oStationInfo.gps);
}
@ -74,7 +74,7 @@ namespace TINK.Model.Connector
/// <summary> Gets the position from StationInfo object. </summary>
/// <param name="p_oStationInfo">Object to get information from.</param>
/// <returns>Position information.</returns>
public static IEnumerable<string> GetGroup(this StationsAllResponse.StationInfo p_oStationInfo)
public static IEnumerable<string> GetGroup(this StationsAvailableResponse.StationInfo p_oStationInfo)
{
try
{

View file

@ -11,6 +11,8 @@ using Serilog;
using BikeInfo = TINK.Model.Bike.BC.BikeInfo;
using IBikeInfoMutable = TINK.Model.Bikes.Bike.BC.IBikeInfoMutable;
using System.Globalization;
using TINK.Model.Station.Operator;
using Xamarin.Forms;
namespace TINK.Model.Connector
{
@ -34,37 +36,44 @@ namespace TINK.Model.Connector
/// Gets all statsion for station provider and add them into station list.
/// </summary>
/// <param name="p_oStationList">List of stations to update.</param>
public static StationDictionary GetStationsAllMutable(this StationsAllResponse p_oStationsAllResponse)
public static StationDictionary GetStationsAllMutable(this StationsAvailableResponse stationsAllResponse)
{
// Get stations from Copri/ file/ memory, ....
if (p_oStationsAllResponse == null
|| p_oStationsAllResponse.stations == null)
if (stationsAllResponse == null
|| stationsAllResponse.stations == null)
{
// Latest list of stations could not be retrieved from provider.
return new StationDictionary();
}
Version.TryParse(p_oStationsAllResponse.copri_version, out Version l_oCopriVersion);
Version.TryParse(stationsAllResponse.copri_version, out Version copriVersion);
var l_oStations = new StationDictionary(p_oVersion: l_oCopriVersion);
var stations = new StationDictionary(p_oVersion: copriVersion);
foreach (var l_oStation in p_oStationsAllResponse.stations)
foreach (var station in stationsAllResponse.stations)
{
if (l_oStations.GetById(l_oStation.Value.station) != null)
if (stations.GetById(station.Value.station) != null)
{
// Can not add station to list of station. Id is not unique.
throw new InvalidResponseException<StationsAllResponse>(
string.Format("Station id {0} is not unique.", l_oStation.Value.station), p_oStationsAllResponse);
throw new InvalidResponseException<StationsAvailableResponse>(
string.Format("Station id {0} is not unique.", station.Value.station), stationsAllResponse);
}
l_oStations.Add(new Station.Station(
l_oStation.Value.station,
l_oStation.Value.GetGroup(),
l_oStation.Value.GetPosition(),
l_oStation.Value.description));
stations.Add(new Station.Station(
station.Value.station,
station.Value.GetGroup(),
station.Value.GetPosition(),
station.Value.description,
new Data(station.Value.operator_data?.operator_name,
station.Value.operator_data?.operator_phone,
station.Value.operator_data?.operator_hours,
station.Value.operator_data?.operator_email,
!string.IsNullOrEmpty(station.Value.operator_data?.operator_color)
? Color.FromHex(station.Value.operator_data?.operator_color)
: (Color?)null)));
}
return l_oStations;
return stations;
}
/// <summary> Gets account object from login response.</summary>

View file

@ -1,4 +1,5 @@
using System.Collections.Generic;
using TINK.Model.Station.Operator;
namespace TINK.Model.Station
{
@ -15,5 +16,8 @@ namespace TINK.Model.Station
/// <summary> Holds the gps- position of the station.</summary>
Position Position { get; }
/// <summary> Holds operator related data.</summary>
IData OperatorData { get; }
}
}

View file

@ -1,4 +1,5 @@
using System.Collections.Generic;
using TINK.Model.Station.Operator;
namespace TINK.Model.Station
{
@ -16,5 +17,8 @@ namespace TINK.Model.Station
/// <summary> Holds the gps- position of the station.</summary>
public Position Position => new Position(double.NaN, double.NaN);
/// <summary> Holds operator related data.</summary>
public IData OperatorData => new Data();
}
}

View file

@ -0,0 +1,36 @@
using Xamarin.Forms;
namespace TINK.Model.Station.Operator
{
/// <summary> Holds operator related data.</summary>
public class Data : IData
{
public Data(
string name = null,
string phoneNumberText = null,
string hours = null,
string mailAddressText = null, Color? color = null)
{
Name = name ?? string.Empty;
PhoneNumberText = phoneNumberText ?? string.Empty;
Hours = hours ?? string.Empty;
MailAddressText = mailAddressText ?? string.Empty;
Color = color;
}
/// <summary> Name of the operator.</summary>
public string Name { get; private set; }
/// <summary> Support phone number of the operator.</summary>
public string PhoneNumberText { get; private set; }
/// <summary> Office times when support is available.</summary>
public string Hours { get; private set; }
/// <summary> Support mails address of the operator.</summary>
public string MailAddressText { get; private set; }
/// <summary> Color of the operator (operator specific skin)</summary>
public Color? Color { get; private set; }
}
}

View file

@ -0,0 +1,22 @@
using Xamarin.Forms;
namespace TINK.Model.Station.Operator
{
public interface IData
{
/// <summary> Name of the operator.</summary>
string Name { get; }
/// <summary> Support phone number of the operator.</summary>
string PhoneNumberText { get; }
/// <summary> Office times when support is available.</summary>
string Hours { get; }
/// <summary> Support mails address of the operator.</summary>
string MailAddressText { get; }
/// <summary> Color of the operator (operator specific skin)</summary>
Color? Color { get; }
}
}

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using TINK.Model.Station.Operator;
namespace TINK.Model.Station
{
@ -7,20 +8,22 @@ namespace TINK.Model.Station
public class Station : IStation
{
/// <summary> Constructs a station object.</summary>
/// <param name="p_iId">Id of the station.</param>
/// <param name="p_oGroup">Group (TINK, Konrad) to which station is related.</param>
/// <param name="p_oPosition">GPS- position of the station.</param>
/// <param name="p_strStationName">Name of the station.</param>
/// <param name="id">Id of the station.</param>
/// <param name="group">Group (TINK, Konrad) to which station is related.</param>
/// <param name="position">GPS- position of the station.</param>
/// <param name="stationName">Name of the station.</param>
public Station(
string p_iId,
IEnumerable<string> p_oGroup,
Position p_oPosition,
string p_strStationName = "")
string id,
IEnumerable<string> group,
Position position,
string stationName = "",
Data operatorData = null)
{
Id = p_iId;
Group = p_oGroup ?? throw new ArgumentException("Can not construct station object. Group of stations must not be null.");
Position = p_oPosition;
StationName = p_strStationName ?? string.Empty;
Id = id;
Group = group ?? throw new ArgumentException("Can not construct station object. Group of stations must not be null.");
Position = position;
StationName = stationName ?? string.Empty;
OperatorData = operatorData ?? new Data();
}
/// <summary> Holds the unique id of the station.c</summary>
@ -34,5 +37,8 @@ namespace TINK.Model.Station
/// <summary> Holds the gps- position of the station.</summary>
public Position Position { get; }
/// <summary> Holds operator related info.</summary>
public IData OperatorData { get; }
}
}

View file

@ -322,7 +322,7 @@ namespace TINK.Model
public ICipher Cipher { get; }
/// <summary> Name of the station which is selected. </summary>
public IStation SelectedStation { get; set; } = new Station.Station(null, new List<string>(), null);
public IStation SelectedStation { get; set; } = new NullStation();
/// <summary> Holds the stations availalbe. </summary>
public IEnumerable<IStation> Stations { get; set; } = new List<Station.Station>();

View file

@ -413,6 +413,10 @@ namespace TINK.Model
{
new Version(3, 0, 240),
AppResources.ChangeLog3_0_240
},
{
new Version(3, 0, 241),
AppResources.ChangeLog3_0_241
}
};