-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
677 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using Emblazon; | ||
using Microsoft.AspNetCore.Components; | ||
using Microsoft.Blazor.Native.Elements.Handlers; | ||
using XF = Xamarin.Forms; | ||
|
||
namespace Microsoft.Blazor.Native.Elements | ||
{ | ||
public class BaseShellItem : NavigableElement | ||
{ | ||
static BaseShellItem() | ||
{ | ||
ElementHandlerRegistry.RegisterElementHandler<BaseShellItem>( | ||
renderer => new BaseShellItemHandler(renderer, new XF.BaseShellItem())); | ||
} | ||
|
||
[Parameter] public XF.ImageSource FlyoutIcon { get; set; } | ||
[Parameter] public XF.ImageSource Icon { get; set; } | ||
[Parameter] public bool? IsEnabled { get; set; } | ||
[Parameter] public bool? IsTabStop { get; set; } | ||
[Parameter] public string Route { get; set; } | ||
[Parameter] public string Title { get; set; } | ||
[Parameter] public int? TabIndex { get; set; } | ||
|
||
[Parameter] public EventCallback OnAppearing { get; set; } | ||
[Parameter] public EventCallback OnDisappearing { get; set; } | ||
|
||
protected override void RenderAttributes(AttributesBuilder builder) | ||
{ | ||
base.RenderAttributes(builder); | ||
|
||
if (FlyoutIcon != null) | ||
{ | ||
builder.AddAttribute(nameof(FlyoutIcon), AttributeHelper.ImageSourceToString(FlyoutIcon)); | ||
} | ||
if (Icon != null) | ||
{ | ||
builder.AddAttribute(nameof(Icon), AttributeHelper.ImageSourceToString(Icon)); | ||
} | ||
if (IsEnabled != null) | ||
{ | ||
builder.AddAttribute(nameof(IsEnabled), IsEnabled.Value); | ||
} | ||
if (IsTabStop != null) | ||
{ | ||
builder.AddAttribute(nameof(IsTabStop), IsTabStop.Value); | ||
} | ||
if (Route != null) | ||
{ | ||
builder.AddAttribute(nameof(Route), Route); | ||
} | ||
if (Title != null) | ||
{ | ||
builder.AddAttribute(nameof(Title), Title); | ||
} | ||
if (TabIndex != null) | ||
{ | ||
builder.AddAttribute(nameof(TabIndex), TabIndex.Value); | ||
} | ||
|
||
builder.AddAttribute("onappearing", OnAppearing); | ||
builder.AddAttribute("ondisappearing", OnDisappearing); | ||
} | ||
} | ||
} |
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,15 @@ | ||
using Emblazon; | ||
using Microsoft.Blazor.Native.Elements.Handlers; | ||
using XF = Xamarin.Forms; | ||
|
||
namespace Microsoft.Blazor.Native.Elements | ||
{ | ||
public class FlyoutItem : ShellItem | ||
{ | ||
static FlyoutItem() | ||
{ | ||
ElementHandlerRegistry.RegisterElementHandler<FlyoutItem>( | ||
renderer => new FlyoutItemHandler(renderer, new XF.FlyoutItem())); | ||
} | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
src/Microsoft.Blazor.Native/Elements/Handlers/BaseShellItemHandler.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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using Emblazon; | ||
using System; | ||
using XF = Xamarin.Forms; | ||
|
||
namespace Microsoft.Blazor.Native.Elements.Handlers | ||
{ | ||
public class BaseShellItemHandler : NavigableElementHandler | ||
{ | ||
public BaseShellItemHandler(EmblazonRenderer renderer, XF.BaseShellItem baseShellItemControl) : base(renderer, baseShellItemControl) | ||
{ | ||
BaseShellItemControl = baseShellItemControl ?? throw new ArgumentNullException(nameof(baseShellItemControl)); | ||
|
||
BaseShellItemControl.Appearing += (s, e) => | ||
{ | ||
if (AppearingEventHandlerId != default) | ||
{ | ||
renderer.Dispatcher.InvokeAsync(() => renderer.DispatchEventAsync(AppearingEventHandlerId, null, e)); | ||
} | ||
}; | ||
BaseShellItemControl.Disappearing += (s, e) => | ||
{ | ||
if (DisappearingEventHandlerId != default) | ||
{ | ||
renderer.Dispatcher.InvokeAsync(() => renderer.DispatchEventAsync(DisappearingEventHandlerId, null, e)); | ||
} | ||
}; | ||
} | ||
|
||
public XF.BaseShellItem BaseShellItemControl { get; } | ||
public ulong AppearingEventHandlerId { get; set; } | ||
public ulong DisappearingEventHandlerId { get; set; } | ||
|
||
public override void ApplyAttribute(ulong attributeEventHandlerId, string attributeName, object attributeValue, string attributeEventUpdatesAttributeName) | ||
{ | ||
switch (attributeName) | ||
{ | ||
case nameof(XF.BaseShellItem.FlyoutIcon): | ||
BaseShellItemControl.FlyoutIcon = attributeValue == null ? null : AttributeHelper.StringToImageSource((string)attributeValue); | ||
break; | ||
case nameof(XF.BaseShellItem.Icon): | ||
BaseShellItemControl.Icon = attributeValue == null ? null : AttributeHelper.StringToImageSource((string)attributeValue); | ||
break; | ||
case nameof(XF.BaseShellItem.IsEnabled): | ||
BaseShellItemControl.IsEnabled = AttributeHelper.GetBool(attributeValue); | ||
break; | ||
case nameof(XF.BaseShellItem.IsTabStop): | ||
BaseShellItemControl.IsTabStop = AttributeHelper.GetBool(attributeValue); | ||
break; | ||
case nameof(XF.BaseShellItem.Route): | ||
BaseShellItemControl.Route = (string)attributeValue; | ||
break; | ||
case nameof(XF.BaseShellItem.Title): | ||
BaseShellItemControl.Title = (string)attributeValue; | ||
break; | ||
case nameof(XF.BaseShellItem.TabIndex): | ||
BaseShellItemControl.TabIndex = AttributeHelper.GetInt(attributeValue); | ||
break; | ||
|
||
case "onappearing": | ||
Renderer.RegisterEvent(attributeEventHandlerId, () => AppearingEventHandlerId = 0); | ||
AppearingEventHandlerId = attributeEventHandlerId; | ||
break; | ||
case "ondisappearing": | ||
Renderer.RegisterEvent(attributeEventHandlerId, () => DisappearingEventHandlerId = 0); | ||
DisappearingEventHandlerId = attributeEventHandlerId; | ||
break; | ||
default: | ||
base.ApplyAttribute(attributeEventHandlerId, attributeName, attributeValue, attributeEventUpdatesAttributeName); | ||
break; | ||
} | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/Microsoft.Blazor.Native/Elements/Handlers/FlyoutItemHandler.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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Emblazon; | ||
using System; | ||
using XF = Xamarin.Forms; | ||
|
||
namespace Microsoft.Blazor.Native.Elements.Handlers | ||
{ | ||
public class FlyoutItemHandler : ShellItemHandler | ||
{ | ||
public FlyoutItemHandler(EmblazonRenderer renderer, XF.FlyoutItem flyoutItemControl) : base(renderer, flyoutItemControl) | ||
{ | ||
FlyoutItemControl = flyoutItemControl ?? throw new ArgumentNullException(nameof(flyoutItemControl)); | ||
} | ||
|
||
public XF.FlyoutItem FlyoutItemControl { get; } | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/Microsoft.Blazor.Native/Elements/Handlers/ShellContentHandler.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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Emblazon; | ||
using System; | ||
using XF = Xamarin.Forms; | ||
|
||
namespace Microsoft.Blazor.Native.Elements.Handlers | ||
{ | ||
public class ShellContentHandler : BaseShellItemHandler | ||
{ | ||
public ShellContentHandler(EmblazonRenderer renderer, XF.ShellContent shellContentControl) : base(renderer, shellContentControl) | ||
{ | ||
ShellContentControl = shellContentControl ?? throw new ArgumentNullException(nameof(shellContentControl)); | ||
} | ||
|
||
public XF.ShellContent ShellContentControl { get; } | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/Microsoft.Blazor.Native/Elements/Handlers/ShellContentMarkerItem.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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using XF = Xamarin.Forms; | ||
|
||
namespace Microsoft.Blazor.Native.Elements.Handlers | ||
{ | ||
internal sealed class ShellContentMarkerItem : XF.ShellContent | ||
{ | ||
public ShellContentMarkerItem() | ||
{ | ||
// Set dummy content to ensure the item is valid | ||
Content = new XF.ContentPage(); | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/Microsoft.Blazor.Native/Elements/Handlers/ShellGroupItemHandler.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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Emblazon; | ||
using System; | ||
using XF = Xamarin.Forms; | ||
|
||
namespace Microsoft.Blazor.Native.Elements.Handlers | ||
{ | ||
public class ShellGroupItemHandler : BaseShellItemHandler | ||
{ | ||
public ShellGroupItemHandler(EmblazonRenderer renderer, XF.ShellGroupItem shellGroupItemControl) : base(renderer, shellGroupItemControl) | ||
{ | ||
ShellGroupItemControl = shellGroupItemControl ?? throw new ArgumentNullException(nameof(shellGroupItemControl)); | ||
} | ||
|
||
public XF.ShellGroupItem ShellGroupItemControl { get; } | ||
|
||
public override void ApplyAttribute(ulong attributeEventHandlerId, string attributeName, object attributeValue, string attributeEventUpdatesAttributeName) | ||
{ | ||
switch (attributeName) | ||
{ | ||
case nameof(XF.ShellGroupItem.FlyoutDisplayOptions): | ||
ShellGroupItemControl.FlyoutDisplayOptions = (XF.FlyoutDisplayOptions)AttributeHelper.GetInt(attributeValue); | ||
break; | ||
default: | ||
base.ApplyAttribute(attributeEventHandlerId, attributeName, attributeValue, attributeEventUpdatesAttributeName); | ||
break; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.