Skip to content

Commit

Permalink
Added directoin to timetable page
Browse files Browse the repository at this point in the history
  • Loading branch information
damiansikora85 committed Oct 6, 2024
1 parent d7a48a4 commit d56769d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 10 additions & 1 deletion BusSchedule.Core.UI/Pages/TimetableViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ namespace BusSchedule.Core.UI.Pages;
public class TimetableViewModel : INotifyPropertyChanged
{
public Routes Route { get; private set; }
public string Direction { get; private set; }
public string StopName => Station.Stop_Name;
public Stops Station { get; private set; }
public bool HasDirection => _direction.HasValue;

private IDataProvider _dataProvider;
private readonly IDataProvider _dataProvider;
private int? _direction;

public List<TimetableItem> Timetable { get; private set; }
Expand Down Expand Up @@ -44,6 +47,11 @@ public TimetableViewModel(Routes route, Stops station, int? direction, IDataProv

public async Task RefreshTimetableAsync()
{
if (_direction.HasValue)
{
var dest = await _dataProvider.GetRouteDestinations(Route);
Direction = _direction == 0 ? dest.Outbound : dest.Inbound;
}
var legendData = await _dataProvider.GetRouteLegend(Route.Route_Id, _direction);
TimetableLegend = ParseLegend(legendData);
var schedule = await GetScheduleForDay();
Expand All @@ -52,6 +60,7 @@ public async Task RefreshTimetableAsync()

OnPropertyChanged(nameof(Timetable));
OnPropertyChanged(nameof(TimetableLegend));
OnPropertyChanged(nameof(Direction));
}

private void OnPropertyChanged(string propertyName)
Expand Down
6 changes: 6 additions & 0 deletions BusSchedule/Pages/TimetablePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
</Style>
</ResourceDictionary>
</ContentPage.Resources>
<Shell.TitleView>
<VerticalStackLayout VerticalOptions="Center">
<Label Text="{Binding StopName}" TextColor="White" FontSize="18" />
<Label Text="{Binding Direction, StringFormat='Kierunek: {0}'}" TextColor="White" FontSize="12" IsVisible="{Binding HasDirection}" />
</VerticalStackLayout>
</Shell.TitleView>
<ContentPage.Content>
<StackLayout>
<CollectionView
Expand Down

0 comments on commit d56769d

Please sign in to comment.