1// Copyright © SixtyFPS GmbH <info@slint.dev>
2// SPDX-License-Identifier: MIT
3
4import { PageBase } from "page-base.slint";
5import { AppImages } from "./style/styles.slint";
6import { AppText, TextField } from "./controls/generic.slint";
7import { BusyLayerController } from "./controls/busy-layer.slint";
8import { GeoLocation } from "./location_datatypes.slint";
9
10import { Button } from "std-widgets.slint";
11
12export component LocationSearchView inherits PageBase {
13 callback close-request;
14
15 public function clear() {
16 GeoLocation.search_location("");
17 text-field.text = "";
18 }
19
20 forward-focus: text-field;
21
22 VerticalLayout {
23 padding: 20px;
24 spacing: 10px;
25
26 text-field := TextField {
27 icon-source: AppImages.search;
28 placeholder-text: "Search";
29
30 edited => {
31 GeoLocation.search_location(self.text);
32 }
33 }
34
35 Flickable {
36 VerticalLayout {
37 alignment: start;
38
39 for data[index] in GeoLocation.result-list : Rectangle {
40 preferred-height: layout.preferred-height + 20px;
41 min-height: self.preferred-height;
42
43 layout := VerticalLayout {
44 alignment: center;
45 spacing: 5px;
46
47 AppText {
48 text: data.name;
49 font-size: 1.3rem;
50 }
51 AppText {
52 text: data.state == "" ? data.country : data.state + ", " + data.country;
53 font-size: 0.9rem;
54 }
55 }
56
57 TouchArea {
58 clicked => {
59 BusyLayerController.set-busy();
60 GeoLocation.add-location(data);
61 root.close-request();
62 }
63 }
64 }
65 }
66 }
67 }
68}
69