Skip to content

Commit

Permalink
fix(mobile): Scroll to the top when the main tab is clicked
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedBassem committed Mar 15, 2024
1 parent 77b7892 commit c4d7223
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion apps/mobile/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Hoarder App",
"slug": "hoarder",
"scheme": "hoarder",
"version": "1.2.2",
"version": "1.2.3",
"orientation": "portrait",
"icon": "./assets/icon.png",
"userInterfaceStyle": "light",
Expand Down
16 changes: 9 additions & 7 deletions apps/mobile/app/dashboard/(tabs)/lists.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useState } from "react";
import { FlatList, View } from "react-native";
import { FlatList, View, Text, Pressable } from "react-native";
import { Link } from "expo-router";
import { api } from "@/lib/trpc";
import { ChevronRight } from "lucide-react-native";
Expand Down Expand Up @@ -53,12 +53,14 @@ export default function Lists() {
marginTop: 5,
}}
renderItem={(l) => (
<View className="mx-2 flex flex-row justify-between rounded-xl border border-gray-100 bg-white px-4 py-2">
<Link key={l.item.id} href={l.item.href} className="text-lg">
{l.item.logo} {l.item.name}
</Link>
<ChevronRight />
</View>
<Link asChild key={l.item.id} href={l.item.href}>
<Pressable className="mx-2 flex flex-row justify-between rounded-xl border border-gray-100 bg-white px-4 py-2">
<Text className="text-lg">
{l.item.logo} {l.item.name}
</Text>
<ChevronRight />
</Pressable>
</Link>
)}
data={links}
refreshing={refreshing}
Expand Down
6 changes: 5 additions & 1 deletion apps/mobile/components/bookmarks/BookmarkList.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { useEffect, useState } from "react";
import { useEffect, useRef, useState } from "react";
import { Text, View, Keyboard } from "react-native";
import Animated, { LinearTransition } from "react-native-reanimated";
import { api } from "@/lib/trpc";

import FullPageSpinner from "../ui/FullPageSpinner";
import BookmarkCard from "./BookmarkCard";
import { useScrollToTop } from '@react-navigation/native';

export default function BookmarkList({
favourited,
Expand All @@ -17,6 +18,8 @@ export default function BookmarkList({
}) {
const apiUtils = api.useUtils();
const [refreshing, setRefreshing] = useState(false);
const flatListRef = useRef(null);
useScrollToTop(flatListRef);
const { data, isPending, isPlaceholderData } =
api.bookmarks.getBookmarks.useQuery({
favourited,
Expand All @@ -39,6 +42,7 @@ export default function BookmarkList({

return (
<Animated.FlatList
ref={flatListRef}
itemLayoutAnimation={LinearTransition}
contentContainerStyle={{
gap: 15,
Expand Down

0 comments on commit c4d7223

Please sign in to comment.