From 882dd8f54754ab6eb7c0940f464a8f25b88bf434 Mon Sep 17 00:00:00 2001 From: kmmiio99o Date: Sat, 27 Dec 2025 15:28:46 +0100 Subject: [PATCH] update look of the buttons --- .../multi-scrobbler/src/ui/pages/Settings.tsx | 38 ++++-------- .../pages/RPCCustomizationSettingsPage.tsx | 62 +++++++++---------- .../pages/components/TableComponents.tsx | 9 ++- 3 files changed, 51 insertions(+), 58 deletions(-) diff --git a/plugins/multi-scrobbler/src/ui/pages/Settings.tsx b/plugins/multi-scrobbler/src/ui/pages/Settings.tsx index 681f78a..02208f0 100644 --- a/plugins/multi-scrobbler/src/ui/pages/Settings.tsx +++ b/plugins/multi-scrobbler/src/ui/pages/Settings.tsx @@ -8,6 +8,7 @@ import { TableRowGroup, TableRow, TableSwitchRow, + TableCheckboxRow, ScrollView, } from "./pages/components/TableComponents"; @@ -62,7 +63,6 @@ class ServiceFactory { static async testService(service: ServiceType): Promise { try { - // Mock implementation - you can replace with actual service testing switch (service) { case "lastfm": return await this.testLastFmConnection(); @@ -82,9 +82,7 @@ class ServiceFactory { private static async testLastFmConnection(): Promise { const username = getStorage("username"); const apiKey = getStorage("apiKey"); - if (!username || !apiKey) return false; - try { const response = await fetch( `https://ws.audioscrobbler.com/2.0/?method=user.getinfo&user=${username}&api_key=${apiKey}&format=json`, @@ -100,11 +98,8 @@ class ServiceFactory { private static async testLibreFmConnection(): Promise { const username = getStorage("librefmUsername"); const apiKey = getStorage("librefmApiKey"); - if (!username || !apiKey) return false; - try { - // Libre.fm uses similar API to Last.fm const response = await fetch( `https://libre.fm/2.0/?method=user.getinfo&user=${username}&api_key=${apiKey}&format=json`, ); @@ -119,24 +114,16 @@ class ServiceFactory { private static async testListenBrainzConnection(): Promise { const username = getStorage("listenbrainzUsername"); const token = getStorage("listenbrainzToken"); - if (!username) return false; - try { const headers: Record = { "Content-Type": "application/json", }; - - if (token) { - headers["Authorization"] = `Token ${token}`; - } - + if (token) headers["Authorization"] = `Token ${token}`; const response = await fetch( `https://api.listenbrainz.org/1/user/${username}/listen-count`, { headers }, ); - - // If we get any response, the connection is valid return response.status === 200; } catch (error) { console.error("ListenBrainz connection test failed:", error); @@ -156,21 +143,18 @@ export default function Settings() { const getCredentialStatus = (service: ServiceType) => { switch (service) { - case "lastfm": { + case "lastfm": return getStorage("username") && getStorage("apiKey") ? "✅ Configured" : "❌ Missing credentials"; - } - case "librefm": { + case "librefm": return getStorage("librefmUsername") && getStorage("librefmApiKey") ? "✅ Configured" : "❌ Missing credentials"; - } - case "listenbrainz": { + case "listenbrainz": return getStorage("listenbrainzUsername") ? "✅ Configured" : "❌ Missing username"; - } default: return "❓ Unknown"; } @@ -191,13 +175,15 @@ export default function Settings() { /> {(["lastfm", "librefm", "listenbrainz"] as ServiceType[]).map( (service) => ( - { - if (value && service !== currentService) { + // Single choice logic: check if this matches current service + checked={currentService === service} + onPress={() => { + // Only update if clicking a service that isn't already selected + if (service !== currentService) { setStorage("service", service); forceUpdate(); } @@ -308,7 +294,7 @@ export default function Settings() { subLabel="Show off your music status from multiple services" /> - + diff --git a/plugins/multi-scrobbler/src/ui/pages/pages/RPCCustomizationSettingsPage.tsx b/plugins/multi-scrobbler/src/ui/pages/pages/RPCCustomizationSettingsPage.tsx index 06f82f1..362757e 100644 --- a/plugins/multi-scrobbler/src/ui/pages/pages/RPCCustomizationSettingsPage.tsx +++ b/plugins/multi-scrobbler/src/ui/pages/pages/RPCCustomizationSettingsPage.tsx @@ -4,7 +4,7 @@ import { ScrollView, Stack, TableRowGroup, - TableSwitchRow, + TableCheckboxRow, TableRow, } from "./components/TableComponents"; import { plugin } from "@vendetta"; @@ -25,23 +25,20 @@ export default function RPCCustomizationSettingsPage() { Constants.DEFAULT_SETTINGS.showTimestamp, ); - const handleListeningToChange = (value: boolean) => { - setStorage("listeningTo", value); + const handleListeningToChange = () => { + const newValue = !isListeningTo; + setStorage("listeningTo", newValue); - // If turning off "Show as Listening", also turn off "Show Timestamp" - if (!value && showTimestamp) { + if (!newValue && showTimestamp) { setStorage("showTimestamp", false); } forceUpdate(); }; - const handleTimestampChange = (value: boolean) => { - // Only allow turning on timestamp if "Show as Listening" is enabled - if (value && !isListeningTo) { - return; - } - setStorage("showTimestamp", value); + const handleTimestampChange = () => { + if (!isListeningTo) return; + setStorage("showTimestamp", !showTimestamp); forceUpdate(); }; @@ -50,23 +47,24 @@ export default function RPCCustomizationSettingsPage() { - - { - setStorage("showLargeText", value); + checked={getStorage("showLargeText", true)} + onPress={() => { + const current = getStorage("showLargeText", true); + setStorage("showLargeText", !current); forceUpdate(); }} /> - {/* Warning row when timestamp is disabled */} {!isListeningTo && ( )} - - { - setStorage("showAlbumInTooltip", value); + checked={getStorage("showAlbumInTooltip", true)} + onPress={() => { + const current = getStorage("showAlbumInTooltip", true); + setStorage("showAlbumInTooltip", !current); forceUpdate(); }} /> - { - setStorage("showDurationInTooltip", value); + checked={getStorage("showDurationInTooltip", true)} + onPress={() => { + const current = getStorage("showDurationInTooltip", true); + setStorage("showDurationInTooltip", !current); forceUpdate(); }} /> diff --git a/plugins/multi-scrobbler/src/ui/pages/pages/components/TableComponents.tsx b/plugins/multi-scrobbler/src/ui/pages/pages/components/TableComponents.tsx index 23318da..01273b6 100644 --- a/plugins/multi-scrobbler/src/ui/pages/pages/components/TableComponents.tsx +++ b/plugins/multi-scrobbler/src/ui/pages/pages/components/TableComponents.tsx @@ -1,8 +1,15 @@ import { findByProps } from "@vendetta/metro"; export const { ScrollView } = findByProps("ScrollView"); -export const { TableRowGroup, TableSwitchRow, Stack, TableRow } = findByProps( +export const { + TableRowGroup, + TableSwitchRow, + TableCheckboxRow, + Stack, + TableRow, +} = findByProps( "TableSwitchRow", + "TableCheckboxRow", "TableRowGroup", "Stack", "TableRow",