eclipsesource / tabris-js

Create native mobile apps in JavaScript or TypeScript.
https://tabrisjs.com
BSD 3-Clause "New" or "Revised" License
1.4k stars 170 forks source link

how to set the background behind the navigation #1135

Closed ishigo1987 closed 7 years ago

ishigo1987 commented 7 years ago

Hello i want to set the background behind the navigationView i have no result when i set tabris.ui.set({ background: "red" }); How can i do?

mpost commented 7 years ago

While you can set the background of the NavigationView, it will not be visible through a page which has its own background. You can set the page background to transparent but that will show pages underneath when animating page transitions which is most likely not what you want.

mpost commented 7 years ago

btw... to set the background of your entire app window you would change the contentView background:

tabris.ui.contentView.background = 'red';
ishigo1987 commented 7 years ago

hello i have 3 questions Is it possible to have a back button when i jump to one navigationView to another one?if yes how can i enable it? Did you provide an event to handle the back button? thank you

cookieguru commented 7 years ago

Yes, it's as simple as appending a Page to your NavigationView.

tabris.app has a backnavigation event.

ishigo1987 commented 7 years ago

please can you answering to my questions more carefully i want to understand very deeply

ishigo1987 commented 7 years ago

can i have an example to how can i use the backnavigation event?

cookieguru commented 7 years ago

https://github.com/eclipsesource/tabris-js/blob/master/snippets/app.js#L38

cookieguru commented 7 years ago

Sorry, forgot to include the link to the stacked pages snippet for your first two questions.

ishigo1987 commented 7 years ago

thank you for the snippet about the backnavigation about my first question i think that i can't explain exactly my problem I try again i have one navigationView(A) with some pages inside and i have another navigationView(B) with some pages too My question: Is it possible to have a back button to jump to B -> A, how can i enable it

mpost commented 7 years ago

Adding to the snippets that @cookieguru already posted... this one is interesting when having multiple NavigationView instances: https://github.com/eclipsesource/tabris-js/blob/v2.0.0-beta1/snippets/navigationview-tabfolder.js#L52

mpost commented 7 years ago

@ishigo1987 Regarding your question... could you elaborate what you mean by "jump to B -> A"? Do you mean the physical back button or the back arrow on the NavigationView?

ishigo1987 commented 7 years ago

the back arrow on the navigationView.i want to know if i can have a back arrow to back to B navigationView to A navigationView

mpost commented 7 years ago

@ishigo1987 you will receive a disappear event when a page in the nav view is removed. Maybe that can help you. https://tabrisjs.com/documentation/latest/api/Page#disappear-widget

ishigo1987 commented 7 years ago

ok thank you

ishigo1987 commented 7 years ago

but my problem persist because i want to be able to go to B navigationView to A navigationView by press on the back arrow.you didn't provide this between 2 navigationView just between the pages inside one navigationView

mpost commented 7 years ago

So basically you want to intercept the back event from the navview and perform some arbitrary other action?

ishigo1987 commented 7 years ago

yes and i want that the user see the back arrow

mpost commented 7 years ago

Thanks for the input. We will consider this feature.

ishigo1987 commented 7 years ago

ok

cookieguru commented 7 years ago

@ishigo1987 Is your request the same as #880?

mpost commented 7 years ago

We have discussed the issue again, but due to the nature of the iOS NavigationController used in Tabris.js, we are not able to intercept the back event in a cross platform manor as discussed in #880. Additionally you can also edge-swipe on iOS which is technically similar to the back button press but can not be intercepted.

ishigo1987 commented 7 years ago

hello actualy i have this problem on android not on ios

ishigo1987 commented 7 years ago

i try one more time to explain my problem. OS:Android i have two differents navigationView with two differents pages

let navigationA = new tabris.NavigationView({
left: 0, top: 0, right: 0, bottom: 0, toolbarColor:themeColor, titleTextColor:"#fff"
}).appendTo(tabris.ui.contentView);
let pageViewA = new tabris.Page({
      title: `Connection`,
      background:`#fafafa`
    }).appendTo(navigationA);
let navigationB = new tabris.NavigationView({
left: 0, top: 0, right: 0, bottom: 0, toolbarColor:themeColor, titleTextColor:"#fff"
}).appendTo(tabris.ui.contentView);
let pageViewB = new tabris.Page({
      title: `Connection`,
      background:`#fafafa`
    }).appendTo(navigationB);

inside the pageViewA i have some kind of link to bring the user on the NavigationB->pageViewB when the user is on the pageViewB he has no back arrow to back to NavigationA->pageViewA My question is how to enable the back arrow in this case??

cookieguru commented 7 years ago

Don't create a NavigationView for the second page. Just create a Page and open it. See https://github.com/eclipsesource/tabris-js/issues/1135#issuecomment-279942579

ishigo1987 commented 7 years ago

I create another navigationview because i want to have a good animation like whatsapp by example(one view slideUp and cover the previous one) it's not possible inside the same navigationView(because i animate the navigationView not the page)

mpost commented 7 years ago

@ishigo1987 Two things come to mind.

  1. If you want to create a custom animation you can set the animated property on the NavigationView to false and create your own custom animation on the page (or rather its content).

  2. When you need to maintain the two different NavigationViews you could try to create a dummy page on navigationB underneath the pageViewB. Thereby you will see a back button on the navigationB. If you now set the animated flag to false you could use the disappear event on pageViewB to switch back to the navigationA.

ishigo1987 commented 7 years ago

2-When you need to maintain the two different NavigationViews you could try to create a dummy page on navigationB underneath the pageViewB. Thereby you will see a back button on the navigationB. If you now set the animated flag to false you could use the disappear event on pageViewB to switch back to the navigationA. @mpost I admit I am a little bit lost with your second explanation. Please can you provide me a snippet thank you

mpost commented 7 years ago

@ishigo1987 The idea is to disable animations and to use the disappear event to perform any logic you like (eg to show navigationA).

ishigo1987 commented 7 years ago

with the back arrow?

cookieguru commented 7 years ago

@ishigo1987 Yes, when the back arrow is pressed it will fire the disappear event on the page.

ishigo1987 commented 7 years ago

cookieguru please please please can i have a snippet to describe the situation with navigation A and navigation B

mpost commented 7 years ago

Closing this for now. Please create a new issue when questions remain.