| 1 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
| 2 | // SPDX-License-Identifier: MIT |
| 3 | |
| 4 | import { Theme } from "../theme.slint" ; |
| 5 | |
| 6 | export component RadioButton { |
| 7 | in property <bool> checked; |
| 8 | |
| 9 | callback clicked <=> i-touch-area.clicked; |
| 10 | |
| 11 | states [ |
| 12 | checked when checked : { |
| 13 | i-container.border-color: Theme.palette.lemon-green; |
| 14 | i-indicator.background: Theme.palette.lemon-green; |
| 15 | } |
| 16 | ] |
| 17 | |
| 18 | min-height: 18px; |
| 19 | width: self.height; |
| 20 | |
| 21 | i-container := Rectangle { |
| 22 | border-color: Theme.palette.slint-blue-300; |
| 23 | border-width: 2px; |
| 24 | border-radius: self.height / 2; |
| 25 | |
| 26 | animate border-color { duration: Theme.durations.fast; } |
| 27 | |
| 28 | i-indicator := Rectangle { |
| 29 | height: parent.height - 4 * parent.border-width; |
| 30 | width: self.height; |
| 31 | border-radius: self.height / 2; |
| 32 | |
| 33 | animate background { duration: Theme.durations.fast; } |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | i-touch-area := TouchArea {} |
| 38 | } |
| 39 | |