summaryrefslogtreecommitdiff
path: root/app/(tabs)
diff options
context:
space:
mode:
authorJustZvan <justzvan@justzvan.xyz>2026-04-08 19:48:30 +0200
committerJustZvan <justzvan@justzvan.xyz>2026-04-08 19:48:30 +0200
commitfef579b2b794be6f4b8e963fe4ed2c4c8f734aec (patch)
treeb87047d87107ca693e151984f7a8faffe07d6c5c /app/(tabs)
parent3273e7a0fbbce82f4ce6cacbcdb7b6d6848f6c1b (diff)
feat: 1.2main
Diffstat (limited to 'app/(tabs)')
-rw-r--r--app/(tabs)/settings.tsx55
1 files changed, 55 insertions, 0 deletions
diff --git a/app/(tabs)/settings.tsx b/app/(tabs)/settings.tsx
index b4493b4..c19da37 100644
--- a/app/(tabs)/settings.tsx
+++ b/app/(tabs)/settings.tsx
@@ -5,6 +5,7 @@ import {
Device,
getDevices,
getUserProfile,
+ requestKidLinkCode,
renameDevice,
UserProfile,
verifyEmail,
@@ -38,6 +39,12 @@ export default function SettingsScreen() {
success: boolean;
message: string;
}>({ visible: false, success: false, message: "" });
+ const [kidLinkCodeResult, setKidLinkCodeResult] = useState<{
+ visible: boolean;
+ success: boolean;
+ title: string;
+ message: string;
+ }>({ visible: false, success: false, title: "", message: "" });
const showNotWired = () => setAlertVisible(true);
@@ -86,6 +93,32 @@ export default function SettingsScreen() {
setVerifyEmailVisible(false);
};
+ const handleGenerateKidLinkCode = async () => {
+ const result = await requestKidLinkCode();
+
+ if (result.success && result.code) {
+ const expiresMinutes = Math.max(
+ 1,
+ Math.ceil((result.expiresInSeconds ?? 300) / 60),
+ );
+
+ setKidLinkCodeResult({
+ visible: true,
+ success: true,
+ title: t("kidLinkCodeTitle"),
+ message: `${result.code}\n${t("kidLinkCodeExpiresIn")} ${expiresMinutes} min`,
+ });
+ return;
+ }
+
+ setKidLinkCodeResult({
+ visible: true,
+ success: false,
+ title: t("error"),
+ message: result.error || t("failedToGenerateKidLinkCode"),
+ });
+ };
+
return (
<Screen>
<AlertDialog
@@ -122,6 +155,15 @@ export default function SettingsScreen() {
}
/>
+ <AlertDialog
+ visible={kidLinkCodeResult.visible}
+ title={kidLinkCodeResult.title}
+ message={kidLinkCodeResult.message}
+ onClose={() =>
+ setKidLinkCodeResult({ ...kidLinkCodeResult, visible: false })
+ }
+ />
+
<Card>
<Row
left={
@@ -198,6 +240,19 @@ export default function SettingsScreen() {
<Card>
<H2>{t("account")}</H2>
<Divider />
+ <ActionRow
+ title={t("generateKidLinkCode")}
+ subtitle={t("generateKidLinkCodeSubtitle")}
+ onPress={handleGenerateKidLinkCode}
+ right={
+ <Ionicons
+ name="key-outline"
+ size={18}
+ color={colors.onSurfaceVariant}
+ />
+ }
+ />
+ <Divider />
{profile && !profile.emailVerified && (
<>
<ActionRow