-
Notifications
You must be signed in to change notification settings - Fork 470
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add .NET MAUI Blazor Hybrid frontend app (#255)
## Purpose Adds a .NET MAUI Blazor Hybrid frontend app that re-uses the same Razor Components used in the Blazor Web frontend app. This helps showcase how a .NET MAUI cross-platform app can share the same Azure OpenAI functionality as a web app, and run natively on Windows, macOS, iOS, and Android devices. Fixes #253 ## Does this introduce a breaking change? [ ] Yes [x] No ## Pull Request Type What kind of change does this Pull Request introduce? [ ] Bugfix [x] Feature [ ] Code style update (formatting, local variables) [x] Refactoring (no functional changes, no api changes) [ ] Documentation content changes [ ] Other... Please describe: ## How to Test 1. Ensure all existing repo pre-reqs are installed for .NET 8 and Visual Studio, including the .NET MAUI workload 1. Clone repo 1. Follow the existing steps in the repo to publish the app to Azure 1. Get the URL of the app that was published to Azure Container Apps (something like `https://MY_HOSTED_APP.example.azurecontainerapps.io/`) 1. Update the file `app/maui-blazor/MauiProgram.cs` to use that URL to set the `client.BaseAddress` value (there is a 'TODO' note in the file) 1. Set the .NET MAUI Blazor Hybrid app as the startup project 1. Run the app on your device of choice (Windows Desktop, iPhone/iPad, MacBook, Android phone/tablet, etc.) and you should see a UI that exactly matches the Blazor Web app, except that the app is running locally (API calls still go out to Azure as usual) 1. Profit ## Other Information This PR conceptually has a few areas of change: 1. Almost all of the Razor components in the `app/frontend` Blazor Web app were moved to a new shared `app/SharedWebComponents` Razor Class Library (RCL) 2. The Blazor Web app now references that shared code 3. There is a new .NET MAUI Blazor Hybrid project that is mostly just the default template code. Almost all of the brand new code in this PR is standard template code. This new project references the same shared RCL to reuse the exact same functionality and implementation 4. The few notable changes in the apps are: 1. The PDF viewer logic was put behind a service interface so that it could use a web-based viewer in the Blazor Web app, and in the future a native PDF viewer in the .NET MAUI app 2. A UI rendering bug was fixed in `app/SharedWebComponents/Pages/Chat.razor` so that it displays properly on narrow screens (this was a pre-existing issue in the web app, but was very noticable on narrow mobile devices) 3. Some try/catch statements were added in the speech API calls cc @BretJohnson @mattleibow @maddymontaquila @lutzroeder --------- Co-authored-by: Bret Johnson <[email protected]> Co-authored-by: Lutz Roeder <[email protected]> Co-authored-by: Matthew Leibowitz <[email protected]> Co-authored-by: Bret Johnson <[email protected]> Co-authored-by: David Pine <[email protected]>
- Loading branch information
1 parent
030964c
commit caf922e
Showing
113 changed files
with
1,374 additions
and
146 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
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
File renamed without changes.
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
2 changes: 1 addition & 1 deletion
2
...rontend/Components/Answer.razor.Parser.cs → ...ponents/Components/Answer.razor.Parser.cs
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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
app/frontend/Components/AnswerError.razor.cs → ...omponents/Components/AnswerError.razor.cs
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
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
app/frontend/Components/Examples.razor.cs → ...ebComponents/Components/Examples.razor.cs
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
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...rontend/Components/SettingsPanel.razor.cs → ...ponents/Components/SettingsPanel.razor.cs
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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...ponents/SupportingContent.razor.Parser.cs → ...ponents/SupportingContent.razor.Parser.cs
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
2 changes: 1 addition & 1 deletion
2
...end/Components/SupportingContent.razor.cs → ...nts/Components/SupportingContent.razor.cs
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
File renamed without changes.
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
File renamed without changes.
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
2 changes: 1 addition & 1 deletion
2
app/frontend/Extensions/LongExtensions.cs → ...ebComponents/Extensions/LongExtensions.cs
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,26 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
global using System.Globalization; | ||
global using System.Net.Http.Json; | ||
global using System.Runtime.CompilerServices; | ||
global using System.Text; | ||
global using System.Text.Json; | ||
global using System.Text.Json.Serialization; | ||
global using System.Text.RegularExpressions; | ||
global using SharedWebComponents.Components; | ||
global using SharedWebComponents.Extensions; | ||
global using SharedWebComponents.Models; | ||
global using SharedWebComponents.Services; | ||
global using Markdig; | ||
global using Microsoft.AspNetCore.Components; | ||
global using Microsoft.AspNetCore.Components.Forms; | ||
global using Microsoft.AspNetCore.Components.Routing; | ||
global using Microsoft.AspNetCore.Components.Web; | ||
global using Microsoft.Extensions.DependencyInjection; | ||
global using Microsoft.Extensions.Logging; | ||
global using Microsoft.JSInterop; | ||
global using MudBlazor; | ||
global using Shared.Json; | ||
global using Shared.Models; | ||
|
||
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("ClientApp.Tests")] |
2 changes: 1 addition & 1 deletion
2
app/frontend/Models/AnswerResult.cs → ...haredWebComponents/Models/AnswerResult.cs
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
2 changes: 1 addition & 1 deletion
2
app/frontend/Models/AzureCulture.cs → ...haredWebComponents/Models/AzureCulture.cs
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
2 changes: 1 addition & 1 deletion
2
app/frontend/Models/CitationDetails.cs → ...edWebComponents/Models/CitationDetails.cs
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
namespace ClientApp.Models; | ||
namespace SharedWebComponents.Models; | ||
|
||
public record CitationDetails(string Name, string BaseUrl, int Number = 0); |
2 changes: 1 addition & 1 deletion
2
app/frontend/Models/LanguageDirection.cs → ...WebComponents/Models/LanguageDirection.cs
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
2 changes: 1 addition & 1 deletion
2
...ontend/Models/RequestSettingsOverrides.cs → ...onents/Models/RequestSettingsOverrides.cs
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
2 changes: 1 addition & 1 deletion
2
app/frontend/Models/SharedCultures.cs → ...redWebComponents/Models/SharedCultures.cs
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
2 changes: 1 addition & 1 deletion
2
app/frontend/Models/UserQuestion.cs → ...haredWebComponents/Models/UserQuestion.cs
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
2 changes: 1 addition & 1 deletion
2
app/frontend/Models/VoicePreferences.cs → ...dWebComponents/Models/VoicePreferences.cs
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
2 changes: 1 addition & 1 deletion
2
app/frontend/Pages/Chat.razor.cs → app/SharedWebComponents/Pages/Chat.razor.cs
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
Oops, something went wrong.