Clancey / FlyoutNavigation

Other
95 stars 87 forks source link

FlyoutNavigationController is not a UINavigationController #17

Closed jonathanpeppers closed 6 years ago

jonathanpeppers commented 11 years ago

Let's say you have a menu item in the left that has nested items, such as:

       flyout.NavigationRoot = new RootElement(string.Empty)
        {
            new Section()
            {
                new ImageStringElement("Book", NavigateToBook, Theme.PanelIconBook),
                new ImageStringElement("Activities", NavigateToActivities, Theme.PanelIconActivity),
                new ImageStringElement("Notes", NavigateToNotes, Theme.PanelIconPencil),
                new ImageStringElement("Bookmarks", NavigateToBookmarks, Theme.PanelIconBookmark),
                new ImageStringElement("Presentations", NavigateToPresentations, Theme.PanelIconPresentation),
                new RootElement("Settings")
                {
                    new Section()
                    {
                        new StringElement("Change Password"),
                        new StringElement("Log Out"),
                    }
                },
            },
        };

The bottom "Settings" item appears modally because MonoTouch.Dialog can't find a valid NavigationController to push to. This isn't proper iOS navigation for nesting elements, it looks kind of strange.

Making FlyoutNavigationController a UINavigationController might be a way to support this, but I'll leave the implementation details up to you.

Clancey commented 11 years ago

Are you trying to have it push and pop inside the sidebar?

jonathanpeppers commented 11 years ago

Yeah, I think this is a common feature people will want. Mine has Settings->Change Password or Log Out.

jonathanpeppers commented 11 years ago

MonoTouch.Dialog supports it, it just needs a nav controller.

Clancey commented 11 years ago

I am worried about the implications on main navigation. Right now it is a 1:1 mapping between the ViewControllers array and the Dialog View Controller. Allowing multiple depths adds complexity to the API design. I think this would be a complete redesign to make that work while not complicating the API.

On Tuesday, April 9, 2013 at 1:10 PM, Jonathan Peppers wrote:

MonoTouch.Dialog supports it, it just needs a nav controller.

