1#![allow(deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/7guis"#]
2// Copyright © SixtyFPS GmbH <info@slint.dev>
3// SPDX-License-Identifier: MIT
4
5import { LineEdit, Button, ComboBox, GridBox } from "std-widgets.slint";
6
7export component Booker inherits Window {
8 // returns true if the string parameter is a valid date
9 pure callback validate-date(string) -> bool;
10 // returns true if the first date is before the second date and they are both valid
11 pure callback compare-date(string, string) -> bool;
12
13 validate-date(_) => { true }
14 compare-date(a, b) => { a <= b }
15
16 private property <bool> message-visible;
17
18 GridBox {
19 combo := ComboBox {
20 row: 0;
21 model: ["one-way flight", "return flight"];
22 current-value: "one-way flight";
23 current-index: 0;
24 }
25 t1 := LineEdit {
26 row: 1;
27 text: "27.03.2014";
28 }
29 Rectangle {
30 row: 1; // over the previous line edit
31 background: root.validate-date(t1.text) ? transparent : #f008;
32 }
33 t2 := LineEdit {
34 row: 2;
35 text: "27.03.2014";
36 enabled: combo.current-index == 1;
37 }
38 Rectangle {
39 row: 2; // over the previous line edit
40 background: root.validate-date(t2.text) ? transparent : #f008;
41 }
42 Button {
43 row: 3;
44 text: "Book";
45 clicked() => { root.message-visible = true; }
46 enabled: combo.current-index != 1 ? root.validate-date(t1.text) : root.compare-date(t1.text, t2.text);
47 }
48 }
49
50 if (root.message-visible) : Rectangle {
51 width: 100%;
52 height: 100%;
53 background: #ee8;
54 Text {
55 width: 100%;
56 height: 100%;
57 text: "You have booked a " + combo.current-value + " on " + t1.text;
58 vertical-alignment: center;
59 horizontal-alignment: center;
60 }
61 TouchArea {
62 width: 100%;
63 height: 100%;
64 clicked => { root.message-visible = false; }
65 }
66 }
67}
68}
69