1 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
2 | // SPDX-License-Identifier: MIT |
3 | |
4 | import { Theme, ScreenSize } from "theme.slint" ; |
5 | import { SmallMain } from "small_main.slint" ; |
6 | import { BigMain } from "big_main.slint" ; |
7 | import { MidMain } from "mid_main.slint" ; |
8 | import { MidMain } from "mid_main.slint" ; |
9 | import { MobileMain } from "mobile_main.slint" ; |
10 | import { BarTileModel } from "widgets/widgets.slint" ; |
11 | import { Images } from "images.slint" ; |
12 | import { Theme } from "theme.slint" ; |
13 | import { HeaderAdapter } from "blocks/blocks.slint" ; |
14 | import { Navigation, MenuButton, Menu, Value } from "widgets/widgets.slint" ; |
15 | import { BalanceAdapter, OverviewAdapter, UsageAdapter, WeatherAdapter, MenuPageAdapter, MenuOverviewAdapter, SettingsAdapter } from "pages/pages.slint" ; |
16 | import { KioskOverlay } from "blocks/kiosk_overlay.slint" ; |
17 | |
18 | export { OverviewAdapter, UsageAdapter, Value, WeatherAdapter, MenuPageAdapter, MenuOverviewAdapter, SettingsAdapter, |
19 | BarTileModel, Images, HeaderAdapter } |
20 | |
21 | export component MainWindow inherits Window { |
22 | private property <length> big-break-point: 1366px; |
23 | private property <length> mid-break-point: 799px; |
24 | private property <length> mobile-break-point: 444px; |
25 | private property <ScreenSize> screen-size: root.get-screen-size(); |
26 | |
27 | title: "EnergyMNG Demo" ; |
28 | min-width: 320px; |
29 | min-height: 240px; |
30 | background: Theme.palette.pure-black; |
31 | preferred-width: 800px; |
32 | preferred-height: 480px; |
33 | |
34 | /* The design is not finished yet |
35 | if root.screen-size == ScreenSize.Desktop : BigMain { |
36 | preferred-width: 100%; |
37 | preferred-height: 100%; |
38 | } |
39 | */ |
40 | |
41 | if root.screen-size == ScreenSize.Mobile : MobileMain { |
42 | preferred-width: 100%; |
43 | preferred-height: 100%; |
44 | } |
45 | |
46 | if root.screen-size == ScreenSize.EmbeddedMedium : MidMain { |
47 | preferred-width: 100%; |
48 | preferred-height: 100%; |
49 | } |
50 | |
51 | if root.screen-size == ScreenSize.EmbeddedSmall : SmallMain { |
52 | preferred-width: 100%; |
53 | preferred-height: 100%; |
54 | } |
55 | |
56 | if SettingsAdapter.kiosk-mode-checked : KioskOverlay {} |
57 | |
58 | pure function get-screen-size() -> ScreenSize { |
59 | if (root.width <= root.mobile-break-point && root.width < root.height) { |
60 | return ScreenSize.Mobile; |
61 | } |
62 | |
63 | if (root.width < root.mid-break-point) { |
64 | return ScreenSize.EmbeddedSmall; |
65 | } |
66 | |
67 | return ScreenSize.EmbeddedMedium; |
68 | } |
69 | } |