1// Copyright © SixtyFPS GmbH <info@slint.dev>
2// SPDX-License-Identifier: MIT
3
4import { AppState, Orientation } from "appState.slint";
5import { Date, Time } from "std-widgets.slint";
6
7export enum WeatherCondition {
8 sunny,
9 sunny-rainy,
10 sunny-cloudy,
11 cloudy,
12 rainy,
13}
14export struct WeatherData {
15 condition: WeatherCondition,
16 day: string,
17 temperature: float,
18}
19
20export global Api {
21 in property <float> indoor-temperature: 22.0;
22 in property <float> outdoor-temperature: 24.0;
23
24 in property <float> price-of-electricity: 13.0;
25 in property <float> current-electricity-use: 152.9;
26
27 out property <Orientation> orientation <=> AppState.orientation;
28 in-out property <bool> graphics-accelerator-available <=> AppState.graphics-accelerator-available;
29
30 in property <Date> current-date: {
31 year: 2025,
32 month: 3,
33 day: 18,
34 };
35
36 in property <Time> current-time: {
37 hour: 15,
38 minute: 12,
39 second: 33,
40 };
41
42 pure public function return-month() -> string {
43 if current-date.month == 1 {
44 return "January";
45 } else if current-date.month == 2 {
46 return "February";
47 } else if current-date.month == 3 {
48 return "March";
49 } else if current-date.month == 4 {
50 return "April";
51 } else if current-date.month == 5 {
52 return "May";
53 } else if current-date.month == 6 {
54 return "June";
55 } else if current-date.month == 7 {
56 return "July";
57 } else if current-date.month == 8 {
58 return "August";
59 } else if current-date.month == 9 {
60 return "September";
61 } else if current-date.month == 10 {
62 return "October";
63 } else if current-date.month == 11 {
64 return "November";
65 } else if current-date.month == 12 {
66 return "December";
67 }
68 return "Unknown";
69 }
70
71 in property <[WeatherData]> weather-forecast: [
72 {
73 condition: WeatherCondition.rainy,
74 day: "Mon",
75 temperature: 21.0,
76 },
77 {
78 condition: WeatherCondition.sunny-rainy,
79 day: "Tue",
80 temperature: 16.0,
81 },
82 {
83 condition: WeatherCondition.cloudy,
84 day: "Wed",
85 temperature: 18.0,
86 },
87 {
88 condition: WeatherCondition.sunny-cloudy,
89 day: "Thu",
90 temperature: 20.0,
91 },
92 {
93 condition: WeatherCondition.sunny,
94 day: "Fri",
95 temperature: 23.0,
96 },
97 ];
98}
99