RootScreen:
    Home:
    Main:
    ShowcaseS:

###########
# POPUPS
###########
<AppQuitting>:
    title: "App is quitting"
    auto_dismiss: False
    GridLayout:
        cols: 1
        Label:
            text: "App is closing remaining processes..."
            font_size: 30
        Label:
            text: "Please wait..."
            font_size: 20


<ConnectPU>:
    title: "Connect to Server"
    auto_dismiss: False
    size_hint: 0.8, 0.8
    GridLayout:
        cols: 1
        Label:
            text: "Please enter the Server's IP address below!"
        Label:
            text: ""
            id: output
        TextInput:
            text: ""
            id: url
            hint_text: "Enter Server-IP"
        GridLayout:
            cols: 2
            Button:
                text: "Connect"
                on_release:
                    root.tryconnect()
            Button:
                text: "Cancel"
                on_release:
                    root.dismiss()


<QuitPU>:
    title: "MusicPlayer"
    font_size: 50
    size_hint: 0.5, 0.4
    auto_dismiss: False
    GridLayout:
        cols:1
        Label:
            text: "Are you sure you want to leave?"
            font_size: 20
        GridLayout:
            cols:2
            Button:
                text: "Yes"
                font_size: 15
                on_release:
                    root.quitapp()
                    app.stop()
            Button:
                text: "No"
                font_size: 15
                on_press:
                    root.dismiss()

<PathMissingPU>:
    title: "NOTICE!"
    font_size: 50
    size_hint: 0.5, 0.4
    auto_dismiss: False
    GridLayout:
        cols:1
        Label:
            text: "No path specified, unable to proceed"
            font_size: 18
        Label:
            text: "Please enter a path and try again"
            font_size: 15
        Button:
            text:"Ok"
            on_release:
                root.dismiss()

<PathWrongPU>:
    title: "NOTICE!"
    font_size: 50
    size_hint: 0.5, 0.4
    auto_dismiss: False
    GridLayout:
        cols:1
        Label:
            text: "Path without any mp3/wav files specified"
            font_size: 18
        Label:
            text: "Please enter another path and try again"
            font_size: 15
        Button:
            text:"Ok"
            on_release:
                root.dismiss()

<invalidpathPU>:
    title: "NOTICE!"
    font_size: 50
    size_hint: 0.7, 0.6
    auto_dismiss: False
    GridLayout:
        cols:1
        Label:
            text: "Invalid path specified"
            font_size: 18
        Label:
            text: "Please enter a valid path and try again"
            font_size: 15
        Label:
            text: "Please be aware, that you cannot specify any other file type other than \"Directory\""
            font_size: 12
        Button:
            text:"Ok"
            on_release:
                root.dismiss()

<NotConnected>:
    title: "NOTICE!"
    font_size: 50
    size_hint: 0.5, 0.4
    auto_dismiss: False
    GridLayout:
        cols:1
        Label:
            text: "You are not connected to a server!"
            font_size: 18
        Label:
            text: "Therefore this function is not available!"
            font_size: 15
        Button:
            text:"Ok"
            on_release:
                root.dismiss()

<LeavePU>:
    title: "DISABLE FULLSCREEN AND LEAVE"
    font_size: 50
    size_hint: 0.5, 0.4
    auto_dismiss: False
    GridLayout:
        cols:1
        Label:
            text: "Please enter the password to leave the fullscreen mode!"
            font_size: 18
        TextInput:
            id: passw
            multiline: False
            on_text_validate: root.returnToFullscreen()
        Label:
            id: output
            text: ""
        Button:
            text:"Ok"
            on_release:
                root.check_pwd()
        Button:
            text: "cancel"
            on_release:
                root.dismiss()

###########
# SCREENS
###########

