Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:app="clr-namespace:Bit.BlazorUI.Playground.Web"
xmlns:b="clr-namespace:Microsoft.AspNetCore.Components.WebView.Maui;assembly=Microsoft.AspNetCore.Components.WebView.Maui"
BackgroundColor="{DynamicResource PageBackgroundColor}">
BackgroundColor="{DynamicResource PageBackgroundColor}"
Loaded="ContentPage_Loaded">

<b:BlazorWebView HostPage="wwwroot/index.html">
<b:BlazorWebView x:Name="blazorWebView" HostPage="wwwroot/index.html">
<b:BlazorWebView.RootComponents>
<b:RootComponent ComponentType="{x:Type app:Main}" Selector="app" />
</b:BlazorWebView.RootComponents>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,59 @@
using Microsoft.AspNetCore.Components.WebView.Maui;
using System;
using Microsoft.AspNetCore.Components.WebView.Maui;
using Microsoft.Maui;

namespace Bit.BlazorUI.Playground.Web
namespace Bit.BlazorUI.Playground.Web;

public partial class MainPage
{
public partial class MainPage
public MainPage()
{
public MainPage()
InitializeComponent();

BlazorWebViewHandler.BlazorWebViewMapper.AppendToMapping("CustomBlazorWebViewMapper", (handler, view) =>
{
InitializeComponent();
#if IOS || MACCATALYST
handler.PlatformView.BackgroundColor = UIKit.UIColor.Clear;
handler.PlatformView.Opaque = false;
#endif

BlazorWebViewHandler.BlazorWebViewMapper.AppendToMapping("CustomBlazorWebViewMapper", (handler, view) =>
{
#if ANDROID
Android.Webkit.WebSettings settings = handler.PlatformView.Settings;
Android.Webkit.WebSettings settings = handler.PlatformView.Settings;

settings.AllowFileAccessFromFileURLs =
settings.AllowUniversalAccessFromFileURLs =
settings.AllowContentAccess =
settings.AllowFileAccess =
settings.DatabaseEnabled =
settings.JavaScriptCanOpenWindowsAutomatically =
settings.DomStorageEnabled = true;
settings.AllowFileAccessFromFileURLs =
settings.AllowUniversalAccessFromFileURLs =
settings.AllowContentAccess =
settings.AllowFileAccess =
settings.DatabaseEnabled =
settings.JavaScriptCanOpenWindowsAutomatically =
settings.DomStorageEnabled = true;

#if DEBUG
settings.MixedContentMode = Android.Webkit.MixedContentHandling.AlwaysAllow;
settings.MixedContentMode = Android.Webkit.MixedContentHandling.AlwaysAllow;
#endif

settings.BlockNetworkLoads =
settings.BlockNetworkImage = false;
settings.BlockNetworkLoads =
settings.BlockNetworkImage = false;
#endif
});
});
}

private async void ContentPage_Loaded(object sender, EventArgs e)
{
try
{
#if WINDOWS && RELEASE
var webView2 = (blazorWebView.Handler.PlatformView as Microsoft.UI.Xaml.Controls.WebView2);
await webView2.EnsureCoreWebView2Async();

var settings = webView2.CoreWebView2.Settings;
settings.IsZoomControlEnabled = false;
settings.AreBrowserAcceleratorKeysEnabled = false;
#endif
}
catch (Exception)
{
throw;
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
* {
box-sizing: border-box;
font-family: "Segoe UI";
-webkit-user-drag: none;
-webkit-user-select: none;
overscroll-behavior: none;
-webkit-tap-highlight-color: transparent;
}

html, body, #app-container {
-webkit-font-smoothing: antialiased;
-webkit-tap-highlight-color: transparent;
height: 100%;
width: 100%;
margin: 0;
Expand Down Expand Up @@ -139,6 +142,9 @@
<script src="_content/Bit.BlazorUI.Charts/scripts/bit.blazorui.charts.min.js"></script>
<script src="scripts/app.js"></script>
<script src="_framework/blazor.webview.js" autostart="false"></script>
<script>
window.addEventListener('contextmenu', (event) => event.preventDefault());
</script>

</body>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
x:Class="AdminPanel.Client.App.MainPage"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:client="clr-namespace:AdminPanel.Client.Shared;assembly=AdminPanel.Client.Shared"
xmlns:b="clr-namespace:Microsoft.AspNetCore.Components.WebView.Maui;assembly=Microsoft.AspNetCore.Components.WebView.Maui"
xmlns:client="clr-namespace:AdminPanel.Client.Shared;assembly=AdminPanel.Client.Shared"
BackgroundColor="{DynamicResource PageBackgroundColor}"
Loaded="ContentPage_Loaded"
NavigationPage.HasNavigationBar="False">

<b:BlazorWebView BackgroundColor="#FBFCFF" HostPage="wwwroot/index.html">
<b:BlazorWebView
x:Name="blazorWebView"
BackgroundColor="#FBFCFF"
HostPage="wwwroot/index.html">
<b:BlazorWebView.RootComponents>
<b:RootComponent ComponentType="{x:Type client:App}" Selector="app" />
</b:BlazorWebView.RootComponents>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public MainPage()

BlazorWebViewHandler.BlazorWebViewMapper.AppendToMapping("CustomBlazorWebViewMapper", (handler, view) =>
{
#if IOS
#if IOS || MACCATALYST
handler.PlatformView.BackgroundColor = UIKit.UIColor.Clear;
handler.PlatformView.Opaque = false;
#endif
Expand All @@ -34,4 +34,23 @@ public MainPage()
#endif
});
}

private async void ContentPage_Loaded(object sender, EventArgs e)
{
try
{
#if WINDOWS && RELEASE
var webView2 = (blazorWebView.Handler.PlatformView as Microsoft.UI.Xaml.Controls.WebView2);
await webView2.EnsureCoreWebView2Async();

var settings = webView2.CoreWebView2.Settings;
settings.IsZoomControlEnabled = false;
settings.AreBrowserAcceleratorKeysEnabled = false;
#endif
}
catch (Exception)
{
throw;
}
}
}
Loading