Skip to content

Commit

Permalink
Merge pull request MvvmCross#45 from MarcBruins/develop
Browse files Browse the repository at this point in the history
Rotate dynamic width for menu
  • Loading branch information
martijn00 committed Oct 10, 2016
2 parents c677333 + 2ba7ef6 commit 5bc8776
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ protected virtual void InitSidebar()
var xamarinSidebarMenu = ViewController as IMvxSidebarMenu;
if (xamarinSidebarMenu != null)
{

sidebarController.HasShadowing = xamarinSidebarMenu.HasShadowing;
sidebarController.MenuWidth = xamarinSidebarMenu.MenuWidth;

barButtonItem = new UIBarButtonItem(xamarinSidebarMenu.MenuButtonImage
, UIBarButtonItemStyle.Plain
Expand All @@ -59,18 +59,22 @@ protected virtual void InitSidebar()
sidebarController.ViewWillAppear(false);
sidebarController.ToggleMenu();
});

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


var topViewController = SidebarPanelController.NavigationController.TopViewController;

sidebarController.ChangeMenuView(ViewController);
Expand Down
2 changes: 1 addition & 1 deletion MvvmCross_iOSSupport.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvvmCross.iOS.Support", "Mv
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SideMenuSample", "SideMenuSample", "{19AB8DF5-4F81-4E53-9CB7-FAFC410E98C7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvvmCross.iOS.Support.iOS", "Samples\SideMenuSample\MvvmCross.iOS.Support.iOS\MvvmCross.iOS.Support.iOS.csproj", "{4B3F7784-069E-47EE-903A-25542CCF03C3}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvvmCross.iOS.Support.Sidepanels", "Samples\SideMenuSample\MvvmCross.iOS.Support.iOS\MvvmCross.iOS.Support.Sidepanels.csproj", "{4B3F7784-069E-47EE-903A-25542CCF03C3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvvmCross.iOS.Support.Core", "Samples\SideMenuSample\MvvmCross.iOS.Support.Core\MvvmCross.iOS.Support.Core.csproj", "{760EE7E0-BC68-46A7-8AB3-4BE2D8C806FA}"
EndProject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ 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
Expand Up @@ -10,6 +10,16 @@ public class BaseMenuViewController<TViewModel> : BaseViewController<TViewModel>
public virtual UIImage MenuButtonImage => UIImage.FromBundle("threelines");

public virtual bool HasShadowing => true;
public virtual int MenuWidth => 320;
private int MaxMenuWidth = 300;
private int MinSpaceRightOfTheMenu = 55;

public int MenuWidth => UserInterfaceIdiomIsPhone ?
int.Parse(UIScreen.MainScreen.Bounds.Width.ToString()) - MinSpaceRightOfTheMenu : MaxMenuWidth;

private bool UserInterfaceIdiomIsPhone
{
get { return UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone; }
}

}
}

0 comments on commit 5bc8776

Please sign in to comment.