[UI > AssetBrowser] Add
This commit is contained in:
parent
ed5fc58845
commit
111720806c
4 changed files with 63 additions and 1 deletions
27
src/ui/settings/components/AssetBrowser.tsx
Normal file
27
src/ui/settings/components/AssetBrowser.tsx
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
import { React, ReactNative as RN } from "@metro/common";
|
||||||
|
import { Forms } from "@ui/components";
|
||||||
|
import { all } from "@ui/assets";
|
||||||
|
import AssetDisplay from "./AssetDisplay";
|
||||||
|
|
||||||
|
const { FormInput } = Forms
|
||||||
|
|
||||||
|
export default function AssetBrowser() {
|
||||||
|
const [searchName, setSearchName] = React.useState("");
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<FormInput
|
||||||
|
value={searchName}
|
||||||
|
onChange={(v: string) => setSearchName(v)}
|
||||||
|
title="SEARCH"
|
||||||
|
/>
|
||||||
|
<RN.FlatList
|
||||||
|
data={Object.values(all).filter(a => a.name.startsWith(searchName))}
|
||||||
|
renderItem={({ item }) => (
|
||||||
|
<AssetDisplay asset={item} />
|
||||||
|
)}
|
||||||
|
keyExtractor={item => item.name}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
25
src/ui/settings/components/AssetDisplay.tsx
Normal file
25
src/ui/settings/components/AssetDisplay.tsx
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
import { Asset } from "@types";
|
||||||
|
import { React, ReactNative as RN } from "@metro/common";
|
||||||
|
import { Forms } from "@ui/components";
|
||||||
|
|
||||||
|
interface AssetDisplayProps {
|
||||||
|
asset: Asset;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { FormRow } = Forms;
|
||||||
|
|
||||||
|
const styles = RN.StyleSheet.create({
|
||||||
|
asset: {
|
||||||
|
width: 32,
|
||||||
|
height: 32,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default function AssetDisplay({ asset }: AssetDisplayProps) {
|
||||||
|
return (
|
||||||
|
<FormRow
|
||||||
|
label={`${asset.name} - ${asset.id}`}
|
||||||
|
trailing={() => <RN.Image source={asset.id} style={styles.asset} />}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
|
@ -15,6 +15,11 @@ export default function SettingsSection({ navigation }: SettingsSectionProps) {
|
||||||
trailing={FormRow.Arrow}
|
trailing={FormRow.Arrow}
|
||||||
onPress={() => navigation.push("VendettaSettings")}
|
onPress={() => navigation.push("VendettaSettings")}
|
||||||
/>
|
/>
|
||||||
|
<FormRow
|
||||||
|
label="Asset Browser"
|
||||||
|
trailing={FormRow.Arrow}
|
||||||
|
onPress={() => navigation.push("VendettaAssetBrowser")}
|
||||||
|
/>
|
||||||
</FormSection>
|
</FormSection>
|
||||||
)
|
)
|
||||||
}
|
}
|
|
@ -4,6 +4,7 @@ import { after } from "@lib/patcher";
|
||||||
import findInReactTree from "@utils/findInReactTree";
|
import findInReactTree from "@utils/findInReactTree";
|
||||||
import Settings from "./components/Settings";
|
import Settings from "./components/Settings";
|
||||||
import SettingsSection from "./components/SettingsSection";
|
import SettingsSection from "./components/SettingsSection";
|
||||||
|
import AssetBrowser from "./components/AssetBrowser";
|
||||||
|
|
||||||
const screensModule = findByDisplayName("getScreens", false);
|
const screensModule = findByDisplayName("getScreens", false);
|
||||||
const settingsModule = findByDisplayName("UserSettingsOverviewWrapper", false);
|
const settingsModule = findByDisplayName("UserSettingsOverviewWrapper", false);
|
||||||
|
@ -15,6 +16,10 @@ export default function initSettings() {
|
||||||
VendettaSettings: {
|
VendettaSettings: {
|
||||||
title: "Vendetta Settings",
|
title: "Vendetta Settings",
|
||||||
render: Settings
|
render: Settings
|
||||||
|
},
|
||||||
|
VendettaAssetBrowser: {
|
||||||
|
title: "Asset Browser",
|
||||||
|
render: AssetBrowser
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue