Skip to content

Commit 1bf4f88

Browse files
authored
Merge pull request #84 from egvijayanand/working
UnifiedDateCalculator solution updated to .NET 8
2 parents 0df27fd + fbd2d65 commit 1bf4f88

File tree

148 files changed

+536
-296
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+536
-296
lines changed

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ Made available in the `src\NET_8\` directory:
2020
- WinForms project to illustrate the reuse of ViewModels across non-XAML UI framework too
2121
- Shared business logic as a separate library project
2222
- ViewModels implemented with [CommunityToolkit.Mvvm](https://www.nuget.org/packages/CommunityToolkit.Mvvm) NuGet package
23+
* `UnifiedDateCalculator`
24+
- Shared class library sample
25+
- UI, ViewModel, Model, and Business logic all from shared project
26+
- Head projects serve as an app container
27+
- Both Xamarin.Forms and .NET MAUI from a single project - `DateCalculator.UI`
2328

2429
Made available in the `src\NET_9\` directory:
2530
* `EmbeddedWindows` - .NET MAUI Page embedded in a Native WinUI 3 App, targeting .NET 9 (`net9.0-windows10.0.19041.0`)
@@ -36,11 +41,6 @@ Made available in the the `src\` directory:
3641
- State sharing between .NET MAUI and Razor Components
3742
- Components from shared Razor Class Library (RCL)
3843
* `MauiAppCS` - .NET MAUI C# Markup based Sample
39-
* `UnifiedDateCalculator`
40-
- Shared class library sample
41-
- UI, ViewModel, Model, and Business logic all from shared project
42-
- Head projects serve as an app container
43-
- Both Xamarin.Forms and .NET MAUI from a single project - `DateCalculator.UI`
4444
* `EmbeddedAndroid` - .NET MAUI Page embedded in a Native Android App, targeting .NET 6 (`net6.0-android`)
4545
* `MediaElement` - Sample project in both .NET 6 and 7. Now made available in Preview bits as part of the .NET MAUI CommunityToolkit - And it'll be a separate NuGet package titled `CommunityToolkit.Maui.MediaElement`
4646
* `MauiHotReload` - Sample project to demonstrate **C# Hot Reload** feature supported via [MetadataUpdateHandler](https://learn.microsoft.com/en-us/dotnet/api/system.reflection.metadata.metadataupdatehandlerattribute?view=net-6.0) (refer to HotReloadService.cs). Core logic is abstracted into a base page named `MauiPage`, inherit the content pages from it and implement the UI logic in the override of the abstract `Build()` method. Source is available in the `src\MauiHotReload` folder.
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454
<Reference Include="System.Numerics.Vectors" />
5555
</ItemGroup>
5656
<ItemGroup>
57-
<PackageReference Include="Xamarin.Forms" Version="[5.0.0.2401]" />
58-
<PackageReference Include="Xamarin.Essentials" Version="1.7.3" />
57+
<PackageReference Include="Xamarin.Forms" Version="5.*" />
58+
<PackageReference Include="Xamarin.Essentials" Version="1.*" />
5959
</ItemGroup>
6060
<ItemGroup>
6161
<Compile Include="MainActivity.cs" />
@@ -93,4 +93,4 @@
9393
</ProjectReference>
9494
</ItemGroup>
9595
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
96-
</Project>
96+
</Project>

src/UnifiedDateCalculator/UnifiedDateCalculator/DateCalculator.Forms/App.xaml.cs renamed to src/NET_8/UnifiedDateCalculator/DateCalculator.Forms/App.xaml.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using DateCalculator.UI.Services;
2-
using DateCalculator.UI.Views;
32
using Xamarin.Forms;
43

54
namespace DateCalculator.Forms
@@ -10,7 +9,7 @@ public App()
109
{
1110
InitializeComponent();
1211
BindableProperties.Register();
13-
MainPage = new DatePage();
12+
MainPage = new AppShell();
1413
}
1514

1615
protected override void OnStart()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<Shell
3+
x:Class="DateCalculator.Forms.AppShell"
4+
xmlns="http://xamarin.com/schemas/2014/forms"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
6+
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
7+
xmlns:local="clr-namespace:DateCalculator.Forms"
8+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9+
xmlns:vw="clr-namespace:DateCalculator.UI.Views;assembly=DateCalculator.UI"
10+
FlyoutBehavior="Disabled"
11+
mc:Ignorable="d">
12+
<!--
13+
The overall app visual hierarchy is defined here, along with navigation.
14+
Ensure atleast a Flyout item or a TabBar is defined for Shell to work
15+
-->
16+
<Shell.Resources />
17+
<!--
18+
When the Flyout is visible this defines the content to display in the flyout.
19+
FlyoutDisplayOptions="AsMultipleItems" will create a separate flyout item for each child element
20+
-->
21+
<!--
22+
Uncomment the below section to enable Shell Flyout item(s)
23+
And ensure appropriate page definitions are available for it work as expected
24+
-->
25+
<FlyoutItem Title="Date Calculation">
26+
<ShellContent
27+
ContentTemplate="{DataTemplate vw:DatePage}"
28+
Route="date-calc" />
29+
</FlyoutItem>
30+
<!--
31+
<FlyoutItem Title="Search">
32+
<ShellContent ContentTemplate="{DataTemplate local:SearchPage}" Route="search" />
33+
</FlyoutItem>
34+
-->
35+
<!--
36+
When the Flyout is visible this will be a menu item you can tie a click behavior to
37+
-->
38+
<!--
39+
Uncomment the below section to enable Menu item(s)
40+
And ensure appropriate page definitions are available for it work as expected
41+
-->
42+
<!--
43+
<MenuItem Clicked="OnMenuItemClicked" Text="Logout" />
44+
-->
45+
<!--
46+
TabBar lets you define content that won't show up in a Flyout menu. When this content is active
47+
the flyout menu won't be available. This is useful for creating areas of the application where
48+
you don't want users to be able to navigate away from. If you would like to navigate to this
49+
content you can do so by calling
50+
await Shell.Current.GoToAsync("//login");
51+
-->
52+
<!--
53+
Uncomment the below section to enable TabBar item(s)
54+
And ensure appropriate page definitions are available for it work as expected
55+
-->
56+
<!--
57+
<TabBar>
58+
<ShellContent ContentTemplate="{DataTemplate local:LoginPage}" Route="login" />
59+
</TabBar>
60+
-->
61+
<!-- Optional Templates
62+
// These may be provided inline as below or as separate classes.
63+
64+
// This header appears at the top of the Flyout
65+
<Shell.FlyoutHeaderTemplate>
66+
<DataTemplate>
67+
<Grid>ContentHere</Grid>
68+
</DataTemplate>
69+
</Shell.FlyoutHeaderTemplate>
70+
71+
// ItemTemplate is for ShellItems as displayed in a Flyout
72+
<Shell.ItemTemplate>
73+
<DataTemplate>
74+
<ContentView>
75+
Bindable Properties: Title, Icon
76+
</ContentView>
77+
</DataTemplate>
78+
</Shell.ItemTemplate>
79+
80+
// MenuItemTemplate is for MenuItems as displayed in a Flyout
81+
<Shell.MenuItemTemplate>
82+
<DataTemplate>
83+
<ContentView>
84+
Bindable Properties: Text, Icon
85+
</ContentView>
86+
</DataTemplate>
87+
</Shell.MenuItemTemplate>
88+
89+
// This footer appears at the bottom of the Flyout
90+
<Shell.FlyoutFooterTemplate>
91+
<DataTemplate>
92+
<Grid>ContentHere</Grid>
93+
</DataTemplate>
94+
</Shell.FlyoutFooterTemplate>
95+
-->
96+
</Shell>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Xamarin.Forms;
2+
using Xamarin.Forms.Xaml;
3+
4+
namespace DateCalculator.Forms
5+
{
6+
[XamlCompilation(XamlCompilationOptions.Compile)]
7+
public partial class AppShell : Shell
8+
{
9+
public AppShell()
10+
{
11+
InitializeComponent();
12+
}
13+
14+
// UnComment the below method to handle Shell Menu item click event
15+
// And ensure appropriate page definitions are available for it work as expected
16+
//private async void OnMenuItemClicked(object sender, EventArgs e)
17+
//{
18+
// await Current.GoToAsync("//login");
19+
//}
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
<RootNamespace>DateCalculator.Forms</RootNamespace>
6+
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
7+
</PropertyGroup>
8+
9+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
10+
<DebugType>portable</DebugType>
11+
<DebugSymbols>true</DebugSymbols>
12+
</PropertyGroup>
13+
14+
<ItemGroup>
15+
<EmbeddedResource Include="Resources\Fonts\OpenSans-Regular.ttf" />
16+
<EmbeddedResource Include="Resources\Fonts\OpenSans-SemiBold.ttf" />
17+
</ItemGroup>
18+
19+
<ItemGroup>
20+
<PackageReference Include="Xamarin.Forms" Version="5.*" />
21+
</ItemGroup>
22+
23+
<ItemGroup>
24+
<ProjectReference Include="..\DateCalculator.UI\DateCalculator.UI.csproj" />
25+
</ItemGroup>
26+
27+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using DateCalculator.UI.Services;
2+
3+
namespace DateCalculator.Maui
4+
{
5+
public partial class App : Application
6+
{
7+
public App()
8+
{
9+
InitializeComponent();
10+
BindableProperties.Register();
11+
MainPage = new AppShell();
12+
}
13+
14+
protected override Window CreateWindow(IActivationState? activationState)
15+
{
16+
var window = base.CreateWindow(activationState);
17+
window.Title = "Date Calculator";
18+
return window;
19+
}
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<Shell
3+
x:Class="DateCalculator.Maui.AppShell"
4+
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
6+
xmlns:d="http://schemas.microsoft.com/dotnet/2021/maui/design"
7+
xmlns:local="clr-namespace:DateCalculator.Maui"
8+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9+
xmlns:vw="clr-namespace:DateCalculator.UI.Views;assembly=DateCalculator.UI"
10+
FlyoutBehavior="Disabled"
11+
mc:Ignorable="d">
12+
<!--
13+
The overall app visual hierarchy is defined here, along with navigation.
14+
Ensure atleast a Flyout item or a TabBar is defined for Shell to work
15+
-->
16+
<Shell.Resources />
17+
<!--
18+
When the Flyout is visible this defines the content to display in the flyout.
19+
FlyoutDisplayOptions="AsMultipleItems" will create a separate flyout item for each child element
20+
-->
21+
<!--
22+
Uncomment the below section to enable Shell Flyout item(s)
23+
And ensure appropriate page definitions are available for it work as expected
24+
-->
25+
<FlyoutItem Title="Date Calculation">
26+
<ShellContent
27+
ContentTemplate="{DataTemplate vw:DatePage}"
28+
Route="date-calc" />
29+
</FlyoutItem>
30+
<!--
31+
<FlyoutItem Title="Search">
32+
<ShellContent
33+
ContentTemplate="{DataTemplate local:SearchPage}"
34+
Route="search" />
35+
</FlyoutItem>
36+
-->
37+
<!--
38+
When the Flyout is visible this will be a menu item you can tie a click behavior to
39+
-->
40+
<!--
41+
Uncomment the below section to enable Menu item(s)
42+
And ensure appropriate page definitions are available for it work as expected
43+
-->
44+
<!--
45+
<MenuItem
46+
Clicked="OnMenuItemClicked"
47+
Text="Logout" />
48+
-->
49+
<!--
50+
TabBar lets you define content that won't show up in a Flyout menu. When this content is active
51+
the flyout menu won't be available. This is useful for creating areas of the application where
52+
you don't want users to be able to navigate away from. If you would like to navigate to this
53+
content you can do so by calling
54+
await Shell.Current.GoToAsync("//login");
55+
-->
56+
<!--
57+
Uncomment the below section to enable TabBar item(s)
58+
And ensure appropriate page definitions are available for it work as expected
59+
-->
60+
<!--
61+
<TabBar>
62+
<ShellContent
63+
ContentTemplate="{DataTemplate local:LoginPage}"
64+
Route="login" />
65+
</TabBar>
66+
-->
67+
<!-- Optional Templates
68+
// These may be provided inline as below or as separate classes.
69+
70+
// This header appears at the top of the Flyout
71+
<Shell.FlyoutHeaderTemplate>
72+
<DataTemplate>
73+
<Grid>ContentHere</Grid>
74+
</DataTemplate>
75+
</Shell.FlyoutHeaderTemplate>
76+
77+
// ItemTemplate is for ShellItems as displayed in a Flyout
78+
<Shell.ItemTemplate>
79+
<DataTemplate>
80+
<ContentView>
81+
Bindable Properties: Title, Icon
82+
</ContentView>
83+
</DataTemplate>
84+
</Shell.ItemTemplate>
85+
86+
// MenuItemTemplate is for MenuItems as displayed in a Flyout
87+
<Shell.MenuItemTemplate>
88+
<DataTemplate>
89+
<ContentView>
90+
Bindable Properties: Text, Icon
91+
</ContentView>
92+
</DataTemplate>
93+
</Shell.MenuItemTemplate>
94+
95+
// This footer appears at the bottom of the Flyout
96+
<Shell.FlyoutFooterTemplate>
97+
<DataTemplate>
98+
<Grid>ContentHere</Grid>
99+
</DataTemplate>
100+
</Shell.FlyoutFooterTemplate>
101+
-->
102+
</Shell>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace DateCalculator.Maui
2+
{
3+
public partial class AppShell : Shell
4+
{
5+
public AppShell()
6+
{
7+
InitializeComponent();
8+
}
9+
10+
// UnComment the below method to handle Shell Menu item click event
11+
// And ensure appropriate page definitions are available for it work as expected
12+
//private async void OnMenuItemClicked(object sender, EventArgs e)
13+
//{
14+
// await Current.GoToAsync("//login");
15+
//}
16+
}
17+
}

0 commit comments

Comments
 (0)