Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shell hamburger #5961

Merged
merged 4 commits into from Apr 25, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -79,8 +79,6 @@ public void OnClick(global::Android.Views.View v)
renderer1.OnClick();
else if (picker?.Parent?.Parent?.Parent is IPickerRenderer renderer2)
renderer2.OnClick();
else
throw new System.Exception("Renderer not found temp check for Shane things");
}
}
}
@@ -1,4 +1,5 @@
using CoreGraphics;
using Foundation;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
@@ -54,13 +55,15 @@ public Page Page
UISearchController _searchController;
SearchHandler _searchHandler;
Page _page;
NSCache _nSCache;

BackButtonBehavior BackButtonBehavior { get; set; }
UINavigationItem NavigationItem { get; set; }

public ShellPageRendererTracker(IShellContext context)
{
_context = context;
_nSCache = new NSCache();
}

public async void OnFlyoutBehaviorChanged(FlyoutBehavior behavior)
@@ -247,14 +250,55 @@ async Task SetDrawerArrowDrawableFromFlyoutIcon()
}
item = item?.Parent;
}
if (image == null)
image = "3bar.png";
var icon = await image.GetNativeImageAsync();

UIImage icon = null;

if (image != null)
icon = await image.GetNativeImageAsync();
else
icon = DrawHamburger();


var barButtonItem = new UIBarButtonItem(icon, UIBarButtonItemStyle.Plain, OnMenuButtonPressed);

barButtonItem.AccessibilityIdentifier = "OK";
NavigationItem.LeftBarButtonItem = barButtonItem;
}

UIImage DrawHamburger()
{
const string hamburgerKey = "Hamburger";
UIImage img = (UIImage)_nSCache.ObjectForKey((NSString)hamburgerKey);

if (img != null)
return img;

var rect = new CGRect(0, 0, 23f, 23f);

UIGraphics.BeginImageContextWithOptions(rect.Size, false, 0);
var ctx = UIGraphics.GetCurrentContext();
ctx.SaveState();
ctx.SetStrokeColor(UIColor.Blue.CGColor);

float size = 3f;
float start = 4f;
ctx.SetLineWidth(size);

for(int i = 0; i< 3; i++)
{
ctx.MoveTo(1f, start + i * (size * 2));

This comment has been minimized.

Copy link
@kingces95

kingces95 Apr 25, 2019

Member

Nice. Just like LOGO writer.

ctx.AddLineToPoint(22f, start + i * (size * 2));
ctx.StrokePath();
}

ctx.RestoreState();
img = UIGraphics.GetImageFromCurrentImageContext();
UIGraphics.EndImageContext();

_nSCache.SetObjectforKey(img, (NSString)hamburgerKey);
return img;
}

void OnMenuButtonPressed(object sender, EventArgs e)
{
_context.Shell.SetValueFromRenderer(Shell.FlyoutIsPresentedProperty, true);
Binary file not shown.
Binary file not shown.
@@ -40,9 +40,6 @@
<Reference Include="Xamarin.iOS" />
<Reference Include="System.Net.Http" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\3bar%402x.png" />
</ItemGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)ContextActionCell.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ContextScrollViewDelegate.cs" />
@@ -266,8 +263,5 @@
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\3bar.png" />
</ItemGroup>
<ItemGroup />
</Project>
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.