import { SpinBox, Button, CheckBox, Slider, LineEdit, ScrollView, ListView,
HorizontalBox, VerticalBox, GridBox, StandardButton , ComboBox} from "std-widgets.slint";
export struct SlintUser{
first_name: string,
id: int,
mail: string,
}
export struct SSchool{
name: string,
id: int,
}
export enum State{
logged,
notlogged,
}
export global Callbacks{
callback login();
callback logout();
callback get_key();
}
export global Data{
in-out property <State> state: State.notlogged;
in-out property <SlintUser> user;
in-out property <[SSchool]> schools;
in-out property <string> key: "";
in-out property <bool> logged: false;
}
export global LForm{
in-out property<string> email: "";
in-out property<string> password: "";
}
export component MainPage inherits VerticalBox{
width: 90%;
padding-bottom: 5px;
// padding-top: 5px;
Text{
// vertical-alignment: top;
horizontal-alignment: center;
text: "Merhaba " + Data.user.first-name;
}
// HorizontalBox {
ListView {
height: 150px;
width: 150px;
for s in Data.schools:Text{
text: s.name;
}
}
// }
Text{
padding-top: 10px;
padding-bottom: 10px;
horizontal-alignment: center;
text: Data.key;
}
Button{
height: 10%;
text: "Kod iste";
clicked => {
Callbacks.get-key();
}
}
Button{
height: 10%;
text: "Çıkış Yap";
clicked =>{
Data.logged = false;
Callbacks.logout();
}
}
}
component LoginPage inherits VerticalBox{
width: 80%;
alignment: center;
LineEdit{
padding-top: 20px;
width: 20%;
text: "";
placeholder-text:"e-posta gir";
input-type: InputType.text;
edited(email)=>{
LForm.email = email;
}
}
LineEdit{
placeholder-text: "Şifreyi gir";
input-type: InputType.password;
edited(passwd)=>{
LForm.password = passwd;
}
}
Button{
text: "Giriş Yap";
clicked=>{
//is_login=true;
Callbacks.login();
}
}
}
export component MyApp inherits Window {
in-out property <State> state: State.notlogged;
if !Data.logged: login_page := LoginPage{}
if Data.logged: main := MainPage{
}
}