Skip to content

Commit

Permalink
State button update (#8)
Browse files Browse the repository at this point in the history
* update

* Update README.md
  • Loading branch information
IeuanWalker authored Apr 12, 2023
1 parent 0e37966 commit 58f496d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Demo/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using StateButton;
using IeuanWalker.Maui.StateButton;

namespace App;

Expand All @@ -15,7 +15,7 @@ public static MauiApp CreateMauiApp()
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
fonts.AddFont("fa-solid-900.ttf", "FASolid900");
})
.ConfigureStateButton();
.UseStateButton();

return builder.Build();
}
Expand Down
11 changes: 2 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
| :memo: | This is a MAUI version of my [Xamarin NuGet](https://github.com/IeuanWalker/Xamarin.Forms.Breadcrumb) |
|---------------|:------------------------|

| :warning: | I havnt tested iOS <i>yet, (all should be fine though)</i> |
|---------------|:------------------------|

# Maui.Breadcrumb [![Nuget](https://img.shields.io/nuget/v/IeuanWalker.Maui.Breadcrumb)](https://www.nuget.org/packages/IeuanWalker.Maui.Breadcrumb) [![Nuget](https://img.shields.io/nuget/dt/IeuanWalker.Maui.Breadcrumb)](https://www.nuget.org/packages/IeuanWalker.Maui.Breadcrumb)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FIeuanWalker%2FMaui.Breadcrumb.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2FIeuanWalker%2FMaui.Breadcrumb?ref=badge_shield) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/8893845ed9bc4f208def01baae7cb6c6)](https://app.codacy.com/gh/IeuanWalker/Maui.Breadcrumb?utm_source=github.com&utm_medium=referral&utm_content=IeuanWalker/Maui.Breadcrumb&utm_campaign=Badge_Grade_Settings)
Expand All @@ -25,15 +22,11 @@ Install the [NuGet package](https://www.nuget.org/packages/IeuanWalker.Maui.Brea
Install-Package IeuanWalker.Maui.Breadcrumb
```

This control uses one of my other controls [StateButton](https://github.com/IeuanWalker/Maui.StateButton), this is to make this control accessible. So you'll need to add StateButton configuration method in the MauiProgram.cs -
```csharp
using StateButton;
```
This control uses one of my other controls, [StateButton](https://github.com/IeuanWalker/Maui.StateButton), this is to make this control accessible. Ao you'll need to register the using in the `MauiProgram.cs` on the `MauiAppBuilder`
```csharp
builder
.UseMauiApp<App>()
.UseMauiCommunityToolkit()
.ConfigureStateButton();
.UseStateButton();
```

To add to a page the first thing we need to do is tell our XAML page where it can find the Breadcrumb control, which is done by adding the following attribute to our ContentPage:
Expand Down
2 changes: 1 addition & 1 deletion Scr/Breadcrumb.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="IeuanWalker.Maui.StateButton" Version="1.0.1" />
<PackageReference Include="IeuanWalker.Maui.StateButton" Version="1.1.1" />
</ItemGroup>

<ItemGroup>
Expand Down
11 changes: 6 additions & 5 deletions Scr/Breadcrumb.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.ComponentModel;
using IeuanWalker.Maui.StateButton;
using Microsoft.Maui.Controls.Shapes;

namespace Breadcrumb;
Expand Down Expand Up @@ -179,7 +180,7 @@ async void BreadCrumbContainer_Loaded(object sender, EventArgs e)

// Add ChildAdded event to trigger animation
BreadCrumbContainer.ChildAdded += AnimatedStack_ChildAdded;

// Move BreadCrumb of selectedPage to start the animation
breadcrumb.TranslationX = Application.Current?.MainPage?.Width ?? 0;

Expand Down Expand Up @@ -211,14 +212,14 @@ async void BreadCrumbContainer_Loaded(object sender, EventArgs e)
Border BreadcrumbCreator(Page page, bool isLast, bool isFirst)
{
// Create border control for the breadcrumb
Border container = IsNavigationEnabled && !isLast ?
new StateButton.StateButton
Border container = IsNavigationEnabled && !isLast ?
new StateButton
{
ClickedCommand = new Command<Page>(async item => await GoBack(item).ConfigureAwait(false)),
ClickedCommandParameter = page
}
: new Border();

container.BackgroundColor = Colors.Transparent;
container.StrokeShape = new RoundRectangle
{
Expand All @@ -231,7 +232,7 @@ Border BreadcrumbCreator(Page page, bool isLast, bool isFirst)
container.SetBinding(BackgroundColorProperty, new Binding(isLast ? nameof(LastBreadcrumbBackgroundColor) : nameof(BreadcrumbBackgroundColor), source: new RelativeBindingSource(RelativeBindingSourceMode.FindAncestor, typeof(Breadcrumb))));

SemanticProperties.SetDescription(container, page.Title);

if (isFirst && FirstBreadcrumb is not null)
{
container.Content = new Image
Expand Down

0 comments on commit 58f496d

Please sign in to comment.