Skip to content

Commit fc900a2

Browse files
committed
Added new view navigation and associated MVVM libs
1 parent 2b3fd00 commit fc900a2

10 files changed

Lines changed: 1165 additions & 239 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929

3030
env:
3131
BUILD_CONFIG: 'Release'
32-
SOLUTION: 'MADE.NET.sln'
32+
SOLUTION: 'MADE.NET.NoSamples.slnf'
3333

3434
runs-on: windows-latest
3535

MADE.NET.NoSamples.slnf

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"solution": {
3+
"path": "MADE.NET.sln",
4+
"projects": [
5+
"src\\MADE.Collections\\MADE.Collections.csproj",
6+
"src\\MADE.Data.Converters\\MADE.Data.Converters.csproj",
7+
"src\\MADE.Data.EFCore\\MADE.Data.EFCore.csproj",
8+
"src\\MADE.Data.Validation\\MADE.Data.Validation.csproj",
9+
"src\\MADE.Diagnostics\\MADE.Diagnostics.csproj",
10+
"src\\MADE.Media.Image\\MADE.Media.Image.csproj",
11+
"src\\MADE.Networking\\MADE.Networking.csproj",
12+
"src\\MADE.Runtime\\MADE.Runtime.csproj",
13+
"src\\MADE.Testing\\MADE.Testing.csproj",
14+
"src\\MADE.Threading\\MADE.Threading.csproj",
15+
"src\\MADE.UI.Controls.DropDownList\\MADE.UI.Controls.DropDownList.csproj",
16+
"src\\MADE.UI.Controls.FilePicker\\MADE.UI.Controls.FilePicker.csproj",
17+
"src\\MADE.UI.Controls.Validator\\MADE.UI.Controls.Validator.csproj",
18+
"src\\MADE.UI.Styling\\MADE.UI.Styling.csproj",
19+
"src\\MADE.UI.ViewManagement\\MADE.UI.ViewManagement.csproj",
20+
"src\\MADE.UI.Views.Dialogs\\MADE.UI.Views.Dialogs.csproj",
21+
"src\\MADE.UI.Views.Navigation.Mvvm\\MADE.UI.Views.Navigation.Mvvm.csproj",
22+
"src\\MADE.UI.Views.Navigation\\MADE.UI.Views.Navigation.csproj",
23+
"src\\MADE.UI\\MADE.UI.csproj",
24+
"src\\MADE.Web.Mvc\\MADE.Web.Mvc.csproj",
25+
"src\\MADE.Web\\MADE.Web.csproj",
26+
"tests\\MADE.Collections.Tests\\MADE.Collections.Tests.csproj",
27+
"tests\\MADE.Data.Converters.Tests\\MADE.Data.Converters.Tests.csproj",
28+
"tests\\MADE.Data.Validation.Tests\\MADE.Data.Validation.Tests.csproj",
29+
"tests\\MADE.Diagnostics.Tests\\MADE.Diagnostics.Tests.csproj",
30+
"tests\\MADE.Networking.Tests\\MADE.Networking.Tests.csproj",
31+
"tests\\MADE.Web.Tests\\MADE.Web.Tests.csproj"
32+
]
33+
}
34+
}

MADE.NET.sln

