I have an app with two levels of a LayoutAware pages with FlipViews.
GoBack is causing me headaches since it remembers my original navigation parameter instead of saving its last state when it was navigated away from.
Navigation flow:
1) MainPage:
Selecting an item navigates to the flip view page with the current item selected:
this.Frame.Navigate(typeof(ItemFlipViewPage), selectedItem1);
2) ItemFlipViewPage:
Set FlipView selected item based on LoadState navigation parameter (selectedItem1 in this example)
Change the FlipView's selected item (for example selectedItem3) and navigate to the GalleryFlipViewPage:
this.Frame.Navigate(typeof(GalleryFlipViewPage), selectedItem3_Image1);
3) GalleryFlipViewPage:
Clicking the GoBack button causes ItemFlpViewPage to be loaded with the original Navigation parameter of selectedItem1.
What's the best way to preserve my selected item on GoBack?
Set Page.NavigationCacheMode="Required".
Related
I need to SHOW a view when scroll is started and HIDE a view when scroll is stopped.
To detect the scroll movement, there is two ways:
Called when the user begins to drag the scroll view.
onScrollBeginDrag={this.showView}
onScrollEndDrag={this.hideView}
Called when the momentum scroll starts and Ends
onMomentumScrollBegin={this.showView}
onMomentumScrollEnd={this.hideView}
Exptected Behaviour:
If continues scroll is happening, it should not hide the view even onScrollEndDrag is called and still show the view until onMomentumScrollEnd.
If continues scroll is not active, its should hide when onScrollEndDrag called
Actual Behaviour:
If continues scroll is happening, its hide the view when onScrollEndDrag is called and shows the view again until onMomentumScrollEnd. So in between view is disappeared and then its appears when drag released.
Call a debounced function in onScroll.
Debouncing will mean it is called at the end (or start) of a bunch of
events. More Info
// Debounce
this.ViewVisibility = lodash.debounce(this.ViewVisibility, 100);
onScroll={() => {
this.ViewVisibility();
}}
ViewVisibility = () => {
console.log('Debouncing');
this.hideView();
}
My react component hierarchy looks like
StackNavigation
- MainScreen
- List
- Row
- Button
My usecase involves go to a new screen on click of the button. My main screen receives react-navigation's navigation props. How do I pass it down to my button in a sane manner.
You'd better pass a callback to your button through all the hierarchy and call it when button is pressed. Afterwards when you know which button is pressed (on which row) you can navigate to necessary screen from your MainScreen.
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());
When I create a new window in Appcelerator I need to change the background image. This is done by setting “barImage”. The window itself is a child of a navigation group and has its own children. When I use the “barImage” parameter it hides the nav bar title text on the initial load of the window. If I navigate to its child window and then back the title text is displayed in the nav bar.
var sectionWindow = Titanium.UI.createWindow({
backgroundColor:'#fff',
fullscreen:false,
title:’My Sub Page',
modal:true,
barImage:'images/nav_bar.png'
});
How can I get the title text to consistently display?
I believe there are known issues with the barImage in the 1.7.2 release, please check the 1.8x CI builds where the issue has been addressed
I have a component mxml in which I have a save button, on click of the save button I need to display another component which will be in a tab navigator, for this I am using the view stack. My problem is, on click of save I need to display the second tab instead of the first tab, but by default the first tab will be displayed.
How could this be accomplished?
I'll put a sample code piece on what my requirement was and how I did it.
In my main mxml i have a view stack
<mx:ViewStack id="loginViewStack" width="100%" height="100%">
<mx:ViewStack id="navigationViewStack" width="100%" height="100%">
<components:login id="id_login" label="Login"/>
<components:offering id="id_screen1" label="Screen1" />
</mx:ViewStack>
</mx:ViewStack>
Now say I completed successful login. I need to be taken to screen one, My screen (which is a component mxml). My screen contains a tab navigator and the requirement is I need to be taken to the second tab. So what I do is in the creation complete of my screen1 component I set the selectedIndex of my tab navigator to 1. and hurray! this solves the problem.
private function ():void
{
id_tabNavigator.selectedIndex = 1;
}