-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from AathifMahir/hybrid
Blazor/Maui Hybrid Support without Maui Artifacts
- Loading branch information
Showing
91 changed files
with
2,817 additions
and
149 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,14 @@ | ||
<?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" | ||
xmlns:local="clr-namespace:MauiTheme.Sample.BlazorHybrid" | ||
x:Class="MauiTheme.Sample.BlazorHybrid.App"> | ||
<Application.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<ResourceDictionary Source="Resources/Styles/Colors.xaml" /> | ||
<ResourceDictionary Source="Resources/Styles/Styles.xaml" /> | ||
</ResourceDictionary.MergedDictionaries> | ||
</ResourceDictionary> | ||
</Application.Resources> | ||
</Application> |
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,31 @@ | ||
using MauiTheme.Core; | ||
|
||
namespace MauiTheme.Sample.BlazorHybrid; | ||
|
||
public partial class App : Application | ||
{ | ||
public App() | ||
{ | ||
InitializeComponent(); | ||
|
||
MauiTheme.Default.InitializeTheme<App>(x => | ||
{ | ||
// Default Theme | ||
x.DefaultTheme = MauiAppTheme.Light; | ||
// Default Styles Resources | ||
x.DefaultStyleResources = ["Resources/Styles/Styles.xaml"]; | ||
// All Resources Excluding Styles | ||
x.Resources = new() | ||
{ | ||
{"Blue", "Resources/Styles/Blue.xaml"}, | ||
{"Purple", "Resources/Styles/Colors.xaml"}, | ||
{"Yellow", "Resources/Styles/Yellow.xaml" }, | ||
{"Green", "Resources/Styles/Green.xaml" } | ||
}; | ||
}); | ||
|
||
MainPage = new MainPage(); | ||
|
||
|
||
} | ||
} |
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,89 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:local="clr-namespace:MauiTheme.Sample.BlazorHybrid" | ||
xmlns:shared="clr-namespace:MauiTheme.Sample.Shared;assembly=MauiTheme.Sample.Shared" | ||
xmlns:mtc="clr-namespace:MauiTheme.Core;assembly=MauiTheme.Core" | ||
x:DataType="local:MainPage" | ||
x:Class="MauiTheme.Sample.BlazorHybrid.MainPage"> | ||
|
||
<Grid> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="*"/> | ||
<ColumnDefinition Width="*"/> | ||
</Grid.ColumnDefinitions> | ||
|
||
|
||
|
||
<BlazorWebView x:Name="blazorWebView" HostPage="wwwroot/index.html" Grid.Column="0"> | ||
<BlazorWebView.RootComponents> | ||
<RootComponent Selector="#app" ComponentType="{x:Type shared:Routes}" /> | ||
</BlazorWebView.RootComponents> | ||
</BlazorWebView> | ||
|
||
<Grid Grid.Column="1"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="*"/> | ||
<RowDefinition Height="150"/> | ||
</Grid.RowDefinitions> | ||
|
||
<VerticalStackLayout Grid.Row="0"> | ||
<StackLayout RadioButtonGroup.GroupName="Theme" | ||
RadioButtonGroup.SelectedValue="{Binding Selection}" HorizontalOptions="Center" VerticalOptions="Center" Padding="12,12"> | ||
<Label FontAttributes="Bold" Text="Theme" FontSize="Large"/> | ||
<RadioButton Content="System" Value="{x:Static mtc:MauiAppTheme.Unspecified}" GroupName="Theme"/> | ||
<RadioButton Content="Light" Value="{x:Static mtc:MauiAppTheme.Light}" GroupName="Theme"/> | ||
<RadioButton Content="Dark" Value="{x:Static mtc:MauiAppTheme.Dark}" GroupName="Theme"/> | ||
<Label > | ||
<Label.FormattedText> | ||
<FormattedString> | ||
<Span Text="You have chosen: " /> | ||
<Span FontAttributes="Bold" Text="{Binding Selection}" /> | ||
</FormattedString> | ||
</Label.FormattedText> | ||
</Label> | ||
</StackLayout> | ||
|
||
<StackLayout RadioButtonGroup.GroupName="Color" | ||
RadioButtonGroup.SelectedValue="{Binding ColorKey}" HorizontalOptions="Center" VerticalOptions="Center" Padding="12,12"> | ||
<Label FontAttributes="Bold" Text="Color" FontSize="Large"/> | ||
<RadioButton Value="Blue" GroupName="Color"> | ||
<RadioButton.Content> | ||
<Rectangle Fill="Blue" WidthRequest="50" HeightRequest="50"/> | ||
</RadioButton.Content> | ||
</RadioButton> | ||
<RadioButton Value="Purple" GroupName="Color"> | ||
<RadioButton.Content> | ||
<Rectangle Fill="Purple" WidthRequest="50" HeightRequest="50"/> | ||
</RadioButton.Content> | ||
</RadioButton> | ||
<RadioButton Value="Yellow" GroupName="Color"> | ||
<RadioButton.Content> | ||
<Rectangle Fill="Yellow" WidthRequest="50" HeightRequest="50"/> | ||
</RadioButton.Content> | ||
</RadioButton> | ||
<RadioButton Value="Green" GroupName="Color"> | ||
<RadioButton.Content> | ||
<Rectangle Fill="Green" WidthRequest="50" HeightRequest="50"/> | ||
</RadioButton.Content> | ||
</RadioButton> | ||
<Label> | ||
<Label.FormattedText> | ||
<FormattedString> | ||
<Span Text="You have chosen: " /> | ||
<Span FontAttributes="Bold" Text="{Binding ColorKey}" /> | ||
</FormattedString> | ||
</Label.FormattedText> | ||
</Label> | ||
</StackLayout> | ||
</VerticalStackLayout> | ||
|
||
<Rectangle Grid.Row="1" Fill="{AppThemeBinding Dark={DynamicResource PrimaryDark}, Light={DynamicResource Primary}}"/> | ||
|
||
</Grid> | ||
|
||
|
||
</Grid> | ||
|
||
|
||
</ContentPage> |
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,50 @@ | ||
using MauiTheme.Core; | ||
using MauiTheme.Core.Events; | ||
|
||
namespace MauiTheme.Sample.BlazorHybrid; | ||
|
||
public partial class MainPage : ContentPage | ||
{ | ||
public MainPage() | ||
{ | ||
InitializeComponent(); | ||
BindingContext = this; | ||
|
||
MauiTheme.Default.ThemeChanged += Default_ThemeChanged; | ||
MauiTheme.Default.ResourceChanged += Default_ResourceChanged; | ||
} | ||
|
||
private void Default_ResourceChanged(object? sender, ResourceChangedEventArgs e) | ||
{ | ||
OnPropertyChanged(nameof(ColorKey)); | ||
} | ||
|
||
private void Default_ThemeChanged(object? sender, MauiAppThemeChangedEventArgs e) | ||
{ | ||
OnPropertyChanged(nameof(Selection)); | ||
} | ||
public MauiAppTheme Selection | ||
{ | ||
get => MauiTheme.Default.CurrentAppTheme; | ||
set | ||
{ | ||
if (value != MauiTheme.Default.CurrentAppTheme) | ||
{ | ||
MauiTheme.Default.CurrentAppTheme = value; | ||
OnPropertyChanged(nameof(Selection)); | ||
} | ||
} | ||
} | ||
public string ColorKey | ||
{ | ||
get => MauiTheme.Default.CurrentResource; | ||
set | ||
{ | ||
if (value != MauiTheme.Default.CurrentResource) | ||
{ | ||
MauiTheme.Default.CurrentResource = value; | ||
OnPropertyChanged(nameof(ColorKey)); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.