Skip to content

Added sample WhatToEat App #607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions 10.0/Apps/WhatToEat/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) Microsoft Corporation.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE
23 changes: 23 additions & 0 deletions 10.0/Apps/WhatToEat/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: .NET MAUI - WhatToEat
description: Weather '21 application that demonstrates how to effectively use Shell for intuitive navigation and seamless app structuring.
page_type: sample
languages:
- csharp
- xaml
products:
- dotnet-maui
urlFragment: apps-whattoeat
---

# WhatToEat

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.

![.NET MAUI WhatToEat App on all platforms](images/screen_search_recipes.png)

## Additional Resources

https://docs.microsoft.com/dotnet/maui

https://github.com/dotnet/maui
Binary file added 10.0/Apps/WhatToEat/images/app_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 10.0/Apps/WhatToEat/images/screen_starting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 63 additions & 0 deletions 10.0/Apps/WhatToEat/src/WhatToEat.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31602.29
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WhatToEat", "WhatToEat\WhatToEat.csproj", "{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|ARM64 = Debug|ARM64
Debug|iPhone = Debug|iPhone
Debug|iPhoneSimulator = Debug|iPhoneSimulator
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM = Release|ARM
Release|ARM64 = Release|ARM64
Release|iPhone = Release|iPhone
Release|iPhoneSimulator = Release|iPhoneSimulator
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Debug|ARM.ActiveCfg = Debug|Any CPU
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Debug|ARM.Build.0 = Debug|Any CPU
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Debug|ARM64.Build.0 = Debug|Any CPU
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Debug|iPhone.Build.0 = Debug|Any CPU
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Debug|x64.ActiveCfg = Debug|Any CPU
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Debug|x64.Build.0 = Debug|Any CPU
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Debug|x86.ActiveCfg = Debug|Any CPU
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Debug|x86.Build.0 = Debug|Any CPU
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Debug|x86.Deploy.0 = Debug|Any CPU
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Release|Any CPU.Build.0 = Release|Any CPU
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Release|Any CPU.Deploy.0 = Release|Any CPU
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Release|ARM.ActiveCfg = Release|Any CPU
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Release|ARM.Build.0 = Release|Any CPU
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Release|ARM64.ActiveCfg = Release|Any CPU
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Release|ARM64.Build.0 = Release|Any CPU
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Release|iPhone.ActiveCfg = Release|Any CPU
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Release|iPhone.Build.0 = Release|Any CPU
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Release|x64.ActiveCfg = Release|Any CPU
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Release|x64.Build.0 = Release|Any CPU
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Release|x86.ActiveCfg = Release|Any CPU
{A2021E63-BCCF-411E-B0AE-DF2EABB8EB34}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0CFA77A0-D78C-48CB-884F-4627FC7138FF}
EndGlobalSection
EndGlobal
69 changes: 69 additions & 0 deletions 10.0/Apps/WhatToEat/src/WhatToEat/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Recipes.App"
xmlns:windows="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific;assembly=Microsoft.Maui.Controls"
windows:Application.ImageDirectory="Assets">
<!--
Define global resources and styles here, that apply to all pages in your app.
-->
<Application.Resources>
<ResourceDictionary>
<Color x:Key="Primary">#176515</Color>
<Color x:Key="Secondary">#90b28d</Color>

<Style TargetType="Button">
<Setter Property="MinimumHeightRequest" Value="44"></Setter>
<Setter Property="MinimumWidthRequest" Value="44"></Setter>
</Style>
<Style TargetType="Button" x:Key="DefaultButtonStyle">
<Setter Property="FontSize" Value="16"/>
<Setter Property="TextColor" Value="{AppThemeBinding Dark={StaticResource Primary}, Light=White}"/>
<Setter Property="BackgroundColor" Value="{AppThemeBinding Dark=White, Light={StaticResource Primary}}"/>
</Style>
<Style TargetType="Button" x:Key="RecipeCategoryButtonStyle" BasedOn="{StaticResource DefaultButtonStyle}">
<Setter Property="TextColor" Value="{AppThemeBinding Dark=White, Light={StaticResource Primary}}"/>
<Setter Property="BackgroundColor" Value="{AppThemeBinding Dark=#2A2A2A, Light=#F7F7F7}"/>
<Setter Property="ContentLayout" Value="Top,0"/>
<Setter Property="FontAttributes" Value="Bold"/>
<Setter Property="Padding" Value="5,15"/>
<Setter Property="FontSize" Value="24"></Setter>
<Setter Property="MinimumWidthRequest" Value="150"></Setter>
<Setter Property="MinimumHeightRequest" Value="{OnPlatform Android=150, Default=-1}"></Setter>
</Style>

<Style TargetType="Label">
<Setter Property="TextColor" Value="{AppThemeBinding Dark=White, Light=Black}"/>
</Style>
<Style TargetType="Label" x:Key="RecipeNameStyle">
<Setter Property="TextColor" Value="{AppThemeBinding Dark=White, Light=Black}"/>
<Setter Property="BackgroundColor" Value="{AppThemeBinding Dark=Black, Light=White}"/>
<Setter Property="FontAttributes" Value="Bold"/>
</Style>
<Style TargetType="Label" x:Key="RecipeItemLabelStyle">
<Setter Property="TextColor" Value="{AppThemeBinding Dark=White, Light={StaticResource Primary}}"/>
<Setter Property="FontSize" Value="16"/>
</Style>

