Commit c29438f1 authored by kempe's avatar kempe

Refactored BrowseByCategory page part of #6

* Divided in .qml and .ui.qml
parent 6f9d3a27
......@@ -32,7 +32,6 @@ OTHER_FILES += qml/harbour-received.qml \
qml/components/js/Storage.js \
qml/components/js/Favorites.js \
translations/harbour-received-sv.ts \
qml/pages/BrowseByCategory.qml \
qml/components/SleepTimer.qml \
qml/components/RadioAPI.qml
......@@ -68,5 +67,7 @@ DISTFILES += \
qml/pages/Settings2.qml \
qml/components/RecivedUpgrader.qml \
qml/pages/BrowsePageForm.ui.qml \
qml/pages/BrowsePage.qml
qml/pages/BrowsePage.qml \
qml/pages/BrowseByCategoryPageForm.ui.qml \
qml/pages/BrowseByCategoryPage.qml
import QtQuick 2.6
import "../components/js/Utils.js" as Utils
BrowseByCategoryPageForm {
headerTitle: headerTitle.toLocaleLowerCase()
browseByListView.onCurrentIndexChanged: {
var item = browseByModel.get(browseByListView.currentIndex)
pageStack.push(Qt.resolvedUrl("StationsPage.qml"), {listType: new Utils.ListType(title),
category: item.category, value: item.title});
}
// Other
// Set a custom search action in navigation menu
navigationMenu.searchAction: function() {
pageStack.replaceAbove(
pageStack.find(function(page) {
return page.firstPage === true}),
Qt.resolvedUrl("StationsPage.qml"),
{listType: Utils.Search});
}
Component.onCompleted: {
radioAPI.getCategories(category.toLocaleLowerCase(), browseByModel);
}
}
import QtQuick 2.6
import Sailfish.Silica 1.0
import "../components/js/Utils.js" as Utils
Page {
id: page
property alias browseByListView: browseByListView
property alias browseByModel: browseByModel
property alias navigationMenu: navigationMenu
property string category: ""
property string headerTitle: ""
......@@ -14,24 +18,18 @@ Page {
anchors.fill: parent
NavigationMenu {
id: pulleyMeny
id: navigationMenu
hideBrowseAction: true
searchAction: function() {
pageStack.replaceAbove(
pageStack.find(function(page) {
return page.firstPage === true}),
Qt.resolvedUrl("StationsPage.qml"),
{listType: Utils.Search});
}
}
header: Column {
PageHeader {
title: qsTr("Browse by") + " " + headerTitle.toLocaleLowerCase()
title: qsTr("Browse by") + " " + headerTitle
width: page.width
}
}
currentIndex: -1
model: ListModel {
id: browseByModel
}
......@@ -50,13 +48,10 @@ Page {
anchors.topMargin: 7
}
onClicked: {
pageStack.push(Qt.resolvedUrl("StationsPage.qml"), {listType: new Utils.ListType(title), category: category, value: title});
Connections {
target: listItem
onClicked: browseByListView.currentIndex = index
}
}
}
Component.onCompleted: {
radioAPI.getCategories(category.toLocaleLowerCase(), browseByModel);
}
}
......@@ -17,7 +17,7 @@ BrowsePageForm {
pageStack.push(Qt.resolvedUrl("StationsPage.qml"), {listType: Utils.Local});
break;
default:
pageStack.push(Qt.resolvedUrl("BrowseByCategory.qml"), {category: item.originalTitle, headerTitle: item.title});
pageStack.push(Qt.resolvedUrl("BrowseByCategoryPage.qml"), {category: item.originalTitle, headerTitle: item.title});
break;
}
}
......
......@@ -2,10 +2,10 @@
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>BrowseByCategory</name>
<name>BrowseByCategoryPageForm.ui</name>
<message>
<source>Browse by</source>
<translation>Bläddra efter</translation>
<translation type="unfinished">Bläddra efter</translation>
</message>
</context>
<context>
......
......@@ -2,7 +2,7 @@
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>BrowseByCategory</name>
<name>BrowseByCategoryPageForm.ui</name>
<message>
<source>Browse by</source>
<translation type="unfinished"></translation>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment