From af3d404c4d33324e25aa4be63b1a5b65c01eed4b Mon Sep 17 00:00:00 2001 From: PalmDevs Date: Sat, 7 Jun 2025 15:51:52 +0700 Subject: [PATCH] feat(plugins/developer-settings): improve Asset Browser --- .../screens/AssetBrowserSettingScreen.tsx | 70 ++++++++++++------- 1 file changed, 46 insertions(+), 24 deletions(-) diff --git a/src/plugins/init/developer-settings/screens/AssetBrowserSettingScreen.tsx b/src/plugins/init/developer-settings/screens/AssetBrowserSettingScreen.tsx index 5e070aa..24113eb 100644 --- a/src/plugins/init/developer-settings/screens/AssetBrowserSettingScreen.tsx +++ b/src/plugins/init/developer-settings/screens/AssetBrowserSettingScreen.tsx @@ -1,9 +1,13 @@ import { getAssets } from '@revenge-mod/assets' -import { AlertActionCreators } from '@revenge-mod/discord/actions' +import { + AlertActionCreators, + ToastActionCreators, +} from '@revenge-mod/discord/actions' import { Design } from '@revenge-mod/discord/design' import { Clipboard } from '@revenge-mod/externals/react-native-clipboard' import { FlashList } from '@revenge-mod/externals/shopify' import { React, ReactNative } from '@revenge-mod/react' +import { lookupGeneratedIconComponent } from '@revenge-mod/utils/discord' import Page from '~/components/Page' import SearchInput from '~/components/SearchInput' import TableRowAssetIcon from '~/components/TableRowAssetIcon' @@ -41,6 +45,7 @@ export default function AssetBrowserSettingScreen() { setSearch(v)} size="md" /> asset.id @@ -78,8 +83,18 @@ function AssetDisplay({ const metadata = [ ['ID', id.toString()], ['Type', asset.type], - ['Module ID', moduleId?.toString()], - ] as const + ] as [string, string, unpressable?: boolean, hiddenInText?: boolean][] + + metadata.push( + moduleId + ? ['Module ID', moduleId.toString()] + : [ + 'Custom asset', + 'This is a custom asset registered by a plugin.', + true, + true, + ], + ) return ( openAssetDisplayAlert(asset, id, metadata)} start={start} subLabel={metadata + .filter(([, , , hiddenInText]) => !hiddenInText) .map(([name, value]) => `${name}: ${value ?? 'N/A'}`) - .join(' • ')} + .join(' • ')} variant={isDisplayable ? 'default' : 'danger'} /> ) } +const CopyIcon = lookupGeneratedIconComponent('CopyIcon') + function openAssetDisplayAlert( asset: Asset, id: AssetId, - metadata: - | Readonly[]> - | [string, string | undefined][], + metadata: [string, string, pressable?: boolean, ...unknown[]][], ) { const isDisplayable = Displayable.has(asset.type) @@ -132,23 +148,26 @@ function openAssetDisplayAlert( )} - {metadata.map(([name, value]) => - value ? ( - Clipboard.setString(value)} - subLabel={value} - /> - ) : ( - - ), - )} + {metadata.map(([name, value, unpressable]) => ( + { + Clipboard.setString(value) + + ToastActionCreators.open({ + key: 'ASSET_BROWSER_COPIED', + IconComponent: CopyIcon, + content: `Copied ${name} to clipboard`, + }) + } + } + subLabel={value} + /> + ))} Note: Asset IDs and module IDs are not consistent @@ -175,6 +194,9 @@ function PreviewUnavailable({ type }: { type: string }) { } const styles = StyleSheet.create({ + listContainer: { + paddingBottom: 16, + }, smallPreview: { height: 32, width: 32,