1 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
2 | // SPDX-License-Identifier: MIT |
3 | |
4 | import { Theme } from "theme.slint" ; |
5 | import { Navigation, MenuButton, Menu, Value } from "widgets/widgets.slint" ; |
6 | import { Balance, Overview, Usage, UsageAdapter, Weather, MenuPage, MenuOverviewAdapter, About } from "pages/pages.slint" ; |
7 | |
8 | export component SmallMain { |
9 | i-navigation := Navigation { |
10 | pagination-clicked => { |
11 | i-menu.open-menu(); |
12 | i-navigation.hide(); |
13 | } |
14 | |
15 | clicked => { |
16 | // if the navigation is clicked and the arrow displayed a open menu button should be hide. |
17 | i-menu.hide-button(); |
18 | } |
19 | |
20 | current-index <=> MenuOverviewAdapter.current-page; |
21 | page-count: MenuOverviewAdapter.count; |
22 | |
23 | // check current-index to generate only displayed items |
24 | if(i-navigation.current-index <= 1 && !i-menu.open) : Overview { |
25 | index: 0; |
26 | current-index: i-navigation.current-index; |
27 | } |
28 | |
29 | if(i-navigation.current-index >= 0 && i-navigation.current-index <= 2 && !i-menu.open) : Usage { |
30 | index: 1; |
31 | current-index: i-navigation.current-index; |
32 | } |
33 | |
34 | if(i-navigation.current-index >= 1 && i-navigation.current-index <= 3 && !i-menu.open) : Balance { |
35 | index: 2; |
36 | current-index: i-navigation.current-index; |
37 | } |
38 | |
39 | if(i-navigation.current-index >= 2 && i-navigation.current-index <= 4 && !i-menu.open) : Weather { |
40 | index: 3; |
41 | current-index: i-navigation.current-index; |
42 | } |
43 | |
44 | if(i-navigation.current-index >= 3 && i-navigation.current-index <= 5 && !i-menu.open) : About { |
45 | index: 4; |
46 | current-index: i-navigation.current-index; |
47 | } |
48 | } |
49 | |
50 | i-menu := Menu { |
51 | preferred-width: 100%; |
52 | preferred-height: 100%; |
53 | start-y: 25px; |
54 | end-y: 22px; |
55 | menu-width: parent.width - 8px; |
56 | menu-height: parent.height - 14px; |
57 | |
58 | if(i-menu.open) : MenuPage { |
59 | page-changed => { |
60 | i-menu.hide(); |
61 | } |
62 | |
63 | close => { |
64 | i-menu.hide(); |
65 | } |
66 | |
67 | preferred-width: 100%; |
68 | preferred-height: 100%; |
69 | } |
70 | } |
71 | } |
72 | |