diff --git a/plugins/Commands/settings.tsx b/plugins/Commands/settings.tsx index bc268b9..cdc188c 100644 --- a/plugins/Commands/settings.tsx +++ b/plugins/Commands/settings.tsx @@ -1,17 +1,50 @@ -import { plugin } from "@vendetta"; import { storage } from "@vendetta/plugin"; import { useProxy } from "@vendetta/storage"; import { React, ReactNative as RN, stylesheet } from "@vendetta/metro/common"; -import { findByProps } from "@vendetta/metro"; import { NavigationNative } from "@vendetta/metro/common"; import { semanticColors } from "@vendetta/ui"; import { getAssetIDByName } from "@vendetta/ui/assets"; import { Forms } from "@vendetta/ui/components"; import { alerts } from "@vendetta/ui"; -const { ScrollView } = findByProps("ScrollView"); +const { ScrollView } = RN; const { FormRow, FormSwitchRow } = Forms; +// Initialize storage with default values - MOVED TO TOP +storage.factSettings ??= { + sendAsReply: true, + includeCitation: false, +}; + +storage.listSettings ??= { + pluginListAlwaysDetailed: false, + themeListAlwaysDetailed: false, +}; + +storage.garySettings ??= { + imageSource: "gary", +}; + +storage.enabledCommands ??= { + catfact: true, + dogfact: true, + useless: true, + petpet: true, + pluginList: true, + themeList: true, + konoself: true, + konosend: true, + firstmessage: true, + sysinfo: true, + spotifyTrack: true, + spotifyAlbum: true, + spotifyArtists: true, + spotifyCover: true, + gary: true, +}; + +storage.pendingRestart ??= false; + // Better Table Row Group Component function BetterTableRowGroup({ title, @@ -127,34 +160,31 @@ function Header() { ); } -// Facts Commands Settings Page - FIXED with Last.fm pattern +// Facts Commands Settings Page - SIMPLIFIED function FactsSettingsPage() { useProxy(storage); - const styles = stylesheet.createThemedStyleSheet({ - container: { - flex: 1, - backgroundColor: semanticColors.BACKGROUND_PRIMARY, - }, - }); - return ( - - + + } - value={storage.factSettings?.sendAsReply ?? true} - onValueChange={(value: boolean) => storage.factSettings.sendAsReply = value} + value={storage.factSettings.sendAsReply} + onValueChange={(v) => { + storage.factSettings.sendAsReply = v; + }} /> } - value={storage.factSettings?.includeCitation ?? false} - onValueChange={(value: boolean) => storage.factSettings.includeCitation = value} + value={storage.factSettings.includeCitation} + onValueChange={(v) => { + storage.factSettings.includeCitation = v; + }} /> @@ -163,9 +193,9 @@ function FactsSettingsPage() { label="/catfact" subLabel="Get random cat facts" leading={} - value={storage.enabledCommands?.catfact ?? true} - onValueChange={(value: boolean) => { - storage.enabledCommands.catfact = value; + value={storage.enabledCommands.catfact} + onValueChange={(v) => { + storage.enabledCommands.catfact = v; storage.pendingRestart = true; }} /> @@ -173,9 +203,9 @@ function FactsSettingsPage() { label="/dogfact" subLabel="Get random dog facts" leading={} - value={storage.enabledCommands?.dogfact ?? true} - onValueChange={(value: boolean) => { - storage.enabledCommands.dogfact = value; + value={storage.enabledCommands.dogfact} + onValueChange={(v) => { + storage.enabledCommands.dogfact = v; storage.pendingRestart = true; }} /> @@ -183,19 +213,19 @@ function FactsSettingsPage() { label="/useless" subLabel="Get random useless facts" leading={} - value={storage.enabledCommands?.useless ?? true} - onValueChange={(value: boolean) => { - storage.enabledCommands.useless = value; + value={storage.enabledCommands.useless} + onValueChange={(v) => { + storage.enabledCommands.useless = v; storage.pendingRestart = true; }} /> - - + + ); } -// Gary API Settings Page - FIXED with Last.fm pattern +// Gary API Settings Page - SIMPLIFIED with working radio buttons function GaryAPIPage() { useProxy(storage); @@ -216,156 +246,21 @@ function GaryAPIPage() { textAlign: "center", fontWeight: "600", }, - optionContainer: { - flexDirection: "row", - alignItems: "center", - paddingVertical: 12, - paddingHorizontal: 16, - marginHorizontal: 0, - backgroundColor: "transparent", - }, - radioContainer: { - flexDirection: "row", - alignItems: "center", - flex: 1, - }, - radioButton: { - width: 20, - height: 20, - borderRadius: 10, - borderWidth: 2, - borderColor: semanticColors.TEXT_MUTED, - alignItems: "center", - justifyContent: "center", - marginRight: 12, - }, - radioButtonSelected: { - borderColor: semanticColors.BRAND_500, - }, - radioInner: { - width: 10, - height: 10, - borderRadius: 5, - backgroundColor: semanticColors.BRAND_500, - }, - optionIcon: { - width: 20, - height: 20, - marginRight: 12, - tintColor: semanticColors.TEXT_MUTED, - }, - optionIconSelected: { - tintColor: semanticColors.BRAND_500, - }, - textContainer: { - flex: 1, - }, - optionTitle: { - fontSize: 16, - fontWeight: "500", - color: semanticColors.TEXT_NORMAL, - }, - optionTitleSelected: { - color: semanticColors.BRAND_500, - fontWeight: "600", - }, - optionDescription: { - fontSize: 14, - color: semanticColors.TEXT_MUTED, - marginTop: 2, - lineHeight: 18, - }, }); - const currentSource = storage.garySettings?.imageSource || "gary"; - - const options = [ - { - value: "gary", - title: "Gary API", - description: "Original Gary the cat images from api.garythe.cat", - icon: getAssetIDByName("ImageIcon"), - }, - { - value: "catapi", - title: "Cat API", - description: "Random cat pictures from thecatapi.com", - icon: getAssetIDByName("ImageIcon"), - }, - { - value: "minker", - title: "Minker API", - description: "Minky images from minky.materii.dev", - icon: getAssetIDByName("ImageIcon"), - }, - { - value: "goober", - title: "Goober API", - description: "Goober images from api.garythe.cat/goober", - icon: getAssetIDByName("ImageIcon"), - }, - ]; - - const renderOption = (option: typeof options[0]) => { - const isSelected = currentSource === option.value; - - return ( - { - storage.garySettings.imageSource = option.value; - }} - android_ripple={{ color: semanticColors.ANDROID_RIPPLE, radius: 300 }} - > - - - {isSelected && } - - - - - - - {option.title} - - - {option.description} - - - - - ); - }; + const currentSource = storage.garySettings.imageSource; return ( - - + + } - value={storage.enabledCommands?.gary ?? true} - onValueChange={(value: boolean) => { - storage.enabledCommands.gary = value; + value={storage.enabledCommands.gary} + onValueChange={(v) => { + storage.enabledCommands.gary = v; storage.pendingRestart = true; }} /> @@ -378,7 +273,42 @@ function GaryAPIPage() { - {options.map(renderOption)} + } + value={currentSource === "gary"} + onValueChange={(v) => { + if (v) storage.garySettings.imageSource = "gary"; + }} + /> + } + value={currentSource === "catapi"} + onValueChange={(v) => { + if (v) storage.garySettings.imageSource = "catapi"; + }} + /> + } + value={currentSource === "minker"} + onValueChange={(v) => { + if (v) storage.garySettings.imageSource = "minker"; + }} + /> + } + value={currentSource === "goober"} + onValueChange={(v) => { + if (v) storage.garySettings.imageSource = "goober"; + }} + /> @@ -390,43 +320,37 @@ function GaryAPIPage() { currentSource === "goober" ? "Goober API" : "Gary API" } - - Tap an option above to change the image source. - - - + + ); } -// List Commands Settings Page - FIXED with Last.fm pattern +// Simple List Settings Page function ListSettingsPage() { useProxy(storage); - const styles = stylesheet.createThemedStyleSheet({ - container: { - flex: 1, - backgroundColor: semanticColors.BACKGROUND_PRIMARY, - }, - }); - return ( - - + + } - value={storage.listSettings?.pluginListAlwaysDetailed ?? false} - onValueChange={(value: boolean) => storage.listSettings.pluginListAlwaysDetailed = value} + value={storage.listSettings.pluginListAlwaysDetailed} + onValueChange={(v) => { + storage.listSettings.pluginListAlwaysDetailed = v; + }} /> } - value={storage.listSettings?.themeListAlwaysDetailed ?? false} - onValueChange={(value: boolean) => storage.listSettings.themeListAlwaysDetailed = value} + value={storage.listSettings.themeListAlwaysDetailed} + onValueChange={(v) => { + storage.listSettings.themeListAlwaysDetailed = v; + }} /> @@ -435,9 +359,9 @@ function ListSettingsPage() { label="/plugin-list" subLabel="List all installed plugins" leading={} - value={storage.enabledCommands?.pluginList ?? true} - onValueChange={(value: boolean) => { - storage.enabledCommands.pluginList = value; + value={storage.enabledCommands.pluginList} + onValueChange={(v) => { + storage.enabledCommands.pluginList = v; storage.pendingRestart = true; }} /> @@ -445,40 +369,33 @@ function ListSettingsPage() { label="/theme-list" subLabel="List all installed themes" leading={} - value={storage.enabledCommands?.themeList ?? true} - onValueChange={(value: boolean) => { - storage.enabledCommands.themeList = value; + value={storage.enabledCommands.themeList} + onValueChange={(v) => { + storage.enabledCommands.themeList = v; storage.pendingRestart = true; }} /> - - + + ); } -// Image Commands Settings Page - FIXED with Last.fm pattern +// Simple Image Settings Page function ImageSettingsPage() { useProxy(storage); - const styles = stylesheet.createThemedStyleSheet({ - container: { - flex: 1, - backgroundColor: semanticColors.BACKGROUND_PRIMARY, - }, - }); - return ( - - + + } - value={storage.enabledCommands?.petpet ?? true} - onValueChange={(value: boolean) => { - storage.enabledCommands.petpet = value; + value={storage.enabledCommands.petpet} + onValueChange={(v) => { + storage.enabledCommands.petpet = v; storage.pendingRestart = true; }} /> @@ -489,9 +406,9 @@ function ImageSettingsPage() { label="/konoself" subLabel="Get random image from KonoChan (private)" leading={} - value={storage.enabledCommands?.konoself ?? true} - onValueChange={(value: boolean) => { - storage.enabledCommands.konoself = value; + value={storage.enabledCommands.konoself} + onValueChange={(v) => { + storage.enabledCommands.konoself = v; storage.pendingRestart = true; }} /> @@ -499,46 +416,33 @@ function ImageSettingsPage() { label="/konosend" subLabel="Send random image from KonoChan to channel" leading={} - value={storage.enabledCommands?.konosend ?? true} - onValueChange={(value: boolean) => { - storage.enabledCommands.konosend = value; + value={storage.enabledCommands.konosend} + onValueChange={(v) => { + storage.enabledCommands.konosend = v; storage.pendingRestart = true; }} /> - - + + ); } -// Spotify Commands Settings Page - FIXED with Last.fm pattern +// Simple Spotify Settings Page function SpotifySettingsPage() { useProxy(storage); - const styles = stylesheet.createThemedStyleSheet({ - container: { - flex: 1, - backgroundColor: semanticColors.BACKGROUND_PRIMARY, - }, - infoText: { - fontSize: 14, - color: semanticColors.TEXT_MUTED, - textAlign: "center", - lineHeight: 20, - }, - }); - return ( - - + + } - value={storage.enabledCommands?.spotifyTrack ?? true} - onValueChange={(value: boolean) => { - storage.enabledCommands.spotifyTrack = value; + value={storage.enabledCommands.spotifyTrack} + onValueChange={(v) => { + storage.enabledCommands.spotifyTrack = v; storage.pendingRestart = true; }} /> @@ -546,9 +450,9 @@ function SpotifySettingsPage() { label="/spotify album" subLabel="Share your current track's album" leading={} - value={storage.enabledCommands?.spotifyAlbum ?? true} - onValueChange={(value: boolean) => { - storage.enabledCommands.spotifyAlbum = value; + value={storage.enabledCommands.spotifyAlbum} + onValueChange={(v) => { + storage.enabledCommands.spotifyAlbum = v; storage.pendingRestart = true; }} /> @@ -556,9 +460,9 @@ function SpotifySettingsPage() { label="/spotify artists" subLabel="Share your current track's artists" leading={} - value={storage.enabledCommands?.spotifyArtists ?? true} - onValueChange={(value: boolean) => { - storage.enabledCommands.spotifyArtists = value; + value={storage.enabledCommands.spotifyArtists} + onValueChange={(v) => { + storage.enabledCommands.spotifyArtists = v; storage.pendingRestart = true; }} /> @@ -566,46 +470,44 @@ function SpotifySettingsPage() { label="/spotify cover" subLabel="Share your current track's cover" leading={} - value={storage.enabledCommands?.spotifyCover ?? true} - onValueChange={(value: boolean) => { - storage.enabledCommands.spotifyCover = value; + value={storage.enabledCommands.spotifyCover} + onValueChange={(v) => { + storage.enabledCommands.spotifyCover = v; storage.pendingRestart = true; }} /> - + These commands allow you to share your current Spotify activity in Discord. Make sure you have Spotify connected to Discord for these commands to work properly. - - + + ); } -// Other Commands Settings Page - FIXED with Last.fm pattern +// Simple Other Settings Page function OtherSettingsPage() { useProxy(storage); - const styles = stylesheet.createThemedStyleSheet({ - container: { - flex: 1, - backgroundColor: semanticColors.BACKGROUND_PRIMARY, - }, - }); - return ( - - + + } - value={storage.enabledCommands?.firstmessage ?? true} - onValueChange={(value: boolean) => { - storage.enabledCommands.firstmessage = value; + value={storage.enabledCommands.firstmessage} + onValueChange={(v) => { + storage.enabledCommands.firstmessage = v; storage.pendingRestart = true; }} /> @@ -616,19 +518,19 @@ function OtherSettingsPage() { label="/sysinfo" subLabel="Display system information" leading={} - value={storage.enabledCommands?.sysinfo ?? true} - onValueChange={(value: boolean) => { - storage.enabledCommands.sysinfo = value; + value={storage.enabledCommands.sysinfo} + onValueChange={(v) => { + storage.enabledCommands.sysinfo = v; storage.pendingRestart = true; }} /> - - + + ); } -// FIXED Credits Page - changed "contributor" to "developer" +// Credits Page function CreditsPage() { const styles = stylesheet.createThemedStyleSheet({ container: { @@ -748,8 +650,8 @@ function CreditsPage() { }; return ( - - + + Thanks to this developers for creating such a nice plugins!{'\n'} @@ -782,68 +684,16 @@ function CreditsPage() { Version 1.0.0 - - + + ); } -// Initialize storage with default values -if (!storage.factSettings) { - storage.factSettings = { - sendAsReply: true, - includeCitation: false, - }; -} - -if (!storage.listSettings) { - storage.listSettings = { - pluginListAlwaysDetailed: false, - themeListAlwaysDetailed: false, - }; -} - -if (!storage.garySettings) { - storage.garySettings = { - imageSource: "gary", - }; -} - -if (!storage.enabledCommands) { - storage.enabledCommands = { - catfact: true, - dogfact: true, - useless: true, - petpet: true, - pluginList: true, - themeList: true, - konoself: true, - konosend: true, - firstmessage: true, - sysinfo: true, - spotifyTrack: true, - spotifyAlbum: true, - spotifyArtists: true, - spotifyCover: true, - gary: true, - }; -} - -if (!storage.pendingRestart) { - storage.pendingRestart = false; -} - -// Main Settings Component - FIXED with Last.fm pattern +// MAIN SETTINGS COMPONENT - ULTRA SIMPLIFIED export default function Settings() { useProxy(storage); const navigation = NavigationNative.useNavigation(); - const styles = stylesheet.createThemedStyleSheet({ - container: { - flex: 1, - backgroundColor: semanticColors.BACKGROUND_PRIMARY, - }, - }); - // Check for pending restart when unmounting React.useEffect(() => { return () => { @@ -861,95 +711,91 @@ export default function Settings() { }, []); return ( - - -
+ +
- {/* Command Categories */} - - } - trailing={} - onPress={() => navigation.push("VendettaCustomPage", { - title: "Facts Commands", - render: FactsSettingsPage, - })} - /> - } - trailing={} - onPress={() => navigation.push("VendettaCustomPage", { - title: "List Commands", - render: ListSettingsPage, - })} - /> - } - trailing={} - onPress={() => navigation.push("VendettaCustomPage", { - title: "Image Commands", - render: ImageSettingsPage, - })} - /> - } - trailing={} - onPress={() => navigation.push("VendettaCustomPage", { - title: "Gary Commands", - render: GaryAPIPage, - })} - /> - } - trailing={} - onPress={() => navigation.push("VendettaCustomPage", { - title: "Spotify Commands", - render: SpotifySettingsPage, - })} - /> - } - trailing={} - onPress={() => navigation.push("VendettaCustomPage", { - title: "Other Commands", - render: OtherSettingsPage, - })} - /> - + {/* Command Categories */} + + } + trailing={} + onPress={() => navigation.push("VendettaCustomPage", { + title: "Facts Commands", + render: FactsSettingsPage, + })} + /> + } + trailing={} + onPress={() => navigation.push("VendettaCustomPage", { + title: "List Commands", + render: ListSettingsPage, + })} + /> + } + trailing={} + onPress={() => navigation.push("VendettaCustomPage", { + title: "Image Commands", + render: ImageSettingsPage, + })} + /> + } + trailing={} + onPress={() => navigation.push("VendettaCustomPage", { + title: "Gary Commands", + render: GaryAPIPage, + })} + /> + } + trailing={} + onPress={() => navigation.push("VendettaCustomPage", { + title: "Spotify Commands", + render: SpotifySettingsPage, + })} + /> + } + trailing={} + onPress={() => navigation.push("VendettaCustomPage", { + title: "Other Commands", + render: OtherSettingsPage, + })} + /> + - {/* More Options */} - - } - trailing={} - onPress={() => navigation.push("VendettaCustomPage", { - title: "Credits", - render: CreditsPage, - })} - /> - - - + {/* More Options */} + + } + trailing={} + onPress={() => navigation.push("VendettaCustomPage", { + title: "Credits", + render: CreditsPage, + })} + /> + + + + ); }