feat(mobile): mix trending posts into the Feed, update app icon assets
- explore.getTrending posts are now interleaved into the chronological Feed at semi-random intervals (src/lib/interleave-trending.ts), marked with a small "Trending" badge on PostCard — a lightweight stand-in for web's separate Explore "Trending" tab, which mobile wasn't going to get as its own screen. No backend change: reuses the existing explore.getTrending procedure as-is. - update app icon / splash / favicon / Android adaptive-icon assets (user-provided) - README: correct the now-stale Dark Mode "not yet converted" list (Explore/Notifications/pet profile/health were converted in the found.md batch) and document the report/date-format/pinch-zoom/ legal-links fixes
No files matched your search
@@ -245,9 +245,13 @@ screen is focused since messages.ts has no realtime mechanism) are done
|
||||
and verified end-to-end against the live backend on a real Android
|
||||
emulator. Still missing, roughly in the order they'd unblock the most:
|
||||
|
||||
- Web's Explore "Trending" tab (algorithmic hot-posts grid + trending
|
||||
hashtags, `explore.getTrending`) — mobile's Explore only has the
|
||||
species/breed-filtered pet grid (`explore.listPets`), not this second tab.
|
||||
- Web's Explore "Trending" **hashtags** — mobile has no hashtag search/browse
|
||||
UI at all. The trending **posts** half of that tab isn't a separate mobile
|
||||
screen either, but its data (`explore.getTrending`) is now surfaced by
|
||||
mixing a few of those posts into the Feed itself at semi-random intervals
|
||||
(`src/lib/interleave-trending.ts`, marked with a small "Trending" badge on
|
||||
`PostCard`) rather than building a second tab/grid — see the Feed section
|
||||
of "Folder structure" above for where that lives.
|
||||
|
||||
Onboarding (`/onboarding/pet` — guidelines → upload consent →
|
||||
Arachnophobie-Helfer opt-in → pet form → avatar), sign-up, dark mode, and
|
||||
@@ -316,17 +320,22 @@ import from `theme/tokens.ts`. `theme/tokens.ts`'s top comment and
|
||||
`ThemeContext.tsx`'s own comment cover this in more depth.
|
||||
|
||||
**Converted so far:** the shared primitives (`Button`, `TextField`,
|
||||
`Card`, `PetAvatar`), `PostCard`, `StoryTray`, the Feed tab, the Pets tab,
|
||||
and all navigation chrome (root `_layout.tsx`'s status bar, `(app)/_layout.tsx`
|
||||
and `onboarding/_layout.tsx`'s Stack headers, `(tabs)/_layout.tsx`'s
|
||||
tab bar and headers) — Stack/Tabs `options` objects are plain props
|
||||
recomputed on every render, so those didn't need the `makeStyles` dance,
|
||||
just reading `colors` from `useTheme()` directly. **Not yet converted:**
|
||||
essentially everything else — Explore, Notifications, Search, Messages,
|
||||
comments, stories, milestones, health, post/story/milestone creation,
|
||||
pet profile/edit/followers/following. They'll render correctly in light
|
||||
mode regardless of the device/account theme setting until someone
|
||||
applies the same `makeStyles` conversion to them.
|
||||
`Card`, `PetAvatar`, `OptionPicker`), `PostCard`, `StoryTray`, the Feed
|
||||
tab, the Explore tab, the Notifications tab, the Pets tab, the full pet
|
||||
profile (view/edit/followers/following), the whole health area (consent
|
||||
gate + weight/vet/vaccine sections), and all navigation chrome (root
|
||||
`_layout.tsx`'s status bar, `(app)/_layout.tsx` and `onboarding/_layout.tsx`'s
|
||||
Stack headers — including `headerTintColor`, without which the back
|
||||
button's default tint stayed invisible against a dark header — and
|
||||
`(tabs)/_layout.tsx`'s tab bar and headers) — Stack/Tabs `options` objects
|
||||
are plain props recomputed on every render, so those didn't need the
|
||||
`makeStyles` dance, just reading `colors` from `useTheme()` directly.
|
||||
**Not yet converted:** Search, Messages, comments, stories, milestones,
|
||||
sign-in/sign-up, and the post/story/milestone creation screens, plus a
|
||||
few shared components whose icon colors don't fully adapt (`PawButton`,
|
||||
`PawBackButton`, `PetIdentityBadges`, `RepostCard`, `VideoPlayer`). They'll
|
||||
render correctly in light mode regardless of the device/account theme
|
||||
setting until someone applies the same `makeStyles` conversion to them.
|
||||
|
||||
### Internationalization (i18n)
|
||||
|
||||
@@ -437,3 +446,39 @@ app is redeployed too (`ssh` to the NAS, `git pull`, `./docker/rolling-deploy.sh
|
||||
a "mobile" feature session still needs a web deploy — [[project_mobile_deployment_target]]'s
|
||||
"mobile changes need no NAS deploy" is about `mobile/` code itself, not
|
||||
backend endpoints mobile happens to call.
|
||||
|
||||
### Content moderation, health-form dates, and image zoom
|
||||
|
||||
Three smaller found.md fixes worth documenting since they're easy to
|
||||
regress:
|
||||
|
||||
- **Reporting** (`src/components/ReportSheet.tsx`) — a `MoreVertical`
|
||||
button on `PostCard`'s header opens a bottom sheet with the same 5
|
||||
`ReportReason` values as web's `ReportSheet.tsx`, calling the existing
|
||||
`reports.create` (no backend change needed). Trimmed versus web: tapping
|
||||
a reason submits immediately, there's no separate optional notes
|
||||
textarea yet even though the backend already accepts one.
|
||||
- **Health form dates** (`src/lib/date-format.ts`) — the weight/vet-visit/
|
||||
vaccine forms take `DD-MM-YYYY` and convert to the backend's
|
||||
`YYYY-MM-DD` right before the mutation call. The actual found.md
|
||||
"Gesundheitsdaten werden nicht gespeichert" bug wasn't persistence at
|
||||
all — `addWeightLog`/`addVetVisit`/`addVaccine` had no `onError`
|
||||
handler, so a validation failure (wrong date format) just silently did
|
||||
nothing. All three now show an alert on failure.
|
||||
- **Pinch-to-zoom** (`app/(app)/image-viewer.tsx`) — a plain `PanResponder`
|
||||
tracking two-finger distance, driving an `Animated.Value` scale on the
|
||||
full-size image. Deliberately not `react-native-gesture-handler` (not a
|
||||
dependency yet) — this is a single scale gesture with no pan/rotate, a
|
||||
raw `PanResponder` is enough.
|
||||
|
||||
### Pets tab: legal links, version, language flags
|
||||
|
||||
Below the language switcher, `LegalSection` (`app/(app)/(tabs)/pets.tsx`)
|
||||
links to the same fixed-language legal pages web links to
|
||||
(`/impressum`, `/datenschutz`, `/nutzungsbedingungen` — see root
|
||||
`CLAUDE.md`, these are never localized) via `Linking.openURL`, plus the
|
||||
installed app version read from `Constants.expoConfig?.version`. The
|
||||
language switcher's three buttons use flag emoji (🇩🇪/🇬🇧/🌐) instead of an
|
||||
icon — Android renders these natively, unlike the Windows-Chrome
|
||||
flag-emoji-renders-as-text-codes problem web ran into (fixed there with
|
||||
inline SVGs instead), which doesn't apply on a native Android renderer.
|
||||
@@ -1,19 +1,23 @@
|
||||
import { useMemo } from "react";
|
||||
import { useMemo, useRef } from "react";
|
||||
import { View, Text, FlatList, ActivityIndicator, RefreshControl, StyleSheet } from "react-native";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useInfiniteQuery } from "@tanstack/react-query";
|
||||
import { useInfiniteQuery, useQuery } from "@tanstack/react-query";
|
||||
import { useTRPC } from "../../../src/api/trpc";
|
||||
import { useActivePet } from "../../../src/context/ActivePetContext";
|
||||
import { useTheme } from "../../../src/context/ThemeContext";
|
||||
import { PostCard } from "../../../src/components/PostCard";
|
||||
import { StoryTray } from "../../../src/components/StoryTray";
|
||||
import { interleaveTrending } from "../../../src/lib/interleave-trending";
|
||||
import { getTypography, type ColorTokens, type Typography } from "../../../src/theme/tokens";
|
||||
import type { FeedPost } from "../../../src/api/types";
|
||||
import type { FeedPost, TrendingPost } from "../../../src/api/types";
|
||||
|
||||
/**
|
||||
* Port of web's src/components/feed/FeedList.tsx: infinite-scroll feed data
|
||||
* with the StoryTray as a list header. No ads or feed-mode ("algo" vs
|
||||
* "chrono") toggle yet.
|
||||
* "chrono") toggle yet. A handful of explore.getTrending posts are mixed
|
||||
* in at semi-random intervals (see interleave-trending.ts) — a lightweight
|
||||
* stand-in for web's separate Explore "Trending" tab, which mobile hasn't
|
||||
* built and isn't planning to as its own screen.
|
||||
*/
|
||||
export default function FeedScreen() {
|
||||
const { t } = useTranslation();
|
||||
@@ -21,6 +25,9 @@ export default function FeedScreen() {
|
||||
const { activePetId, isLoading: isActivePetLoading } = useActivePet();
|
||||
const { colors, typography } = useTheme();
|
||||
const styles = useMemo(() => makeStyles(colors), [colors]);
|
||||
// Fixed once per screen mount so trending posts don't jump to new spots
|
||||
// as more feed pages load — see interleaveTrending's own comment.
|
||||
const spacingSeed = useRef(Array.from({ length: 20 }, () => 4 + Math.floor(Math.random() * 3))).current;
|
||||
|
||||
const { data, isLoading, isFetchingNextPage, fetchNextPage, hasNextPage, refetch, isRefetching, error } =
|
||||
useInfiniteQuery({
|
||||
@@ -31,6 +38,11 @@ export default function FeedScreen() {
|
||||
enabled: !!activePetId,
|
||||
});
|
||||
|
||||
const { data: trendingData } = useQuery({
|
||||
...trpc.explore.getTrending.queryOptions(),
|
||||
enabled: !!activePetId,
|
||||
});
|
||||
|
||||
if (isActivePetLoading || (isLoading && !data)) {
|
||||
return (
|
||||
<View style={styles.center}>
|
||||
@@ -48,13 +60,20 @@ export default function FeedScreen() {
|
||||
}
|
||||
|
||||
const posts: FeedPost[] = data?.pages.flatMap((page) => page.posts) ?? [];
|
||||
const trendingPosts: TrendingPost[] = trendingData?.posts ?? [];
|
||||
const feedItems = useMemo(
|
||||
() => interleaveTrending(posts, trendingPosts, spacingSeed),
|
||||
[posts, trendingPosts, spacingSeed]
|
||||
);
|
||||
|
||||
return (
|
||||
<FlatList
|
||||
data={posts}
|
||||
data={feedItems}
|
||||
keyExtractor={(post) => post.id}
|
||||
contentContainerStyle={styles.list}
|
||||
renderItem={({ item }) => <PostCard post={item} actingPetId={activePetId!} />}
|
||||
renderItem={({ item }) => (
|
||||
<PostCard post={item} actingPetId={activePetId!} isTrending={item.isTrending} />
|
||||
)}
|
||||
ListHeaderComponent={<StoryTray />}
|
||||
ItemSeparatorComponent={() => (
|
||||
<View style={styles.separatorWrap}>
|
||||
|
||||
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 8.4 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 8.8 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 9.9 KiB |
@@ -11,3 +11,4 @@ export type Conversation = RouterOutputs["conversations"]["list"][number];
|
||||
export type PostComment = RouterOutputs["comments"]["listByPost"]["comments"][number];
|
||||
export type ChatMessage = RouterOutputs["messages"]["list"]["messages"][number];
|
||||
export type MilestonePost = RouterOutputs["milestones"]["listByPet"][number];
|
||||
export type TrendingPost = RouterOutputs["explore"]["getTrending"]["posts"][number];
|
||||
@@ -1,8 +1,9 @@
|
||||
import { useMemo, useState } from "react";
|
||||
import { View, Text, Pressable, StyleSheet, ScrollView, useWindowDimensions } from "react-native";
|
||||
import { useRouter } from "expo-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Image } from "expo-image";
|
||||
import { MessageCircle, MoreVertical } from "lucide-react-native";
|
||||
import { MessageCircle, MoreVertical, Flame } from "lucide-react-native";
|
||||
import { PetAvatar } from "./PetAvatar";
|
||||
import { PetIdentityBadges } from "./PetIdentityBadges";
|
||||
import { PawButton } from "./PawButton";
|
||||
@@ -63,6 +64,8 @@ type Props = {
|
||||
post: PostCardPost;
|
||||
/** The signed-in owner's currently active pet — the one reacting/acting. */
|
||||
actingPetId: string;
|
||||
/** Set when this post was mixed into the feed from explore.getTrending rather than being a real followed-pet post — see FeedScreen's interleaving logic. */
|
||||
isTrending?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -72,7 +75,8 @@ type Props = {
|
||||
* playback UI is an explicit fast-follow). Repost ("Paw-Back") posts
|
||||
* delegate entirely to RepostCard before any of this renders.
|
||||
*/
|
||||
export function PostCard({ post, actingPetId }: Props) {
|
||||
export function PostCard({ post, actingPetId, isTrending }: Props) {
|
||||
const { t } = useTranslation();
|
||||
const { width } = useWindowDimensions();
|
||||
const router = useRouter();
|
||||
const { colors } = useTheme();
|
||||
@@ -100,6 +104,12 @@ export function PostCard({ post, actingPetId }: Props) {
|
||||
<View style={styles.nameRow}>
|
||||
<Text style={styles.name}>{formatPetName(post.pet)}</Text>
|
||||
<PetIdentityBadges isVerified={post.pet.isVerified} sponsor={post.pet.owner} />
|
||||
{isTrending && (
|
||||
<View style={styles.trendingBadge}>
|
||||
<Flame size={11} color={colors.marigoldDeep} fill={colors.marigoldDeep} />
|
||||
<Text style={styles.trendingBadgeText}>{t("feed.trendingBadge")}</Text>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
<Text style={styles.timestamp}>{formatRelativeTime(post.createdAt)}</Text>
|
||||
</View>
|
||||
@@ -187,8 +197,19 @@ function makeStyles(colors: ColorTokens) {
|
||||
header: { flex: 1, flexDirection: "row", alignItems: "center", gap: 10 },
|
||||
moreButton: { padding: 4 },
|
||||
headerText: { flex: 1 },
|
||||
nameRow: { flexDirection: "row", alignItems: "center" },
|
||||
nameRow: { flexDirection: "row", alignItems: "center", flexWrap: "wrap" },
|
||||
name: { ...typography.body, fontFamily: typography.title.fontFamily },
|
||||
trendingBadge: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
gap: 3,
|
||||
marginLeft: 8,
|
||||
paddingHorizontal: 7,
|
||||
paddingVertical: 2,
|
||||
borderRadius: radii.sm,
|
||||
backgroundColor: colors.marigoldTint,
|
||||
},
|
||||
trendingBadgeText: { ...typography.label, textTransform: "none", letterSpacing: 0, fontSize: 10, color: colors.marigoldDeep },
|
||||
timestamp: { ...typography.label, textTransform: "none", letterSpacing: 0 },
|
||||
caption: { ...typography.body },
|
||||
actions: { flexDirection: "row", alignItems: "center", gap: 20 },
|
||||
|
||||
@@ -46,7 +46,8 @@
|
||||
},
|
||||
"feed": {
|
||||
"empty": "Noch keine Beiträge im Feed.",
|
||||
"storyLabel": "Story"
|
||||
"storyLabel": "Story",
|
||||
"trendingBadge": "Trending"
|
||||
},
|
||||
"explore": {
|
||||
"allTab": "Alle",
|
||||
|
||||
@@ -46,7 +46,8 @@
|
||||
},
|
||||
"feed": {
|
||||
"empty": "No posts in your feed yet.",
|
||||
"storyLabel": "Story"
|
||||
"storyLabel": "Story",
|
||||
"trendingBadge": "Trending"
|
||||
},
|
||||
"explore": {
|
||||
"allTab": "All",
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
type WithId = { id: string };
|
||||
|
||||
/**
|
||||
* Mixes a few trending posts into the chronological feed at semi-random
|
||||
* intervals — web has a separate "Trending" tab (explore.getTrending,
|
||||
* "könnte dir auch gefallen") that mobile never got; rather than building a
|
||||
* second tab/UI, interleaving trending posts directly into the Feed (marked
|
||||
* via `isTrending` on PostCard) gets the same discovery value for a
|
||||
* fraction of the work.
|
||||
*
|
||||
* `spacingSeed` is generated once by the caller (a ref, not `Math.random()`
|
||||
* inline here) so re-running this on a longer `posts` array as more feed
|
||||
* pages load doesn't reshuffle where earlier trending posts landed — the
|
||||
* function is a pure walk over `posts` in order and only ever appends
|
||||
* further into the result as `posts` grows, it never revisits the prefix.
|
||||
*/
|
||||
export function interleaveTrending<F extends WithId, T extends WithId>(
|
||||
posts: F[],
|
||||
trending: T[],
|
||||
spacingSeed: number[]
|
||||
): Array<(F | T) & { isTrending?: boolean }> {
|
||||
if (trending.length === 0) return posts;
|
||||
|
||||
const feedIds = new Set(posts.map((p) => p.id));
|
||||
const candidates = trending.filter((p) => !feedIds.has(p.id));
|
||||
if (candidates.length === 0) return posts;
|
||||
|
||||
const result: Array<(F | T) & { isTrending?: boolean }> = [];
|
||||
let candidateIndex = 0;
|
||||
let sinceLastInsert = 0;
|
||||
let spacingIndex = 0;
|
||||
|
||||
posts.forEach((post, i) => {
|
||||
result.push(post);
|
||||
sinceLastInsert++;
|
||||
const spacing = spacingSeed[spacingIndex % spacingSeed.length] ?? 5;
|
||||
// Never in the first couple posts — feels odd to see an unfollowed
|
||||
// pet's post before the feed has even established itself.
|
||||
if (i >= 2 && sinceLastInsert >= spacing && candidateIndex < candidates.length) {
|
||||
result.push({ ...candidates[candidateIndex], isTrending: true });
|
||||
candidateIndex++;
|
||||
spacingIndex++;
|
||||
sinceLastInsert = 0;
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||