Chapter 6

Integrating Comments

YOU WILL FOLLOW the same process used for creating the controllers in the previous chapter to create a comment.js controller and commentRow.js controller. The comment.xml view will hold a Titanium.UI.TableView, which will be a list of comments. The Titanium.UI.TableViewRow will be represented as the commentRow.xml views. This pattern is the exact same one you used in the previous chapter, so I will move quickly through the content.

Creating the Comment Table View Layout

You’ll first create the comment.xml view file, similar in layout to the feed.xml with some different button functionality. Here, I have added a newCommentButton, which will be used for creating new comments. You connect that functionality to the controller later in the chapter, but for now I am focusing on listing the comments associated with the photo selected.

I also have created the commentTable that will hold the list of comments added to the application and associated it with the currentPhoto.

<Alloy>    <Window id="commentWindow" title="Comments">        <RightNavButton>            <Button id="newCommentButton">Comment</Button>        </RightNavButton>        <TableView id="commentTable"></TableView>    </Window></Alloy>

Since you are building a cross-platform solution, you need to account for the differences in the Android solution. This code will work fine on iOS, but there are a few changes needed to support Android.

First, you do not have the concept of navigation buttons ...

Get Building Cross-Platform Apps using Titanium, Alloy, and Appcelerator Cloud Services now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.