Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions app/controllers/controls/views/scrollableviewVertical.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { logger } from 'logger';

/**
* The scoped constructor of the controller.
**/
(function constructor() {

}());

function onPostLayout() {
$.toolbar.top = $.getView().safeAreaPadding.top + 10;
$.scrollable.bottom = $.getView().safeAreaPadding.bottom + 10;
}

function scrollToView() {
$.scrollable.scrollToView(1); // Index or view
}

function addNewView() {
const newView = Ti.UI.createView({
backgroundColor: 'rgba(' + _.random(0, 255) + ',' + _.random(0, 255) + ',' + _.random(0, 255) + ', 1.0)' // Generate rgba-color
});

$.scrollable.addView(newView);
logger.log('Ti.UI.ScrollableView added new view at index ' + ($.scrollable.views.length - 1));

validateButtons();
}

function removeLastView() {
$.scrollable.removeView($.scrollable.views[$.scrollable.views.length - 1]);
logger.log('Ti.UI.ScrollableView deleted last view');

validateButtons();
}

function scrollableViewDidScroll(e) {
logger.log('Ti.UI.ScrollableView did scroll to index ' + e.currentPage);
}

function validateButtons() {
$.remove.enabled = $.scrollable.views.length > 0;
$.scrollTo.enabled = $.scrollable.views.length >= 2;
}
1 change: 1 addition & 0 deletions app/views/controls/views/index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<ListItem title="Masked Image (Tint)" itemId="maskedimageTint" />
<ListItem title="Scroll View" itemId="scrollview" />
<ListItem title="Scrollable View" itemId="scrollableview" />
<ListItem title="Scrollable View (vertical)" itemId="scrollableviewVertical" platform="android"/>
<ListItem title="Table View" itemId="tableview" />
<ListItem title="View" itemId="view" />
<ListItem title="View (events)" itemId="view_events" />
Expand Down
24 changes: 24 additions & 0 deletions app/views/controls/views/scrollableviewVertical.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Alloy>
<Window title="Scrollable View (vertical)" layout="vertical" onPostlayout="onPostLayout">
<Toolbar id="toolbar" width="Ti.UI.FILL">
<Items>
<Button id="add" style="Ti.UI.BUTTON_STYLE_OPTION_POSITIVE" title="Add" onClick="addNewView"/>
<FlexSpace platform="ios"/>
<Button id="remove" style="Ti.UI.BUTTON_STYLE_OPTION_NEUTRAL" title="Remove Last" onClick="removeLastView"/>
<FlexSpace platform="ios"/>
<Button id="scrollTo" style="Ti.UI.BUTTON_STYLE_OPTION_NEUTRAL" title="Scroll to View 2" onClick="scrollToView"/>
</Items>
</Toolbar>
<ScrollableView id="scrollable" width="Ti.UI.FILL" height="Ti.UI.FILL" onScrollend="scrollableViewDidScroll" scrollType="vertical" showPagingControl="false">
<View id="view1" backgroundColor="#836">
<Label>View 1</Label>
</View>
<View id="view2" backgroundColor="#246">
<Label>View 2</Label>
</View>
<View id="view3" backgroundColor="#48b">
<Label>View 3</Label>
</View>
</ScrollableView>
</Window>
</Alloy>
2 changes: 1 addition & 1 deletion tiapp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,5 @@
<module platform="android">ti.identity</module>
<module platform="iphone">ti.identity</module>
</modules>
<sdk-version>13.1.1.GA</sdk-version>
<sdk-version>13.3.0.GA</sdk-version>
</ti:app>
Loading