Create Index.ts
This commit is contained in:
parent
bdb448eb94
commit
24ebe343bd
1 changed files with 54 additions and 0 deletions
54
src/core/plugins/custom background music/Index.ts
Normal file
54
src/core/plugins/custom background music/Index.ts
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
import { findByProps } from "@vendetta/metro";
|
||||||
|
import { React, ReactNative } from "@vendetta/metro/common";
|
||||||
|
import { storage } from "@vendetta/plugin";
|
||||||
|
import { before } from "@vendetta/patcher";
|
||||||
|
import Settings from "./Settings";
|
||||||
|
|
||||||
|
const { ImageBackground } = ReactNative;
|
||||||
|
|
||||||
|
export const settings: {
|
||||||
|
backgroundUrl?: string;
|
||||||
|
opacity?: number;
|
||||||
|
blur?: number;
|
||||||
|
} = storage;
|
||||||
|
|
||||||
|
let unpatch: (() => void) | undefined;
|
||||||
|
|
||||||
|
// Locate the root view that wraps the app's main content.
|
||||||
|
// This is the part most likely to need adjusting for GoonCord specifically —
|
||||||
|
// Vendetta-family clients usually expose something like this via findByProps,
|
||||||
|
// but the exact export name can differ between forks.
|
||||||
|
const AppContainer = findByProps("AppContainer") ?? findByProps("MainTabsView");
|
||||||
|
|
||||||
|
function applyBackground() {
|
||||||
|
if (!AppContainer) return;
|
||||||
|
|
||||||
|
unpatch = before("default", AppContainer, (args) => {
|
||||||
|
const url = settings.backgroundUrl;
|
||||||
|
if (!url) return;
|
||||||
|
|
||||||
|
const original = args[0]?.children;
|
||||||
|
args[0].children = React.createElement(
|
||||||
|
ImageBackground,
|
||||||
|
{
|
||||||
|
source: { uri: url },
|
||||||
|
style: { flex: 1 },
|
||||||
|
imageStyle: { opacity: settings.opacity ?? 0.3 },
|
||||||
|
blurRadius: settings.blur ?? 0,
|
||||||
|
},
|
||||||
|
original
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
onLoad: () => {
|
||||||
|
settings.opacity ??= 0.3;
|
||||||
|
settings.blur ??= 0;
|
||||||
|
applyBackground();
|
||||||
|
},
|
||||||
|
onUnload: () => {
|
||||||
|
unpatch?.();
|
||||||
|
},
|
||||||
|
settings: Settings,
|
||||||
|
};
|
||||||
Loading…
Add table
Reference in a new issue