~nik90/podbird/new-navigation-structure

« back to all changes in this revision

Viewing changes to app/ui/EpisodesTab.qml

  • Committer: Nekhelesh Ramananthan
  • Date: 2015-06-20 13:51:40 UTC
  • mfrom: (110.1.1 change-click-behavior)
  • Revision ID: krnekhelesh@gmail.com-20150620135140-ped2l75zi8ycz91v
Changed default click behaviour to play an episode rather than show the description as per the recommendation of Kevin Feyder.

Show diffs side-by-side

added added

removed removed

Lines of Context:
213
213
            }
214
214
        }
215
215
 
 
216
        /*
 
217
         Note (nik90): After the upgrade to Ubuntu.Components 1.2, it seems the new listitems don't have their trailing
 
218
         action width clamped. As a result when the list item expands and the user swipes left, it leads to a rather huge
 
219
         trailing edge action. This has been reported upstream at http://pad.lv/1465582. Until this is fixed, the
 
220
         episode description is shown in a dialog.
 
221
        */
 
222
        Component {
 
223
            id: episodeDescriptionDialog
 
224
            Dialog {
 
225
                id: dialogInternal
 
226
                property string description
 
227
                title: "<b>%1</b>".arg(i18n.tr("Episode Description"))
 
228
                text: description
 
229
                Button {
 
230
                    text: i18n.tr("Close")
 
231
                    color: podbird.appTheme.positiveActionButton
 
232
                    onClicked: {
 
233
                        PopupUtils.close(dialogInternal)
 
234
                    }
 
235
                }
 
236
            }
 
237
        }
 
238
 
216
239
        UbuntuListView {
217
240
            id: episodeList
218
241
 
279
302
                subtitle: model.duration === 0 || model.duration === undefined ? model.artist
280
303
                                                                               : Podcasts.formatEpisodeTime(model.duration) + " | " + model.artist
281
304
 
282
 
                description: model.description
283
 
 
284
305
                isDownloaded: model.downloadedfile ? true : false
285
306
 
286
307
                showProgressBar: downloader.downloadingGuid === model.guid
333
354
                        },
334
355
 
335
356
                        Action {
336
 
                            iconName: currentUrl != "" && playerLoader.item.playbackState === MediaPlayer.PlayingState && currentGuid === model.guid ? "media-playback-pause"
337
 
                                                                                                                                                     : "media-playback-start"
 
357
                            iconName: "info"
338
358
                            onTriggered: {
339
 
                                var db = Podcasts.init();
340
 
                                db.transaction(function (tx) {
341
 
                                    if (currentGuid === model.guid && currentUrl != "") {
342
 
                                        if (playerLoader.item.playbackState === MediaPlayer.PlayingState) {
343
 
                                            playerLoader.item.pause()
344
 
                                        } else {
345
 
                                            playerLoader.item.play()
346
 
                                        }
347
 
                                    } else {
348
 
                                        currentGuid = "";
349
 
                                        currentUrl = model.downloadedfile ? model.downloadedfile : model.audiourl;
350
 
                                        var rs = tx.executeSql("SELECT position FROM Episode WHERE guid=?", [model.guid]);
351
 
                                        playerLoader.item.play();
352
 
                                        playerLoader.item.seek(rs.rows.item(0).position);
353
 
                                        currentName = model.name;
354
 
                                        currentArtist = model.artist;
355
 
                                        currentImage = model.image;
356
 
                                        currentGuid = model.guid;
357
 
                                    }
358
 
                                });
 
359
                                var popup = PopupUtils.open(episodeDescriptionDialog, whatsNewTab);
 
360
                                popup.description = model.description
359
361
                            }
360
362
                        }
361
363
                    ]
362
364
                }
363
365
 
364
366
                onClicked: {
365
 
                    expanded = !expanded
 
367
                    Haptics.play()
 
368
                    var db = Podcasts.init();
 
369
                    db.transaction(function (tx) {
 
370
                        if (currentGuid !== model.guid) {
 
371
                            currentGuid = "";
 
372
                            currentUrl = model.downloadedfile ? model.downloadedfile : model.audiourl;
 
373
                            var rs = tx.executeSql("SELECT position FROM Episode WHERE guid=?", [model.guid]);
 
374
                            playerLoader.item.play();
 
375
                            playerLoader.item.seek(rs.rows.item(0).position);
 
376
                            currentName = model.name;
 
377
                            currentArtist = model.artist;
 
378
                            currentImage = model.image;
 
379
                            currentGuid = model.guid;
 
380
                        }
 
381
                    });
366
382
                }
367
383
            }
368
384