Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RefreshControl in listview is lost after switching between winodws. #217

Open
RavindraChherke opened this issue Feb 24, 2018 · 0 comments
Open

Comments

@RavindraChherke
Copy link

RavindraChherke commented Feb 24, 2018

Hi,

I am using this module and it works great on Titanium SDK 5.4.0. I am upgrading my project to support new Titanium SDK 7.0.2. I am using version 2.1.0 of this module.

Issue: I have ListView with refreshcontrol in two different windows. First time when I set the window as centerWindow , refreshcontrol works fine. But when I move to other window and come back to first one the refreshcontrol is gone. I don't want to reload the window everytime user switches between windows that's why I am creating and using window instance just once.

Please check the code below. I am not sure if the bug related to this module or related to Titanium SDK. Same code used to work fine with Titanium SDK 5.4.0.

Please help.
Thanks!

Operating System
  Name                        = Mac OS X
  Version                     = 10.13.3
  Architecture                = 64bit
  # CPUs                      = 8
  Memory                      = 16.0GB

Node.js
  Node.js Version             = 8.9.1
  npm Version                 = 5.5.1

Titanium CLI
  CLI Version                 = 5.0.14
  node-appc Version           = 0.2.41

Titanium SDKs
  7.0.2.GA
    Version                   = 7.0.2


Xcode
  9.1 (build 9B55) - Xcode default
    Install Location          = /Applications/Xcode.app/Contents/Developer
    iOS SDKs                  = 11.1
    iOS Simulators            = 11.1
    Watch SDKs                = 4.1
    Watch Simulators          = 4.1
    Supported by TiSDK 7.0.2.GA = yes
    EULA Accepted             = yes
    Teams                     = none
var NappDrawerModule = require('dk.napp.drawer');

var win1 = openNewNavWindow();
var win2 = openNewNavWindow();

function createAPIExampleWindow() {
	var win = Ti.UI.createWindow();

	var data = [{
		title : 'New Window'
	}, {
		title : 'New Window2'
	}];

	var tableView = Ti.UI.createTableView({
		data : data,
	});

	tableView.addEventListener('click', function(e) {
		Ti.API.info('isLeftWindowOpen: ' + drawer.isLeftWindowOpen());
		switch (e.index) {
		case 0:
			if (drawer.centerWindow != win1) {
				drawer.setCenterWindow(win1);
			}
			drawer.toggleLeftWindow();
			break;
		case 1:
			if (drawer.centerWindow != win2) {
				drawer.setCenterWindow(win2);
			}
			drawer.toggleLeftWindow();
			break;
		}
	});

	win.add(tableView);
	return win;
}

function openNewNavWindow() {
	var leftBtn = Ti.UI.createButton({
		title : 'Left'
	});
	leftBtn.addEventListener('click', function() {
		drawer.toggleLeftWindow();
	});
	var win = Ti.UI.createWindow({
		backgroundColor : '#222',
		translucent : true,
		extendEdges : [Ti.UI.EXTEND_EDGE_TOP],
		title : 'New Nav Window',
		barColor : '#FFA',
		tintColor : 'yellow',
		leftNavButton : leftBtn
	});

	var counter = 0;
	function genData() {
		var data = [];
		var i = 1;
		for ( i = 1; i <= 3; i++) {
			data.push({
				properties : {
					title : 'ROW ' + (counter + i)
				}
			});
		}
		counter += 3;
		return data;
	}

	var section = Ti.UI.createListSection();
	section.setItems(genData());
	var control = Ti.UI.createRefreshControl({
		tintColor : 'red'
	});
	var listView = Ti.UI.createListView({
		sections : [section],
		refreshControl : control
	});
	control.addEventListener('refreshstart', function(e) {
		Ti.API.info('refreshstart');
		setTimeout(function() {
			Ti.API.debug('Timeout');
			section.appendItems(genData());
			control.endRefreshing();
		}, 2000);
	});
	win.add(listView);

	var navController = Ti.UI.iOS.createNavigationWindow({
		window : win
	});
	return navController;
}

var mainWindow = win1;

var drawer = NappDrawerModule.createDrawer({
	leftWindow : createAPIExampleWindow(),
	centerWindow : mainWindow,
	rightWindow : Ti.UI.createWindow({
		backgroundColor : '#FFF'
	}),
	closeDrawerGestureMode : NappDrawerModule.CLOSE_MODE_ALL,
	openDrawerGestureMode : NappDrawerModule.OPEN_MODE_ALL,
	showShadow : false, //no shadow in iOS7
	leftDrawerWidth : 200,
	rightDrawerWidth : 120,
	statusBarStyle : NappDrawerModule.STATUSBAR_WHITE, // remember to set UIViewControllerBasedStatusBarAppearance to false in tiapp.xml
	orientationModes : [Ti.UI.PORTRAIT, Ti.UI.UPSIDE_PORTRAIT]
});

drawer.addEventListener('centerWindowDidFocus', function() {
	Ti.API.info('Center did focus!');
});

drawer.addEventListener('centerWindowDidBlur', function() {
	Ti.API.info('Center did blur!');
});

drawer.addEventListener('windowDidOpen', function(e) {
	Ti.API.info('windowDidOpen');
});

drawer.addEventListener('windowDidClose', function(e) {
	Ti.API.info('windowDidClose');
});

drawer.open();

Ti.API.info('isAnyWindowOpen: ' + drawer.isAnyWindowOpen());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant