mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-31 20:24:27 -04:00
Move delete account button to the settings page
This commit is contained in:
parent
ab6e8962e4
commit
c528d4dd78
@ -27,8 +27,10 @@ import { View } from "react-native";
|
|||||||
|
|
||||||
export const Button = forwardRef<
|
export const Button = forwardRef<
|
||||||
View,
|
View,
|
||||||
{ text: string; icon?: ReactElement } & ComponentProps<typeof PressableFeedback>
|
{ text: string; licon?: ReactElement; icon?: ReactElement } & ComponentProps<
|
||||||
>(function Button({ text, icon, ...props }, ref) {
|
typeof PressableFeedback
|
||||||
|
>
|
||||||
|
>(function Button({ text, icon, licon, ...props }, ref) {
|
||||||
const { css } = useYoshiki("button");
|
const { css } = useYoshiki("button");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -60,6 +62,7 @@ export const Button = forwardRef<
|
|||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
|
{licon}
|
||||||
<P {...css({ textAlign: "center" }, "text")}>{text}</P>
|
<P {...css({ textAlign: "center" }, "text")}>{text}</P>
|
||||||
{icon}
|
{icon}
|
||||||
</View>
|
</View>
|
||||||
|
@ -18,9 +18,8 @@
|
|||||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { deleteAccount, logout, useAccount, useAccounts } from "@kyoo/models";
|
import { logout, useAccount, useAccounts } from "@kyoo/models";
|
||||||
import {
|
import {
|
||||||
Alert,
|
|
||||||
Input,
|
Input,
|
||||||
IconButton,
|
IconButton,
|
||||||
Header,
|
Header,
|
||||||
@ -40,7 +39,6 @@ import Search from "@material-symbols/svg-400/rounded/search-fill.svg";
|
|||||||
import Login from "@material-symbols/svg-400/rounded/login.svg";
|
import Login from "@material-symbols/svg-400/rounded/login.svg";
|
||||||
import Register from "@material-symbols/svg-400/rounded/app_registration.svg";
|
import Register from "@material-symbols/svg-400/rounded/app_registration.svg";
|
||||||
import Logout from "@material-symbols/svg-400/rounded/logout.svg";
|
import Logout from "@material-symbols/svg-400/rounded/logout.svg";
|
||||||
import Delete from "@material-symbols/svg-400/rounded/delete.svg";
|
|
||||||
import Settings from "@material-symbols/svg-400/rounded/settings.svg";
|
import Settings from "@material-symbols/svg-400/rounded/settings.svg";
|
||||||
import { KyooLongLogo } from "./icon";
|
import { KyooLongLogo } from "./icon";
|
||||||
import { forwardRef, useEffect, useRef, useState } from "react";
|
import { forwardRef, useEffect, useRef, useState } from "react";
|
||||||
@ -129,29 +127,6 @@ export const NavbarProfile = () => {
|
|||||||
<>
|
<>
|
||||||
<Menu.Item label={t("login.add-account")} icon={Login} href="/login" />
|
<Menu.Item label={t("login.add-account")} icon={Login} href="/login" />
|
||||||
<Menu.Item label={t("login.logout")} icon={Logout} onSelect={logout} />
|
<Menu.Item label={t("login.logout")} icon={Logout} onSelect={logout} />
|
||||||
<Menu.Item
|
|
||||||
label={t("login.delete")}
|
|
||||||
icon={Delete}
|
|
||||||
onSelect={async () => {
|
|
||||||
Alert.alert(
|
|
||||||
t("login.delete"),
|
|
||||||
t("login.delete-confirmation"),
|
|
||||||
[
|
|
||||||
{ text: t("misc.cancel"), style: "cancel" },
|
|
||||||
{
|
|
||||||
text: t("misc.delete"),
|
|
||||||
onPress: deleteAccount,
|
|
||||||
style: "destructive",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
{
|
|
||||||
cancelable: true,
|
|
||||||
userInterfaceStyle: theme.mode === "auto" ? "light" : theme.mode,
|
|
||||||
icon: "warning",
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Menu>
|
</Menu>
|
||||||
|
@ -25,12 +25,15 @@ import {
|
|||||||
QueryPage,
|
QueryPage,
|
||||||
User,
|
User,
|
||||||
UserP,
|
UserP,
|
||||||
|
deleteAccount,
|
||||||
|
logout,
|
||||||
queryFn,
|
queryFn,
|
||||||
setUserTheme,
|
setUserTheme,
|
||||||
useAccount,
|
useAccount,
|
||||||
useUserTheme,
|
useUserTheme,
|
||||||
} from "@kyoo/models";
|
} from "@kyoo/models";
|
||||||
import {
|
import {
|
||||||
|
Alert,
|
||||||
Button,
|
Button,
|
||||||
Container,
|
Container,
|
||||||
H1,
|
H1,
|
||||||
@ -50,13 +53,15 @@ import { Children, ComponentProps, ReactElement, ReactNode, useState } from "rea
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { ScrollView, View } from "react-native";
|
import { ScrollView, View } from "react-native";
|
||||||
import { px, rem, useYoshiki } from "yoshiki/native";
|
import { px, rem, useYoshiki } from "yoshiki/native";
|
||||||
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||||
|
import { PasswordInput } from "../login/password-input";
|
||||||
|
|
||||||
import Theme from "@material-symbols/svg-400/outlined/dark_mode.svg";
|
import Theme from "@material-symbols/svg-400/outlined/dark_mode.svg";
|
||||||
import Username from "@material-symbols/svg-400/outlined/badge.svg";
|
import Username from "@material-symbols/svg-400/outlined/badge.svg";
|
||||||
import Mail from "@material-symbols/svg-400/outlined/mail.svg";
|
import Mail from "@material-symbols/svg-400/outlined/mail.svg";
|
||||||
import Password from "@material-symbols/svg-400/outlined/password.svg";
|
import Password from "@material-symbols/svg-400/outlined/password.svg";
|
||||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
import Logout from "@material-symbols/svg-400/rounded/logout.svg";
|
||||||
import { PasswordInput } from "../login/password-input";
|
import Delete from "@material-symbols/svg-400/rounded/delete.svg";
|
||||||
|
|
||||||
const Preference = ({
|
const Preference = ({
|
||||||
icon,
|
icon,
|
||||||
@ -100,13 +105,17 @@ const Preference = ({
|
|||||||
const SettingsContainer = ({
|
const SettingsContainer = ({
|
||||||
children,
|
children,
|
||||||
title,
|
title,
|
||||||
|
extra,
|
||||||
|
...props
|
||||||
}: {
|
}: {
|
||||||
children: ReactElement | ReactElement[];
|
children: ReactElement | ReactElement[];
|
||||||
title: string;
|
title: string;
|
||||||
|
extra?: ReactElement;
|
||||||
}) => {
|
}) => {
|
||||||
const { css } = useYoshiki();
|
const { css } = useYoshiki();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container>
|
<Container {...props}>
|
||||||
<H1 {...css({ fontSize: rem(2) })}>{title}</H1>
|
<H1 {...css({ fontSize: rem(2) })}>{title}</H1>
|
||||||
<SwitchVariant>
|
<SwitchVariant>
|
||||||
{({ css }) => (
|
{({ css }) => (
|
||||||
@ -125,6 +134,7 @@ const SettingsContainer = ({
|
|||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
</SwitchVariant>
|
</SwitchVariant>
|
||||||
|
{extra}
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@ -248,6 +258,7 @@ const ChangePasswordPopup = ({
|
|||||||
|
|
||||||
const AccountSettings = ({ setPopup }: { setPopup: (e?: ReactElement) => void }) => {
|
const AccountSettings = ({ setPopup }: { setPopup: (e?: ReactElement) => void }) => {
|
||||||
const account = useAccount();
|
const account = useAccount();
|
||||||
|
const { css, theme } = useYoshiki();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
@ -271,7 +282,43 @@ const AccountSettings = ({ setPopup }: { setPopup: (e?: ReactElement) => void })
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
account && (
|
account && (
|
||||||
<SettingsContainer title={t("settings.account.label")}>
|
<SettingsContainer
|
||||||
|
title={t("settings.account.label")}
|
||||||
|
extra={
|
||||||
|
<View {...css({ marginTop: ts(2), gap: ts(2), flexDirection: "row" })}>
|
||||||
|
<Button
|
||||||
|
licon={<Icon icon={Logout} {...css({ marginX: ts(1) })} />}
|
||||||
|
text={t("login.logout")}
|
||||||
|
onPress={logout}
|
||||||
|
{...css({ flex: 1 })}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
licon={<Icon icon={Delete} {...css({ marginX: ts(1) })} />}
|
||||||
|
text={t("login.delete")}
|
||||||
|
onPress={async () => {
|
||||||
|
Alert.alert(
|
||||||
|
t("login.delete"),
|
||||||
|
t("login.delete-confirmation"),
|
||||||
|
[
|
||||||
|
{ text: t("misc.cancel"), style: "cancel" },
|
||||||
|
{
|
||||||
|
text: t("misc.delete"),
|
||||||
|
onPress: deleteAccount,
|
||||||
|
style: "destructive",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
{
|
||||||
|
cancelable: true,
|
||||||
|
userInterfaceStyle: theme.mode === "auto" ? "light" : theme.mode,
|
||||||
|
icon: "warning",
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
{...css({ flex: 1 })}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
}
|
||||||
|
>
|
||||||
<Preference
|
<Preference
|
||||||
icon={Username}
|
icon={Username}
|
||||||
label={t("settings.account.username.label")}
|
label={t("settings.account.username.label")}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user