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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Cascades Development

Reply
Developer
thubalek
Posts: 296
Registered: ‎10-01-2012
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
Please use plain text.
BlackBerry Development Advisor
garydev
Posts: 1
Registered: ‎10-10-2012
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

Please use plain text.
Developer
tommy20
Posts: 183
Registered: ‎05-18-2011

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
Please use plain text.
Developer
superdirt
Posts: 503
Registered: ‎05-17-2009

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.

Please use plain text.
Developer
tommy20
Posts: 183
Registered: ‎05-18-2011

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
Please use plain text.
Developer
superdirt
Posts: 503
Registered: ‎05-17-2009

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.

 

 

 

 

Please use plain text.