fix(mobile): Story-Editor als eigener Vollbild-Screen (iOS) + Safe-Area (Android)

Tester-Feedback 04.10.:
- iOS: Text-Story liess sich nicht oeffnen, beim Foto aus der Galerie
  verschwand alles und nur das X leuchtete auf. Ursache: der Editor lief im
  Auswahl-Screen, der auf iOS ein Sheet ist; Kopfzeile umschalten und ein
  weiteres natives Modal waehrend der Praesentation scheiterten. Jetzt eigener
  Screen story-editor (fullScreenModal, ohne Kopfzeile, ohne Wisch-zum-
  Schliessen); Texteditor und Auswahlfenster sind Ebenen (EditorLayer) statt
  nativer Modals, Android-Zurueck schliesst sie.
- Android: Farbreihe im Texteditor lag hinter der Gestenleiste → echte
  Safe-Area-Abstaende oben/unten.
- Tippen auf eine freie Stelle der Story oeffnet den Texteditor.

Am Android-Emulator durchgeklickt (Text-Story, Texteditor, Verschieben,
GIF-Suche live, Sticker, X zurueck). iOS nicht testbar.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5.5 committed 2026-10-04 17:20:23 +02:00
1 parent 84a430a92a
commit 6d3136700b
7 files changed
+293 -187

No files matched your search

