2024-08-15 15:20:57 -04:00
< script lang = "ts" >
import { Avatar } from "flowbite-svelte";
2024-09-04 12:05:41 -04:00
import type { AniListUser } from "../anilist/types/AniListTypes";
2024-08-15 16:16:40 -04:00
import { aniListLoggedIn , aniListUser , malLoggedIn , simklLoggedIn , logoutOfAniList , logoutOfMAL , logoutOfSimkl } from "./GlobalVariablesAndHelperFunctions.svelte"
2024-09-04 12:05:41 -04:00
import * as runtime from "../../wailsjs/runtime";
2024-08-15 15:20:57 -04:00
let currentAniListUser: AniListUser
let isAniListLoggedIn: boolean
let isSimklLoggedIn: boolean
let isMALLoggedIn: boolean
aniListUser.subscribe((value) => currentAniListUser = value)
aniListLoggedIn.subscribe((value) => isAniListLoggedIn = value)
simklLoggedIn.subscribe((value) => isSimklLoggedIn = value)
malLoggedIn.subscribe((value) => isMALLoggedIn = value)
function dropdownUser(): void {
let dropdown = document.querySelector("#userDropdown")
dropdown.classList.toggle("hidden")
}
< / script >
< div class = "relative" >
< button id = "userDropdownButton" on:click = { dropdownUser } >
{ #if isAniListLoggedIn }
< Avatar src = " { currentAniListUser . data . Viewer . avatar . medium } " class = "cursor-pointer"
dot={{ color : 'green' }} />
{ : else }
< Avatar class = "cursor-pointer" dot = {{ color : 'red' }} / >
{ /if }
< / button >
< div id = "userDropdown"
2024-08-15 15:44:11 -04:00
class="absolute hidden right-0 2xl:left-1/2 2xl:-translate-x-1/2 z-10 bg-white divide-y divide-gray-100 rounded-lg shadow w-44 dark:bg-gray-700 dark:divide-gray-600">
2024-08-15 15:20:57 -04:00
< div class = "px-4 py-3 text-sm text-gray-900 dark:text-white" >
{ #if isAniListLoggedIn }
< div > { currentAniListUser . data . Viewer . name } </ div >
{ : else }
< div > You are not logged into AniList< / div >
{ /if }
< / div >
< ul class = "py-2 text-sm text-gray-700 dark:text-gray-200"
aria-labelledby="dropdownUserAvatarButton">
{ #if isAniListLoggedIn }
< li >
2024-08-15 16:16:40 -04:00
< button on:click = { logoutOfAniList }
2024-08-15 15:20:57 -04:00
class="block px-4 py-2 w-full hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
Logout Anilist
< / button >
< / li >
{ /if }
{ #if isMALLoggedIn }
< li >
2024-08-15 16:16:40 -04:00
< button on:click = { logoutOfMAL }
2024-08-15 15:20:57 -04:00
class="block px-4 py-2 w-full hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
Logout MAL
< / button >
< / li >
{ /if }
{ #if isSimklLoggedIn }
< li >
2024-08-15 16:16:40 -04:00
< button on:click = { logoutOfSimkl }
2024-08-15 15:20:57 -04:00
class="block px-4 py-2 w-full hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
Logout Simkl
< / button >
< / li >
{ /if }
< / ul >
< div class = "py-2" >
< button on:click = {() => runtime . Quit ()}
class="block px-4 py-2 w-full text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white">
Exit Application
< / button >
< / div >
< / div >
< / div >