<Style TargetType="SearchBar">
<Setter Property="TextColor" Value="{AppThemeBinding Dark=White, Light=Black}"/>
<Setter Property="BackgroundColor" Value="{AppThemeBinding Dark=Black, Light=White}"></Setter>
<Setter Property="PlaceholderColor" Value="{AppThemeBinding Dark=LightGray, Light={StaticResource Primary}}"></Setter>
<Setter Property="CancelButtonColor" Value="{AppThemeBinding Dark=LightGray, Light={StaticResource Primary}}"></Setter>
<Setter Property="MinimumHeightRequest" Value="44"></Setter>
</Style>
<Style TargetType="Entry">
<Setter Property="MinimumHeightRequest" Value="44"></Setter>
</Style>
<Style TargetType="Editor">
<Setter Property="MinimumHeightRequest" Value="44"></Setter>
</Style>
<Style TargetType="CheckBox">
<Setter Property="MinimumHeightRequest" Value="44"></Setter>
</Style>
<Style TargetType="RadioButton">
<Setter Property="MinimumHeightRequest" Value="44"></Setter>
</Style>
</ResourceDictionary>
</Application.Resources>
</Application>
14 changes: 14 additions & 0 deletions 10.0/Apps/WhatToEat/src/WhatToEat/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Recipes.Services;

namespace Recipes;

public partial class App : Microsoft.Maui.Controls.Application
{

public App()
{
InitializeComponent();
DependencyService.Register<MockDataStore>();
MainPage = new AppShell();
}
}
36 changes: 36 additions & 0 deletions 10.0/Apps/WhatToEat/src/WhatToEat/AppShell.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<Shell xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Recipes.Views"
xmlns:sharedTransitions="clr-namespace:Plugin.SharedTransitions;assembly=Plugin.SharedTransitions"
Title="WhatToEat"
x:Class="Recipes.AppShell">
<!--
The overall app visual hierarchy is defined here, along with navigation.

https://docs.microsoft.com/xamarin/xamarin-forms/app-fundamentals/shell/

Need to Review if NavBarHasShadow=true is also weird on iOS
-->
<Shell.Resources>
<ResourceDictionary>
<Style x:Key="BaseStyle" TargetType="Element">
<Setter Property="Shell.BackgroundColor" Value="{AppThemeBinding Dark=Black, Light=White}" />
<Setter Property="Shell.ForegroundColor" Value="{AppThemeBinding Dark=White, Light={StaticResource Primary}}" />
<Setter Property="Shell.TitleColor" Value="{AppThemeBinding Dark=White, Light={StaticResource Primary}}" />
<Setter Property="Shell.DisabledColor" Value="{AppThemeBinding Dark=DarkGray, Light=LightGray}" />
<Setter Property="Shell.UnselectedColor" Value="{AppThemeBinding Dark=LightGray, Light=#587656}" />
<Setter Property="Shell.TabBarBackgroundColor" Value="{AppThemeBinding Dark=Black, Light=White}" />
<Setter Property="Shell.TabBarForegroundColor" Value="{AppThemeBinding Dark=White, Light={StaticResource Primary}}" />
<Setter Property="Shell.TabBarTitleColor" Value="{AppThemeBinding Dark=White, Light={StaticResource Primary}}" />
<Setter Property="Shell.TabBarUnselectedColor" Value="{AppThemeBinding Dark=LightGray, Light=#587656}" />
</Style>
<Style TargetType="TabBar" BasedOn="{StaticResource BaseStyle}" />
<Style TargetType="FlyoutItem" BasedOn="{StaticResource BaseStyle}" />
</ResourceDictionary>
</Shell.Resources>
<TabBar>
<ShellContent Title="Recipe Search" Icon="search.png" Route="StartingPage" ContentTemplate="{DataTemplate local:StartingPage}" />
<ShellContent Title="My Recipes" Icon="cookbook.png" Route="MyRecipesPage" ContentTemplate="{DataTemplate local:MyRecipesPage}" />
</TabBar>
</Shell>
22 changes: 22 additions & 0 deletions 10.0/Apps/WhatToEat/src/WhatToEat/AppShell.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Recipes.Models;
using Recipes.Views;

namespace Recipes;

public partial class AppShell : Shell
{
public AppShell()
{
InitializeComponent();
Routing.RegisterRoute(nameof(SearchResultsPage), typeof(SearchResultsPage));
Routing.RegisterRoute(nameof(SearchResultDetailPage), typeof(SearchResultDetailPage));
Routing.RegisterRoute(nameof(RecipeDetailPage), typeof(RecipeDetailPage));
Routing.RegisterRoute(nameof(NewRecipePage), typeof(NewRecipePage));
Routing.RegisterRoute(nameof(EditRecipePage), typeof(EditRecipePage));
}

public static RecipeData Data { get; set; }

public static Item[] MyRecipes { get; set; }

}
3 changes: 3 additions & 0 deletions 10.0/Apps/WhatToEat/src/WhatToEat/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using Microsoft.Maui.Controls.Xaml;

[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
23 changes: 23 additions & 0 deletions 10.0/Apps/WhatToEat/src/WhatToEat/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace Recipes
{
public class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureMauiHandlers(_ =>
{
Microsoft.Maui.Controls.Handlers.Items.CollectionViewHandler.Mapper.AppendToMapping("KeyboardAccessibleCollectionView", (handler, view) =>
{
#if WINDOWS
handler.PlatformView.SingleSelectionFollowsFocus = false;
#endif
});
});

return builder.Build();
}
}
}
Loading
Loading