Skip to content

Commit

Permalink
Fix a regression in the select route view
Browse files Browse the repository at this point in the history
  • Loading branch information
sandermvanvliet committed Nov 19, 2023
1 parent fc78d5e commit ea53c4b
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class DesignTimeLandingPageViewModel : LandingPageViewModel
public DesignTimeLandingPageViewModel()
: base(new DesignTimeWorldStore(), new DummyUserPreferences(), new DesignTimeWindowService(), null!)
{
InProgress = true;
InProgress = false;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,25 @@ public LandingPageViewModel(IWorldStore worldStore, IUserPreferences userPrefere
async _ => await LoadMyRoutes(),
_ => !InProgress)
.SubscribeTo(this, () => InProgress);

SearchRouteCommand = new AsyncRelayCommand(
async _ => await SearchRoute(),
_ => true);
}

private async Task<CommandResult> SearchRoute()
{
var result = await _windowService.ShowOpenRouteDialog();

if (result.PlannedRoute != null)
{
SelectedRoute = new Shared.ViewModels.RouteViewModel(new RouteModel
{
PlannedRoute = result.PlannedRoute
});
}

return CommandResult.Success();
}

private async Task<CommandResult> LoadMyRoutes()
Expand Down Expand Up @@ -91,6 +110,7 @@ protected set
public ICommand SelectSportCommand { get; }
public ICommand ResetDefaultSportCommand { get; }
public ICommand LoadMyRoutesCommand { get; }
public ICommand SearchRouteCommand { get; }

public WorldViewModel[] Worlds
{
Expand Down
21 changes: 19 additions & 2 deletions src/RoadCaptain.App.RouteBuilder/Views/LandingPage.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -207,25 +207,42 @@
<Grid.RowDefinitions>
<RowDefinition Height="24" />
<RowDefinition Height="*" />
<RowDefinition Height="40" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="Or select one of your routes:" FontSize="16" Margin="4,6,0,6" />
<Button Grid.Row="0" Content="🗘" ToolTip.Tip="Refresh" HorizontalAlignment="Right" Margin="4,8,4,4" Command="{Binding LoadMyRoutesCommand}" />
<controls:RoutesList
Grid.Row="1"
Routes="{Binding Path=MyRoutes, Mode=OneWay}"
Margin="0,0,4,8"
Margin="0,0,4,0"
SelectedRoute="{Binding SelectedRoute, Mode=TwoWay}" />
<Grid
Grid.Row="1"
IsVisible="{Binding InProgress}"
Background="LightGray"
Opacity="0.7"
Margin="0,0,4,8">
Margin="0,0,4,0">
<TextBlock Text="Loading..."
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontWeight="Bold"/>
</Grid>
<StackPanel
Grid.Row="2"
Orientation="Horizontal">
<StackPanel.Styles>
<Style Selector="TextBlock">
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="4,0,0,0" />
</Style>
<Style Selector="Button">
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="8,0,0,0" />
</Style>
</StackPanel.Styles>
<TextBlock Text="Or open another route to use as a starter" />
<Button Content="Open" Command="{Binding Path=SearchRouteCommand}" />
</StackPanel>
</Grid>
</Grid>
</UserControl>
4 changes: 3 additions & 1 deletion src/RoadCaptain.App.Shared/Views/SelectRouteWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@
VerticalAlignment="Center" />
</Grid>

<controls:RoutesList Grid.Row="1" Grid.Column="1" DataContext="{Binding Path=Routes}" RouteSelected="RoutesList_OnRouteSelected" />
<controls:RoutesList Grid.Row="1" Grid.Column="1"
Routes="{Binding Path=Routes}"
RouteSelected="RoutesList_OnRouteSelected" />

<!-- Bottom button row -->
<Grid Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2">
Expand Down

0 comments on commit ea53c4b

Please sign in to comment.