Improvements
This commit is contained in:
@@ -9,6 +9,10 @@ public partial class App : Application
|
|||||||
public App()
|
public App()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
MainPage = new AppShell();
|
}
|
||||||
|
|
||||||
|
protected override Window CreateWindow(IActivationState? activationState)
|
||||||
|
{
|
||||||
|
return new Window(new AppShell());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
BackgroundColor="{AppThemeBinding Light=#FAFAFA, Dark=#2C2C2C}"
|
BackgroundColor="{AppThemeBinding Light=#FAFAFA, Dark=#2C2C2C}"
|
||||||
SelectionChanged="OnFruitsSelectionChanged">
|
SelectionChanged="OnFruitsSelectionChanged">
|
||||||
<CollectionView.ItemTemplate>
|
<CollectionView.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate x:DataType="x:String">
|
||||||
<Label Text="{Binding}"
|
<Label Text="{Binding}"
|
||||||
Padding="10"
|
Padding="10"
|
||||||
TextColor="{AppThemeBinding Light={StaticResource TextPrimaryLight}, Dark={StaticResource TextPrimaryDark}}" />
|
TextColor="{AppThemeBinding Light={StaticResource TextPrimaryLight}, Dark={StaticResource TextPrimaryDark}}" />
|
||||||
@@ -58,7 +58,7 @@
|
|||||||
BackgroundColor="{AppThemeBinding Light=White, Dark=#1E1E1E}"
|
BackgroundColor="{AppThemeBinding Light=White, Dark=#1E1E1E}"
|
||||||
SelectionChanged="OnColorsSelectionChanged">
|
SelectionChanged="OnColorsSelectionChanged">
|
||||||
<CollectionView.ItemTemplate>
|
<CollectionView.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate x:DataType="x:String">
|
||||||
<Label Text="{Binding}"
|
<Label Text="{Binding}"
|
||||||
Padding="10"
|
Padding="10"
|
||||||
TextColor="{AppThemeBinding Light={StaticResource TextPrimaryLight}, Dark={StaticResource TextPrimaryDark}}" />
|
TextColor="{AppThemeBinding Light={StaticResource TextPrimaryLight}, Dark={StaticResource TextPrimaryDark}}" />
|
||||||
@@ -86,7 +86,7 @@
|
|||||||
BackgroundColor="{AppThemeBinding Light=White, Dark=#1E1E1E}"
|
BackgroundColor="{AppThemeBinding Light=White, Dark=#1E1E1E}"
|
||||||
SelectionChanged="OnContactsSelectionChanged">
|
SelectionChanged="OnContactsSelectionChanged">
|
||||||
<CollectionView.ItemTemplate>
|
<CollectionView.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate x:DataType="x:String">
|
||||||
<Label Text="{Binding}"
|
<Label Text="{Binding}"
|
||||||
Padding="10"
|
Padding="10"
|
||||||
TextColor="{AppThemeBinding Light={StaticResource TextPrimaryLight}, Dark={StaticResource TextPrimaryDark}}" />
|
TextColor="{AppThemeBinding Light={StaticResource TextPrimaryLight}, Dark={StaticResource TextPrimaryDark}}" />
|
||||||
|
|||||||
@@ -6,12 +6,32 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
|
||||||
|
<!-- Application Info -->
|
||||||
|
<ApplicationTitle>OpenMaui Shell Demo</ApplicationTitle>
|
||||||
|
<ApplicationId>com.openmaui.shelldemo</ApplicationId>
|
||||||
|
<ApplicationVersion>1.0.0</ApplicationVersion>
|
||||||
|
|
||||||
|
<!-- MAUI Settings -->
|
||||||
|
<UseMaui>true</UseMaui>
|
||||||
|
<SingleProject>true</SingleProject>
|
||||||
|
<EnableDefaultXamlItems>true</EnableDefaultXamlItems>
|
||||||
|
|
||||||
|
<!-- Linux Runtime -->
|
||||||
|
<RuntimeIdentifiers>linux-x64;linux-arm64</RuntimeIdentifiers>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<!-- OpenMaui Linux Platform (local development reference) -->
|
||||||
<ProjectReference Include="../../maui-linux/OpenMaui.Controls.Linux.csproj" />
|
<ProjectReference Include="../../maui-linux/OpenMaui.Controls.Linux.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- XAML Files -->
|
||||||
|
<ItemGroup>
|
||||||
|
<MauiXaml Update="**/*.xaml" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- Embedded Resources (icons) -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="Resources\Images\*.svg" />
|
<EmbeddedResource Include="Resources\Images\*.svg" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -11,9 +11,12 @@ public partial class App : Application
|
|||||||
public App()
|
public App()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Window CreateWindow(IActivationState? activationState)
|
||||||
|
{
|
||||||
// Determine current theme for navigation bar colors
|
// Determine current theme for navigation bar colors
|
||||||
var isDarkMode = Application.Current?.RequestedTheme == AppTheme.Dark;
|
var isDarkMode = Current?.RequestedTheme == AppTheme.Dark;
|
||||||
var barBackground = isDarkMode ? Color.FromArgb("#3949AB") : Color.FromArgb("#5C6BC0");
|
var barBackground = isDarkMode ? Color.FromArgb("#3949AB") : Color.FromArgb("#5C6BC0");
|
||||||
|
|
||||||
NavigationPage = new NavigationPage(new TodoListPage())
|
NavigationPage = new NavigationPage(new TodoListPage())
|
||||||
@@ -24,12 +27,12 @@ public partial class App : Application
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Update navigation bar when theme changes
|
// Update navigation bar when theme changes
|
||||||
Application.Current!.RequestedThemeChanged += (s, e) =>
|
Current!.RequestedThemeChanged += (s, e) =>
|
||||||
{
|
{
|
||||||
var dark = e.RequestedTheme == AppTheme.Dark;
|
var dark = e.RequestedTheme == AppTheme.Dark;
|
||||||
NavigationPage.BarBackgroundColor = dark ? Color.FromArgb("#3949AB") : Color.FromArgb("#5C6BC0");
|
NavigationPage.BarBackgroundColor = dark ? Color.FromArgb("#3949AB") : Color.FromArgb("#5C6BC0");
|
||||||
};
|
};
|
||||||
|
|
||||||
MainPage = NavigationPage;
|
return new Window(NavigationPage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,12 +6,32 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
|
||||||
|
<!-- Application Info -->
|
||||||
|
<ApplicationTitle>OpenMaui Todo</ApplicationTitle>
|
||||||
|
<ApplicationId>com.openmaui.todoapp</ApplicationId>
|
||||||
|
<ApplicationVersion>1.0.0</ApplicationVersion>
|
||||||
|
|
||||||
|
<!-- MAUI Settings -->
|
||||||
|
<UseMaui>true</UseMaui>
|
||||||
|
<SingleProject>true</SingleProject>
|
||||||
|
<EnableDefaultXamlItems>true</EnableDefaultXamlItems>
|
||||||
|
|
||||||
|
<!-- Linux Runtime -->
|
||||||
|
<RuntimeIdentifiers>linux-x64;linux-arm64</RuntimeIdentifiers>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<!-- OpenMaui Linux Platform (local development reference) -->
|
||||||
<ProjectReference Include="../../maui-linux/OpenMaui.Controls.Linux.csproj" />
|
<ProjectReference Include="../../maui-linux/OpenMaui.Controls.Linux.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- XAML Files -->
|
||||||
|
<ItemGroup>
|
||||||
|
<MauiXaml Update="**/*.xaml" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- Embedded Resources (icons) -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="Resources\Images\*.svg" />
|
<EmbeddedResource Include="Resources\Images\*.svg" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -11,9 +11,12 @@ public partial class App : Application
|
|||||||
public App()
|
public App()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Window CreateWindow(IActivationState? activationState)
|
||||||
|
{
|
||||||
// Determine current theme for navigation bar colors
|
// Determine current theme for navigation bar colors
|
||||||
var isDarkMode = Application.Current?.RequestedTheme == AppTheme.Dark;
|
var isDarkMode = Current?.RequestedTheme == AppTheme.Dark;
|
||||||
var barBackground = isDarkMode ? Color.FromArgb("#3949AB") : Color.FromArgb("#5C6BC0");
|
var barBackground = isDarkMode ? Color.FromArgb("#3949AB") : Color.FromArgb("#5C6BC0");
|
||||||
|
|
||||||
NavigationPage = new NavigationPage(new WebViewPage())
|
NavigationPage = new NavigationPage(new WebViewPage())
|
||||||
@@ -24,12 +27,12 @@ public partial class App : Application
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Update navigation bar when theme changes
|
// Update navigation bar when theme changes
|
||||||
Application.Current!.RequestedThemeChanged += (s, e) =>
|
Current!.RequestedThemeChanged += (s, e) =>
|
||||||
{
|
{
|
||||||
var dark = e.RequestedTheme == AppTheme.Dark;
|
var dark = e.RequestedTheme == AppTheme.Dark;
|
||||||
NavigationPage.BarBackgroundColor = dark ? Color.FromArgb("#3949AB") : Color.FromArgb("#5C6BC0");
|
NavigationPage.BarBackgroundColor = dark ? Color.FromArgb("#3949AB") : Color.FromArgb("#5C6BC0");
|
||||||
};
|
};
|
||||||
|
|
||||||
MainPage = NavigationPage;
|
return new Window(NavigationPage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,147 +2,136 @@
|
|||||||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
x:Class="WebViewDemo.WebViewPage"
|
x:Class="WebViewDemo.WebViewPage"
|
||||||
Title="WebView Demo"
|
Title="OpenMaui Browser"
|
||||||
BackgroundColor="{AppThemeBinding Light={StaticResource PageBackgroundLight}, Dark={StaticResource PageBackgroundDark}}">
|
BackgroundColor="{AppThemeBinding Light={StaticResource PageBackgroundLight}, Dark={StaticResource PageBackgroundDark}}">
|
||||||
|
|
||||||
<Grid RowDefinitions="Auto,Auto,Auto,*,Auto,Auto" Padding="16" RowSpacing="12">
|
<Grid RowDefinitions="Auto,*,Auto">
|
||||||
|
|
||||||
<!-- Header -->
|
<!-- Browser Toolbar -->
|
||||||
<Label Grid.Row="0"
|
<Grid Grid.Row="0"
|
||||||
Text="WebView Demo - WebKitGTK"
|
ColumnDefinitions="Auto,Auto,Auto,*,Auto,Auto,Auto"
|
||||||
FontSize="22"
|
ColumnSpacing="4"
|
||||||
FontAttributes="Bold"
|
Padding="8"
|
||||||
TextColor="{StaticResource PrimaryColor}"
|
BackgroundColor="{AppThemeBinding Light={StaticResource CardBackgroundLight}, Dark={StaticResource CardBackgroundDark}}">
|
||||||
HorizontalOptions="Center" />
|
|
||||||
|
|
||||||
<!-- Navigation Bar -->
|
<!-- Back Button -->
|
||||||
<Border Grid.Row="1"
|
<ImageButton Grid.Column="0"
|
||||||
BackgroundColor="{AppThemeBinding Light={StaticResource CardBackgroundLight}, Dark={StaticResource CardBackgroundDark}}"
|
x:Name="BackButton"
|
||||||
StrokeThickness="0"
|
|
||||||
Padding="12">
|
|
||||||
<Border.StrokeShape>
|
|
||||||
<RoundRectangle CornerRadius="8" />
|
|
||||||
</Border.StrokeShape>
|
|
||||||
|
|
||||||
<HorizontalStackLayout Spacing="12" HorizontalOptions="Center">
|
|
||||||
<ImageButton x:Name="BackButton"
|
|
||||||
Source="{AppThemeBinding Light=arrow_back_light.svg, Dark=arrow_back_dark.svg}"
|
Source="{AppThemeBinding Light=arrow_back_light.svg, Dark=arrow_back_dark.svg}"
|
||||||
WidthRequest="44"
|
WidthRequest="36"
|
||||||
HeightRequest="44"
|
HeightRequest="36"
|
||||||
Padding="10"
|
Padding="8"
|
||||||
BackgroundColor="{StaticResource ButtonColor}"
|
BackgroundColor="Transparent"
|
||||||
CornerRadius="8"
|
Clicked="OnBackClicked"
|
||||||
Clicked="OnBackClicked" />
|
ToolTipProperties.Text="Go Back" />
|
||||||
<ImageButton x:Name="ForwardButton"
|
|
||||||
|
<!-- Forward Button -->
|
||||||
|
<ImageButton Grid.Column="1"
|
||||||
|
x:Name="ForwardButton"
|
||||||
Source="{AppThemeBinding Light=arrow_forward_light.svg, Dark=arrow_forward_dark.svg}"
|
Source="{AppThemeBinding Light=arrow_forward_light.svg, Dark=arrow_forward_dark.svg}"
|
||||||
WidthRequest="44"
|
WidthRequest="36"
|
||||||
HeightRequest="44"
|
HeightRequest="36"
|
||||||
Padding="10"
|
Padding="8"
|
||||||
BackgroundColor="{StaticResource ButtonColor}"
|
BackgroundColor="Transparent"
|
||||||
CornerRadius="8"
|
Clicked="OnForwardClicked"
|
||||||
Clicked="OnForwardClicked" />
|
ToolTipProperties.Text="Go Forward" />
|
||||||
<ImageButton x:Name="ReloadButton"
|
|
||||||
|
<!-- Reload Button -->
|
||||||
|
<ImageButton Grid.Column="2"
|
||||||
|
x:Name="ReloadButton"
|
||||||
Source="{AppThemeBinding Light=refresh_light.svg, Dark=refresh_dark.svg}"
|
Source="{AppThemeBinding Light=refresh_light.svg, Dark=refresh_dark.svg}"
|
||||||
WidthRequest="44"
|
WidthRequest="36"
|
||||||
HeightRequest="44"
|
HeightRequest="36"
|
||||||
Padding="10"
|
Padding="8"
|
||||||
BackgroundColor="{StaticResource ButtonColor}"
|
BackgroundColor="Transparent"
|
||||||
CornerRadius="8"
|
Clicked="OnReloadClicked"
|
||||||
Clicked="OnReloadClicked" />
|
ToolTipProperties.Text="Reload Page" />
|
||||||
</HorizontalStackLayout>
|
|
||||||
</Border>
|
|
||||||
|
|
||||||
<!-- URL Bar -->
|
<!-- URL Bar -->
|
||||||
<Border Grid.Row="2"
|
<Border Grid.Column="3"
|
||||||
BackgroundColor="{AppThemeBinding Light={StaticResource CardBackgroundLight}, Dark={StaticResource CardBackgroundDark}}"
|
BackgroundColor="{AppThemeBinding Light=#F0F0F0, Dark=#2A2A2A}"
|
||||||
StrokeThickness="0"
|
StrokeThickness="1"
|
||||||
Padding="12">
|
Stroke="{AppThemeBinding Light={StaticResource BorderLight}, Dark={StaticResource BorderDark}}"
|
||||||
|
Padding="8,4"
|
||||||
|
Margin="4,0">
|
||||||
<Border.StrokeShape>
|
<Border.StrokeShape>
|
||||||
<RoundRectangle CornerRadius="8" />
|
<RoundRectangle CornerRadius="18" />
|
||||||
</Border.StrokeShape>
|
</Border.StrokeShape>
|
||||||
|
|
||||||
<Grid ColumnDefinitions="*,Auto" ColumnSpacing="8">
|
|
||||||
<Entry x:Name="UrlEntry"
|
<Entry x:Name="UrlEntry"
|
||||||
Grid.Column="0"
|
Placeholder="Enter URL or search..."
|
||||||
Placeholder="Enter URL..."
|
|
||||||
Text="https://dotnet.microsoft.com"
|
Text="https://dotnet.microsoft.com"
|
||||||
FontSize="14"
|
FontSize="14"
|
||||||
TextColor="{AppThemeBinding Light={StaticResource TextPrimaryLight}, Dark={StaticResource TextPrimaryDark}}"
|
TextColor="{AppThemeBinding Light={StaticResource TextPrimaryLight}, Dark={StaticResource TextPrimaryDark}}"
|
||||||
PlaceholderColor="{AppThemeBinding Light={StaticResource TextSecondaryLight}, Dark={StaticResource TextSecondaryDark}}"
|
PlaceholderColor="{AppThemeBinding Light={StaticResource TextSecondaryLight}, Dark={StaticResource TextSecondaryDark}}"
|
||||||
|
BackgroundColor="Transparent"
|
||||||
VerticalOptions="Center"
|
VerticalOptions="Center"
|
||||||
Completed="OnUrlSubmitted" />
|
Completed="OnUrlSubmitted" />
|
||||||
<ImageButton x:Name="GoButton"
|
|
||||||
Grid.Column="1"
|
|
||||||
Source="{AppThemeBinding Light=send_light.svg, Dark=send_dark.svg}"
|
|
||||||
WidthRequest="44"
|
|
||||||
HeightRequest="44"
|
|
||||||
Padding="10"
|
|
||||||
BackgroundColor="{StaticResource AccentColor}"
|
|
||||||
CornerRadius="8"
|
|
||||||
Clicked="OnGoClicked" />
|
|
||||||
</Grid>
|
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
<!-- WebView -->
|
<!-- Go Button -->
|
||||||
<Border Grid.Row="3"
|
<ImageButton Grid.Column="4"
|
||||||
BackgroundColor="{AppThemeBinding Light={StaticResource CardBackgroundLight}, Dark={StaticResource CardBackgroundDark}}"
|
x:Name="GoButton"
|
||||||
StrokeThickness="1"
|
Source="{AppThemeBinding Light=send_light.svg, Dark=send_dark.svg}"
|
||||||
Stroke="{AppThemeBinding Light={StaticResource BorderLight}, Dark={StaticResource BorderDark}}">
|
WidthRequest="36"
|
||||||
<Border.StrokeShape>
|
HeightRequest="36"
|
||||||
<RoundRectangle CornerRadius="8" />
|
Padding="8"
|
||||||
</Border.StrokeShape>
|
BackgroundColor="{StaticResource AccentColor}"
|
||||||
|
CornerRadius="18"
|
||||||
|
Clicked="OnGoClicked"
|
||||||
|
ToolTipProperties.Text="Navigate" />
|
||||||
|
|
||||||
<WebView x:Name="MainWebView"
|
<!-- Load HTML Demo Button -->
|
||||||
|
<ImageButton Grid.Column="5"
|
||||||
|
x:Name="LoadHtmlButton"
|
||||||
|
Source="{AppThemeBinding Light=code_light.svg, Dark=code_dark.svg}"
|
||||||
|
WidthRequest="36"
|
||||||
|
HeightRequest="36"
|
||||||
|
Padding="8"
|
||||||
|
BackgroundColor="Transparent"
|
||||||
|
Clicked="OnLoadHtmlClicked"
|
||||||
|
ToolTipProperties.Text="Load Demo HTML" />
|
||||||
|
|
||||||
|
<!-- Eval JS Demo Button -->
|
||||||
|
<ImageButton Grid.Column="6"
|
||||||
|
x:Name="EvalJsButton"
|
||||||
|
Source="{AppThemeBinding Light=play_arrow_light.svg, Dark=play_arrow_dark.svg}"
|
||||||
|
WidthRequest="36"
|
||||||
|
HeightRequest="36"
|
||||||
|
Padding="8"
|
||||||
|
BackgroundColor="Transparent"
|
||||||
|
Clicked="OnEvalJsClicked"
|
||||||
|
ToolTipProperties.Text="Run JavaScript" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<!-- Loading Progress Bar -->
|
||||||
|
<ProgressBar Grid.Row="1"
|
||||||
|
x:Name="LoadingProgress"
|
||||||
|
VerticalOptions="Start"
|
||||||
|
HeightRequest="3"
|
||||||
|
ProgressColor="{StaticResource AccentColor}"
|
||||||
|
Progress="0"
|
||||||
|
IsVisible="False"
|
||||||
|
ZIndex="1" />
|
||||||
|
|
||||||
|
<!-- WebView - Main Content Area -->
|
||||||
|
<WebView Grid.Row="1"
|
||||||
|
x:Name="MainWebView"
|
||||||
VerticalOptions="Fill"
|
VerticalOptions="Fill"
|
||||||
HorizontalOptions="Fill"
|
HorizontalOptions="Fill"
|
||||||
Navigating="OnNavigating"
|
Navigating="OnNavigating"
|
||||||
Navigated="OnNavigated" />
|
Navigated="OnNavigated" />
|
||||||
</Border>
|
|
||||||
|
|
||||||
<!-- Action Buttons -->
|
|
||||||
<Border Grid.Row="4"
|
|
||||||
BackgroundColor="{AppThemeBinding Light={StaticResource CardBackgroundLight}, Dark={StaticResource CardBackgroundDark}}"
|
|
||||||
StrokeThickness="0"
|
|
||||||
Padding="12">
|
|
||||||
<Border.StrokeShape>
|
|
||||||
<RoundRectangle CornerRadius="8" />
|
|
||||||
</Border.StrokeShape>
|
|
||||||
|
|
||||||
<HorizontalStackLayout Spacing="12" HorizontalOptions="Center">
|
|
||||||
<ImageButton x:Name="LoadHtmlButton"
|
|
||||||
Source="{AppThemeBinding Light=code_light.svg, Dark=code_dark.svg}"
|
|
||||||
WidthRequest="44"
|
|
||||||
HeightRequest="44"
|
|
||||||
Padding="10"
|
|
||||||
BackgroundColor="{StaticResource PrimaryColor}"
|
|
||||||
CornerRadius="8"
|
|
||||||
Clicked="OnLoadHtmlClicked" />
|
|
||||||
<ImageButton x:Name="EvalJsButton"
|
|
||||||
Source="{AppThemeBinding Light=play_arrow_light.svg, Dark=play_arrow_dark.svg}"
|
|
||||||
WidthRequest="44"
|
|
||||||
HeightRequest="44"
|
|
||||||
Padding="10"
|
|
||||||
BackgroundColor="{StaticResource PrimaryColor}"
|
|
||||||
CornerRadius="8"
|
|
||||||
Clicked="OnEvalJsClicked" />
|
|
||||||
</HorizontalStackLayout>
|
|
||||||
</Border>
|
|
||||||
|
|
||||||
<!-- Status Bar -->
|
<!-- Status Bar -->
|
||||||
<Border Grid.Row="5"
|
<Grid Grid.Row="2"
|
||||||
BackgroundColor="{StaticResource PrimaryDarkColor}"
|
Padding="8,4"
|
||||||
StrokeThickness="0"
|
BackgroundColor="{AppThemeBinding Light=#E8E8E8, Dark=#1A1A1A}">
|
||||||
Padding="12,8">
|
|
||||||
<Border.StrokeShape>
|
|
||||||
<RoundRectangle CornerRadius="6" />
|
|
||||||
</Border.StrokeShape>
|
|
||||||
|
|
||||||
<Label x:Name="StatusLabel"
|
<Label x:Name="StatusLabel"
|
||||||
Text="Ready"
|
Text="Ready"
|
||||||
FontSize="13"
|
FontSize="12"
|
||||||
TextColor="White"
|
TextColor="{AppThemeBinding Light={StaticResource TextSecondaryLight}, Dark={StaticResource TextSecondaryDark}}"
|
||||||
HorizontalOptions="Center" />
|
VerticalOptions="Center" />
|
||||||
</Border>
|
</Grid>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</ContentPage>
|
</ContentPage>
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ namespace WebViewDemo;
|
|||||||
|
|
||||||
public partial class WebViewPage : ContentPage
|
public partial class WebViewPage : ContentPage
|
||||||
{
|
{
|
||||||
|
private CancellationTokenSource? _progressCts;
|
||||||
|
|
||||||
public WebViewPage()
|
public WebViewPage()
|
||||||
{
|
{
|
||||||
Console.WriteLine("[WebViewPage] Constructor starting");
|
Console.WriteLine("[WebViewPage] Constructor starting");
|
||||||
@@ -70,10 +72,16 @@ public partial class WebViewPage : ContentPage
|
|||||||
{
|
{
|
||||||
StatusLabel.Text = $"Loading: {e.Url}";
|
StatusLabel.Text = $"Loading: {e.Url}";
|
||||||
Console.WriteLine($"[WebViewPage] Navigating to: {e.Url}");
|
Console.WriteLine($"[WebViewPage] Navigating to: {e.Url}");
|
||||||
|
|
||||||
|
// Start progress animation
|
||||||
|
StartProgressAnimation();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnNavigated(object? sender, WebNavigatedEventArgs e)
|
private void OnNavigated(object? sender, WebNavigatedEventArgs e)
|
||||||
{
|
{
|
||||||
|
// Stop progress animation and complete
|
||||||
|
StopProgressAnimation(e.Result == WebNavigationResult.Success);
|
||||||
|
|
||||||
StatusLabel.Text = e.Result == WebNavigationResult.Success
|
StatusLabel.Text = e.Result == WebNavigationResult.Success
|
||||||
? $"Loaded: {e.Url}"
|
? $"Loaded: {e.Url}"
|
||||||
: $"Failed: {e.Result}";
|
: $"Failed: {e.Result}";
|
||||||
@@ -82,9 +90,68 @@ public partial class WebViewPage : ContentPage
|
|||||||
Console.WriteLine($"[WebViewPage] Navigated: {e.Result} - {e.Url}");
|
Console.WriteLine($"[WebViewPage] Navigated: {e.Result} - {e.Url}");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnLoadHtmlClicked(object? sender, EventArgs e)
|
private void StartProgressAnimation()
|
||||||
|
{
|
||||||
|
// Cancel any existing animation
|
||||||
|
_progressCts?.Cancel();
|
||||||
|
_progressCts = new CancellationTokenSource();
|
||||||
|
|
||||||
|
// Show and reset progress bar
|
||||||
|
LoadingProgress.Progress = 0;
|
||||||
|
LoadingProgress.IsVisible = true;
|
||||||
|
|
||||||
|
// Animate progress (simulated since WebView doesn't report actual progress)
|
||||||
|
var token = _progressCts.Token;
|
||||||
|
Dispatcher.Dispatch(async () =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Quick initial progress
|
||||||
|
await LoadingProgress.ProgressTo(0.3, 200, Easing.CubicOut);
|
||||||
|
if (token.IsCancellationRequested) return;
|
||||||
|
|
||||||
|
// Slower middle progress
|
||||||
|
await LoadingProgress.ProgressTo(0.6, 500, Easing.Linear);
|
||||||
|
if (token.IsCancellationRequested) return;
|
||||||
|
|
||||||
|
// Even slower as we wait
|
||||||
|
await LoadingProgress.ProgressTo(0.85, 1000, Easing.CubicIn);
|
||||||
|
}
|
||||||
|
catch (TaskCanceledException)
|
||||||
|
{
|
||||||
|
// Expected when navigation completes
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StopProgressAnimation(bool success)
|
||||||
|
{
|
||||||
|
_progressCts?.Cancel();
|
||||||
|
|
||||||
|
Dispatcher.Dispatch(async () =>
|
||||||
|
{
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
// Complete the progress bar
|
||||||
|
await LoadingProgress.ProgressTo(1.0, 150, Easing.CubicOut);
|
||||||
|
await Task.Delay(100);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hide the progress bar
|
||||||
|
LoadingProgress.IsVisible = false;
|
||||||
|
LoadingProgress.Progress = 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void OnLoadHtmlClicked(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Console.WriteLine("[WebViewPage] Load HTML button clicked");
|
Console.WriteLine("[WebViewPage] Load HTML button clicked");
|
||||||
|
StatusLabel.Text = "Loading demo HTML...";
|
||||||
|
|
||||||
|
// Show quick progress for HTML loading
|
||||||
|
LoadingProgress.Progress = 0;
|
||||||
|
LoadingProgress.IsVisible = true;
|
||||||
|
await LoadingProgress.ProgressTo(0.5, 100, Easing.CubicOut);
|
||||||
|
|
||||||
var html = @"
|
var html = @"
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
@@ -156,7 +223,14 @@ public partial class WebViewPage : ContentPage
|
|||||||
</html>";
|
</html>";
|
||||||
|
|
||||||
MainWebView.Source = new HtmlWebViewSource { Html = html };
|
MainWebView.Source = new HtmlWebViewSource { Html = html };
|
||||||
StatusLabel.Text = "Loaded custom HTML";
|
|
||||||
|
// Complete progress
|
||||||
|
await LoadingProgress.ProgressTo(1.0, 100, Easing.CubicOut);
|
||||||
|
await Task.Delay(100);
|
||||||
|
LoadingProgress.IsVisible = false;
|
||||||
|
|
||||||
|
StatusLabel.Text = "Loaded demo HTML";
|
||||||
|
UrlEntry.Text = "about:demo";
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void OnEvalJsClicked(object? sender, EventArgs e)
|
private async void OnEvalJsClicked(object? sender, EventArgs e)
|
||||||
|
|||||||
@@ -43,8 +43,11 @@ class Program
|
|||||||
// Create the MAUI app with all handlers registered
|
// Create the MAUI app with all handlers registered
|
||||||
var app = MauiProgram.CreateMauiApp();
|
var app = MauiProgram.CreateMauiApp();
|
||||||
|
|
||||||
// Run on Linux platform
|
// Run on Linux platform with GTK mode for WebView support
|
||||||
LinuxApplication.Run(app, args);
|
LinuxApplication.Run(app, args, options =>
|
||||||
|
{
|
||||||
|
options.UseGtk = true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,12 +6,32 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
|
||||||
|
<!-- Application Info -->
|
||||||
|
<ApplicationTitle>OpenMaui WebView Demo</ApplicationTitle>
|
||||||
|
<ApplicationId>com.openmaui.webviewdemo</ApplicationId>
|
||||||
|
<ApplicationVersion>1.0.0</ApplicationVersion>
|
||||||
|
|
||||||
|
<!-- MAUI Settings -->
|
||||||
|
<UseMaui>true</UseMaui>
|
||||||
|
<SingleProject>true</SingleProject>
|
||||||
|
<EnableDefaultXamlItems>true</EnableDefaultXamlItems>
|
||||||
|
|
||||||
|
<!-- Linux Runtime -->
|
||||||
|
<RuntimeIdentifiers>linux-x64;linux-arm64</RuntimeIdentifiers>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<!-- OpenMaui Linux Platform (local development reference) -->
|
||||||
<ProjectReference Include="../../maui-linux/OpenMaui.Controls.Linux.csproj" />
|
<ProjectReference Include="../../maui-linux/OpenMaui.Controls.Linux.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- XAML Files -->
|
||||||
|
<ItemGroup>
|
||||||
|
<MauiXaml Update="**/*.xaml" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- Embedded Resources (icons) -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="Resources\Images\*.svg" />
|
<EmbeddedResource Include="Resources\Images\*.svg" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user