feat: add option to put Avatar somewhere else
This commit is contained in:
parent
4414c2d291
commit
7b0e6d68f6
2 changed files with 27 additions and 8 deletions
|
|
@ -10,6 +10,7 @@ const Flux = findByProps("useStateFromStores");
|
||||||
const { Pressable, View } = ReactNative;
|
const { Pressable, View } = ReactNative;
|
||||||
|
|
||||||
const ChatInputActions = find(m => m?.type?.displayName === "ChatInputActions") || findByName("ChatInputActions");
|
const ChatInputActions = find(m => m?.type?.displayName === "ChatInputActions") || findByName("ChatInputActions");
|
||||||
|
const ChatInputSendButton = find(m => m?.type?.displayName === "ChatInputSendButton") || findByName("ChatInputSendButton");
|
||||||
|
|
||||||
const Avatar = findByProps("default", "AvatarSizes", "getStatusSize")?.default || findByProps("getStatusSize")?.default || findByName("Avatar");
|
const Avatar = findByProps("default", "AvatarSizes", "getStatusSize")?.default || findByProps("getStatusSize")?.default || findByName("Avatar");
|
||||||
|
|
||||||
|
|
@ -99,31 +100,39 @@ export default {
|
||||||
showStatusCutout: true,
|
showStatusCutout: true,
|
||||||
profileType: "server",
|
profileType: "server",
|
||||||
showInDms: true,
|
showInDms: true,
|
||||||
|
position: "after_actions",
|
||||||
};
|
};
|
||||||
for (const key in defaults) {
|
for (const key in defaults) {
|
||||||
plugin.storage[key] = plugin.storage[key] ?? defaults[key];
|
plugin.storage[key] = plugin.storage[key] ?? defaults[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ChatInputActions) return;
|
if (ChatInputActions) {
|
||||||
|
const target = ChatInputActions.type || ChatInputActions;
|
||||||
if (ChatInputActions.type) {
|
|
||||||
patches.push(
|
patches.push(
|
||||||
after("render", ChatInputActions.type, (args, ret) => {
|
after("render", target, (args, ret) => {
|
||||||
|
const position = getSetting("position", "after_actions");
|
||||||
|
if (position === "near_send") return ret;
|
||||||
return (
|
return (
|
||||||
<View style={{ flexDirection: "row", alignItems: "center" }}>
|
<View style={{ flexDirection: "row", alignItems: "center" }}>
|
||||||
|
{position === "before_actions" && <AvatarAction />}
|
||||||
{ret}
|
{ret}
|
||||||
<AvatarAction />
|
{position === "after_actions" && <AvatarAction />}
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
if (ChatInputSendButton) {
|
||||||
|
const target = ChatInputSendButton.type || ChatInputSendButton;
|
||||||
patches.push(
|
patches.push(
|
||||||
after("render", ChatInputActions, (args, ret) => {
|
after("render", target, (args, ret) => {
|
||||||
|
const position = getSetting("position", "after_actions");
|
||||||
|
if (position !== "near_send") return ret;
|
||||||
return (
|
return (
|
||||||
<View style={{ flexDirection: "row", alignItems: "center" }}>
|
<View style={{ flexDirection: "row", alignItems: "center" }}>
|
||||||
{ret}
|
|
||||||
<AvatarAction />
|
<AvatarAction />
|
||||||
|
{ret}
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,16 @@ export default function ChatboxAvatarSettings() {
|
||||||
<TableRadioRow value="main" label="Prefer Main Profile" />
|
<TableRadioRow value="main" label="Prefer Main Profile" />
|
||||||
</TableRadioGroup>
|
</TableRadioGroup>
|
||||||
</TableRowGroup>
|
</TableRowGroup>
|
||||||
|
<TableRowGroup title="Position">
|
||||||
|
<TableRadioGroup
|
||||||
|
value={get("position", "after_actions")}
|
||||||
|
onChange={(v: string) => { set("position", v); forceUpdate(); }}
|
||||||
|
>
|
||||||
|
<TableRadioRow value="before_actions" label="Before Action Buttons" />
|
||||||
|
<TableRadioRow value="after_actions" label="After Action Buttons" />
|
||||||
|
<TableRadioRow value="near_send" label="Near Send Button" />
|
||||||
|
</TableRadioGroup>
|
||||||
|
</TableRowGroup>
|
||||||
<TableRowGroup title="Status Icon">
|
<TableRowGroup title="Status Icon">
|
||||||
<TableRadioGroup
|
<TableRadioGroup
|
||||||
value={get("showStatusCutout", true) ? "true" : "false"}
|
value={get("showStatusCutout", true) ? "true" : "false"}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue