XAML Xamarin Forms navigation drawer sample code for iOS/Android - xaml

Does anyone know how a navigation drawer similar to the one in the Sonos app can be implemented? I have checked both Android and iOS versions of the app and see that the navigation drawer has been implemented in the same way for both platforms.
The two key things that I like and want to implement are:
the slide out drawer is below the navigation bar. When it slides out, the navigation bar is still visible
it appears as if it is the drawer that slides out, rather than the detail view moving to the right. I've noticed that the default master detail page slides out in a different way and it's not what we want.
Have a look at the images below so see I mean.
thanks

Although not technically a good practice, if you put a MasterDetailPage into a NavigationPage, it will slide out like in the above pictures. Here's how you do that:
In the App.cs constructor or your app's OnStart() method:
MainPage = new NavigationPage(new MyMasterDetailPage()) {
Title = "Your Title"
};
Create a new MasterDetailPage called MyMasterDetailPage.
In the constructor, add the following code:
Detail = new HomePage();
Master = new MenuPage()
{
Title = "Menu"
};
You then need to create a ContentPage for both HomePage and MenuPage.
One issue that you will run into if you use this method, is that if you don't call MyMasterDetailPage as the first page upon opening the app, the three horizontal bars on the NavigationBar won't appear, which will make it hard for users to tell there is a drawer. So if you need users to go to a login page or another page before your MasterDetailPage, you may want to find another implementation.

Related

What is react-native component doing when the component is in background

What is react-native component doing when the component is in background?
And What will react-native do when component re-active to foreground?
Like Page A navigate to Page B.
And Page B back to Page A.What happened to A and B?
Is there any ui update like onResume on Android or something?
Edit:
I have a TabNavagation with four tab.One of the tabs renders an Android UI Component which is a custom frameLayout(a listview is in the frameLayout).
When the frameLayout first rendered, the listview position is not correct(position is -4 item height).But when I navigate to a child page and goback, I found that the frameLayout is correct now and does't enter any android lifecycle.
So I'm wondering is it doing something background?
It is hard to tell without detail information on what type of navigation you are using but I can explain it considering you are using common navigation packages.
If your navigation is some sort of stack navigation, when you navigate/push a new screen to view the previous screen lays under the stack and doesn't un-mount. It is much like dealing a deck of card to a pile. It doesn't re-render unless the props or state of that specific component changes. When you navigate back the new screen un-mounts and the previous screen shows back.
Common packages lets you to pass props to the next screen and if you need to re-render a previous component a easy hack to achieve this by sending a function from the previous component and running it on componentWillUnmount life-cycle event of the current screen. I explained this sort of usage in this answer.
After debug many many times, I found that it is the react-navigation.
Four tabs in homepage with bottom tabbar.When I enter a child page with navigationOptions:{header:null}, the bottom bar is gone. And when I goback from the child page, the bottom bar has back meanwhile and the whole view has corrected.Seems the whole view is re-draw?So I called view.requestLayout() in createViewInstance().So the final result is the view need to requestLayout manual.
UPDATE:
answer top is not totally correct.The final problem is the custom view should measure self in its requestLayout.
I found the answer in https://github.com/facebook/react-native/issues/4990
#Override
public void requestLayout() {
super.requestLayout();
post(measureAndLayout);
}
private final Runnable measureAndLayout = new Runnable() {
#Override
public void run() {
measure(MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(getHeight(), MeasureSpec.EXACTLY));
layout(getLeft(), getTop(), getRight(), getBottom());
}
};
And thanks for your answers.#bennygenel #Jouke

How to show navigation page button on all views Xamarin Forms

