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 {
|
||||
id: page
|
||||
|
||||
// Campi di ricerca FUORI dall'header della lista: gli id dichiarati nel
|
||||
// componente header hanno scope chiuso e le funzioni del Page non li
|
||||
// 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()
|
||||
}
|
||||
}
|
||||
// Messaggio mostrato nel footer quando la lista è vuota
|
||||
property string hintMsg: ""
|
||||
|
||||
SilicaListView {
|
||||
id: list
|
||||
anchors.top: topCol.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.fill: parent
|
||||
model: ListModel { id: resultModel }
|
||||
|
||||
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 {
|
||||
width: parent.width
|
||||
height: resultModel.count === 0 ? Theme.itemSizeSmall * 1.6 : 0
|
||||
height: resultModel.count === 0 ? Theme.itemSizeSmall * 1.8 : 0
|
||||
Label {
|
||||
visible: resultModel.count === 0
|
||||
anchors.fill: parent
|
||||
anchors.margins: Theme.horizontalPageMargin
|
||||
text: search.text.trim() === ""
|
||||
? qsTr("Type to search among all Italian towns and known ports.")
|
||||
: qsTr("No local results — press Enter to search online.")
|
||||
text: page.hintMsg
|
||||
color: Theme.secondaryColor
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
wrapMode: Text.Wrap
|
||||
@@ -119,10 +115,14 @@ Page {
|
||||
return "±" + (cost[1][0] + cost[2][0]).toFixed(2) + " m"
|
||||
}
|
||||
|
||||
function updateList() {
|
||||
var q = norm(search.text.trim())
|
||||
function updateList(q) {
|
||||
q = norm(q.trim())
|
||||
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
|
||||
// porti noti (match su nome o paese)
|
||||
for (i = 0; i < Tides.PORTS.length; i++) {
|
||||
@@ -233,8 +233,8 @@ Page {
|
||||
xhr.send()
|
||||
}
|
||||
|
||||
function findOnline() {
|
||||
var q = search.text.trim()
|
||||
function findOnline(q) {
|
||||
q = q.trim()
|
||||
console.log("[tide] findOnline:", q)
|
||||
if (q === "") return
|
||||
// se è un porto noto, apri direttamente
|
||||
@@ -263,7 +263,7 @@ Page {
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
updateList()
|
||||
updateList("")
|
||||
var pref = appSettings.preferredPort
|
||||
if (pref !== "") {
|
||||
var found = false
|
||||
|
||||
Reference in New Issue
Block a user