Skip to content
This repository has been archived by the owner on Nov 4, 2022. It is now read-only.

Commit

Permalink
Merge pull request #11 from vniehues/develop
Browse files Browse the repository at this point in the history
Added GoToSection to BaseMethods
  • Loading branch information
vniehues authored May 11, 2022
2 parents 52c7fda + 7fe1058 commit 19ba951
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions samples/mavvmApp/AppShell.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:viewmodels="clr-namespace:mavvmApp.ViewModels" xmlns:mavvm="clr-namespace:mavvm;assembly=mavvm"

x:Class="mavvmApp.AppShell">
<ShellItem>
<ShellItem Route="start">
<mavvm:MavvmShellContent ViewModel="{x:Type viewmodels:MainPageViewModel}">
</mavvm:MavvmShellContent>
</ShellItem>
<TabBar>
<TabBar Route="main">
<Tab Title="Second" Route="firstTab">
<mavvm:MavvmShellContent ViewModel="{x:Type viewmodels:SecondPageViewModel}">
<mavvm:MavvmShellContent Title="MainPageTitle" ViewModel="{x:Type viewmodels:SecondPageViewModel}">
</mavvm:MavvmShellContent>
</Tab>
<Tab Title="Second 2" Route="secondTab">
Expand Down
2 changes: 1 addition & 1 deletion samples/mavvmApp/ViewModels/MainPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void CountUp()

async void Navigate()
{
await BaseMethods.GoToViewModel<SecondPageViewModel>(false, new NavigationParameters{ { "countParam", Count } });
await BaseMethods.GoToSection("main", new NavigationParameters{ { "countParam", Count } });
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions src/mavvm/Navigation/BaseMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ public static async Task GoToSection(string sectionRoute, NavigationParameters p
}
else
{
await Shell.Current.GoToAsync(path, animate, parameters);
await Shell.Current.GoToAsync(path, false, parameters);

if ((Shell.Current?.CurrentItem?.CurrentItem as IShellSectionController)?.PresentedPage.BindingContext is INavigateBackToAware vm)
//HACK: Shell doesn'T immediately know about PresentedPage.
await Task.Delay(50);

if ((Shell.Current?.CurrentItem?.CurrentItem as IShellSectionController)?.PresentedPage?.BindingContext is INavigateToAware vmTo)
{
vm.NavigatedBackTo(parameters);
vmTo.NavigatedTo(parameters);
}

}
}

Expand Down
2 changes: 1 addition & 1 deletion src/mavvm/mavvm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('-windows'))">10.0.18362.0</SupportedOSPlatformVersion>
<PackageId>mavvm</PackageId>
<PackageVersion>1.0.1</PackageVersion>
<PackageVersion>1.0.2</PackageVersion>
<Authors>Vincent Niehues</Authors>
<Copyright>Vincent Niehues 2021</Copyright>
<Owners>Vincent Niehues</Owners>
Expand Down

0 comments on commit 19ba951

Please sign in to comment.