ui(RP): add preview and force updater

This commit is contained in:
amsyarasyiq 2023-04-27 15:36:21 +08:00
parent a3b9edf4f3
commit 41bad09587
3 changed files with 43 additions and 2 deletions

View file

@ -30,7 +30,6 @@ function UpdateButton() {
return <TouchableOpacity onPress={onPressCallback}>
<FormText style={{ marginRight: 12 }}>UPDATE</FormText>
</TouchableOpacity>;
}
export default function Settings() {

View file

@ -1,13 +1,18 @@
import { findByProps, findByStoreName } from "@vendetta/metro";
import { React, stylesheet } from "@vendetta/metro/common";
import { storage } from "@vendetta/plugin";
import { useProxy } from "@vendetta/storage";
import { semanticColors } from "@vendetta/ui";
import { Forms } from "@vendetta/ui/components";
import { Button, Forms } from "@vendetta/ui/components";
import { ScrollView } from "react-native";
const { FormSection, FormInput, FormRow, FormSwitch, FormText } = Forms;
const UserStore = findByStoreName("UserStore");
const profiles = findByProps("showUserProfile");
const styles = stylesheet.createThemedStyleSheet({
subText: {
fontSize: 14,
@ -25,6 +30,16 @@ export default function ConfigEditor({ selection }: { selection: string }) {
return (
<ScrollView style={{ flex: 1 }} contentContainerStyle={{ paddingBottom: 38 }}>
<Button
style={{ margin: 16 }}
color={"brand"}
size={Button.Sizes.MEDIUM}
look={Button.Looks.FILLED}
onPress={async () => {
profiles.showUserProfile({ userId: UserStore.getCurrentUser().id });
}}
text="Preview your profile"
/>
<FormSection title="Basic" titleStyleType="no_border">
<FormInput required autoFocus
title="Application Name"

View file

@ -1,12 +1,39 @@
import RPInstance from ".";
import { NavigationNative } from "@vendetta/metro/common";
import plugin from "@vendetta/plugin";
import { Forms } from "@vendetta/ui/components";
import ConfigEditor from "./ConfigEditor";
import { useEffect } from "react";
import { TouchableOpacity } from "react-native";
const { FormText } = Forms;
const storage = plugin.storage as typeof plugin.storage & {
selected: string;
selections: Record<string, Activity>;
};
function UpdateButton() {
async function onPressCallback() {
RPInstance.onUnload();
RPInstance.onLoad();
}
return <TouchableOpacity onPress={onPressCallback}>
<FormText style={{ marginRight: 12 }}>UPDATE</FormText>
</TouchableOpacity>;
}
export default function Settings() {
const navigation = NavigationNative.useNavigation();
useEffect(() => {
navigation.setOptions({
headerRight: UpdateButton
});
}, []);
return (
<ConfigEditor selection={storage.selected} />
);