New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Micu/fix menu sitution 82 #83

Merged
merged 11 commits into from May 6, 2017
Copy path View file
@@ -10,7 +10,6 @@ Label 1.0 Label.qml
ListItem 1.0 ListItem.qml
OpacityRampEffect 1.0 OpacityRampEffect.qml
PageHeader 1.0 PageHeader.qml
SearchField 1.0 SearchField.qml
Separator 1.0 Separator.qml
SilicaFlickable 1.0 SilicaFlickable.qml
SilicaListView 1.0 SilicaListView.qml
@@ -14,7 +14,6 @@
<file>OpacityRampEffect.qml</file>
<file>PageHeader.qml</file>
<file>qmldir</file>
<file>SearchField.qml</file>
<file>Separator.qml</file>
<file>SilicaFlickable.qml</file>
<file>SilicaListView.qml</file>
@@ -0,0 +1,13 @@
import Sailfish.Silica 1.0 as Silica
import QtQuick 2.2
Silica.MenuItem {
property var icon
property Component pageComponent
property Page page
onClicked: {
pageStack.clear()
page = pageStack.replaceAbove(null, pageComponent)
}
}
@@ -1,9 +1,9 @@
import Sailfish.Silica 1.0 as Silica
import QtQuick 2.0
import QtQuick 2.2
Silica.MenuItem {
property var pageToVisit
property var page
property var icon
onClicked: pageStack.push(pageToVisit)
onClicked: pageStack.push(page)
}
@@ -2,6 +2,24 @@ import Sailfish.Silica 1.0 as Silica
import QtQuick 2.2
Silica.PullDownMenu {
property var initialMenuItem
id: menu
property Page menuPage
flickable: menuPage.flickable
// Always keep the menu on the current root page
data: [
Connections {
target: pageStack
onDepthChanged: {
if ( "undefined" !== typeof(pageStack.currentPage)
&& "undefined" !== typeof(pageStack.currentPage.flickable)
&& pageStack.depth === 1)
{
menuPage = pageStack.currentPage
}
}
}]
}
@@ -0,0 +1,26 @@
import Sailfish.Silica 1.0 as Silica
import QtQuick 2.2
Item {
id: abstractionItem
property Item flickableForSailfish
property string text
onFlickableForSailfishChanged: {
flickableForSailfish.header = nativeSearchField
}
property Component nativeSearchField: Silica.SearchField {
id: nativeSearch
width: abstractionItem.width
text: abstractionItem.text
onTextChanged: {
if (abstractionItem.text !== text)
{
abstractionItem.text = text
}
}
}
}
@@ -7,3 +7,5 @@ NavigationMenu 1.0 NavigationMenu.qml
Map 1.0 Map.qml
MenuItem 1.0 MenuItem.qml
SectionHeader 1.0 SectionHeader.qml
SearchField 1.0 SearchField.qml
ActionMenuItem 1.0 ActionMenuItem.qml
@@ -9,5 +9,7 @@
<file>MenuItem.qml</file>
<file>Platform.qml</file>
<file>SectionHeader.qml</file>
<file>SearchField.qml</file>
<file>ActionMenuItem.qml</file>
</qresource>
</RCC>
@@ -0,0 +1,15 @@
import QtQuick 2.7
import VPlayApps 1.0
import BerlinVegan.components.platform 1.0 as BVApp
BVApp.MenuItem {
property Component pageComponent
onPageComponentChanged:
{
page = pageComponent.createObject()
}
signal clicked
onSelected: clicked()
}
@@ -1,38 +1,15 @@
import QtQuick 2.7
import VPlayApps 1.0
import BerlinVegan.components.platform 1.0 as BVApp
NavigationItem {
id: item
property var pageToVisit
property var page
property alias text: item.title
NavigationStack {
id: stack
initialPage: pageToVisit
navigationBar.rightBarItem: IconButtonBarItem {
id: attachedButton
property var attachedPage
property var props
property var attachedTo
visible: attachedPage !== undefined
&& attachedTo === stack.currentPage
onClicked: {
if (visible)
{
stack.push(attachedPage, props)
}
}
}
function pushAttached(page, props, icon)
{
attachedButton.attachedTo = stack.currentPage
attachedButton.attachedPage = page
attachedButton.props = props
attachedButton.icon = icon
}
BVApp.NavigationStackWithPushAttached
{
initialPage: page
}
Component.onCompleted: {
@@ -2,15 +2,6 @@ import QtQuick 2.7
import VPlayApps 1.0
Navigation {
property var initialMenuItem
property var flickable
property Component initialPageComponent
Component.onCompleted: {
var initObj =
insertNavigationItem(0, Qt.createComponent("MenuItem.qml"))
initObj.icon = initialMenuItem.icon
initObj.pageToVisit = initialMenuItem.pageToVisit
initObj.text = initialMenuItem.text
currentIndex = 0
}
}
@@ -0,0 +1,31 @@
import QtQuick 2.7
import VPlayApps 1.0
NavigationStack {
id: stack
navigationBar.rightBarItem: IconButtonBarItem {
id: attachedButton
property var attachedPage
property var props
property var attachedTo
visible: attachedPage !== undefined
&& attachedTo === stack.currentPage
onClicked: {
if (visible)
{
stack.push(attachedPage, props)
}
}
}
function pushAttached(page, props, icon)
{
attachedButton.attachedTo = stack.currentPage
attachedButton.attachedPage = page
attachedButton.props = props
attachedButton.icon = icon
}
}
@@ -1,3 +1,4 @@
import QtQuick 2.7
import VPlayApps 1.0
SearchBar {
@@ -8,4 +9,5 @@ SearchBar {
// this integrates better on iOS with the overall background color
barBackgroundColor: "white"
property Item flickableForSailfish
}
Copy path View file
@@ -3,7 +3,10 @@ singleton Theme 1.0 Theme.qml
singleton Platform 1.0 Platform.qml
IconButton 1.0 IconButton.qml
Page 1.0 Page.qml
NavigationStackWithPushAttached 1.0 NavigationStackWithPushAttached.qml
NavigationMenu 1.0 NavigationMenu.qml
Map 1.0 Map.qml
MenuItem 1.0 MenuItem.qml
SectionHeader 1.0 SectionHeader.qml
SearchField 1.0 SearchField.qml
ActionMenuItem 1.0 ActionMenuItem.qml
@@ -9,5 +9,8 @@
<file>MenuItem.qml</file>
<file>Platform.qml</file>
<file>SectionHeader.qml</file>
<file>NavigationStackWithPushAttached.qml</file>
<file>SearchField.qml</file>
<file>ActionMenuItem.qml</file>
</qresource>
</RCC>
Copy path View file
@@ -37,6 +37,7 @@ ApplicationWindow
{
id: app
property var jsonModelCollection: gjsonVenueModelCollection
JsonListModel {
id: jsonVenueModel
dynamicRoles: true
@@ -57,24 +58,6 @@ ApplicationWindow
model: jsonShoppingModel
}
PositionSource {
id: globalPositionSource
updateInterval: 5000
property var oldPosition: QtPositioning.coordinate(0, 0)
onPositionChanged: {
console.log(oldPosition + " " + position.coordinate + " " + position.coordinate.distanceTo(oldPosition))
if (position.coordinate.distanceTo(oldPosition) > 100)
{
gjsonVenueModelCollection.reSort();
gjsonShoppingModelCollection.reSort();
oldPosition.latitude = position.coordinate.latitude
oldPosition.longitude = position.coordinate.longitude
}
}
}
BVApp.JsonDownloadHelper {
id: venueDownloadHelper
onFileLoaded:
@@ -95,6 +78,24 @@ ApplicationWindow
}
}
PositionSource {
id: globalPositionSource
updateInterval: 5000
property var oldPosition: QtPositioning.coordinate(0, 0)
onPositionChanged: {
if (position.coordinate.distanceTo(oldPosition) > 100)
{
gjsonVenueModelCollection.reSort();
gjsonShoppingModelCollection.reSort();
oldPosition.latitude = position.coordinate.latitude
oldPosition.longitude = position.coordinate.longitude
}
}
}
Component.onCompleted: {
venueDownloadHelper.loadVenueJson()
shoppingDownloadHelper.loadShoppingJson()
@@ -112,46 +113,58 @@ ApplicationWindow
}
}
cover: Component { CoverPage {
id: cover
jsonModelCollection: gjsonVenueModelCollection
jsonModelCollection: app.jsonModelCollection
positionSource: globalPositionSource
} }
initialPage: VenueList {
jsonModelCollection: gjsonVenueModelCollection
positionSource: globalPositionSource
id: listPage
}
initialPage: Component { VenueList {
id: venueList
positionSource: globalPositionSource
jsonModelCollection: app.jsonModelCollection
BVApp.NavigationMenu {
id: myMenu
onSearchStringChanged: {
gjsonShoppingModelCollection.searchString = searchString
gjsonVenueModelCollection.searchString = searchString
}
} }
flickable: initialPage.flickable
BVApp.NavigationMenu {
initialMenuItem: BVApp.MenuItem {
pageToVisit: initialPage
icon: BVApp.Theme.iconBy("food")
//% "Food"
text: qsTrId("id-venue-list")
}
BVApp.ActionMenuItem {
icon: BVApp.Theme.iconBy("food")
//% "Food"
text: qsTrId("id-venue-list")
BVApp.MenuItem {
pageToVisit: VenueList {
jsonModelCollection: gjsonShoppingModelCollection
positionSource: globalPositionSource
id: shoppingPage
onClicked: {
app.jsonModelCollection = gjsonVenueModelCollection
page.searchString = gjsonVenueModelCollection.searchString
}
icon: BVApp.Theme.iconBy("shopping")
//% "Shopping"
text: qsTrId("id-shopping-venue-list")
}
BVApp.MenuItem {
pageToVisit: AboutBerlinVegan { }
pageComponent: app.initialPage
}
BVApp.ActionMenuItem {
icon: BVApp.Theme.iconBy("shopping")
//% "Shopping"
text: qsTrId("id-shopping-venue-list")
onClicked: {
app.jsonModelCollection = gjsonShoppingModelCollection
page.searchString = gjsonShoppingModelCollection.searchString
}
pageComponent: app.initialPage
}
BVApp.MenuItem {
icon: BVApp.Theme.iconBy("about")
//% "About"
text: qsTrId("id-about-venue-list")
page: AboutBerlinVegan { }
}
}
}
Oops, something went wrong.
ProTip! Use n and p to navigate between commits in a pull request.