Loading files
2955876e1This file is pinned to the selected release. Download the original to open it in your design tool.
import { NavBar, NavBarItemData } from "navbar.slint";
export component SlideView inherits VerticalLayout {
in property <[NavBarItemData]> pages;
in-out property <int> current-index: 0;
in-out property <int> current-navbar-index: current-index;
callback page-clicked(index: int);
page-clicked(index) => {
current-index = index;
}
navbar := NavBar {
items: pages;
current-index: current-navbar-index;
page-clicked(index) => {
root.page-clicked(index);
}
}
Rectangle {
height: 1px;
background: #555555;
}
// Using a Rectangle instead of a Flickable, see explanation in
// https://github.com/slint-ui/slint/issues/9080.
Rectangle {
property <float> animated-index: max(min(current-index, pages.length - 1), 0);
animate animated-index { duration: 200ms; }
clip: true;
HorizontalLayout {
x: -parent.width * animated-index;
width: parent.width * pages.length;
height: 100%;
@children
}
}
}