fix(mobile): content hidden under Android gesture bar on stack screens
Android is edge-to-edge, and stack screens (no tab bar below) had no bottom inset on their scroll containers — the first post on a pet profile sat in the gesture area and couldn't be tapped (found.md). New useBottomSafePadding hook adds insets.bottom to the contentContainerStyle of pet profile, followers, following, health, milestones, edit pet, settings, search, messages list and delete account. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e4139a1b9b
commit
de237f19a1
11 files changed
+49
-11
No files matched your search
@@ -11,6 +11,7 @@ import { Button } from "../../src/components/Button";
|
||||
import { TextField } from "../../src/components/TextField";
|
||||
import { env } from "../../src/lib/env";
|
||||
import { getTypography, radii, type ColorTokens, type Typography } from "../../src/theme/tokens";
|
||||
import { useBottomSafePadding } from "../../src/hooks/useBottomSafePadding";
|
||||
|
||||
const DELETED_ITEMS = ["itemPets", "itemPosts", "itemMedia", "itemMessages", "itemHealth", "itemAccount"] as const;
|
||||
|
||||
@@ -27,6 +28,7 @@ export default function DeleteAccountScreen() {
|
||||
const { t } = useTranslation();
|
||||
const { colors } = useTheme();
|
||||
const styles = useMemo(() => makeStyles(colors), [colors]);
|
||||
const bottomPadding = useBottomSafePadding();
|
||||
const { getToken, signOut } = useAuth();
|
||||
const { pets, clearActivePetId } = useActivePet();
|
||||
const queryClient = useQueryClient();
|
||||
@@ -78,7 +80,7 @@ export default function DeleteAccountScreen() {
|
||||
|
||||
return (
|
||||
<KeyboardAvoidingView style={styles.flex} behavior={Platform.OS === "ios" ? "padding" : undefined}>
|
||||
<ScrollView contentContainerStyle={styles.content} keyboardShouldPersistTaps="handled">
|
||||
<ScrollView contentContainerStyle={[styles.content, bottomPadding]} keyboardShouldPersistTaps="handled">
|
||||
<View style={styles.titleRow}>
|
||||
<TriangleAlert color={colors.alertRed} size={22} />
|
||||
<Text style={styles.title}>{t("deleteAccount.warningTitle")}</Text>
|
||||
|
||||
@@ -10,6 +10,7 @@ import { PetAvatar } from "../../../src/components/PetAvatar";
|
||||
import { formatPetName, formatRelativeTime } from "../../../src/lib/format";
|
||||
import { getTypography, type ColorTokens, type Typography } from "../../../src/theme/tokens";
|
||||
import type { Conversation } from "../../../src/api/types";
|
||||
import { useBottomSafePadding } from "../../../src/hooks/useBottomSafePadding";
|
||||
|
||||
/** Conversations list (conversations.list) — taps a row to open the chat detail/compose screen. */
|
||||
export default function MessagesScreen() {
|
||||
@@ -19,6 +20,7 @@ export default function MessagesScreen() {
|
||||
const { activePetId } = useActivePet();
|
||||
const { colors } = useTheme();
|
||||
const styles = useMemo(() => makeStyles(colors), [colors]);
|
||||
const bottomPadding = useBottomSafePadding();
|
||||
|
||||
const { data, isLoading, error } = useQuery({
|
||||
...trpc.conversations.list.queryOptions({ petId: activePetId ?? "" }),
|
||||
@@ -45,7 +47,7 @@ export default function MessagesScreen() {
|
||||
<FlatList
|
||||
data={data ?? []}
|
||||
keyExtractor={(item) => item.id}
|
||||
contentContainerStyle={styles.list}
|
||||
contentContainerStyle={[styles.list, bottomPadding]}
|
||||
ItemSeparatorComponent={() => <View style={styles.separator} />}
|
||||
renderItem={({ item }) => (
|
||||
<ConversationRow conversation={item} onPress={() => router.push(`/messages/${item.id}`)} />
|
||||
|
||||
@@ -12,6 +12,7 @@ import { Button } from "../../../../src/components/Button";
|
||||
import { BreedPicker } from "../../../../src/components/pet/BreedPicker";
|
||||
import { radii, getTypography, type ColorTokens, type Typography } from "../../../../src/theme/tokens";
|
||||
import { displayDateToIso, isoToDisplayDate } from "../../../../src/lib/date-format";
|
||||
import { useBottomSafePadding } from "../../../../src/hooks/useBottomSafePadding";
|
||||
|
||||
/**
|
||||
* Edit form (name, nickname, breed, bio, adoption story, birthday, adoption
|
||||
@@ -29,6 +30,7 @@ export default function EditPetScreen() {
|
||||
const { activePetId, clearActivePetId } = useActivePet();
|
||||
const { colors } = useTheme();
|
||||
const styles = useMemo(() => makeStyles(colors), [colors]);
|
||||
const bottomPadding = useBottomSafePadding();
|
||||
|
||||
const { data: pet, isLoading } = useQuery(trpc.pets.byId.queryOptions({ petId }));
|
||||
|
||||
@@ -122,7 +124,7 @@ export default function EditPetScreen() {
|
||||
<FlatList
|
||||
data={EMPTY_DATA}
|
||||
renderItem={null}
|
||||
contentContainerStyle={styles.container}
|
||||
contentContainerStyle={[styles.container, bottomPadding]}
|
||||
ListHeaderComponent={
|
||||
<>
|
||||
<Text style={styles.label}>{t("editPet.nameLabel")}</Text>
|
||||
|
||||
@@ -9,6 +9,7 @@ import { useTheme } from "../../../../src/context/ThemeContext";
|
||||
import { PetAvatar } from "../../../../src/components/PetAvatar";
|
||||
import { formatPetName } from "../../../../src/lib/format";
|
||||
import { type ColorTokens } from "../../../../src/theme/tokens";
|
||||
import { useBottomSafePadding } from "../../../../src/hooks/useBottomSafePadding";
|
||||
|
||||
export default function FollowersScreen() {
|
||||
const { t } = useTranslation();
|
||||
@@ -17,6 +18,7 @@ export default function FollowersScreen() {
|
||||
const trpc = useTRPC();
|
||||
const { colors, typography } = useTheme();
|
||||
const styles = useMemo(() => makeStyles(colors), [colors]);
|
||||
const bottomPadding = useBottomSafePadding();
|
||||
const { data, isLoading } = useQuery(trpc.follows.listFollowers.queryOptions({ petId }));
|
||||
|
||||
if (isLoading) {
|
||||
@@ -31,7 +33,7 @@ export default function FollowersScreen() {
|
||||
<FlatList
|
||||
data={data?.items ?? []}
|
||||
keyExtractor={(item) => item.follower.id}
|
||||
contentContainerStyle={styles.list}
|
||||
contentContainerStyle={[styles.list, bottomPadding]}
|
||||
ItemSeparatorComponent={() => <View style={styles.separator} />}
|
||||
renderItem={({ item }) => (
|
||||
<Pressable style={styles.row} onPress={() => router.push(`/pets/${item.follower.id}`)}>
|
||||
|
||||
@@ -9,6 +9,7 @@ import { useTheme } from "../../../../src/context/ThemeContext";
|
||||
import { PetAvatar } from "../../../../src/components/PetAvatar";
|
||||
import { formatPetName } from "../../../../src/lib/format";
|
||||
import { type ColorTokens } from "../../../../src/theme/tokens";
|
||||
import { useBottomSafePadding } from "../../../../src/hooks/useBottomSafePadding";
|
||||
|
||||
export default function FollowingScreen() {
|
||||
const { t } = useTranslation();
|
||||
@@ -17,6 +18,7 @@ export default function FollowingScreen() {
|
||||
const trpc = useTRPC();
|
||||
const { colors, typography } = useTheme();
|
||||
const styles = useMemo(() => makeStyles(colors), [colors]);
|
||||
const bottomPadding = useBottomSafePadding();
|
||||
const { data, isLoading } = useQuery(trpc.follows.listFollowing.queryOptions({ petId }));
|
||||
|
||||
if (isLoading) {
|
||||
@@ -31,7 +33,7 @@ export default function FollowingScreen() {
|
||||
<FlatList
|
||||
data={data?.items ?? []}
|
||||
keyExtractor={(item) => item.followee.id}
|
||||
contentContainerStyle={styles.list}
|
||||
contentContainerStyle={[styles.list, bottomPadding]}
|
||||
ItemSeparatorComponent={() => <View style={styles.separator} />}
|
||||
renderItem={({ item }) => (
|
||||
<Pressable style={styles.row} onPress={() => router.push(`/pets/${item.followee.id}`)}>
|
||||
|
||||
@@ -7,6 +7,7 @@ import { VetVisitSection } from "../../../../../src/components/health/VetVisitSe
|
||||
import { VaccineSection } from "../../../../../src/components/health/VaccineSection";
|
||||
import { useTheme } from "../../../../../src/context/ThemeContext";
|
||||
import { type ColorTokens } from "../../../../../src/theme/tokens";
|
||||
import { useBottomSafePadding } from "../../../../../src/hooks/useBottomSafePadding";
|
||||
|
||||
/**
|
||||
* Port of web's src/app/(app)/pets/[petId]/health/page.tsx, scoped to the
|
||||
@@ -18,9 +19,10 @@ export default function PetHealthScreen() {
|
||||
const { petId } = useLocalSearchParams<{ petId: string }>();
|
||||
const { colors } = useTheme();
|
||||
const styles = useMemo(() => makeStyles(colors), [colors]);
|
||||
const bottomPadding = useBottomSafePadding();
|
||||
|
||||
return (
|
||||
<ScrollView contentContainerStyle={styles.container}>
|
||||
<ScrollView contentContainerStyle={[styles.container, bottomPadding]}>
|
||||
<HealthConsentGate petId={petId}>
|
||||
<WeightLogSection petId={petId} />
|
||||
<VetVisitSection petId={petId} />
|
||||
|
||||
@@ -18,6 +18,7 @@ import { useVisiblePostIds } from "../../../../src/hooks/useVisiblePostIds";
|
||||
import { formatPetName } from "../../../../src/lib/format";
|
||||
import { getAvatarUrl } from "../../../../src/lib/media-url";
|
||||
import { getTypography, type ColorTokens, type Typography } from "../../../../src/theme/tokens";
|
||||
import { useBottomSafePadding } from "../../../../src/hooks/useBottomSafePadding";
|
||||
|
||||
/**
|
||||
* Port of web's src/app/(app)/pets/[petId]/page.tsx: identity, bio/adoption
|
||||
@@ -34,6 +35,7 @@ export default function PetProfileScreen() {
|
||||
const { activePetId, pets: ownPets } = useActivePet();
|
||||
const { colors, typography } = useTheme();
|
||||
const styles = useMemo(() => makeStyles(colors), [colors]);
|
||||
const bottomPadding = useBottomSafePadding();
|
||||
const { visibleIds, viewabilityConfigCallbackPairs } = useVisiblePostIds();
|
||||
|
||||
const { data: pet, isLoading, error } = useQuery(trpc.pets.getProfile.queryOptions({ petId }));
|
||||
@@ -112,7 +114,7 @@ export default function PetProfileScreen() {
|
||||
<FlatList
|
||||
data={posts}
|
||||
keyExtractor={(post) => post.id}
|
||||
contentContainerStyle={styles.list}
|
||||
contentContainerStyle={[styles.list, bottomPadding]}
|
||||
renderItem={({ item }) => (
|
||||
<PostCard post={item} actingPetId={activePetId ?? petId} isVisible={visibleIds.has(item.id)} />
|
||||
)}
|
||||
|
||||
@@ -12,6 +12,7 @@ import { getMediaUrl } from "../../../../src/lib/media-url";
|
||||
import { MILESTONE_META, type MilestoneType } from "../../../../src/lib/milestone-meta";
|
||||
import { radii, getTypography, type ColorTokens, type Typography } from "../../../../src/theme/tokens";
|
||||
import type { MilestonePost } from "../../../../src/api/types";
|
||||
import { useBottomSafePadding } from "../../../../src/hooks/useBottomSafePadding";
|
||||
|
||||
/**
|
||||
* Port of web's Milestones profile tab (milestones.listByPet). Structured
|
||||
@@ -25,6 +26,7 @@ export default function MilestonesScreen() {
|
||||
const trpc = useTRPC();
|
||||
const { colors, typography } = useTheme();
|
||||
const styles = useMemo(() => makeStyles(colors), [colors]);
|
||||
const bottomPadding = useBottomSafePadding();
|
||||
const isOwnPet = activePetId === petId;
|
||||
|
||||
const { data: milestones = [], isLoading } = useQuery(trpc.milestones.listByPet.queryOptions({ petId }));
|
||||
@@ -41,7 +43,7 @@ export default function MilestonesScreen() {
|
||||
<FlatList
|
||||
data={milestones}
|
||||
keyExtractor={(item) => item.id}
|
||||
contentContainerStyle={styles.list}
|
||||
contentContainerStyle={[styles.list, bottomPadding]}
|
||||
ItemSeparatorComponent={() => <View style={styles.separator} />}
|
||||
renderItem={({ item }) => <MilestoneRow post={item} />}
|
||||
ListEmptyComponent={
|
||||
|
||||
@@ -14,6 +14,7 @@ import { PetAvatar } from "../../src/components/PetAvatar";
|
||||
import { FollowButton } from "../../src/components/FollowButton";
|
||||
import { getMediaUrl } from "../../src/lib/media-url";
|
||||
import { radii, getTypography, type ColorTokens } from "../../src/theme/tokens";
|
||||
import { useBottomSafePadding } from "../../src/hooks/useBottomSafePadding";
|
||||
|
||||
type Tab = "pets" | "people" | "tags";
|
||||
type Styles = ReturnType<typeof makeStyles>;
|
||||
@@ -39,6 +40,7 @@ export default function SearchScreen() {
|
||||
const { activePetId } = useActivePet();
|
||||
const { colors } = useTheme();
|
||||
const styles = useMemo(() => makeStyles(colors), [colors]);
|
||||
const bottomPadding = useBottomSafePadding();
|
||||
|
||||
const [query, setQuery] = useState("");
|
||||
const [tab, setTab] = useState<Tab>("pets");
|
||||
@@ -88,7 +90,7 @@ export default function SearchScreen() {
|
||||
<FlatList
|
||||
data={petResults?.pets ?? []}
|
||||
keyExtractor={(pet) => pet.id}
|
||||
contentContainerStyle={styles.list}
|
||||
contentContainerStyle={[styles.list, bottomPadding]}
|
||||
ListEmptyComponent={<EmptyState styles={styles} text={t("search.noPetsFor", { query: trimmed })} />}
|
||||
renderItem={({ item }) => (
|
||||
<PetRow styles={styles} pet={item} activePetId={activePetId} onPress={() => router.push(`/pets/${item.id}`)} />
|
||||
@@ -105,7 +107,7 @@ export default function SearchScreen() {
|
||||
<FlatList
|
||||
data={ownerResults?.owners ?? []}
|
||||
keyExtractor={(owner) => owner.id}
|
||||
contentContainerStyle={styles.list}
|
||||
contentContainerStyle={[styles.list, bottomPadding]}
|
||||
ListEmptyComponent={<EmptyState styles={styles} text={t("search.noPeopleFor", { query: trimmed })} />}
|
||||
renderItem={({ item: owner }) => {
|
||||
const displayName = owner.username
|
||||
|
||||
@@ -9,6 +9,7 @@ import { LogoutSection } from "../../src/components/settings/LogoutSection";
|
||||
import { DeleteAccountSection } from "../../src/components/settings/DeleteAccountSection";
|
||||
import { FooterErrorBoundary } from "../../src/components/settings/FooterErrorBoundary";
|
||||
import type { ColorTokens } from "../../src/theme/tokens";
|
||||
import { useBottomSafePadding } from "../../src/hooks/useBottomSafePadding";
|
||||
|
||||
/**
|
||||
* Dedicated Settings screen, reached via the gear icon in every tab's header
|
||||
@@ -35,10 +36,11 @@ import type { ColorTokens } from "../../src/theme/tokens";
|
||||
export default function SettingsScreen() {
|
||||
const { colors } = useTheme();
|
||||
const styles = useMemo(() => makeStyles(colors), [colors]);
|
||||
const bottomPadding = useBottomSafePadding();
|
||||
|
||||
return (
|
||||
<FooterErrorBoundary>
|
||||
<ScrollView contentContainerStyle={styles.content}>
|
||||
<ScrollView contentContainerStyle={[styles.content, bottomPadding]}>
|
||||
<AppearanceSection />
|
||||
<LanguageSection />
|
||||
<PetSuggestionsSection />
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import { useMemo } from "react";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
|
||||
const BASE_PADDING = 16;
|
||||
|
||||
/**
|
||||
* Bottom padding for scroll containers on stack screens (no tab bar below).
|
||||
* Android is edge-to-edge, so without this the last item scrolls under the
|
||||
* gesture/navigation bar — found.md: the first post on a pet profile sat in
|
||||
* the gesture area and couldn't be tapped. Same idea as comments.tsx /
|
||||
* messages/[conversationId].tsx, which pass insets.bottom into makeStyles.
|
||||
*
|
||||
* Usage: `contentContainerStyle={[styles.list, bottomPadding]}`.
|
||||
*/
|
||||
export function useBottomSafePadding(base: number = BASE_PADDING) {
|
||||
const { bottom } = useSafeAreaInsets();
|
||||
return useMemo(() => ({ paddingBottom: base + bottom }), [base, bottom]);
|
||||
}
|
||||
Reference in new issue
Block a user