import { ComboBox, LineEdit } from "std-widgets.slint";
import { Style } from "globals.slint";
import { IconButton } from "widgets/icon-button.slint";

export component LoginView inherits VerticalLayout {
    padding: Style.spacing;
    spacing: Style.spacing;
    in property <[string]> usernames <=> combo_box_username.model;
    callback users_clicked();
    callback pw_accepted(string, string);
    Rectangle { }

    HorizontalLayout {
        spacing: Style.spacing;
        IconButton {
            icon: @image-url("images/users.svg");
            clicked => {
                users_clicked();
            }
        }

        combo_box_username := ComboBox { }

        line_edit_user_pw := LineEdit {
            input-type: InputType.password;
            placeholder-text: "Password";
            accepted(text) => {
                root.pw_accepted(combo_box_username.current-value, text);
            }
        }

        IconButton {
            icon: @image-url("images/log-in.svg");
            clicked => {
                root.pw_accepted(combo_box_username.current-value, line_edit_user_pw.text);
            }
        }
    }

    Rectangle { }
}