— Reply to this email directly or view it on GitHub (https://github.com/Clancey/FlyoutNavigation/issues/17#issuecomment-16136990).

jonathanpeppers commented 11 years ago

One option is to use a Dictionary<int, UIViewController> instead of UIViewController[] as the list of controllers. Then the developer could choose certain rows to do something different than replace the controller

Another option is for me to roll my own I guess, I have wanted to use this library on 2 apps because it works well -- I have not ever been able to use it straight out of the box. The previous project I had to setup my own UITableViewSource and overwrite everything.

Clancey commented 11 years ago

You can pass in null for the view controller at that index, that would work. But like I said, once it switches screens that array wouldn't align anymore.

James Clancey

On Tuesday, April 9, 2013 at 1:29 PM, Jonathan Peppers wrote:

One option is to use a Dictionary instead of UIViewController[] as the list of controllers. Then the developer could choose certain rows to do something different than replace the controller Another option is for me to roll my own I guess, I have wanted to use this library on 2 apps because it works well -- I have not ever been able to use it straight out of the box. The previous project I had to setup my own UITableViewSource and overwrite everything.

— Reply to this email directly or view it on GitHub (https://github.com/Clancey/FlyoutNavigation/issues/17#issuecomment-16138009).

Clancey commented 11 years ago

I do that with gMusic. The switch row has null passed in at that index. I then do something based on the switch value change. http://screencast.com/t/kYQ1IvhxgBpe

The real issues comes, this was designed as a replacement for the tabview controller. Just a one dimensional array.

James Clancey

On Tuesday, April 9, 2013 at 1:31 PM, James Clancey wrote:

You can pass in null for the view controller at that index, that would work. But like I said, once it switches screens that array wouldn't align anymore.

James Clancey

On Tuesday, April 9, 2013 at 1:29 PM, Jonathan Peppers wrote:

One option is to use a Dictionary instead of UIViewController[] as the list of controllers. Then the developer could choose certain rows to do something different than replace the controller Another option is for me to roll my own I guess, I have wanted to use this library on 2 apps because it works well -- I have not ever been able to use it straight out of the box. The previous project I had to setup my own UITableViewSource and overwrite everything.

— Reply to this email directly or view it on GitHub (https://github.com/Clancey/FlyoutNavigation/issues/17#issuecomment-16138009).

jonathanpeppers commented 11 years ago

I think I'm just going to fork this -- it is a decent starting point and I can add the features I'm needing.

I'll probably drop MT.Dialog while I'm at it for my version.

Clancey commented 11 years ago

I have already started removing MT.d myself ;)

James Clancey

On Tuesday, April 9, 2013 at 1:34 PM, Jonathan Peppers wrote:

I think I'm just going to fork this -- it is a decent starting point and I can add the features I'm needing. I'll probably drop MT.Dialog while I'm at it for my version.

— Reply to this email directly or view it on GitHub (https://github.com/Clancey/FlyoutNavigation/issues/17#issuecomment-16138330).

Clancey commented 11 years ago

If you keep it generic enough, and the API stays simple I can help and/or take pull requests.

James Clancey

On Tuesday, April 9, 2013 at 1:34 PM, James Clancey wrote:

I have already started removing MT.d myself ;)

James Clancey

On Tuesday, April 9, 2013 at 1:34 PM, Jonathan Peppers wrote:

I think I'm just going to fork this -- it is a decent starting point and I can add the features I'm needing. I'll probably drop MT.Dialog while I'm at it for my version.

— Reply to this email directly or view it on GitHub (https://github.com/Clancey/FlyoutNavigation/issues/17#issuecomment-16138330).

rohithc commented 10 years ago

Do we have an example of using the flyout naviagtion component with a nested navigation? It works well on the first dimension but when i navigate to a new view when selecting the row item on one of the tabe view, it goes to the view but I loose the navigation stack to go back. Is there a workaround for this?

Clancey commented 10 years ago

just give each one its own view controller. menu.ViewControllers = new []{ new UINavigationController(new VC1()), new UINavigationController(new VC1()), }

James Clancey

Xamarin Evolve 2014 tickets go on sale April 10th. Sign up here (http://www.xamarin.com/evolve/2014) for early registration access.

On Saturday, March 22, 2014 at 3:40 PM, rohithc wrote:

Do we have an example of using the flyout naviagtion component with a nested navigation? It works well on the first dimension but when i navigate to a new view when selecting the row item on one of the tabe view, it goes to the view but I loose the navigation stack to go back. Is there a workaround for this?

— Reply to this email directly or view it on GitHub (https://github.com/Clancey/FlyoutNavigation/issues/17#issuecomment-38361925).

rohithc commented 10 years ago

Thanks Clancey. I got the first part working as in the sample. I have the menu like this

var navigation = new FlyoutNavigationController { // Create the navigation menu NavigationRoot = new RootElement ("Navigation") { new Section ("Pages") { new StringElement ("View 1"), new StringElement ("View 2"), new StringElement ("View 3"), } }, // Supply view controllers corresponding to menu items: ViewControllers = new [] { new UINavigationController (new ViewController1()), new UINavigationController (new ViewController2()),, new UINavigationController (new ViewController3()),, }, };

And this works. Also I have a left bar button item image to represent the burger menu(google or facebook style). ?Now when I click on one of the table cells in the viewcontroller 1 and navigate to another view with NavigationController.PushViewController(new ViewController4(), true); and it does navigate to the new view. But i dont have the back option as we normally have to go back to viewcontroller 3.

Clancey commented 10 years ago

That is caused by your Hamburger menu.
You only set it on the root view controllers. You can do it one of 2 ways, Set a flag on the root views, or you can check the vc.NavigationController.ViewControllers.Length and base it that way.

James Clancey

Xamarin Evolve 2014 tickets go on sale April 10th. Sign up here (http://www.xamarin.com/evolve/2014) for early registration access.

On Saturday, March 22, 2014 at 4:30 PM, appcoder wrote:

Thanks Clancey. I got the first part working as in the sample. I have the menu like this var navigation = new FlyoutNavigationController { // Create the navigation menu NavigationRoot = new RootElement ("Navigation") { new Section ("Pages") { new StringElement ("View 1"), new StringElement ("View 2"), new StringElement ("View 3"), } }, // Supply view controllers corresponding to menu items: ViewControllers = new [] { new UINavigationController (new ViewController1()), new UINavigationController (new ViewController2()),, new UINavigationController (new ViewController3()),, }, };
And this works. Also I have a left bar button item image to represent the burger menu(google or facebook style). ?Now when I click on one of the table cells in the viewcontroller 1 and navigate to another view with NavigationController.PushViewController(new ViewController4(), true); and it does navigate to the new view. But i dont have the back option as we normally have to go back to viewcontroller 3.

— Reply to this email directly or view it on GitHub (https://github.com/Clancey/FlyoutNavigation/issues/17#issuecomment-38363145).

rohithc commented 10 years ago

Thanks. That works. Is there any way we can have both the menu indicator and the navigation back stack button. I am not sure if any apps have it like that though

Clancey commented 10 years ago

Sure, you need to create your own back button. Just set the left bar buttons.

Sent from my iPhone

On Mar 22, 2014, at 7:09 PM, appcoder notifications@github.com wrote:

Thanks. That works. Is there any way we can have both the menu indicator and the navigation back stack button. I am not sure if any apps have it like that though

— Reply to this email directly or view it on GitHub.

hashbrown229 commented 9 years ago

var frame = mainView.Frame; This code throws nullReferanceException Error while i run the solution. My flyout menu had the same problem, when i clicks on menu button once after login! it doesn't allow me to navigate. I have used your given code above. but now its throws "nullReferanceException".

73 FlyoutNavigationController.cs File

public override void ViewWillAppear(bool animated) { CGRect navFrame = navigation.View.Frame; navFrame.Width = menuWidth; if (Position == FlyOutNavigationPosition.Right) navFrame.X = mainView.Frame.Width - menuWidth; navFrame.Location = CGPoint.Empty; navigation.View.Frame = navFrame; View.BackgroundColor = NavigationTableView.BackgroundColor;

        var frame = mainView.Frame;

        setViewSize ();
        SetLocation (frame);
        navigation.OnSelection += NavigationItemSelected;
        base.ViewWillAppear(animated);
    } 

MainController.cs File

public override void ViewDidLoad () { base.ViewDidLoad ();

        // Create the flyout view controller, make it large,
        // and add it as a subview:
        navigation = new FlyoutNavigationController ();
        navigation.Position = FlyOutNavigationPosition.Left;
        navigation.View.Frame = UIScreen.MainScreen.Bounds;
        View.AddSubview (navigation.View);
        this.AddChildViewController (navigation);

        navigation = new FlyoutNavigationController {
            NavigationRoot = new RootElement ("Access") {
                new Section ("Pages") {
                    new StringElement ("Login"),
                    new StringElement ("Home Page"),
                    new StringElement ("Search"),
                }
            },
            //Supply viewcontroller
            ViewControllers = new [] {
                new UINavigationController (new MyStoryboardViewController ()),
                new UINavigationController (new HomePageViewController ()),
                new UINavigationController (new SearchPageViewController ()),
            },

        };

What should be the changes ??

jonathanpeppers commented 6 years ago

This is so old, it should be closed.