Skip to content

Commit 4b2bfa7

Browse files
authored
Merge pull request #607 from dotnet/whattoeat
Added sample WhatToEat App
2 parents 321ac7a + efb67c2 commit 4b2bfa7

File tree

168 files changed

+5956
-0
lines changed

Some content is hidden

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

168 files changed

+5956
-0
lines changed

10.0/Apps/WhatToEat/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) Microsoft Corporation.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE

10.0/Apps/WhatToEat/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
name: .NET MAUI - WhatToEat
3+
description: Weather '21 application that demonstrates how to effectively use Shell for intuitive navigation and seamless app structuring.
4+
page_type: sample
5+
languages:
6+
- csharp
7+
- xaml
8+
products:
9+
- dotnet-maui
10+
urlFragment: apps-whattoeat
11+
---
12+
13+
# WhatToEat
14+
15+
This is a [.NET MAUI](https://github.com/dotnet/maui) app showcasing how to effectively use Shell for intuitive navigation and seamless app structuring. It showcases key features, including navigation patterns and route management, to help developers build robust and user-friendly applications.
16+
17+
![.NET MAUI WhatToEat App on all platforms](images/screen_search_recipes.png)
18+
19+
## Additional Resources
20+
21+
https://docs.microsoft.com/dotnet/maui
22+
23+
https://github.com/dotnet/maui
102 KB
Loading
Loading
Loading
Loading
Loading
Loading
Loading
153 KB
Loading

10.0/Apps/WhatToEat/src/WhatToEat.sln

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
Microsoft Visual Studio Solution File, Format Version 12.00
2+
# Visual Studio Version 17
3+
VisualStudioVersion = 17.0.31602.29
4+
MinimumVisualStudioVersion = 10.0.40219.1
5+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WhatToEat", "WhatToEat\WhatToEat.csproj", "{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}"
6+
EndProject
7+
Global
8+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
9+
Debug|Any CPU = Debug|Any CPU
10+
Debug|ARM = Debug|ARM
11+
Debug|ARM64 = Debug|ARM64
12+
Debug|iPhone = Debug|iPhone
13+
Debug|iPhoneSimulator = Debug|iPhoneSimulator
14+
Debug|x64 = Debug|x64
15+
Debug|x86 = Debug|x86
16+
Release|Any CPU = Release|Any CPU
17+
Release|ARM = Release|ARM
18+
Release|ARM64 = Release|ARM64
19+
Release|iPhone = Release|iPhone
20+
Release|iPhoneSimulator = Release|iPhoneSimulator
21+
Release|x64 = Release|x64
22+
Release|x86 = Release|x86
23+
EndGlobalSection
24+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
25+
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26+
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Debug|Any CPU.Build.0 = Debug|Any CPU
27+
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
28+
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Debug|ARM.ActiveCfg = Debug|Any CPU
29+
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Debug|ARM.Build.0 = Debug|Any CPU
30+
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Debug|ARM64.ActiveCfg = Debug|Any CPU
31+
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Debug|ARM64.Build.0 = Debug|Any CPU
32+
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Debug|iPhone.ActiveCfg = Debug|Any CPU
33+
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Debug|iPhone.Build.0 = Debug|Any CPU
34+
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
35+
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
36+
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Debug|x64.ActiveCfg = Debug|Any CPU
37+
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Debug|x64.Build.0 = Debug|Any CPU
38+
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Debug|x86.ActiveCfg = Debug|Any CPU
39+
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Debug|x86.Build.0 = Debug|Any CPU
40+
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Debug|x86.Deploy.0 = Debug|Any CPU
41+
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Release|Any CPU.ActiveCfg = Release|Any CPU
42+
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Release|Any CPU.Build.0 = Release|Any CPU
43+
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Release|Any CPU.Deploy.0 = Release|Any CPU
44+
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Release|ARM.ActiveCfg = Release|Any CPU
45+
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Release|ARM.Build.0 = Release|Any CPU
46+
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Release|ARM64.ActiveCfg = Release|Any CPU
47+
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Release|ARM64.Build.0 = Release|Any CPU
48+
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Release|iPhone.ActiveCfg = Release|Any CPU
49+
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Release|iPhone.Build.0 = Release|Any CPU
50+
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
51+
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
52+
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Release|x64.ActiveCfg = Release|Any CPU
53+
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Release|x64.Build.0 = Release|Any CPU
54+
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Release|x86.ActiveCfg = Release|Any CPU
55+
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Release|x86.Build.0 = Release|Any CPU
56+
EndGlobalSection
57+
GlobalSection(SolutionProperties) = preSolution
58+
HideSolutionNode = FALSE
59+
EndGlobalSection
60+
GlobalSection(ExtensibilityGlobals) = postSolution
61+
SolutionGuid = {0CFA77A0-D78C-48CB-884F-4627FC7138FF}
62+
EndGlobalSection
63+
EndGlobal
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
x:Class="Recipes.App"
5+
xmlns:windows="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific;assembly=Microsoft.Maui.Controls"
6+
windows:Application.ImageDirectory="Assets">
7+
<!--
8+
Define global resources and styles here, that apply to all pages in your app.
9+
-->
10+
<Application.Resources>
11+
<ResourceDictionary>
12+
<Color x:Key="Primary">#176515</Color>
13+
<Color x:Key="Secondary">#90b28d</Color>
14+
15+
<Style TargetType="Button">
16+
<Setter Property="MinimumHeightRequest" Value="44"></Setter>
17+
<Setter Property="MinimumWidthRequest" Value="44"></Setter>
18+
</Style>
19+
<Style TargetType="Button" x:Key="DefaultButtonStyle">
20+
<Setter Property="FontSize" Value="16"/>
21+
<Setter Property="TextColor" Value="{AppThemeBinding Dark={StaticResource Primary}, Light=White}"/>
22+
<Setter Property="BackgroundColor" Value="{AppThemeBinding Dark=White, Light={StaticResource Primary}}"/>
23+
</Style>
24+
<Style TargetType="Button" x:Key="RecipeCategoryButtonStyle" BasedOn="{StaticResource DefaultButtonStyle}">
25+
<Setter Property="TextColor" Value="{AppThemeBinding Dark=White, Light={StaticResource Primary}}"/>
26+
<Setter Property="BackgroundColor" Value="{AppThemeBinding Dark=#2A2A2A, Light=#F7F7F7}"/>
27+
<Setter Property="ContentLayout" Value="Top,0"/>
28+
<Setter Property="FontAttributes" Value="Bold"/>
29+
<Setter Property="Padding" Value="5,15"/>
30+
<Setter Property="FontSize" Value="24"></Setter>
31+
<Setter Property="MinimumWidthRequest" Value="150"></Setter>
32+
<Setter Property="MinimumHeightRequest" Value="{OnPlatform Android=150, Default=-1}"></Setter>
33+
</Style>
34+
35+
<Style TargetType="Label">
36+
<Setter Property="TextColor" Value="{AppThemeBinding Dark=White, Light=Black}"/>
37+
</Style>
38+
<Style TargetType="Label" x:Key="RecipeNameStyle">
39+
<Setter Property="TextColor" Value="{AppThemeBinding Dark=White, Light=Black}"/>
40+
<Setter Property="BackgroundColor" Value="{AppThemeBinding Dark=Black, Light=White}"/>
41+
<Setter Property="FontAttributes" Value="Bold"/>
42+
</Style>
43+
<Style TargetType="Label" x:Key="RecipeItemLabelStyle">
44+
<Setter Property="TextColor" Value="{AppThemeBinding Dark=White, Light={StaticResource Primary}}"/>
45+
<Setter Property="FontSize" Value="16"/>
46+
</Style>
47+
48+
<Style TargetType="SearchBar">
49+
<Setter Property="TextColor" Value="{AppThemeBinding Dark=White, Light=Black}"/>
50+
<Setter Property="BackgroundColor" Value="{AppThemeBinding Dark=Black, Light=White}"></Setter>
51+
<Setter Property="PlaceholderColor" Value="{AppThemeBinding Dark=LightGray, Light={StaticResource Primary}}"></Setter>
52+
<Setter Property="CancelButtonColor" Value="{AppThemeBinding Dark=LightGray, Light={StaticResource Primary}}"></Setter>
53+
<Setter Property="MinimumHeightRequest" Value="44"></Setter>
54+
</Style>
55+
<Style TargetType="Entry">
56+
<Setter Property="MinimumHeightRequest" Value="44"></Setter>
57+
</Style>
58+
<Style TargetType="Editor">
59+
<Setter Property="MinimumHeightRequest" Value="44"></Setter>
60+
</Style>
61+
<Style TargetType="CheckBox">
62+
<Setter Property="MinimumHeightRequest" Value="44"></Setter>
63+
</Style>
64+
<Style TargetType="RadioButton">
65+
<Setter Property="MinimumHeightRequest" Value="44"></Setter>
66+
</Style>
67+
</ResourceDictionary>
68+
</Application.Resources>
69+
</Application>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using Recipes.Services;
2+
3+
namespace Recipes;
4+
5+
public partial class App : Microsoft.Maui.Controls.Application
6+
{
7+
8+
public App()
9+
{
10+
InitializeComponent();
11+
DependencyService.Register<MockDataStore>();
12+
MainPage = new AppShell();
13+
}
14+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Shell xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:local="clr-namespace:Recipes.Views"
5+
xmlns:sharedTransitions="clr-namespace:Plugin.SharedTransitions;assembly=Plugin.SharedTransitions"
6+
Title="WhatToEat"
7+
x:Class="Recipes.AppShell">
8+
<!--
9+
The overall app visual hierarchy is defined here, along with navigation.
10+
11+
https://docs.microsoft.com/xamarin/xamarin-forms/app-fundamentals/shell/
12+
13+
Need to Review if NavBarHasShadow=true is also weird on iOS
14+
-->
15+
<Shell.Resources>
16+
<ResourceDictionary>
17+
<Style x:Key="BaseStyle" TargetType="Element">
18+
<Setter Property="Shell.BackgroundColor" Value="{AppThemeBinding Dark=Black, Light=White}" />
19+
<Setter Property="Shell.ForegroundColor" Value="{AppThemeBinding Dark=White, Light={StaticResource Primary}}" />
20+
<Setter Property="Shell.TitleColor" Value="{AppThemeBinding Dark=White, Light={StaticResource Primary}}" />
21+
<Setter Property="Shell.DisabledColor" Value="{AppThemeBinding Dark=DarkGray, Light=LightGray}" />
22+
<Setter Property="Shell.UnselectedColor" Value="{AppThemeBinding Dark=LightGray, Light=#587656}" />
23+
<Setter Property="Shell.TabBarBackgroundColor" Value="{AppThemeBinding Dark=Black, Light=White}" />
24+
<Setter Property="Shell.TabBarForegroundColor" Value="{AppThemeBinding Dark=White, Light={StaticResource Primary}}" />
25+
<Setter Property="Shell.TabBarTitleColor" Value="{AppThemeBinding Dark=White, Light={StaticResource Primary}}" />
26+
<Setter Property="Shell.TabBarUnselectedColor" Value="{AppThemeBinding Dark=LightGray, Light=#587656}" />
27+
</Style>
28+
<Style TargetType="TabBar" BasedOn="{StaticResource BaseStyle}" />
29+
<Style TargetType="FlyoutItem" BasedOn="{StaticResource BaseStyle}" />
30+
</ResourceDictionary>
31+
</Shell.Resources>
32+
<TabBar>
33+
<ShellContent Title="Recipe Search" Icon="search.png" Route="StartingPage" ContentTemplate="{DataTemplate local:StartingPage}" />
34+
<ShellContent Title="My Recipes" Icon="cookbook.png" Route="MyRecipesPage" ContentTemplate="{DataTemplate local:MyRecipesPage}" />
35+
</TabBar>
36+
</Shell>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using Recipes.Models;
2+
using Recipes.Views;
3+
4+
namespace Recipes;
5+
6+
public partial class AppShell : Shell
7+
{
8+
public AppShell()
9+
{
10+
InitializeComponent();
11+
Routing.RegisterRoute(nameof(SearchResultsPage), typeof(SearchResultsPage));
12+
Routing.RegisterRoute(nameof(SearchResultDetailPage), typeof(SearchResultDetailPage));
13+
Routing.RegisterRoute(nameof(RecipeDetailPage), typeof(RecipeDetailPage));
14+
Routing.RegisterRoute(nameof(NewRecipePage), typeof(NewRecipePage));
15+
Routing.RegisterRoute(nameof(EditRecipePage), typeof(EditRecipePage));
16+
}
17+
18+
public static RecipeData Data { get; set; }
19+
20+
public static Item[] MyRecipes { get; set; }
21+
22+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
using Microsoft.Maui.Controls.Xaml;
2+
3+
[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
namespace Recipes
2+
{
3+
public class MauiProgram
4+
{
5+
public static MauiApp CreateMauiApp()
6+
{
7+
var builder = MauiApp.CreateBuilder();
8+
builder
9+
.UseMauiApp<App>()
10+
.ConfigureMauiHandlers(_ =>
11+
{
12+
Microsoft.Maui.Controls.Handlers.Items.CollectionViewHandler.Mapper.AppendToMapping("KeyboardAccessibleCollectionView", (handler, view) =>
13+
{
14+
#if WINDOWS
15+
handler.PlatformView.SingleSelectionFollowsFocus = false;
16+
#endif
17+
});
18+
});
19+
20+
return builder.Build();
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)