Summary
I'm looking to have a single MvvmCross solution for iOS and Android that implements FlyoutNavigation/hamburger menu/sliding menu for the navigation.
Sample Code
https://github.com/benhysell/V.FlyoutTest
Problem
The Android project works without issue, the iOS project is taking the Views and doubling the frame size. I'm not sure if its because of how I'm using the FlyoutNavigation
component on iOS, or something I'm doing with using FlyoutNavigation
in MvvmCross. I played around with custom ViewPresenters without any luck.
Detailed Problem Description
I've seen several solutions to implementing a FlyoutNavigation/hamburger menu/sliding menu for MvvmCross, but none of the implementations address both Android and iOS in a unified solution. Each method had their own Core project and then their own ideas on where to put the menu data, manage views, etc.
Thus I set out to create one unified architecture.
See https://github.com/benhysell/V.FlyoutTest for the working demo of a single solution with both iOS and Android projects that both implement a FlyoutNavigation/hamburger menu/sliding menu.
I found and followed http://motzcod.es/post/60427389481/effective-navigation-in-xamarin-android-part-1, source: https://github.com/jamesmontemagno/Xam.NavDrawer for the Android project, and it works great. The Android project uses a native navigation drawer with fragments and swaps Views
in and out nicely.
In my solution using this architecture I have three main ViewModel
s...HomeViewModel
, EnterTimeViewModel
, and CreateNewJobViewModel
. HomeViewModel
holds the sliding menu data, the other two provide the views the user would interact with. In my example I'm creating an hours entry application, thus a user can enter time against a job, or create a new job.
To use my ViewModel
s in iOS I decided to use the FlyoutNavigation
component, https://github.com/Clancey/FlyoutNavigation. I attempted to use the links/projects described in http://slodge.blogspot.com/2013/07/awesome-sliding-menus-from-big-frank.html, but was not successful augmenting their implementation with the already established .Core project that the Android project was dependent on.
I was able to quickly implement the FlyoutNavigation
component in my HomeView
in iOS and I thought I was free and clear, but the Views
themselves are 2x the size they should be on the device. In the screen shots the titles of 'Enter Time' and 'Create New Job' should be centered, like any other title in MvvmCross, but are way off to the right. See the three screen shots of 'Enter Time' View, the menu open, and 'Create New Job' View. ::I used the Pause button for a quick and dirty 'hamburger'::
It feels like I'm missing something simple/I need to implement a custom ViewPresenter
for iOS, but my attempts to follow others have not been successful. Thoughts on a direction I should be taking/things I should be trying?
Found it! @Stuart pointed me in the correct direction!
I do not proclaim this is the cleanest solution for Android and iOS menus...but it is a start.
To solve my resizing issues I changed where I was setting the FlyoutNavigation
View.Frame
and View.Bounds
to ViewWillAppear
in HomeView
.
public override void ViewWillAppear(bool animated)
{
base.ViewWillAppear(animated);
navigation.View.Frame = UIScreen.MainScreen.Bounds;
navigation.View.Bounds = UIScreen.MainScreen.Bounds;
}
Updated code is posted to github https://github.com/benhysell/V.FlyoutTest