| 1 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
| 2 | // SPDX-License-Identifier: MIT |
| 3 | |
| 4 | import { Page } from "page.slint" ; |
| 5 | import { GroupBox, ValueDisplay, Value } from "../widgets/widgets.slint" ; |
| 6 | |
| 7 | export global OverviewAdapter { |
| 8 | in property <string> production-title: "Production" ; |
| 9 | in property <string> self-consumption-title: "Self-consumption" ; |
| 10 | in property <[Value]> production-model: [ |
| 11 | { |
| 12 | title: "Daily" , |
| 13 | value: 12.56, |
| 14 | unit: "kWh" , |
| 15 | }, |
| 16 | { |
| 17 | title: "Weekly" , |
| 18 | value: 90.28, |
| 19 | unit: "kWh" , |
| 20 | } |
| 21 | ]; |
| 22 | in property <[Value]> self-consumption-model: [ |
| 23 | { |
| 24 | title: "Weekly" , |
| 25 | value: 54.08, |
| 26 | unit: "kWh" , |
| 27 | }, |
| 28 | { |
| 29 | title: "Monthly" , |
| 30 | value: 320.18, |
| 31 | unit: "kWh" , |
| 32 | } |
| 33 | ]; |
| 34 | } |
| 35 | |
| 36 | export component Overview inherits Page { |
| 37 | in property <string> production-title <=> OverviewAdapter.production-title; |
| 38 | in property <string> self-consumption-title <=> OverviewAdapter.self-consumption-title; |
| 39 | in property <[Value]> production-model <=> OverviewAdapter.production-model; |
| 40 | in property <[Value]> self-consumption-model <=> OverviewAdapter.self-consumption-model; |
| 41 | |
| 42 | width: 100%; |
| 43 | height: 100%; |
| 44 | |
| 45 | VerticalLayout { |
| 46 | spacing: 12px; |
| 47 | |
| 48 | i-production-group := GroupBox { |
| 49 | title: root.production-title; |
| 50 | |
| 51 | ValueDisplay { |
| 52 | active: root.active; |
| 53 | model: root.production-model; |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | i-self-consumption-group := GroupBox { |
| 58 | title: root.self-consumption-title; |
| 59 | |
| 60 | ValueDisplay { |
| 61 | active: root.active; |
| 62 | alternative-colors: true; |
| 63 | |
| 64 | model: root.self-consumption-model; |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | } |