Skip to content

Commit

Permalink
Add non-generic WarmUp
Browse files Browse the repository at this point in the history
  • Loading branch information
m-sadegh-sh committed Sep 11, 2024
1 parent 83dbcde commit 923318c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
23 changes: 18 additions & 5 deletions Core/Navigation/Nav.cs
Original file line number Diff line number Diff line change
Expand Up @@ -471,15 +471,28 @@ public static async Task WarmUp<TPage>() where TPage : Page

var page = GetOrCreateTargetPage(typeof(TPage)).Item1;

if (CacheViewAttribute.IsCacheable(page))
await WarmUp(page);
}

/// <summary>
/// Warmp-up cachable target page to enable to navigate faster.
/// </summary>
public static async Task WarmUp(Page page)
{
if (CacheViewAttribute.IsCacheable(page) == false)
{
CachedPages.Add(page);
await View.Root.Add(page.X(View.Root.ActualWidth).Y(0));
Log.For<Nav>().Error("The WarmUp navigation just work on cachable pages, please make sure the target page has the CacheViewAttribute");
return;
}
else

if (CachedPages.Contains(page))
{
Log.For<Nav>().Error("The WarmUp navigation just work on cachable pages, please make sure the target page has the CacheViewAttribute");
Log.For<Nav>().Info($"{page.GetType()} is already cached.");
return;
}

CachedPages.Add(page);
await View.Root.Add(page.X(View.Root.ActualWidth).Y(0));
}

static IDictionary<string, object> SerializeToDictionary(object navParams)
Expand Down
2 changes: 1 addition & 1 deletion Core/ViewModel/Templates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Zebble.Mvvm
{
partial class Templates
{
internal static View GetOrCreate(ViewModel target)
public static View GetOrCreate(ViewModel target)
{
var template = Mappings.GetOrDefault(target.GetType());

Expand Down
2 changes: 1 addition & 1 deletion Zebble/Zebble.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<RootNamespace>Zebble</RootNamespace>
<PackageId>Zebble</PackageId>
<Product>$(AssemblyName) ($(TargetFramework))</Product>
<Version>5.0.60.0</Version>
<Version>5.0.61.0</Version>
<PackOnBuild>true</PackOnBuild>
<NeutralLanguage>en</NeutralLanguage>
<NoWarn>0618;0162</NoWarn>
Expand Down

0 comments on commit 923318c

Please sign in to comment.