Lines changed: 662 additions & 238 deletions
Large diffs are not rendered by default.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<Project Sdk="MSBuild.Sdk.Extras">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>uap10.0.17763;MonoAndroid10.0;xamarinios10;netstandard2.0;xamarinmac20</TargetFrameworks>
5+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
6+
<Product>MADE.NET UI View Navigation for MVVM Toolkit</Product>
7+
<Description>
8+
This package includes enhancements to build page to page navigation with support for the Windows Community Toolkit MVVM library for Windows and Uno Platform such as:
9+
-
10+
</Description>
11+
<PackageTags>MADE UI View Page Navigation MVVM WCT Windows Android iOS macOS Xamarin Uno</PackageTags>
12+
<GenerateLibraryLayout>true</GenerateLibraryLayout>
13+
<RootNamespace>MADE.UI.Views.Navigation</RootNamespace>
14+
</PropertyGroup>
15+
16+
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == 'MonoAndroid' or '$(TargetFrameworkIdentifier)' == 'Xamarin.iOS' or '$(TargetFrameworkIdentifier)' == '.NETStandard' or '$(TargetFrameworkIdentifier)' == 'Xamarin.Mac'">
17+
<PackageReference Include="Uno.UI" Version="3.9.7" />
18+
</ItemGroup>
19+
20+
<ItemGroup>
21+
<Page Include="**\*.xaml" Exclude="bin\**\*.xaml;obj\**\*.xaml">
22+
<SubType>Designer</SubType>
23+
<Generator>MSBuild:Compile</Generator>
24+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
25+
</Page>
26+
</ItemGroup>
27+
28+
<ItemGroup>
29+
<PackageReference Include="CommunityToolkit.Mvvm" Version="7.0.3" />
30+
</ItemGroup>
31+
32+
<ItemGroup>
33+
<ProjectReference Include="..\MADE.UI.Views.Navigation\MADE.UI.Views.Navigation.csproj" />
34+
</ItemGroup>
35+
36+
</Project>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// MADE Apps licenses this file to you under the MIT license.
2+
// See the LICENSE file in the project root for more information.
3+
4+
namespace MADE.UI.Views.Navigation.Pages
5+
{
6+
using MADE.UI.Views.Navigation.ViewModels;
7+
using Windows.UI.Xaml.Navigation;
8+
9+
/// <summary>
10+
/// Defines an MVVM friendly page that is compatible with the Windows Community Toolkit MVVM library.
11+
/// </summary>
12+
public class MvvmPage : Page
13+
{
14+
/// <summary>
15+
/// Called when the page has loaded.
16+
/// </summary>
17+
public override void OnPageLoaded()
18+
{
19+
base.OnPageLoaded();
20+
21+
if (this.DataContext is PageViewModel vm)
22+
{
23+
vm.OnPageLoaded();
24+
}
25+
}
26+
27+
/// <summary>
28+
/// Called when the page has been navigated from.
29+
/// </summary>
30+
/// <param name="e">
31+
/// The navigation event argument for the navigation.
32+
/// </param>
33+
protected override void OnNavigatedFrom(NavigationEventArgs e)
34+
{
35+
base.OnNavigatedFrom(e);
36+
37+
if (this.DataContext is PageViewModel vm)
38+
{
39+
vm.OnNavigatedFrom(e);
40+
}
41+
}
42+
43+
/// <summary>
44+
/// Called when the page has been navigated to.
45+
/// </summary>
46+
/// <param name="e">
47+
/// The navigation event argument for the navigation.
48+
/// </param>
49+
protected override void OnNavigatedTo(NavigationEventArgs e)
50+
{
51+
base.OnNavigatedTo(e);
52+
53+
if (this.DataContext is PageViewModel vm)
54+
{
55+
vm.OnNavigatedTo(e);
56+
}
57+
}
58+
59+
/// <summary>
60+
/// Called when the page is being navigated from.
61+
/// </summary>
62+
/// <param name="e">
63+
/// The navigation event argument for the navigation supporting the cancellation of the navigation.
64+
/// </param>
65+
protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
66+
{
67+
base.OnNavigatingFrom(e);
68+
69+
if (this.DataContext is PageViewModel vm)
70+
{
71+
vm.OnNavigatingFrom(e);
72+
}
73+
}
74+
}
75+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// MADE Apps licenses this file to you under the MIT license.
2+
// See the LICENSE file in the project root for more information.
3+
4+
namespace MADE.UI.Views.Navigation.ViewModels
5+
{
6+
using CommunityToolkit.Mvvm.ComponentModel;
7+
using CommunityToolkit.Mvvm.Messaging;
8+
using Windows.UI.Xaml.Navigation;
9+
10+
/// <summary>
11+
/// Defines a view-model for a MADE page.
12+
/// </summary>
13+
public class PageViewModel : ObservableObject
14+
{
15+
/// <summary>
16+
/// Initializes a new instance of the <see cref="PageViewModel"/> class.
17+
/// </summary>
18+
/// <param name="messenger">
19+
/// The <see cref="IMessenger"/> for exchanging messages between objects.
20+
/// </param>
21+
public PageViewModel(IMessenger messenger)
22+
{
23+
this.Messenger = messenger;
24+
}
25+
26+
/// <summary>
27+
/// Gets the <see cref="IMessenger"/> for exchanging messages between objects.
28+
/// </summary>
29+
public IMessenger Messenger { get; }
30+
31+
/// <summary>
32+
/// Called when the page has loaded.
33+
/// </summary>
34+
public virtual void OnPageLoaded()
35+
{
36+
}
37+
38+
/// <summary>
39+
/// Called when the page has been navigated from.
40+
/// </summary>
41+
/// <param name="e">
42+
/// The navigation event argument for the navigation.
43+
/// </param>
44+
public virtual void OnNavigatedFrom(NavigationEventArgs e)
45+
{
46+
}
47+
48+
/// <summary>
49+
/// Called when the page has been navigated to.
50+
/// </summary>
51+
/// <param name="e">
52+
/// The navigation event argument for the navigation.
53+
/// </param>
54+
public virtual void OnNavigatedTo(NavigationEventArgs e)
55+
{
56+
}
57+
58+
/// <summary>
59+
/// Called when the page is being navigated from.
60+
/// </summary>
61+
/// <param name="e">
62+
/// The navigation event argument for the navigation supporting the cancellation of the navigation.
63+
/// </param>
64+
public virtual void OnNavigatingFrom(NavigatingCancelEventArgs e)
65+
{
66+
}
67+
}
68+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// MADE Apps licenses this file to you under the MIT license.
2+
// See the LICENSE file in the project root for more information.
3+
4+
namespace MADE.UI.Views.Navigation
5+
{
6+
using System;
7+
using Windows.UI.Xaml.Controls;
8+
9+
/// <summary>
10+
/// Defines an interface for frame based page-to-page navigation.
11+
/// </summary>
12+
public interface INavigationService
13+
{
14+
/// <summary>
15+
/// Occurs when a page has navigated.
16+
/// </summary>
17+
event EventHandler<bool> Navigated;
18+
19+
/// <summary>
20+
/// Gets or sets the frame used for navigation.
21+
/// </summary>
22+
Frame NavigationFrame { get; set; }
23+
24+
/// <summary>
25+
/// Gets a value indicating whether there is at least one entry in back navigation history.
26+
/// </summary>
27+
bool CanGoBack { get; }
28+
29+
/// <summary>
30+
/// Gets the type associated with the current page.
31+
/// </summary>
32+
Type CurrentPageType { get; }
33+
34+
/// <summary>
35+
/// Navigates the current frame to the page specified by the given page type.
36+
/// </summary>
37+
/// <param name="pageType">
38+
/// The type associated with the page to navigate to.
39+
/// </param>
40+
/// <returns>
41+
/// Returns true if the navigation service successfully navigated to the page; otherwise, false.
42+
/// </returns>
43+
bool NavigateTo(Type pageType);
44+
45+
/// <summary>
46+
/// Navigates the current frame to the page specified by the given page type.
47+
/// </summary>
48+
/// <param name="pageType">
49+
/// The type associated with the page to navigate to.
50+
/// </param>
51+
/// <param name="parameter">
52+
/// The parameter to pass to the page on navigation.
53+
/// </param>
54+
/// <returns>
55+
/// Returns true if the navigation service successfully navigated to the page; otherwise, false.
56+
/// </returns>
57+
bool NavigateTo(Type pageType, object parameter);
58+
59+
/// <summary>
60+
/// Attempts to navigate the current frame backwards.
61+
/// </summary>
62+
/// <returns>
63+
/// Returns true if the navigation service successfully navigates backwards; otherwise, false.
64+
/// </returns>
65+
bool GoBack();
66+
}
67+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<Project Sdk="MSBuild.Sdk.Extras">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>uap10.0.17763;MonoAndroid10.0;xamarinios10;netstandard2.0;xamarinmac20</TargetFrameworks>
5+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
6+
<Product>MADE.NET UI View Navigation</Product>
7+
<Description>
8+
This package includes enhancements to build page to page navigation for Windows and Uno Platform such as:
9+
- Page, an extension to the app Page type to improve the page experience
10+
- NavigationService providing an easy to use, MVVM friendly, page-to-page navigation service
11+
</Description>
12+
<PackageTags>MADE UI View Page Navigation Windows Android iOS macOS Xamarin Uno</PackageTags>
13+
<GenerateLibraryLayout>true</GenerateLibraryLayout>
14+
</PropertyGroup>
15+
16+
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == 'MonoAndroid' or '$(TargetFrameworkIdentifier)' == 'Xamarin.iOS' or '$(TargetFrameworkIdentifier)' == '.NETStandard' or '$(TargetFrameworkIdentifier)' == 'Xamarin.Mac'">
17+
<PackageReference Include="Uno.UI" Version="3.9.7" />
18+
</ItemGroup>
19+
20+
<ItemGroup>
21+
<Page Include="**\*.xaml" Exclude="bin\**\*.xaml;obj\**\*.xaml">
22+
<SubType>Designer</SubType>
23+
<Generator>MSBuild:Compile</Generator>
24+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
25+
</Page>
26+
</ItemGroup>
27+
28+
<ItemGroup>
29+
<ProjectReference Include="..\MADE.UI\MADE.UI.csproj" />
30+
</ItemGroup>
31+
32+
</Project>

0 commit comments

Comments
 (0)