AathifMahir.MauiBlazor.MauiBlazorBridge 1.0.0-preview5

Prefix Reserved
This is a prerelease version of AathifMahir.MauiBlazor.MauiBlazorBridge.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package AathifMahir.MauiBlazor.MauiBlazorBridge --version 1.0.0-preview5                
NuGet\Install-Package AathifMahir.MauiBlazor.MauiBlazorBridge -Version 1.0.0-preview5                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AathifMahir.MauiBlazor.MauiBlazorBridge" Version="1.0.0-preview5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AathifMahir.MauiBlazor.MauiBlazorBridge --version 1.0.0-preview5                
#r "nuget: AathifMahir.MauiBlazor.MauiBlazorBridge, 1.0.0-preview5"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AathifMahir.MauiBlazor.MauiBlazorBridge as a Cake Addin
#addin nuget:?package=AathifMahir.MauiBlazor.MauiBlazorBridge&version=1.0.0-preview5&prerelease

// Install AathifMahir.MauiBlazor.MauiBlazorBridge as a Cake Tool
#tool nuget:?package=AathifMahir.MauiBlazor.MauiBlazorBridge&version=1.0.0-preview5&prerelease                

MauiBlazorBridge

MauiBlazorBridge is a Helper Utitlity That Makes Easier for Maui Blazor Hybrid Developers to Seamlessly Detect Platform, FormFactor and Etc..

Get Started

1. In order to use the MauiBlazorHybrid you need to call the extension method in your Program.cs file as follows:

builder.Services.AddMauiBlazorBridge();

2. In the _imports.razor file, you need to import the namespace as follows:

@using MauiBlazorBridge

3. In MainLayout.razor file, you need to add BridgeProvider to Initialize the Bridge. Additionally Setting ListenerType Property to Global Makes Bridge to Listen to FormFactor Changes Globaly Instead of Creating and Disposing Listener During the Usage of BridgeFormFactor Component, Additionally If it is Set to Suppressed that would prevent Bridge from Creating a Listener Instead Get Values Once from the Device and Use Across the Bridge

@inherits LayoutComponentBase
<div class="page">
    <div class="sidebar">
        <NavMenu />
    </div>

    <main>
        <article class="content px-4">
            @Body
        </article>
        
        <BridgeProvider/>
    </main>
</div>

Disclaimer: When it comes PreRendering Enabled Blazor Flavor, You don't need to add BridgeProvider in MainLayout.razor file, Instead you need to add BridgeProvider in all the different Blazor Components that Utilizes Bridge. Additionally you need to Enable Interactivity for that Specific Component or Page

Usage

@inject IBridge Bridge

<BridgeFormFactor>
    <Mobile>
        <h3>FormFactor : Mobile</h3>
    </Mobile>
    <Tablet>
        <h3>FormFactor : Tablet</h3>
    </Tablet>
    <Desktop>
        <h3>FormFactor : Desktop</h3>
    </Desktop>
    <Default>
        <h3>FormFactor : Unknown</h3>
    </Default>
</BridgeFormFactor>

<h3>Platform : @Bridge.Platform</h3>
<h3>Platform Version : @Bridge.PlatformVersion</h3>
<h3>FrameWork : @Bridge.Framework</h3>

Components

BridgeFormFactor

<BridgeFormFactor>
    <Mobile>
        <h3>FormFactor : Mobile</h3>
    </Mobile>
    <Tablet>
        <h3>FormFactor : Tablet</h3>
    </Tablet>
    <Desktop>
        <h3>FormFactor : Desktop</h3>
    </Desktop>
    <Default>
        <h3>FormFactor : Unknown</h3>
    </Default>
</BridgeFormFactor>

Recommended Approach: To obtain the current Form Factor, bind to the FormFactorChanged EventCallBack in the BridgeFormFactor component as Shown in the below example


<BridgeFormFactor @bind:FormFactorChanged="FormFactorChanged">
    <Mobile>
        <h3>FormFactor : Mobile</h3>
    </Mobile>
    <Tablet>
        <h3>FormFactor : Tablet</h3>
    </Tablet>
    <Desktop>
        <h3>FormFactor : Desktop</h3>
    </Desktop>
    <Default>
        <h3>FormFactor : Unknown</h3>
    </Default>
</BridgeFormFactor>

@code {
	private DeviceFormFactor FormFactorChanged { get; set; }
}

BridgePlatform

<BridgePlatform>
	<Android>
		<h3>Platform : Android</h3>
	</Android>
	<IOS>
		<h3>Platform : iOS</h3>
	</IOS>
	<Windows>
		<h3>Platform : Windows</h3>
	</Windows>
	<Mac>
		<h3>Platform : MacCatalyst</h3>
	</Mac>
	<Default>
		<h3>Platform : Unknown</h3>
	</Default>
</BridgePlatform>

BridgeFramework

<BridgeFramework>
  <Maui>
   <h3>Framework : Maui</h3>
  </Maui>
  <Blazor>
  <h3>Framework : Blazor</h3>
  </Blazor>
</BridgeFramework>

Note

The Documentation is Under Construction, More Features and Components will be Added Soon.

License

MauiBlazorBridge is licensed under the MIT license

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-android34.0 is compatible.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-ios17.2 is compatible.  net8.0-maccatalyst was computed.  net8.0-maccatalyst17.2 is compatible.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net8.0-windows10.0.19041 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0-preview7 50 7/23/2024
1.0.0-preview6 67 7/4/2024
1.0.0-preview5 47 7/3/2024
1.0.0-preview4 51 7/3/2024
1.0.0-preview3 50 6/26/2024

v1.0.0-preview5
• Minor Fixes and Improvements

v1.0.0-preview4
• Improved BridgeFormFactor Component
• Various Enhancements and Bug Fixes

v1.0.0-preview3
• Initial Preview Release