From 96a45ee76c867ee2963809f65c72b1e1a466ebd7 Mon Sep 17 00:00:00 2001 From: ameer2468 <33054370+ameer2468@users.noreply.github.com> Date: Mon, 20 May 2024 23:29:56 +0100 Subject: [PATCH] [MOB-97] Fade select tags and empty location state (#2496) * fade select tags and empty location state * smaller tags * smaller tags in filters and add tags modal --- .../src/components/modal/AddTagModal.tsx | 37 +++++++++++++++++-- .../components/search/filters/FiltersBar.tsx | 8 ++-- .../src/components/search/filters/Tags.tsx | 2 +- apps/mobile/src/screens/browse/Location.tsx | 14 ++++++- 4 files changed, 52 insertions(+), 9 deletions(-) diff --git a/apps/mobile/src/components/modal/AddTagModal.tsx b/apps/mobile/src/components/modal/AddTagModal.tsx index 463e15143..1beee726a 100644 --- a/apps/mobile/src/components/modal/AddTagModal.tsx +++ b/apps/mobile/src/components/modal/AddTagModal.tsx @@ -1,11 +1,12 @@ import { Tag, getItemObject, useLibraryMutation, useLibraryQuery, useRspcContext } from "@sd/client"; import { CaretLeft, Plus } from "phosphor-react-native"; import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from "react"; -import { FlatList, Pressable, Text, View } from "react-native"; +import { FlatList, NativeScrollEvent, Pressable, Text, View } from "react-native"; import useForwardedRef from "~/hooks/useForwardedRef"; import { tw, twStyle } from "~/lib/tailwind"; import { useActionsModalStore } from "~/stores/modalStore"; import Card from "../layout/Card"; +import Fade from "../layout/Fade"; import { Modal, ModalRef } from "../layout/Modal"; import { Button } from "../primitive/Button"; import CreateTagModal from "./tag/CreateTagModal"; @@ -20,6 +21,8 @@ const AddTagModal = forwardRef((_, ref) => { const modalRef = useForwardedRef(ref); const newTagRef = useRef(null); + const [startedScrolling, setStartedScrolling] = useState(false); + const [reachedBottom, setReachedBottom] = useState(true); // needs to be set to true for initial rendering fade to be correct const rspc = useRspcContext(); const tagsQuery = useLibraryQuery(['tags.list']); @@ -98,6 +101,15 @@ const AddTagModal = forwardRef((_, ref) => { ); } + // Fade the tags when scrolling + const fadeScroll = ({ layoutMeasurement, contentOffset, contentSize }: NativeScrollEvent) => { + const isScrolling = contentOffset.y > 0; + setStartedScrolling(isScrolling); + + const hasReachedBottom = layoutMeasurement.height + contentOffset.y >= contentSize.height; + setReachedBottom(hasReachedBottom); + } + return ( <> ((_, ref) => { > + { + if (e.nativeEvent.layout.height >= 80) { + setReachedBottom(false); + } else { + setReachedBottom(true); + } + }} style={twStyle(`relative mt-4 h-[70%]`)}> + fadeScroll(e.nativeEvent)} extraData={selectedTags} key={tagsData ? 'tags' : '_'} keyExtractor={(item) => item.id.toString()} - contentContainerStyle={tw`mx-auto mt-4 p-4 pb-10`} + contentContainerStyle={tw`mx-auto p-4 pb-6`} ItemSeparatorComponent={() => } renderItem={({ item }) => ( isSelected(item.id)} select={() => selectTag(item.id)} tag={item} /> )} /> + +