10-07-2012 02:31 PM
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
10-10-2012 09:42 AM
Hi Tom,
>Is there ready made Cascades component
No
> I listen touch and move events and implement it by myself
Yes.
-garydev
4 weeks ago
4 weeks ago
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.
4 weeks ago
4 weeks ago - last edited 4 weeks ago
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.