home: layout standard Silica (header+ricerca dentro la lista) — elimina la fascia verde del pulley all'avvio
This commit is contained in:
+34
-34
@@ -6,33 +6,12 @@ import "../js/comuni.js" as Comuni
|
|||||||
Page {
|
Page {
|
||||||
id: page
|
id: page
|
||||||
|
|
||||||
// Campi di ricerca FUORI dall'header della lista: gli id dichiarati nel
|
// Messaggio mostrato nel footer quando la lista è vuota
|
||||||
// componente header hanno scope chiuso e le funzioni del Page non li
|
property string hintMsg: ""
|
||||||
// vedono (ReferenceError "filter is not defined").
|
|
||||||
Column {
|
|
||||||
id: topCol
|
|
||||||
width: parent.width
|
|
||||||
|
|
||||||
PageHeader {
|
|
||||||
title: "Tide"
|
|
||||||
description: "v" + appVersion
|
|
||||||
}
|
|
||||||
|
|
||||||
SearchField {
|
|
||||||
id: search
|
|
||||||
placeholderText: qsTr("Search a port or a town…")
|
|
||||||
onTextChanged: updateList()
|
|
||||||
EnterKey.enabled: text.trim().length > 0
|
|
||||||
EnterKey.onClicked: findOnline()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SilicaListView {
|
SilicaListView {
|
||||||
id: list
|
id: list
|
||||||
anchors.top: topCol.bottom
|
anchors.fill: parent
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
model: ListModel { id: resultModel }
|
model: ListModel { id: resultModel }
|
||||||
|
|
||||||
PullDownMenu {
|
PullDownMenu {
|
||||||
@@ -42,16 +21,33 @@ Page {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Header della lista: titolo + ricerca (i campi qui scrollano con la
|
||||||
|
// lista; le funzioni della pagina ricevono il testo come parametro,
|
||||||
|
// perché gli id dell'header non sono visibili fuori dal componente)
|
||||||
|
header: Column {
|
||||||
|
width: parent.width
|
||||||
|
|
||||||
|
PageHeader {
|
||||||
|
title: "Tide"
|
||||||
|
description: "v" + appVersion
|
||||||
|
}
|
||||||
|
|
||||||
|
SearchField {
|
||||||
|
placeholderText: qsTr("Search a port or a town…")
|
||||||
|
onTextChanged: page.updateList(text)
|
||||||
|
EnterKey.enabled: text.trim().length > 0
|
||||||
|
EnterKey.onClicked: page.findOnline(text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
footer: Item {
|
footer: Item {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: resultModel.count === 0 ? Theme.itemSizeSmall * 1.6 : 0
|
height: resultModel.count === 0 ? Theme.itemSizeSmall * 1.8 : 0
|
||||||
Label {
|
Label {
|
||||||
visible: resultModel.count === 0
|
visible: resultModel.count === 0
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: Theme.horizontalPageMargin
|
anchors.margins: Theme.horizontalPageMargin
|
||||||
text: search.text.trim() === ""
|
text: page.hintMsg
|
||||||
? qsTr("Type to search among all Italian towns and known ports.")
|
|
||||||
: qsTr("No local results — press Enter to search online.")
|
|
||||||
color: Theme.secondaryColor
|
color: Theme.secondaryColor
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
wrapMode: Text.Wrap
|
wrapMode: Text.Wrap
|
||||||
@@ -119,10 +115,14 @@ Page {
|
|||||||
return "±" + (cost[1][0] + cost[2][0]).toFixed(2) + " m"
|
return "±" + (cost[1][0] + cost[2][0]).toFixed(2) + " m"
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateList() {
|
function updateList(q) {
|
||||||
var q = norm(search.text.trim())
|
q = norm(q.trim())
|
||||||
resultModel.clear()
|
resultModel.clear()
|
||||||
if (q === "") return
|
if (q === "") {
|
||||||
|
hintMsg = qsTr("Type to search among all Italian towns and known ports.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
hintMsg = qsTr("No local results — press Enter to search online.")
|
||||||
var i, p, name
|
var i, p, name
|
||||||
// porti noti (match su nome o paese)
|
// porti noti (match su nome o paese)
|
||||||
for (i = 0; i < Tides.PORTS.length; i++) {
|
for (i = 0; i < Tides.PORTS.length; i++) {
|
||||||
@@ -233,8 +233,8 @@ Page {
|
|||||||
xhr.send()
|
xhr.send()
|
||||||
}
|
}
|
||||||
|
|
||||||
function findOnline() {
|
function findOnline(q) {
|
||||||
var q = search.text.trim()
|
q = q.trim()
|
||||||
console.log("[tide] findOnline:", q)
|
console.log("[tide] findOnline:", q)
|
||||||
if (q === "") return
|
if (q === "") return
|
||||||
// se è un porto noto, apri direttamente
|
// se è un porto noto, apri direttamente
|
||||||
@@ -263,7 +263,7 @@ Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
updateList()
|
updateList("")
|
||||||
var pref = appSettings.preferredPort
|
var pref = appSettings.preferredPort
|
||||||
if (pref !== "") {
|
if (pref !== "") {
|
||||||
var found = false
|
var found = false
|
||||||
|
|||||||
Reference in New Issue
Block a user