| 1 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
| 2 | // SPDX-License-Identifier: MIT |
| 3 | import { AppState, WidgetType, ComponentData } from "../../appState.slint" ; |
| 4 | import { Lamp } from "../lamp.slint" ; |
| 5 | import { Appliance } from "../appliance.slint" ; |
| 6 | import { Overhead } from "../overhead.slint" ; |
| 7 | import { Info } from "../info.slint" ; |
| 8 | import { Graph } from "../graph.slint" ; |
| 9 | import { Control } from "../control.slint" ; |
| 10 | import { MusicPlayer } from "../musicPlayer.slint" ; |
| 11 | import { Camera } from "../camera.slint" ; |
| 12 | import { HVAC } from "../hvac.slint" ; |
| 13 | import { Alarm } from "../alarm.slint" ; |
| 14 | import { Measurements, Animation } from "../../common.slint" ; |
| 15 | |
| 16 | |
| 17 | export component FullScreenWidgetLoader { |
| 18 | in property <int> index; |
| 19 | in property <ComponentData> data; |
| 20 | property <bool> show: false; |
| 21 | property <bool> moveMode: false; |
| 22 | in property <bool> skip-initial-fade: false; |
| 23 | in property <WidgetType> type; |
| 24 | property <length> animTargetX: data.x * 1px; |
| 25 | property <length> animTargetY: data.y * 1px; |
| 26 | property <length> animTargetWidth: data.width * 1px; |
| 27 | property <length> animTargetHeight: data.height * 1px; |
| 28 | |
| 29 | animate animTargetX, animTargetY, animTargetWidth, animTargetHeight { |
| 30 | duration: Animation.full-screen-duration; |
| 31 | easing: ease-in-out-sine; |
| 32 | } |
| 33 | |
| 34 | changed data => { |
| 35 | animTargetX = self.data.x * 1px; |
| 36 | animTargetY = self.data.y * 1px; |
| 37 | animTargetWidth = self.data.width * 1px; |
| 38 | animTargetHeight = self.data.height * 1px; |
| 39 | } |
| 40 | |
| 41 | opacity: 1; |
| 42 | x: animTargetX * AppState.x-scale; |
| 43 | y: animTargetY * AppState.y-scale; |
| 44 | width: animTargetWidth * AppState.x-scale; |
| 45 | height: animTargetHeight * AppState.y-scale; |
| 46 | |
| 47 | // Use the correct component based on type |
| 48 | if root.type == WidgetType.lamp: Lamp { |
| 49 | name: AppState.component-details[root.index].name; |
| 50 | id: AppState.component-details[root.index].id; |
| 51 | width: root.width; |
| 52 | height: root.height; |
| 53 | full-screen: true; |
| 54 | } |
| 55 | |
| 56 | if root.type == WidgetType.appliance: Appliance { |
| 57 | name: AppState.component-details[root.index].name; |
| 58 | id: AppState.component-details[root.index].id; |
| 59 | width: root.width; |
| 60 | height: root.height; |
| 61 | full-screen: true; |
| 62 | } |
| 63 | |
| 64 | if root.type == WidgetType.overhead: Overhead { |
| 65 | name: AppState.component-details[root.index].name; |
| 66 | id: AppState.component-details[root.index].id; |
| 67 | width: root.width; |
| 68 | height: root.height; |
| 69 | full-screen: true; |
| 70 | } |
| 71 | |
| 72 | if root.type == WidgetType.info: Info { |
| 73 | name: AppState.component-details[root.index].name; |
| 74 | id: AppState.component-details[root.index].id; |
| 75 | width: root.width; |
| 76 | height: root.height; |
| 77 | full-screen: true; |
| 78 | } |
| 79 | |
| 80 | if root.type == WidgetType.graph: Graph { |
| 81 | name: AppState.component-details[root.index].name; |
| 82 | id: AppState.component-details[root.index].id; |
| 83 | width: root.width; |
| 84 | height: root.height; |
| 85 | full-screen: true; |
| 86 | } |
| 87 | |
| 88 | if root.type == WidgetType.control: Control { |
| 89 | name: AppState.component-details[root.index].name; |
| 90 | id: AppState.component-details[root.index].id; |
| 91 | width: root.width; |
| 92 | height: root.height; |
| 93 | full-screen: true; |
| 94 | } |
| 95 | if root.type == WidgetType.music: MusicPlayer { |
| 96 | name: AppState.component-details[root.index].name; |
| 97 | id: AppState.component-details[root.index].id; |
| 98 | width: root.width; |
| 99 | height: root.height; |
| 100 | full-screen: true; |
| 101 | } |
| 102 | if root.type == WidgetType.hvac: HVAC { |
| 103 | name: AppState.component-details[root.index].name; |
| 104 | id: AppState.component-details[root.index].id; |
| 105 | index: root.index; |
| 106 | width: root.width; |
| 107 | height: root.height; |
| 108 | full-screen: true; |
| 109 | } |
| 110 | if root.type == WidgetType.camera: Camera { |
| 111 | name: AppState.component-details[root.index].name; |
| 112 | id: AppState.component-details[root.index].id; |
| 113 | width: root.width; |
| 114 | height: root.height; |
| 115 | full-screen: true; |
| 116 | } |
| 117 | if root.type == WidgetType.alarm: Alarm { |
| 118 | name: AppState.component-details[root.index].name; |
| 119 | id: AppState.component-details[root.index].id; |
| 120 | width: root.width; |
| 121 | height: root.height; |
| 122 | full-screen: true; |
| 123 | } |
| 124 | } |
| 125 | |