I am working with Xamarin Forms and I am using MasterDetailPage and NavigationPage and everything is working. Now, I need to configure the page button (three bars on the left) to be visible on all views.
I have a MasterDetailPage with a menu and the user clicks a menu its navigate to other pages. First page (homepage) look like that:
<MasterDetailPage.Detail>
<NavigationPage>
<x:Arguments>
<home:HomePage />
</x:Arguments>
</NavigationPage>
</MasterDetailPage.Detail>
When the user clicks in menu inside masterdetailpage or other menus outside masterdetailpage it performs a navigation:
The three bars page button is visible only on the first view, when I navigate to others views, that button disapears.
But, I want something like that:
The page back button showns automatically when i navigate to other pages and it's fine.
How to let the three bars page button visible to all views and maintain the back page button?
I am using the following code to navigate between views:
await Navigation.PushAsync(MyNewPage());
Thanks!
Your master detail page has to handle the navigation to the detail pages for it to work correctly.
Connect the menu listview:
ListView.ItemSelected += OnItemSelected;
In the OnItemSelected event.
{MasterDetailPage}.Detail.Navigation.PushAsync(new MyNewPage());
Here is an example of master detail navigation:
async void OnItemSelected(object sender, SelectedItemChangedEventArgs e)
{
var item = e.SelectedItem as MasterPageItem;
if (item != null)
{
NavigationPage nextDetailPage = null;
await Task.Run(() =>
{
nextDetailPage = new NavigationPage((Page)Activator.CreateInstance(item.TargetType));
});
Detail = nextDetailPage;
masterPage.ListView.SelectedItem = null;
IsPresented = false;
}
}
This is not possible, as you can't have two buttons on the left side. And as many applications I have seen, no app supports this kind of UI. Unless you write custom navigation bar and put it on top of every page.
You can create a stack of detail pages in your main MasterDetailPage. So whenever you want to push a new page, instead you can just set page as Detail and put old Detail in your own stack.
For Android you can wrap back button event to pop page from stack, but on iOS there is no back button, so you will have to create some sort of back button in detail page's toolbar.
I think that you will have to write a Custom Renderer to achieve what you want.
But if you want only to keep the hamburger button, without the back button, you can navigate to your pages using this code:
Detail = new NavigationPage(new MyNewPage());

React Native NavigatorExperimental - Combine AnimatedView with CardStack

i 've a NavigationAnimatedView which rendering a ListView with pushed DetailsView.
In the NavigationHeader, on the rightComponent, i have a button and i want to display a view with NavigationCardStack from bottomToTop. How can i combine the two modes of navigation ?
Like the filters button on the F8 app on the home screen.
i don't understand how with a dispatch action (navigatePush ?) on the FiltersButton, i can't switch with a navigationCardStack to display a FilterViews from BottomToTop.
You can provide props to NavigationCard when you render it:
_renderScene(props) {
return (
<NavigationCard
style={NavigationCardStackStyleInterpolator.forVertical(props)}
...
Sorry that part isn't documented very well right now!

UWP Page Transition Animations

I programing in Windows 10 UWP.
I have a Frame in Xaml that I would like to have the Page/Content to slide left and off screen when the use navigates away from the page to another page. Any Idea how to do Frame Navigation Animations?
Try to use build-in animation:
protected virtual void SetUpPageAnimation()
{
TransitionCollection collection = new TransitionCollection();
NavigationThemeTransition theme = new NavigationThemeTransition();
var info = new ContinuumNavigationTransitionInfo();
theme.DefaultNavigationTransitionInfo = info;
collection.Add(theme);
this.Transitions = collection;
}
Call this method in Page's constructor and you will find that there will be animation when you enter or leave a Page.
There are few build-in animations which names end with Info, you should try them by yourself.
There's a built-in way to do this, but that only supports a set of not customizable animations / page transitions.
If you want to do custom animations you'll need to implement your own Frame + Page subclasses, where your Pages contain their own entrance/leaving animations and your Frame calls these when navigating.

Sencha Touch 2.1 calling another view based on MVC

Using ST 2.1 and MVC I am trying to call another view. Shouldn't I have a view and a controller for each panel? If needed of course. I think a static about page will not need a controller.
So my layout would be.
app
controller
Main.js
Contact.js
view
Main.js
Contact.js
About.js
resources
css
images
app.js
index.html
Here is my overall project structure.
My app.js calls Main.js. This is my main view and controller. My Main view extends Container. On the Main view I have created a titlebar with left and right buttons and a title. Then I created a panel that holds my main buttons. Then I created a toolbar at the bottom that just has an image.
I want my Main container to change the panel in the middle but keep the top and bottom bars. Each of my views is a panel with various things on them. I can get the overall screen to change but it takes my titlebar and toolbar with it.
I hope this is enough info. Thanks, Donnie
If you want to change just the panel you have to put that panel as item into parent panel. When you want to change this panel with other panel or anything else just get reference of parent panel and remove existing content before adding new panel.
var p = Ext.getCmp("myPanel");
var pp = Ext.getCmp("parentPanel");
var newPanel = Ext.create('Ext.panel', {html : "some content"});
pp.remove(p, true);
pp.add(newPanel);
PS - I haven't tested this code, its just guideline.