+5
View File
@@ -70,6 +70,11 @@ export default function AppLayout() {
headerLeft: () => <CloseModalButton />,
}}
/>
{/* Story-Editor: eigener Vollbild-Screen, ohne Wisch-zum-Schließen (Ziehgesten der Overlays). */}
<Stack.Screen
name="story-editor"
options={{ headerShown: false, presentation: "fullScreenModal", animation: "fade", gestureEnabled: false }}
/>
<Stack.Screen
name="milestone-new"
options={{
+183
View File
@@ -0,0 +1,183 @@
import { useState, useCallback, useMemo } from "react";
import { View, Text, Image as RNImage, StyleSheet } from "react-native";
import { useLocalSearchParams, useRouter } from "expo-router";
import { useTranslation } from "react-i18next";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { useTRPC } from "../../src/api/trpc";
import { useActivePet } from "../../src/context/ActivePetContext";
import { uploadImageToSupabase, uploadFileToUrl } from "../../src/lib/upload";
import { resizeForUpload } from "../../src/lib/resize-image";
import { StoryEditor, type EditorMedia, type EditorResult } from "../../src/components/story-editor/StoryEditor";
import { fontFamily } from "../../src/theme/tokens";
type Params = { kind: "image" | "video" | "text"; uri?: string; width?: string; height?: string; mimeType?: string };
/** Echte Pixelmaße der (verkleinerten) Datei — der Picker meldet bei gedrehten Handyfotos teils vertauschte Werte. */
function imageSize(uri: string): Promise<{ width: number; height: number }> {
return new Promise((resolve, reject) => RNImage.getSize(uri, (width, height) => resolve({ width, height }), reject));
}
function mediaFromParams(params: Params): EditorMedia | null {
if (params.kind === "text") return { kind: "text" };
const width = Number(params.width);
const height = Number(params.height);
if (!params.uri || !width || !height) return null;
return params.kind === "video"
? { kind: "video", uri: params.uri, width, height, mimeType: params.mimeType || undefined }
: { kind: "image", uri: params.uri, width, height };
}
/**
* Story-Editor als eigener Vollbild-Screen (fullScreenModal, ohne Kopfzeile,
* ohne Wisch-zum-Schließen). Vorher lief er innerhalb des Auswahl-Screens
* story-new, der auf iOS ein Sheet ist — dort das Umschalten der Kopfzeile und
* ein weiteres Modal führten dazu, dass alles verschwand und nur das X kurz
* aufleuchtete (Tester-Feedback 04.10.). Das Medium kommt als Route-Parameter.
*
* Upload wie bisher: Foto verkleinert zu Supabase, Video direkt zu Mux
* (createVideoUpload legt die PROCESSING-Story an), Text-Story ohne Datei.
*/
export default function StoryEditorScreen() {
const params = useLocalSearchParams<Params>();
const { t } = useTranslation();
const router = useRouter();
const trpc = useTRPC();
const queryClient = useQueryClient();
const { activePetId } = useActivePet();
const media = useMemo(() => mediaFromParams(params), [params]);
const { data: flags } = useQuery({ ...trpc.stories.featureFlags.queryOptions(), staleTime: 60_000 });
const [error, setError] = useState<string | null>(null);
const [isUploading, setIsUploading] = useState(false);
const [uploadPercent, setUploadPercent] = useState<number | null>(null);
const getPresignedUrlMutation = useMutation(trpc.stories.getPresignedUrl.mutationOptions());
const createMutation = useMutation(trpc.stories.create.mutationOptions());
const createTextMutation = useMutation(trpc.stories.createText.mutationOptions());
const createVideoUploadMutation = useMutation(trpc.stories.createVideoUpload.mutationOptions());
const finish = useCallback(async () => {
await queryClient.invalidateQueries(trpc.follows.pathFilter());
await queryClient.invalidateQueries(trpc.stories.pathFilter());
// Editor + Auswahl-Screen schließen → zurück dorthin, wo die Story gestartet wurde.
router.dismissAll();
}, [queryClient, trpc, router]);
const handleSubmit = useCallback(
async ({ overlays, background }: EditorResult) => {
if (!media || !activePetId) return;
setError(null);
const editorFields = overlays.length > 0 ? { overlays } : {};
try {
if (media.kind === "text") {
await createTextMutation.mutateAsync({ petId: activePetId, background: background ?? "sunset", overlays });
await finish();
return;
}
if (media.kind === "video") {
const { uploadUrl } = await createVideoUploadMutation.mutateAsync({
petId: activePetId,
aiDisclosure: "NONE",
...editorFields,
mediaWidth: media.width,
mediaHeight: media.height,
});
setIsUploading(true);
setUploadPercent(0);
await uploadFileToUrl(media.uri, uploadUrl ?? "", media.mimeType ?? "video/mp4", (fraction) => {
const pct = Math.round(fraction * 100);
setUploadPercent((prev) => (prev === pct ? prev : pct));
});
await finish();
return;
}
setIsUploading(true);
const resized = await resizeForUpload(media.uri, media.width, media.height);
const size = await imageSize(resized.uri).catch(() => ({ width: media.width, height: media.height }));
const { presignedUrl, key } = await getPresignedUrlMutation.mutateAsync({
petId: activePetId,
contentType: resized.mimeType,
fileSize: resized.fileSize,
});
await uploadImageToSupabase(resized.uri, presignedUrl, resized.mimeType);
await createMutation.mutateAsync({
petId: activePetId,
storageKey: key,
blurhash: null,
...editorFields,
mediaWidth: size.width,
mediaHeight: size.height,
});
await finish();
} catch (err) {
setError(err instanceof Error && err.message ? err.message : t("onboarding.uploadError"));
} finally {
setIsUploading(false);
setUploadPercent(null);
}
},
[media, activePetId, createTextMutation, createVideoUploadMutation, getPresignedUrlMutation, createMutation, finish, t]
);
const isSubmitting =
isUploading ||
getPresignedUrlMutation.isPending ||
createMutation.isPending ||
createTextMutation.isPending ||
createVideoUploadMutation.isPending;
if (!media || !activePetId) {
return (
<View style={styles.missing}>
<Text style={styles.missingText}>{t("onboarding.uploadError")}</Text>
</View>
);
}
return (
<StoryEditor
media={media}
petId={activePetId}
toolsEnabled={flags?.storyEditor ?? false}
isSubmitting={isSubmitting}
submitLabel={isSubmitting ? t("milestones.sharing") : t("story.shareButton")}
onSubmit={handleSubmit}
onCancel={() => {
if (!isSubmitting) router.back();
}}
progress={
<>
{error ? <Text style={styles.error}>{error}</Text> : null}
{isSubmitting && media.kind === "video" ? <UploadProgress percent={uploadPercent} /> : null}
</>
}
/>
);
}
/** Video-Upload zu Mux: erst „wird vorbereitet“, dann echter Fortschritt (expo-file-system onProgress). */
function UploadProgress({ percent }: { percent: number | null }) {
const { t } = useTranslation();
const label = percent === null ? t("story.preparingUpload") : t("story.uploadingVideo", { percent });
return (
<View style={styles.progressWrap} accessibilityRole="progressbar" accessibilityValue={{ min: 0, max: 100, now: percent ?? 0 }} accessibilityLabel={label}>
<View style={styles.progressTrack}>
<View style={[styles.progressFill, { width: `${percent ?? 0}%` }]} />
</View>
<Text style={styles.progressLabel}>{label}</Text>
</View>
);
}
const styles = StyleSheet.create({
missing: { flex: 1, backgroundColor: "#111111", alignItems: "center", justifyContent: "center", padding: 24 },
missingText: { color: "#ffffff", fontFamily: fontFamily.regular, fontSize: 15, textAlign: "center" },
error: { color: "#f87171", fontFamily: fontFamily.regular, fontSize: 14, textAlign: "center" },
progressWrap: { gap: 6 },
progressTrack: { height: 6, borderRadius: 3, backgroundColor: "rgba(255,255,255,0.2)", overflow: "hidden" },
progressFill: { height: "100%", borderRadius: 3, backgroundColor: "#f97316" },
progressLabel: { color: "#ffffff", fontFamily: fontFamily.semiBold, fontSize: 12, textAlign: "center" },
});
+37 -174
View File
@@ -1,39 +1,27 @@
import { useState, useCallback, useMemo, useLayoutEffect } from "react";
import { View, Text, Image as RNImage, Pressable, StyleSheet, Alert } from "react-native";
import { useNavigation, useRouter } from "expo-router";
import { useCallback, useMemo } from "react";
import { View, Text, Pressable, StyleSheet, Alert } from "react-native";
import { useRouter } from "expo-router";
import * as ImagePicker from "expo-image-picker";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { useTranslation } from "react-i18next";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { useQuery } from "@tanstack/react-query";
import { ImagePlus, Camera, Type } from "lucide-react-native";
import { useTRPC } from "../../src/api/trpc";
import { useActivePet } from "../../src/context/ActivePetContext";
import { useTheme } from "../../src/context/ThemeContext";
import { uploadImageToSupabase, uploadFileToUrl } from "../../src/lib/upload";
import { resizeForUpload } from "../../src/lib/resize-image";
import { MAX_STORY_VIDEO_DURATION_SECS } from "../../src/lib/story-video-limits";
import { StoryEditor, type EditorMedia, type EditorResult } from "../../src/components/story-editor/StoryEditor";
import { radii, getTypography, type ColorTokens } from "../../src/theme/tokens";
/** Echte Pixelmaße der (verkleinerten) Datei — der Picker meldet bei gedrehten Handyfotos teils vertauschte Werte. */
function imageSize(uri: string): Promise<{ width: number; height: number }> {
return new Promise((resolve, reject) => RNImage.getSize(uri, (width, height) => resolve({ width, height }), reject));
}
/**
* Story erstellen: Foto, kurzes Video oder reine Text-Story (Farbverlauf),
* danach der Story-Editor (Text, @-Markierungen, GIFs, Sticker — siehe
* src/components/story-editor/). Overlays gehen als Daten mit, nicht ins Bild
* gerechnet. Der Video-Pfad entspricht web's StoryForm.tsx: createVideoUpload
* legt die (PROCESSING) Story an, die Bytes gehen direkt zu Mux. Ist der
* Notschalter (Admin) aus, gibt es nur Vorschau + Teilen wie früher.
* Story erstellen — Schritt 1: Foto, kurzes Video oder Text-Story wählen.
* Bearbeiten und Teilen passieren im eigenen Vollbild-Screen story-editor.tsx
* (dieser Screen ist auf iOS ein Sheet; den Editor darin einzublenden führte
* dazu, dass alles verschwand — siehe story-editor.tsx). Ist der Notschalter
* (Admin) aus, gibt es keine Text-Story und der Editor zeigt nur Vorschau + Teilen.
*/
export default function NewStoryScreen() {
const { t } = useTranslation();
const router = useRouter();
const trpc = useTRPC();
const queryClient = useQueryClient();
const { activePetId } = useActivePet();
const { colors } = useTheme();
const insets = useSafeAreaInsets();
const styles = useMemo(() => makeStyles(colors, insets.bottom), [colors, insets.bottom]);
@@ -41,28 +29,21 @@ export default function NewStoryScreen() {
const { data: flags } = useQuery({ ...trpc.stories.featureFlags.queryOptions(), staleTime: 60_000 });
const editorEnabled = flags?.storyEditor ?? false;
const [media, setMedia] = useState<EditorMedia | null>(null);
const navigation = useNavigation();
// Im Editor gehört der ganze Bildschirm der Story — Kopfzeile ausblenden.
useLayoutEffect(() => {
navigation.setOptions({ headerShown: media === null });
}, [navigation, media]);
const [error, setError] = useState<string | null>(null);
const [isUploading, setIsUploading] = useState(false);
// Video-Upload in Prozent (0–100), null solange kein Video hochgeladen wird.
const [uploadPercent, setUploadPercent] = useState<number | null>(null);
const getPresignedUrlMutation = useMutation(trpc.stories.getPresignedUrl.mutationOptions());
const createMutation = useMutation(trpc.stories.create.mutationOptions());
const createTextMutation = useMutation(trpc.stories.createText.mutationOptions());
const createVideoUploadMutation = useMutation(trpc.stories.createVideoUpload.mutationOptions());
const finish = useCallback(async () => {
await queryClient.invalidateQueries(trpc.follows.pathFilter());
await queryClient.invalidateQueries(trpc.stories.pathFilter());
router.back();
}, [queryClient, trpc, router]);
const openEditor = useCallback(
(params: { kind: "image" | "video" | "text"; uri?: string; width?: number; height?: number; mimeType?: string | null }) => {
router.push({
pathname: "/story-editor",
params: {
kind: params.kind,
uri: params.uri ?? "",
width: String(params.width ?? 0),
height: String(params.height ?? 0),
mimeType: params.mimeType ?? "",
},
});
},
[router]
);
const pickFromGallery = useCallback(async () => {
const permission = await ImagePicker.requestMediaLibraryPermissionsAsync();
@@ -75,16 +56,18 @@ export default function NewStoryScreen() {
// expo-image-picker meldet `duration` (ms) nur bei Videos — verlässlicher als ein MIME-Typ.
const picked = result.assets[0];
if (picked.duration != null) {
if (picked.duration / 1000 > MAX_STORY_VIDEO_DURATION_SECS) {
Alert.alert(t("story.videoTooLong", { max: MAX_STORY_VIDEO_DURATION_SECS }));
return;
}
setMedia({ kind: "video", uri: picked.uri, width: picked.width, height: picked.height, mimeType: picked.mimeType ?? undefined });
if (picked.duration != null && picked.duration / 1000 > MAX_STORY_VIDEO_DURATION_SECS) {
Alert.alert(t("story.videoTooLong", { max: MAX_STORY_VIDEO_DURATION_SECS }));
return;
}
setMedia({ kind: "image", uri: picked.uri, width: picked.width, height: picked.height });
}, [t]);
openEditor({
kind: picked.duration != null ? "video" : "image",
uri: picked.uri,
width: picked.width,
height: picked.height,
mimeType: picked.mimeType,
});
}, [t, openEditor]);
const takePhoto = useCallback(async () => {
const permission = await ImagePicker.requestCameraPermissionsAsync();
@@ -95,100 +78,9 @@ export default function NewStoryScreen() {
const result = await ImagePicker.launchCameraAsync({ quality: 0.8 });
if (!result.canceled) {
const photo = result.assets[0];
setMedia({ kind: "image", uri: photo.uri, width: photo.width, height: photo.height });
openEditor({ kind: "image", uri: photo.uri, width: photo.width, height: photo.height });
}
}, [t]);
const handleSubmit = useCallback(
async ({ overlays, background }: EditorResult) => {
if (!media || !activePetId) return;
setError(null);
const editorFields = overlays.length > 0 ? { overlays } : {};
try {
if (media.kind === "text") {
await createTextMutation.mutateAsync({ petId: activePetId, background: background ?? "sunset", overlays });
await finish();
return;
}
if (media.kind === "video") {
const { uploadUrl } = await createVideoUploadMutation.mutateAsync({
petId: activePetId,
aiDisclosure: "NONE",
...editorFields,
...(media.width > 0 && media.height > 0 ? { mediaWidth: media.width, mediaHeight: media.height } : {}),
});
setIsUploading(true);
setUploadPercent(0);
await uploadFileToUrl(media.uri, uploadUrl ?? "", media.mimeType ?? "video/mp4", (fraction) => {
const pct = Math.round(fraction * 100);
setUploadPercent((prev) => (prev === pct ? prev : pct));
});
// Story existiert schon (PROCESSING) — story-viewer.tsx fragt den Status ab.
await finish();
return;
}
setIsUploading(true);
const resized = await resizeForUpload(media.uri, media.width, media.height);
const size = await imageSize(resized.uri).catch(() => ({ width: media.width, height: media.height }));
const { presignedUrl, key } = await getPresignedUrlMutation.mutateAsync({
petId: activePetId,
contentType: resized.mimeType,
fileSize: resized.fileSize,
});
await uploadImageToSupabase(resized.uri, presignedUrl, resized.mimeType);
await createMutation.mutateAsync({
petId: activePetId,
storageKey: key,
blurhash: null,
...editorFields,
mediaWidth: size.width,
mediaHeight: size.height,
});
await finish();
} catch (err) {
setError(err instanceof Error && err.message ? err.message : t("onboarding.uploadError"));
} finally {
setIsUploading(false);
setUploadPercent(null);
}
},
[media, activePetId, createTextMutation, createVideoUploadMutation, getPresignedUrlMutation, createMutation, finish, t]
);
const isSubmitting =
isUploading ||
getPresignedUrlMutation.isPending ||
createMutation.isPending ||
createTextMutation.isPending ||
createVideoUploadMutation.isPending;
if (media && activePetId) {
return (
<StoryEditor
media={media}
petId={activePetId}
toolsEnabled={editorEnabled}
isSubmitting={isSubmitting}
submitLabel={isSubmitting ? t("milestones.sharing") : t("story.shareButton")}
onSubmit={handleSubmit}
onCancel={() => {
if (!isSubmitting) {
setMedia(null);
setError(null);
}
}}
progress={
<>
{error ? <Text style={styles.errorOnDark}>{error}</Text> : null}
{isSubmitting && media.kind === "video" ? <UploadProgress percent={uploadPercent} styles={styles} /> : null}
</>
}
/>
);
}
}, [t, openEditor]);
return (
<View style={styles.container}>
@@ -203,7 +95,7 @@ export default function NewStoryScreen() {
</Pressable>
</View>
{editorEnabled && (
<Pressable style={styles.textStoryButton} onPress={() => setMedia({ kind: "text" })}>
<Pressable style={styles.textStoryButton} onPress={() => openEditor({ kind: "text" })}>
<Type color={colors.pureWhite} size={22} />
<Text style={styles.textStoryText}>{t("storyEditor.textStory")}</Text>
</Pressable>
@@ -212,30 +104,6 @@ export default function NewStoryScreen() {
);
}
/**
* Fortschritt beim Video-Upload zu Mux. `percent === null` = Upload wird noch
* vorbereitet (createVideoUpload läuft), dann echter Fortschritt aus
* expo-file-system `onProgress`.
*/
function UploadProgress({ percent, styles }: { percent: number | null; styles: ReturnType<typeof makeStyles> }) {
const { t } = useTranslation();
const label = percent === null ? t("story.preparingUpload") : t("story.uploadingVideo", { percent });
return (
<View
style={styles.progressWrap}
accessibilityRole="progressbar"
accessibilityValue={{ min: 0, max: 100, now: percent ?? 0 }}
accessibilityLabel={label}
>
<View style={styles.progressTrack}>
<View style={[styles.progressFill, { width: `${percent ?? 0}%` }]} />
</View>
<Text style={styles.progressLabel}>{label}</Text>
</View>
);
}
function makeStyles(colors: ColorTokens, bottomInset: number) {
const typography = getTypography(colors);
return StyleSheet.create({
@@ -269,10 +137,5 @@ function makeStyles(colors: ColorTokens, bottomInset: number) {
backgroundColor: colors.marigoldOrange,
},
textStoryText: { ...typography.body, color: colors.pureWhite, fontFamily: typography.title.fontFamily },
errorOnDark: { ...typography.body, color: "#f87171", textAlign: "center" },
progressWrap: { gap: 6 },
progressTrack: { height: 6, borderRadius: 3, backgroundColor: "rgba(255,255,255,0.2)", overflow: "hidden" },
progressFill: { height: "100%", borderRadius: 3, backgroundColor: colors.marigoldOrange },
progressLabel: { ...typography.label, textTransform: "none", letterSpacing: 0, textAlign: "center", color: "#ffffff" },
});
}
@@ -0,0 +1,45 @@
import { useEffect } from "react";
import { BackHandler, KeyboardAvoidingView, Platform, StyleSheet, type StyleProp, type ViewStyle } from "react-native";
/**
* Ebene innerhalb des Story-Editors (statt eines nativen <Modal>): Der Editor
* liegt selbst in einem modal präsentierten Screen. iOS verweigert ein weiteres
* Modal, solange noch eine Präsentation läuft (z. B. direkt beim Öffnen einer
* Text-Story) — der Texteditor erschien dann nicht und man traf nur das X.
* Als normale Ebene gibt es diesen Konflikt nicht; Safe-Area-Abstände setzt der
* Inhalt selbst. Android-Zurück-Taste schließt die Ebene.
*/
export function EditorLayer({
visible,
onRequestClose,
style,
children,
}: {
visible: boolean;
onRequestClose: () => void;
style?: StyleProp<ViewStyle>;
children: React.ReactNode;
}) {
useEffect(() => {
if (!visible) return;
const sub = BackHandler.addEventListener("hardwareBackPress", () => {
onRequestClose();
return true;
});
return () => sub.remove();
}, [visible, onRequestClose]);
if (!visible) return null;
return (
<KeyboardAvoidingView
style={[StyleSheet.absoluteFill, styles.layer, style]}
behavior={Platform.OS === "ios" ? "padding" : undefined}
>
{children}
</KeyboardAvoidingView>
);
}
const styles = StyleSheet.create({
layer: { zIndex: 20, elevation: 20 },
});
@@ -1,14 +1,14 @@
import { Modal, View, Text, Pressable, KeyboardAvoidingView, Platform, StyleSheet } from "react-native";
import { View, Text, Pressable, StyleSheet } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { X } from "lucide-react-native";
import { fontFamily } from "../../theme/tokens";
import { EditorLayer } from "./EditorLayer";
/** Dunkles Bottom-Sheet für die Auswahlfenster des Story-Editors (Markieren, GIF, Sticker). */
/** Dunkles Bottom-Sheet für die Auswahlfenster des Story-Editors (Markieren, GIF, Sticker) — als Ebene, kein natives Modal (siehe EditorLayer). */
export function PickerSheet({ visible, title, onClose, children }: { visible: boolean; title: string; onClose: () => void; children: React.ReactNode }) {
const insets = useSafeAreaInsets();
return (
<Modal visible={visible} transparent animationType="slide" onRequestClose={onClose} statusBarTranslucent>
<KeyboardAvoidingView style={styles.backdrop} behavior={Platform.OS === "ios" ? "padding" : "height"}>
<EditorLayer visible={visible} onRequestClose={onClose} style={styles.backdrop}>
<Pressable style={styles.dismiss} onPress={onClose} accessibilityLabel={title} />
<View style={[styles.sheet, { paddingBottom: insets.bottom + 12 }]}>
<View style={styles.header}>
@@ -19,13 +19,12 @@ export function PickerSheet({ visible, title, onClose, children }: { visible: bo
</View>
{children}
</View>
</KeyboardAvoidingView>
</Modal>
</EditorLayer>
);
}
const styles = StyleSheet.create({
backdrop: { flex: 1, justifyContent: "flex-end" },
backdrop: { justifyContent: "flex-end", backgroundColor: "rgba(0,0,0,0.35)" },
dismiss: { flex: 1 },
sheet: { backgroundColor: "#1c1c1c", borderTopLeftRadius: 20, borderTopRightRadius: 20, paddingTop: 12, paddingHorizontal: 16, maxHeight: "75%", gap: 12 },
header: { flexDirection: "row", alignItems: "center", justifyContent: "space-between" },
@@ -143,6 +143,16 @@ export function StoryEditor({
</View>
)}
{/* Tippen auf eine freie Stelle der Story öffnet den Texteditor (wie Instagram). */}
{toolsEnabled && rect.width > 0 && (
<Pressable
style={{ position: "absolute", left: rect.x, top: rect.y, width: rect.width, height: rect.height }}
onPress={() => setPicker("text")}
accessibilityRole="button"
accessibilityLabel={t("storyEditor.addText")}
/>
)}
{overlays.map((overlay, index) => (
<EditableOverlay
key={index}
@@ -1,9 +1,11 @@
import { useEffect, useState } from "react";
import { Modal, View, Text, TextInput, Pressable, KeyboardAvoidingView, Platform, StyleSheet } from "react-native";
import { View, Text, TextInput, Pressable, StyleSheet } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { useTranslation } from "react-i18next";
import { fontFamily } from "../../theme/tokens";
import { MAX_TEXT_LENGTH, TEXT_COLORS, TEXT_STYLES, type TextColor, type TextFont, type TextStyle } from "../../lib/story-overlays";
import { textAppearance } from "./OverlayContent";
import { EditorLayer } from "./EditorLayer";
export type TextDraft = { text: string; color: TextColor; style: TextStyle; font: TextFont };
@@ -26,6 +28,7 @@ export function TextEditorModal({
onCancel: () => void;
}) {
const { t } = useTranslation();
const insets = useSafeAreaInsets();
const [draft, setDraft] = useState<TextDraft>(initial ?? DEFAULT_DRAFT);
// Beim Öffnen mit dem bearbeiteten Overlay bzw. leer starten.
@@ -38,8 +41,7 @@ export function TextEditorModal({
const nextStyle = TEXT_STYLES[(TEXT_STYLES.indexOf(draft.style) + 1) % TEXT_STYLES.length];
return (
<Modal visible={visible} transparent animationType="fade" onRequestClose={onCancel} statusBarTranslucent>
<KeyboardAvoidingView style={styles.backdrop} behavior={Platform.OS === "ios" ? "padding" : "height"}>
<EditorLayer visible={visible} onRequestClose={onCancel} style={[styles.backdrop, { paddingTop: insets.top + 8, paddingBottom: insets.bottom + 12 }]}>
<View style={styles.topBar}>
<Pressable onPress={onCancel} hitSlop={12} accessibilityRole="button">
<Text style={styles.topButton}>{t("common.cancel")}</Text>
@@ -98,13 +100,12 @@ export function TextEditorModal({
/>
))}
</View>
</KeyboardAvoidingView>
</Modal>
</EditorLayer>
);
}
const styles = StyleSheet.create({
backdrop: { flex: 1, backgroundColor: "rgba(0,0,0,0.7)", paddingTop: 48, paddingBottom: 16 },
backdrop: { backgroundColor: "rgba(0,0,0,0.75)" },
topBar: { flexDirection: "row", alignItems: "center", justifyContent: "space-between", paddingHorizontal: 16 },
topButton: { color: "#ffffff", fontFamily: fontFamily.semiBold, fontSize: 16 },
done: { color: "#f97316" },