<Home>:
    name: "Home"
    md_bg_color: app.theme_cls.accent_dark
    GridLayout:
        cols: 1
        Label:
            id: titleapp
            text: root.initapp()
            color: app.theme_cls.primary_color
            font_size: 50
            bold: True
            italic: True
        FloatLayout:
            GridLayout:
                cols: 1
                pos_hint: {"x":0.05, "y":0.05}
                size_hint: 0.9, 0.9
                FloatLayout:
                    MDTextField:
                        id: filepath
                        hint_text: "Path to Folder containing the Music files"
                        pos_hint: {"x":0.2, "y":0.5}
                        size_hint_x: 0.6
                        focus: True
                        text: "/mnt/storage/SORTED/Music"
                        on_text:
                            root.autocomplete()
                        on_text_validate:
                            root.change_screen()
                    Label:
                        text: ""
                        pos_hint: {"x": 0.2, "y":1}
                        size_hint: 0.6, 0.3
                        text_size: self.size
                        id: cmd_output
                GridLayout:
                    cols: 3
                    Button:
                        text: "Start"
                        color: app.theme_cls.primary_color
                        font_size: 30
                        bold: True
                        background_color: app.theme_cls.accent_dark
                        on_release:
                            root.change_screen()
                    Button:
                        text: "Connect to Server"
                        color: app.theme_cls.primary_color
                        font_size: 30
                        bold: True
                        background_color: app.theme_cls.accent_dark
                        on_release:
                            root.connectServer()
                    Button:
                        text: "Quit"
                        color: app.theme_cls.primary_color
                        font_size: 30
                        bold: True
                        background_color: app.theme_cls.accent_dark
                        on_release:
                            root.quitapp()


<Main>:
    on_pre_enter: root.initialize()
    name: "Main"
    md_bg_color: app.theme_cls.accent_dark
    GridLayout:
        cols: 1
        GridLayout:
            cols: 1
            Label:
                text: "MusicPlayer"
                font_size: 40
                color: app.theme_cls.primary_color
            Label:
                text: "playing song will appear here"
                id: current_song
                font_size: 25
                color: app.theme_cls.primary_dark
        FloatLayout:
            GridLayout:
                size_hint: 0.8, 0.9
                pos_hint: {"x": 0.1, "y": 0.1}
                cols: 1
                GridLayout:
                    cols: 3
                    Button:
                        text: "Previous"
                        background_color: app.theme_cls.accent_dark
                        on_release:
                            root.previoussong()
                    Button:
                        text: "Rewind"
                        background_color: app.theme_cls.accent_dark
                        on_release:
                            root.rewindsong()
                    Button:
                        text: "Next"
                        background_color: app.theme_cls.accent_dark
                        on_release:
                            root.nextsong()

                Button:
                    text: "Play"
                    id: pp_button
                    background_color: app.theme_cls.accent_dark
                    on_release:
                        root.playmusic()
                GridLayout:
                    cols: 3
                    Button:
                        text: "Back"
                        background_color: app.theme_cls.accent_dark
                        on_release:
                            root.go_back()
                    Button:
                        text: "Fullscreen on client\n(Only available if connected)"
                        id: fullscreenc
                        background_color: app.theme_cls.accent_dark
                        on_release:
                            root.changeServerSettings()
                    Button:
                        text: "Showcase"
                        background_color: app.theme_cls.accent_dark
                        on_release:
                            app.root.current = "Showcase"
                            root.manager.transition.direction = "left"
            Label:
                text: "Test"
                id: connectstatus
                pos_hint: {"y": -0.45}

<ShowcaseS>:
    on_pre_enter: root.reset()
    name: "Showcase"
    md_bg_color: (0, 0, 0, 1)
    FloatLayout:
        Label:
            text: "Currently Playing"
            id: titleinfo
            bold: True
            italic: True
            pos_hint: {"y": 0.35}
            font_size: 60
            color: app.theme_cls.primary_color
        MDProgressBar:
            orientation: "horizontal"
            value: 100
            pos_hint: {"top": 0.8}
            color: (1, 1, 1, 0.5)
        MDProgressBar:
            id: progressbars
            orientation: "horizontal"
            value: 0
            pos_hint: {"top": 0.8}
            color: app.theme_cls.primary_dark
        Label:
            id: current_song
            text: "Currently playing Song will appear here"
            pos_hint: {"y": 0.22}
            font_size: 45
            color: app.theme_cls.primary_color
            shorten: False
            halign: "center"
        Label:
            id: upcoming_ind
            text: "upcoming"
            bold: True
            italic: True
            font_size: 35
            pos_hint: {"y": -0.05}
            color: app.theme_cls.primary_color
        Label:
            id: upcoming_songs
            text: "Upcoming Songs will appear here"
            pos_hint: {"y": -0.25}
            font_size: 30
            color: app.theme_cls.primary_color
            shorten: False
            halign: "center"
        Button:
            text: "back"
            font_size: 10
            size_hint: 0.05, 0.05
            background_color: app.theme_cls.accent_light
            on_release:
                root.leave_screen()
        Label:
            text: "Designed and developed by Janis Hutz"
            font_size: 7
            pos_hint: {"y": -0.48}

<SettingsS>:
    name: "Settings"
    md_bg_color: app.theme_cls.accent_color
    ToggleButton:
        text: "Songinfo = Filename"
