Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

Commit

Permalink
Add functionality to progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
liamspitaels committed Jan 16, 2021
1 parent fc9c992 commit 303c4cd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
6 changes: 4 additions & 2 deletions Vecto.UWP/Pages/TripDetailsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@
<Button Height="28" Content="Edit" Click="EditButton_Click" />
<Button Height="28" Content="Add Section" Click="AddSectionButton_Click" />
</StackPanel>
<ProgressBar Grid.Column="1" HorizontalAlignment="Right" Width="200" Height="20" Maximum="1">
<ProgressBar Name="TripProgressBar" Grid.Column="1" HorizontalAlignment="Right" Width="200" Height="20" Maximum="1">
<ToolTipService.ToolTip>
<ToolTip />
<ToolTip>
<TextBlock Name="TripProgressText" />
</ToolTip>
</ToolTipService.ToolTip>
</ProgressBar>
</Grid>
Expand Down
13 changes: 11 additions & 2 deletions Vecto.UWP/Pages/TripDetailsPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections.ObjectModel;
Expand All @@ -12,6 +12,7 @@
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Navigation;
using System.Threading.Tasks;

namespace Vecto.UWP.Pages
{
Expand All @@ -38,8 +39,9 @@ protected override async void OnNavigatedTo(NavigationEventArgs e)
_sections = new ObservableCollection<Section>(sections);

InitializeComponent(); //Initialize here
}

UpdateProgressBar();
}

private async void EditButton_Click(object sender, RoutedEventArgs e)
{
Expand Down Expand Up @@ -150,5 +152,12 @@ private void ProgressBar_PointerEntered(object sender, PointerRoutedEventArgs e)
{
FlyoutBase.ShowAttachedFlyout((FrameworkElement)sender);
}

private async void UpdateProgressBar()
{
double progress = (double)await _service.GetTripProgress(_trip.Id);
TripProgressBar.Value = progress;
TripProgressText.Text = $"Completed: {(int)(progress * 100)}%";
}
}
}
3 changes: 3 additions & 0 deletions Vecto.UWP/Services/IApiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,8 @@ public interface IApiService

[Delete("/trips/{tripId}/sections/{sectionId}/items/{itemId}")]
Task DeleteItem(Guid tripId, Guid sectionId, Guid itemId);

[Get("/trips/{tripId}/progress")]
Task<float> GetTripProgress(Guid tripId);
}
}

0 comments on commit 303c4cd

Please sign in to comment.