using CoreGraphics;
+using Foundation;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
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)
}
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));
+ 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);
<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" />
<Compile Include="$(MSBuildThisFileDirectory)GlobalCloseContextGestureRecognizer.cs" />
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
</ItemGroup>
- <ItemGroup>
- <BundleResource Include="Resources\3bar.png" />
- </ItemGroup>
<ItemGroup />
</Project>
\ No newline at end of file