Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(mobile): add scroll-to-end button #5915

ClosedKapish14(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/5915/headopened View on GitHub

Showing 4 changed files with 67 additions and 8 deletions (loading 1).

x
0 of 4 viewed, 4 left
26 additions and 1 deletionapps/mobile/src/components/ControlPill.tsxModified
View file
@@ -6,6 +6,7 @@
type ComponentProps,
type ReactElement,
type ReactNode,
+ useRef,
} from "react";
import { Platform, Pressable, useColorScheme, View } from "react-native";
import { useThemeColor } from "../lib/useThemeColor";
@@ -21,10 +22,31 @@
readonly label?: string;
readonly accessibilityLabel?: string;
readonly onPress?: () => void;
+ readonly activateOnPressIn?: boolean;
readonly variant?: "circle" | "pill" | "primary" | "danger";
readonly disabled?: boolean;
+ readonly className?: string;
}) {
const variant = props.variant ?? "circle";
+ const activatedOnPressInRef = useRef(false);
+​
+ const handlePressIn = () => {
+ activatedOnPressInRef.current = true;
+ props.onPress?.();
+ };
+ const handlePressOut = () => {
+ // Pressability invokes onPressOut immediately before onPress on release.
+ // Defer the reset so onPress can identify the same physical gesture.
+ setTimeout(() => {
+ activatedOnPressInRef.current = false;