Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20139] iOS Peek & Pop: Events do not include itemIndex, sectionIdex, itemId for TableView

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2015-12-16T19:58:08.000+0000
Affected Version/sRelease 5.1.1
Fix Version/sRelease 5.4.0
ComponentsiOS
Labels3dtouch, peekandpop, qe-5.4.0, tableview
ReporterJason Kneen
AssigneeHans Knöchel
Created2015-12-14T12:56:51.000+0000
Updated2016-06-09T18:09:18.000+0000

Description

When attempting to use Peek and Pop with a Tableview previewContext property, no index properties are provided when a row is clicked, making it impossible to display row-specific information / content. Code missing TableView implementation: https://github.com/appcelerator/titanium_mobile/blob/a8b6440f99f7d1eb945ba92a1fe3e6602fbcc1ec/iphone/Classes/TiPreviewingDelegate.m#L112-L160

Comments

  1. Fokke Zandbergen 2015-12-14

    Looks like we forgot to implement TIMOB-19763 for TableViews as we did for ListViews.
  2. Hans Knöchel 2015-12-14

    We didn't implement the features because we don't support new features for the (legacy) Ti.UI.TableView anymore. Developers should use Ti.UI.ListView for new features like peek and pop.
  3. Jason Kneen 2015-12-14

    There are sometimes good reasons for using a tableview and to limit the features to list view when it *appears* that it's easy enough to implement with a tableview (I've got a basic version working by using touch start to get the index) doesn't make any sense to me. Basically this is forcing us to use listviews for apps where we want peek and pop but that might not be the right list based solution for us -- apparently the fix is quite easy?
  4. Fokke Zandbergen 2015-12-14

    Well, we did implement it in part: https://github.com/appcelerator/titanium_mobile/blob/a8b6440f99f7d1eb945ba92a1fe3e6602fbcc1ec/iphone/Classes/TiPreviewingDelegate.m#L122-L129 And do document it (by inheritance) here: http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.TableView-property-previewContext And since there's still quite some use cases which ListView doesn't support I think we do need to add this to TableView as well.
  5. Hans Knöchel 2015-12-14

    The only reason it's in the docs is because we apply it to every TiViewProxy by default from which the table view inherits. We could plan it for some later release, but since we are after code freeze for 5.2, I'm not sure if we should hype this up. The Ti.UI.TableView will most likely be deprecated in the future, so we encourage developers to migrate the API since 3 years now :-)
  6. Jason Kneen 2015-12-14

    So because of something that could happen "in the future" you're not going to solve this problem now?
  7. Hans Knöchel 2015-12-14

    No, because it's no critical bug right now + we provide an API to fix it on the developer side + we are after code freeze for 5.2.0. Thats why.
  8. Jason Kneen 2015-12-14

    wow. ok. closing ticket.
  9. Hans Knöchel 2015-12-14

    Relax, all good :-) Just means, that it cannot be addressed right now, but for a 5.2.1 Release (or 5.2.0 backport). Since I'm off in december, maybe [~apetkov] can help?
  10. Tim Poulsen 2015-12-14

    Appc has been going to deprecate TableView for about 3 years now. But keep in mind that TableView and ListView are not interchangeable components. Switching from TableView to ListView can involve significant re-architecting of your app (I know, I just did it and it was a royal pain in the you-know-what). There are many things you can do with TableView that you can't do with ListView. For small lists, the speed advantage of ListView is often not worth the effort compared to the coding and conceptual simplicity of the direct-view-access nature of TableView.
  11. Angel Petkov 2015-12-14

    [~jasonkneen] Hello , I can understand you're fustrated ,however we are currently at code freeze as we have a release coming out very soon. This change will be added to the following release after that, i apologies for the inconvenience this might have caused to your app development.
  12. Hans Knöchel 2015-12-15

    PR: https://github.com/appcelerator/titanium_mobile/pull/7580 Docs not updated, since we strongly recommend to use the Ti.UI.ListView to use Peek and Pop.
  13. Jason Kneen 2015-12-15

    But for what reason? Performance or just because it doesn't work out-of-the-box on TableView? I've got an app working with existing TableViews, and peek and pop and it's fine -- I had to do a workaround if I wanted to do the peek against the tableview itself -- using touch start to set the index before the peek -- otherwise it's possible to do the peek against the tableview row much like the mail app does. Thanks for the PR -- assuming this will work fine now for TableViews.
  14. Tim Poulsen 2015-12-15

    [~hansknoechel] You realize that neither http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.TableView nor http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.ListView state that TableView is in a need-to-be-fixed-only state or that ListView is recommended in place of TableView. It's only with a good bit of digging through the guides that one might find details of your recommendation to use ListView. If you're going to deprecate a component, which you're essentially doing here, that should be clearly documented in the API docs.
  15. Angel Petkov 2015-12-16

    FT and CR approved. Thanks Hans!
        var actions = [];
        var win = Ti.UI.createWindow({
            backgroundColor: "white"
        });
        
        // The view to be previewed while popping.
        var previewView = Ti.UI.createView({
            backgroundColor: "blue"
        });
        
        // The window to be opened after popping the preview.
        var detailWindow = Ti.UI.createWindow({
            backgroundColor: "yellow"
        });
        
        detailWindow.add(Ti.UI.createLabel({
            text: "You made it!"
        }));
        
        // The actions to be added to the preview context.
        var action = Ti.UI.iOS.createPreviewAction({
            title: "Preview Action",
            style: Ti.UI.iOS.PREVIEW_ACTION_STYLE_DEFAULT
        });
        
        action.addEventListener("click", function(e) {
            alert(
                "Title: " + e.title +
                "\nStyle: " + e.style +
                "\nIndex: " + e.index +
                "\nSectionIndex: " + e.sectionIndex +
                "\nItemIndex: " + e.itemIndex
            );
        });
        
        actions.push(action);
        
        // Create the preview context
        var context = Ti.UI.iOS.createPreviewContext({
            preview: previewView,
            actions: actions, // Can have both Ti.UI.iOS.PreviewAction + Ti.UI.iOS.PreviewActionGroup
            contentHeight: 300 // When unspecified, we use the available height
        });
        
        // Fired after peeking the preview
        // Use this event to configure the preview depending on the sectionIndex / itemIndex
        context.addEventListener("peek", function(e) {
            Ti.API.warn("sectionIndex: " + e.sectionIndex);
            Ti.API.warn("itemIndex: " + e.itemIndex);
        });
        
        // Fired after popping the preview
        context.addEventListener("pop", function(e) {
            detailWindow.open();
        });
        
        // Assign the preview context
        
        
        var section1 = Ti.UI.createTableViewSection({
            headerTitle: "Section 1"
        });
        
        var section2 = Ti.UI.createTableViewSection({
            headerTitle: "Section 2"
        });
        
        
        for(var i = 1; i <= 5; i++) {
            section1.add(Ti.UI.createTableViewRow({ title: 'Item'+i }));
            section2.add(Ti.UI.createTableViewRow({ title: 'Item'+i }));
        }
        
        var tableView = Ti.UI.createTableView({
            previewContext 	: context, // Will be ignored on unsupported devices
            data 			: [section1, section2]
        });
        
        win.add(tableView);
        win.open();
        
  16. Josh Longton 2016-06-09

    Verified as fixed as an improvement.
 Tested on:
 iPhone 6s Plus (9.3.1) Mac OSX El Capitan 10.11.4 Studio: 4.7.0.201606070951 
Ti SDK: 5.4.0.v20160608165242 
Appc NPM: 4.2.7-2 Appc CLI: 5.4.0-13 
Xcode 7.3 Node v0.12.7 *Closing Ticket.*

JSON Source