Skip to content

Commit

Permalink
Feedback updates
Browse files Browse the repository at this point in the history
  • Loading branch information
aritchie committed Jul 2, 2024
1 parent 0dc733e commit 8ba652f
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 17 deletions.
2 changes: 1 addition & 1 deletion OwnerModule/Handlers/DeleteEventHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public async Task Handle(DeleteVehicleEvent @event, CancellationToken cancellati
{
await data.DeleteByVehicle(@event.VehicleId, cancellationToken);

// this tells bulti-in mediator components to bust their cache values
// this tells built-in mediator components to bust their cache values
await mediator.FlushAllStores(cancellationToken);
}

Expand Down
2 changes: 1 addition & 1 deletion OwnerModule/LinkViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public override async void OnNavigatedTo(INavigationParameters parameters)
base.OnNavigatedTo(parameters);
if (parameters.IsNewNavigation())
{
var request = parameters.Get<LinkNavRequest>();
var request = parameters.GetRequired<LinkNavRequest>();
await Task.WhenAll(this.BindPeople(), this.BindVehicles());

if (request.PersonId == null)
Expand Down
4 changes: 2 additions & 2 deletions PeopleModule.Contracts/Routes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ namespace PeopleModule;

public static class Routes
{
public static string List = "People";
public static string Detail = "Person";
public const string List = "People";
public const string Detail = "Person";
}
2 changes: 1 addition & 1 deletion PeopleModule/DetailViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public override async void OnNavigatedTo(INavigationParameters parameters)

if (parameters.IsNewNavigation())
{
var request = parameters.Get<DetailNavRequest>()!;
var request = parameters.GetRequired<DetailNavRequest>();
this.person = await data.GetById(request.PersonId, CancellationToken.None);
this.Title = this.person!.FullName;

Expand Down
6 changes: 5 additions & 1 deletion PeopleModule/ListPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:peopleModule="clr-namespace:PeopleModule"
xmlns:contracts="clr-namespace:PeopleModule.Contracts;assembly=PeopleModule.Contracts"
xmlns:skeleton="clr-namespace:Maui.Skeleton;assembly=Maui.Skeleton"
NavigationPage.BackButtonTitle="Back"
x:DataType="peopleModule:ListViewModel"
x:Class="PeopleModule.ListPage"
Expand All @@ -12,7 +13,10 @@
IsRefreshing="{Binding IsBusy}">
<CollectionView ItemsSource="{Binding List}"
SelectionMode="Single"
SelectedItem="{Binding SelectedPerson}">
SelectedItem="{Binding SelectedPerson}"
skeleton:Skeleton.IsParent="True"
skeleton:Skeleton.IsBusy="{Binding IsBusy}"
skeleton:Skeleton.Animation="{skeleton:DefaultAnimation Fade}">
<CollectionView.EmptyView>
<Label Text="No People Found"
FontSize="Large"
Expand Down
1 change: 1 addition & 0 deletions PeopleModule/PeopleModule.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<ItemGroup>
<ProjectReference Include="..\SharedLib\SharedLib.csproj"/>
<PackageReference Include="Bogus" Version="35.5.1"/>
<PackageReference Include="HorusStudio.Maui.Skeleton" Version="2.0.0" />
<PackageReference Include="ReactiveUI.Fody" Version="19.5.41"/>
</ItemGroup>
</Project>
13 changes: 8 additions & 5 deletions SharedLib/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ namespace SharedLib;

public static class Extensions
{
public static T? Get<T>(this INavigationParameters parameters)
=> parameters.GetValue<T>(typeof(T).Name);

public static (string, TRequest) ToNavParam<TRequest>(this TRequest request) where TRequest : IRequest
=> (request.GetType().Name, request);
public static T GetRequired<T>(this INavigationParameters parameters)
{
var key = typeof(T).Name;
if (!parameters.ContainsKey(key))
throw new InvalidOperationException($"NavParameter '{key}' was not found");

return parameters.GetValue<T>(key);
}
}
4 changes: 2 additions & 2 deletions VehicleModule.Contracts/Routes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ namespace VehicleModule;

public static class Routes
{
public static string List = "Animals";
public static string Detail = "Animal";
public const string List = "Animals";
public const string Detail = "Animal";
}
3 changes: 2 additions & 1 deletion VehicleModule/DetailViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ IMediator mediator
public override async void OnNavigatedTo(INavigationParameters parameters)
{
base.OnNavigatedTo(parameters);
var request = parameters.Get<DetailNavRequest>()!;

if (parameters.IsNewNavigation())
{
var request = parameters.GetRequired<DetailNavRequest>();

// go idea to safety this
this.vehicle = await data.GetById(request.VehicleId, CancellationToken.None);
this.Title = this.vehicle!.Name;
Expand Down
6 changes: 5 additions & 1 deletion VehicleModule/ListPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:vehicleModule="clr-namespace:VehicleModule"
xmlns:contracts="clr-namespace:VehicleModule.Contracts;assembly=VehicleModule.Contracts"
xmlns:skeleton="clr-namespace:Maui.Skeleton;assembly=Maui.Skeleton"
NavigationPage.BackButtonTitle="Back"
x:DataType="vehicleModule:ListViewModel"
x:Class="VehicleModule.ListPage"
Expand All @@ -12,7 +13,10 @@
IsRefreshing="{Binding IsBusy}">
<CollectionView ItemsSource="{Binding List}"
SelectionMode="Single"
SelectedItem="{Binding SelectedVehicle}">
SelectedItem="{Binding SelectedVehicle}"
skeleton:Skeleton.IsParent="True"
skeleton:Skeleton.IsBusy="{Binding IsBusy}"
skeleton:Skeleton.Animation="{skeleton:DefaultAnimation Fade}">
<CollectionView.EmptyView>
<Label Text="No Vehicles Found"
FontSize="Large"
Expand Down
5 changes: 3 additions & 2 deletions VehicleModule/ListViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ public class ListViewModel : ViewModel
public ListViewModel(BaseServices services, IMediator mediator) : base(services)
{
this.Load = ReactiveCommand.CreateFromTask(async () =>
this.List = await mediator.Request(new GetListRequest())
);
{
this.List = await mediator.Request(new GetListRequest());
});
this.BindBusyCommand(this.Load);

this.WhenAnyValueSelected(
Expand Down
1 change: 1 addition & 0 deletions VehicleModule/VehicleModule.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<ItemGroup>
<ProjectReference Include="..\SharedLib\SharedLib.csproj"/>
<PackageReference Include="Bogus" Version="35.5.1"/>
<PackageReference Include="HorusStudio.Maui.Skeleton" Version="2.0.0" />
<PackageReference Include="ReactiveUI.Fody" Version="19.5.41"/>
</ItemGroup>

Expand Down

0 comments on commit 8ba652f

Please sign in to comment.