Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 325
Registered: ‎10-01-2012
My Device: Dev Alpha C, Playbook 32 GB
My Carrier: BleskMobil

What is best way to implement swipe style switch between views (similar style as Calendar has)?

Hello,

 

I would like to implement swipe style switch between views in container (similar like Calendar on Dev Alpha has).

 

Best would be if top part of the app could be the same and bottom part could be swiped.

 

What is best way how to do it? On Android we are using ViewPager for it (demo at http://youtu.be/AHKOEJSAqn8)

 

Is there ready made Cascades component or should I listen touch and move events and implement it by myself?

 

Thanks a lot

Tom

--------------------------------------------------------------------------------------------
-- My Blackberry 10 app at http://blackberry.hubalek.net
-- My Android apps at http://android.hubalek.net
Highlighted
Retired
Posts: 83
Registered: ‎10-10-2012
My Device: Z30
My Carrier: Bell

Re: What is best way to implement swipe style switch between views (similar style as Calendar has)?

Hi Tom,

 

>Is there ready made Cascades component

 

No

 

> I listen touch and move events and implement it by myself

 

Yes.

 

-garydev

Developer
Posts: 263
Registered: ‎05-18-2011
My Device: Curve 9300, BB10 Dev Alpha C, Z10

Re: What is best way to implement swipe style switch between views (similar style as Calendar has)?

Hi garydev,

Any progress for this since then?
--tom
Developer
Posts: 541
Registered: ‎05-17-2009
My Device: Not Specified

Re: What is best way to implement swipe style switch between views (similar style as Calendar has)?

Create a horizontal ListView that contains the different views. In the case of the calender, they could have used a horizontal ListView that contained vertical ListViews. By doing this, there's no need to do any custom touch detection for the swipes because ListView takes care of all of that.

Developer
Posts: 263
Registered: ‎05-18-2011
My Device: Curve 9300, BB10 Dev Alpha C, Z10

Re: What is best way to implement swipe style switch between views (similar style as Calendar has)?

But then, how can you know the current visible item on the screen?
--tom
Developer
Posts: 541
Registered: ‎05-17-2009
My Device: Not Specified

Re: What is best way to implement swipe style switch between views (similar style as Calendar has)?

[ Edited ]

 

The question is, for what purpose do you need to keep track of the position in the listview?

 

Options:

 

1) Theoretically you would be able to tell which section of the list view was on the screen by placing the listview in a scrollview and keeping track of the viewable area. The problem with doing this is that there is a bug that pops up when you put listviews within scrollviews that causes infinite scrolling - so this is out of the question for now. In future versions of the OS, this bug may be fixed.

 

2) If you need to know which section is in focus because you have trigger items like buttons, you can create the button with an index number which represents the viewable section index in the list. If the button gets triggered, you can emit the index that's stored in the button to communicate back to the controller which button was pressed at what index. 

 

3) Make a custom container that represents each vertical in the scrollview. This container would store its position in the horizontal scrollview (ie it's indexPath in the horizontal list view's DataModel). Connect the signals from all buttons or other triggerable items to this container. If the buttons are triggered, the custom container will catch it and it can respond knowing that it is the container currently in view.