I am a student and have been officially stumped, I am trying to create an image gallery that opens to a screen then when a button is clicked the gallery opens, once the gallery opens users would be able to tap an image and see it in full size on another view and when they're done they can hit the close gallery button and return to the main screen.
here is my code...
In app.js:
var win = Ti.UI.createWindow({ title: "Gallery", modal: true, backgroundColor: "#2C3E50",
}); var navWindow = Ti.UI.iOS.createNavigationWindow({ window: win });
navWindow.open();
var grid = require("grid");
In grid.js //var views = 6;
var numberofCol = 4; var spacing = 4; var numberofSpace = (numberofCol + 1)* spacing; var platformWidth = Ti.Platform.displayCaps.platformHeight;
var viewsContainer = Ti.UI.createScrollView({ layout: "horizontal", //width: newWidth });
var imageList = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, "images"); var dirList = imageList.getDirectoryListing();
var newWidth = (platformWidth - numberofSpace) / dirList.length;
var makeViews = function(){ var imgWin = Ti.UI.createWindow({ title: "Photo Gallery", modal: true, layout: "horizontal" });
for(var i=0, j= dirList.length; i<j; i++){
var imageWrapper = Ti.UI.createView({
borderRadius: 5,
top: 20,
left:15,
width:75,
backgroundColor: "#fff",
//layout: "horizontal"
});
var img = Ti.UI.createImageView({
image: "images/" + dirList [i]
});
imageWrapper.add(img);
imgWin.add(imageWrapper);
viewsContainer.add(imgWin);
navWindow.openWindow(imgWin, {animation: true});
var newView = Ti.UI.createView({
top:4,
right:4,
left:4,
borderRadius: 5,
backgroundColor: "#fff",
width: newWidth,
height: 100
});
var newLable = Ti.UI.createLabel({
text: i,
textAlign: "center"
});
win.add(imageWrapper);
newView.add(newLable);
viewsContainer.add(newView);
}
};
var openButton = Ti.UI.createButton({ title: "View Gallery", color: "#000", font: {fontSize: 22, fontFamily: "arial"}, backgroundColor: "#D4D4D4", top: 360, width: 350, height:60
});
//makeViews(); openButton.addEventListener("click", makeViews); win.add(viewsContainer); win.add(openButton);