titanium-sdk icon indicating copy to clipboard operation
titanium-sdk copied to clipboard

feat(android): refreshControl offset property

Open m1ga opened this issue 5 months ago • 1 comments

Adding a property to the RefreshControl: offset: {start,end}. The default RefreshControl spinner starts at 0 and goes down to around 80. With this property you can set custom values.

Native Android description: https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setProgressViewOffset(boolean,int,int)

var win = Ti.UI.createWindow();

var myTemplate = {
	childTemplates: [{
		type: 'Ti.UI.Label',
		bindId: "text",
	}]
};

const control = Ti.UI.createRefreshControl({
	offset: {
		start: 300,
		end: 400
	}
});
control.addEventListener("refreshstart", function() {
	setTimeout(function() {
		control.endRefreshing();
	}, 1000);
})

var listView = Ti.UI.createListView({
	templates: {
		'template': myTemplate
	},
	refreshControl: control,
	defaultItemTemplate: 'template'
});
var sections = [];
var items = [];
for (var i = 0; i < 50; ++i) {
	items.push({
		text: {
			text: "label " + i
		}
	})
}

var fruitSection = Ti.UI.createListSection({
	items: items
});
sections.push(fruitSection);

listView.sections = sections;
win.add(listView);
win.open();

m1ga avatar Jan 20 '24 16:01 m1ga