diff --git a/mobile/app/(app)/_layout.tsx b/mobile/app/(app)/_layout.tsx
index 91ffbf9..265afce 100644
--- a/mobile/app/(app)/_layout.tsx
+++ b/mobile/app/(app)/_layout.tsx
@@ -70,6 +70,11 @@ export default function AppLayout() {
headerLeft: () => ,
}}
/>
+ {/* Story-Editor: eigener Vollbild-Screen, ohne Wisch-zum-Schließen (Ziehgesten der Overlays). */}
+
{
+ 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();
+ 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(null);
+ const [isUploading, setIsUploading] = useState(false);
+ const [uploadPercent, setUploadPercent] = useState(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 (
+
+ {t("onboarding.uploadError")}
+
+ );
+ }
+
+ return (
+ {
+ if (!isSubmitting) router.back();
+ }}
+ progress={
+ <>
+ {error ? {error} : null}
+ {isSubmitting && media.kind === "video" ? : 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 (
+
+
+
+
+ {label}
+
+ );
+}
+
+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" },
+});
diff --git a/mobile/app/(app)/story-new.tsx b/mobile/app/(app)/story-new.tsx
index 42811f9..c93c4b8 100644
--- a/mobile/app/(app)/story-new.tsx
+++ b/mobile/app/(app)/story-new.tsx
@@ -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(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(null);
- const [isUploading, setIsUploading] = useState(false);
- // Video-Upload in Prozent (0–100), null solange kein Video hochgeladen wird.
- const [uploadPercent, setUploadPercent] = useState(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 (
- {
- if (!isSubmitting) {
- setMedia(null);
- setError(null);
- }
- }}
- progress={
- <>
- {error ? {error} : null}
- {isSubmitting && media.kind === "video" ? : null}
- >
- }
- />
- );
- }
+ }, [t, openEditor]);
return (
@@ -203,7 +95,7 @@ export default function NewStoryScreen() {
{editorEnabled && (
- setMedia({ kind: "text" })}>
+ openEditor({ kind: "text" })}>
{t("storyEditor.textStory")}
@@ -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 }) {
- const { t } = useTranslation();
- const label = percent === null ? t("story.preparingUpload") : t("story.uploadingVideo", { percent });
-
- return (
-
-
-
-
- {label}
-
- );
-}
-
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" },
});
}
diff --git a/mobile/src/components/story-editor/EditorLayer.tsx b/mobile/src/components/story-editor/EditorLayer.tsx
new file mode 100644
index 0000000..94485d3
--- /dev/null
+++ b/mobile/src/components/story-editor/EditorLayer.tsx
@@ -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 ): 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;
+ 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 (
+
+ {children}
+
+ );
+}
+
+const styles = StyleSheet.create({
+ layer: { zIndex: 20, elevation: 20 },
+});
diff --git a/mobile/src/components/story-editor/PickerSheet.tsx b/mobile/src/components/story-editor/PickerSheet.tsx
index 42c2c9a..5668629 100644
--- a/mobile/src/components/story-editor/PickerSheet.tsx
+++ b/mobile/src/components/story-editor/PickerSheet.tsx
@@ -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 (
-
-
+
@@ -19,13 +19,12 @@ export function PickerSheet({ visible, title, onClose, children }: { visible: bo
{children}
-
-
+
);
}
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" },
diff --git a/mobile/src/components/story-editor/StoryEditor.tsx b/mobile/src/components/story-editor/StoryEditor.tsx
index 3c0fcd1..58887f6 100644
--- a/mobile/src/components/story-editor/StoryEditor.tsx
+++ b/mobile/src/components/story-editor/StoryEditor.tsx
@@ -143,6 +143,16 @@ export function StoryEditor({
)}
+ {/* Tippen auf eine freie Stelle der Story öffnet den Texteditor (wie Instagram). */}
+ {toolsEnabled && rect.width > 0 && (
+ setPicker("text")}
+ accessibilityRole="button"
+ accessibilityLabel={t("storyEditor.addText")}
+ />
+ )}
+
{overlays.map((overlay, index) => (
void;
}) {
const { t } = useTranslation();
+ const insets = useSafeAreaInsets();
const [draft, setDraft] = useState(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 (
-
-
+
{t("common.cancel")}
@@ -98,13 +100,12 @@ export function TextEditorModal({
/>
))}
-
-
+
);
}
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" },