Skip to content
This repository has been archived by the owner on Dec 18, 2017. It is now read-only.

Commit

Permalink
Merge pull request #38 from mvanbeusekom/issue_32
Browse files Browse the repository at this point in the history
Add support to configure menu icon
  • Loading branch information
martijn00 committed Sep 22, 2016
2 parents b75940a + 7ac5d1e commit c56c97f
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,33 @@ protected virtual void InitSidebar()
? SidebarPanelController.LeftSidebarController
: SidebarPanelController.RightSidebarController;

UIBarButtonItem barButtonItem;

var xamarinSidebarMenu = ViewController as IMvxSidebarMenu;
if (xamarinSidebarMenu != null)
{
sidebarController.HasShadowing = xamarinSidebarMenu.HasShadowing;
sidebarController.MenuWidth = xamarinSidebarMenu.MenuWidth;

barButtonItem = new UIBarButtonItem(xamarinSidebarMenu.MenuButtonImage
, UIBarButtonItemStyle.Plain
, (sender, args) => {
sidebarController.MenuWidth = xamarinSidebarMenu.MenuWidth;
sidebarController.ViewWillAppear(false);
sidebarController.ToggleMenu();
});
}
else
{
barButtonItem = new UIBarButtonItem("Menu"
, UIBarButtonItemStyle.Plain
, (sender, args) => {
sidebarController.ViewWillAppear(false);
sidebarController.ToggleMenu();
});
}

var barButtonItem = new UIBarButtonItem(UIImage.FromBundle("threelines")
, UIBarButtonItemStyle.Plain, (sender, args) =>
{
if (xamarinSidebarMenu != null)
sidebarController.MenuWidth = xamarinSidebarMenu.MenuWidth;
sidebarController.ViewWillAppear(false);
sidebarController.ToggleMenu();
});


var topViewController = SidebarPanelController.NavigationController.TopViewController;

sidebarController.ChangeMenuView(ViewController);
Expand All @@ -74,7 +85,6 @@ protected virtual void InitSidebar()
sidebarController.MenuLocation = MenuLocations.Right;
topViewController.NavigationItem.SetRightBarButtonItem(barButtonItem, true);
}

}
}
}
Expand Down
5 changes: 4 additions & 1 deletion MvvmCross.iOS.Support.XamarinSidebar/IMvxSidebarMenu.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
namespace MvvmCross.iOS.Support.XamarinSidebar
using UIKit;

namespace MvvmCross.iOS.Support.XamarinSidebar
{
public interface IMvxSidebarMenu
{
UIImage MenuButtonImage { get; }
bool HasShadowing { get; }
int MenuWidth { get; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,10 @@
<Name>MvvmCross.iOS.Support</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<BundleResource Include="Resources\threelines.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\twolines.png" />
</ItemGroup>
</Project>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions Samples/MvvmCross.iOS.Support.Sidebar/Setup.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using MvvmCross.iOS.Support.XamarinSidebar;

namespace MvvmCross.iOS.Support.Sidebar
{
using Platform;
Expand Down Expand Up @@ -34,6 +36,7 @@ protected override IMvxTrace CreateDebugTrace()
protected override IMvxIosViewPresenter CreatePresenter()
{
return new MvxSidebarPresenter((MvxApplicationDelegate)ApplicationDelegate, Window);
//return new MvxSidePanelsPresenter((MvxApplicationDelegate)ApplicationDelegate, Window);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
namespace MvvmCross.iOS.Support.Sidebar.Views
using UIKit;

namespace MvvmCross.iOS.Support.Sidebar.Views
{
using MvvmCross.Core.ViewModels;
using XamarinSidebar;

public class BaseMenuViewController<TViewModel> : BaseViewController<TViewModel>, IMvxSidebarMenu where TViewModel : class, IMvxViewModel
{
public bool HasShadowing => true;
public int MenuWidth => 320;
public virtual UIImage MenuButtonImage => UIImage.FromBundle("threelines");

public virtual bool HasShadowing => true;
public virtual int MenuWidth => 320;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

[Register("LeftPanelView")]
[MvxPanelPresentation(MvxPanelEnum.Left, MvxPanelHintType.ActivePanel, false)]
public class LeftPanelView : BaseViewController<LeftPanelViewModel>
public class LeftPanelView : BaseMenuViewController<LeftPanelViewModel>
{
/// <summary>
/// Called after the controller’s <see cref="P:UIKit.UIViewController.View"/> is loaded into memory.
Expand Down
2 changes: 2 additions & 0 deletions Samples/MvvmCross.iOS.Support.Sidebar/Views/RightPanelView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,7 @@ public override void ViewDidLoad()

);
}

public override UIImage MenuButtonImage => UIImage.FromBundle("twolines");
}
}

0 comments on commit c56c97f

Please sign in to comment.