-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- switch to custom NavigationFactory to avoid reflection - add SFP and PuppeteerSharp to TrimmerRootAssemblies - SFP_UI's updatechecker is broken with this, will fix in a future commit
- Loading branch information
1 parent
0fcfb7a
commit d1540a8
Showing
4 changed files
with
103 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using Avalonia.Controls; | ||
using FluentAvalonia.UI.Controls; | ||
using SFP_UI.Pages; | ||
|
||
namespace SFP_UI.ViewModels; | ||
|
||
public class MainViewViewModel : ViewModelBase | ||
{ | ||
public MainViewViewModel() | ||
{ | ||
NavigationFactory = new NavigationFactory(); | ||
} | ||
|
||
public NavigationFactory NavigationFactory { get; } | ||
} | ||
|
||
public class NavigationFactory : INavigationPageFactory | ||
{ | ||
public NavigationFactory() | ||
{ | ||
Instance = this; | ||
} | ||
|
||
private static NavigationFactory? Instance { get; set; } | ||
|
||
// Create a page based on a Type, but you can create it however you want | ||
public Control? GetPage(Type srcType) | ||
{ | ||
// Return null here because we won't use this method at all | ||
return null; | ||
} | ||
|
||
// Create a page based on an object, such as a view model | ||
public Control? GetPageFromObject(object target) | ||
{ | ||
return target switch | ||
{ | ||
MainPage => _pages[0], | ||
SettingsPage => _pages[1], | ||
_ => throw new Exception() | ||
}; | ||
} | ||
|
||
// Do this to avoid needing Activator.CreateInstance to create from type info | ||
// and to avoid a ridiculous amount of 'ifs' | ||
private readonly Control[] _pages = | ||
{ | ||
new MainPage(), | ||
new SettingsPage(), | ||
}; | ||
|
||
public static Control[] GetPages() | ||
{ | ||
return Instance!._pages; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters