⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.
TypeScript bookmarkbookmark-managercollaborationnextjsreact-nativeread-it-laterself-hostedtypescript
fix centering on android
daniel31x13cd6b01ad1210
diff --git a/apps/mobile/app/(tabs)/collections/index.tsx b/apps/mobile/app/(tabs)/collections/index.tsxindex f8be135c..0fde61a6 100644--- a/apps/mobile/app/(tabs)/collections/index.tsx+++ b/apps/mobile/app/(tabs)/collections/index.tsx@@ -1,12 +1,6 @@-import {- View,- FlatList,- Text,- ActivityIndicator,- ScrollView,- StyleSheet,-} from "react-native";+import { View, FlatList, Text, ActivityIndicator } from "react-native";import useAuthStore from "@/store/auth";+import EmptyState from "@/components/EmptyState";import CollectionListing from "@/components/CollectionListing";import { useLocalSearchParams } from "expo-router";import React, { useEffect, useState } from "react";@@ -57,26 +51,7 @@ export default function CollectionsScreen() {<Text className="text-base mt-2.5 text-neutral">Loading...</Text></View>) : filteredCollections.length === 0 ? (- <View style={{ flex: 1 }}>- <ScrollView- style={StyleSheet.absoluteFill}- contentContainerStyle={{ flexGrow: 1 }}- contentInsetAdjustmentBehavior="never"- showsVerticalScrollIndicator={false}- refreshControl={refreshControl}- />- <View- pointerEvents="none"- style={[- StyleSheet.absoluteFill,- { justifyContent: "center", alignItems: "center" },- ]}- >- <Text className="text-center text-xl text-neutral">- Nothing found...- </Text>- </View>- </View>+ <EmptyState refreshControl={refreshControl} />) : (<FlatListcontentInsetAdjustmentBehavior="automatic"diff --git a/apps/mobile/app/(tabs)/tags/index.tsx b/apps/mobile/app/(tabs)/tags/index.tsxindex 3608ae35..49dfba95 100644--- a/apps/mobile/app/(tabs)/tags/index.tsx+++ b/apps/mobile/app/(tabs)/tags/index.tsx@@ -1,12 +1,6 @@-import {- View,- FlatList,- Text,- ActivityIndicator,- ScrollView,- StyleSheet,-} from "react-native";+import { View, FlatList, Text, ActivityIndicator } from "react-native";import useAuthStore from "@/store/auth";+import EmptyState from "@/components/EmptyState";import TagListing from "@/components/TagListing";import { useLocalSearchParams } from "expo-router";import React, { useMemo } from "react";@@ -76,28 +70,10 @@ export default function TagsScreen() {<Text className="text-base mt-2.5 text-neutral">Loading...</Text></View>) : (filteredTags?.length ?? 0) === 0 ? (- <View style={{ flex: 1 }}>- <ScrollView- style={StyleSheet.absoluteFill}- contentContainerStyle={{ flexGrow: 1 }}- contentInsetAdjustmentBehavior="never"- showsVerticalScrollIndicator={false}- refreshControl={refreshControl}- />- {!tags.isFetching && (- <View- pointerEvents="none"- style={[- StyleSheet.absoluteFill,- { justifyContent: "center", alignItems: "center" },- ]}- >- <Text className="text-center text-xl text-neutral">- Nothing found...- </Text>- </View>- )}- </View>+ <EmptyState+ showMessage={!tags.isFetching}+ refreshControl={refreshControl}+ />) : (<FlatListcontentInsetAdjustmentBehavior="automatic"diff --git a/apps/mobile/components/EmptyState.tsx b/apps/mobile/components/EmptyState.tsxnew file mode 100644index 00000000..af8453e7--- /dev/null+++ b/apps/mobile/components/EmptyState.tsx@@ -0,0 +1,62 @@+import React from "react";+import {+ Platform,+ ScrollView,+ ScrollViewProps,+ StyleSheet,+ Text,+ View,+} from "react-native";+import { useSafeAreaInsets } from "react-native-safe-area-context";++type Props = {+ /** Whether to render the message. Hidden e.g. while still fetching. */+ showMessage?: boolean;+ message?: string;+ refreshControl?: ScrollViewProps["refreshControl"];+};++/**+ * Empty-state for the list screens. A full-window ScrollView keeps pull-to-refresh+ * working, with the message centered via an absolute overlay.+ *+ * The overlay is used (instead of flexGrow/centerContent) because on iOS the+ * transparent large-title header makes the scroll container full-window and the+ * header inset is invisible to JS, so layout-based centering fails/races on cold+ * start. On Android the header is opaque, so the overlay instead fills down behind+ * the bottom system inset and the message lands slightly low — pad it back up.+ */+export default function EmptyState({+ showMessage = true,+ message = "Nothing found...",+ refreshControl,+}: Props) {+ const insets = useSafeAreaInsets();++ return (+ <View style={{ flex: 1 }}>+ <ScrollView+ style={StyleSheet.absoluteFill}+ contentContainerStyle={{ flexGrow: 1 }}+ contentInsetAdjustmentBehavior="never"+ showsVerticalScrollIndicator={false}+ refreshControl={refreshControl}+ />+ {showMessage && (+ <View+ pointerEvents="none"+ style={[+ StyleSheet.absoluteFill,+ {+ justifyContent: "center",+ alignItems: "center",+ paddingBottom: Platform.OS === "android" ? insets.bottom : 0,+ },+ ]}+ >+ <Text className="text-center text-xl text-neutral">{message}</Text>+ </View>+ )}+ </View>+ );+}diff --git a/apps/mobile/components/Links.tsx b/apps/mobile/components/Links.tsxindex 71c2c893..a4e8d191 100644--- a/apps/mobile/components/Links.tsx+++ b/apps/mobile/components/Links.tsx@@ -1,13 +1,6 @@-import {- View,- FlatList,- Text,- ActivityIndicator,- ViewToken,- ScrollView,- StyleSheet,-} from "react-native";+import { View, FlatList, Text, ActivityIndicator, ViewToken } from "react-native";import LinkListing from "@/components/LinkListing";+import EmptyState from "@/components/EmptyState";import React, { useState } from "react";import { LinkIncludingShortenedCollectionAndTags } from "@linkwarden/types/global";import Spinner from "@/components/ui/Spinner";@@ -52,26 +45,7 @@ export default function Links({ links, data }: Props) {<Text className="text-base mt-2.5 text-neutral">Loading...</Text></View>) : (links?.length ?? 0) === 0 ? (- <View style={{ flex: 1 }}>- <ScrollView- style={StyleSheet.absoluteFill}- contentContainerStyle={{ flexGrow: 1 }}- contentInsetAdjustmentBehavior="never"- showsVerticalScrollIndicator={false}- refreshControl={refreshControl}- />- <View- pointerEvents="none"- style={[- StyleSheet.absoluteFill,- { justifyContent: "center", alignItems: "center" },- ]}- >- <Text className="text-center text-xl text-neutral">- Nothing found...- </Text>- </View>- </View>+ <EmptyState refreshControl={refreshControl} />) : (<FlatListcontentInsetAdjustmentBehavior="automatic"