Skip to content

Commit

Permalink
fix: set bottom inset for floating buttons
Browse files Browse the repository at this point in the history
credit to e987723
  • Loading branch information
pylixonly committed Nov 9, 2024
1 parent 5e3f9b7 commit 6f52993
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/core/ui/components/AddonPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import isValidHttpUrl from "@lib/utils/isValidHttpUrl";
import { lazyDestructure } from "@lib/utils/lazy";
import { findByProps } from "@metro";
import { clipboard } from "@metro/common";
import { Button, FlashList, FloatingActionButton, HelpMessage, IconButton, Stack, Text, TextInput } from "@metro/common/components";
import { Button, FlashList, FloatingActionButton, HelpMessage, IconButton, Stack, Text, TextInput, useSafeAreaInsets } from "@metro/common/components";
import { ErrorBoundary, Search } from "@ui/components";
import fuzzysort from "fuzzysort";
import { ComponentType, ReactNode, useCallback, useMemo } from "react";
Expand Down Expand Up @@ -111,6 +111,7 @@ export default function AddonPage<T extends object>({ CardComponent, ...props }:

const [search, setSearch] = React.useState("");
const [sortFn, setSortFn] = React.useState<((a: unknown, b: unknown) => number) | null>(() => null);
const { bottom: bottomInset } = useSafeAreaInsets();

const results = useMemo(() => {
let values = props.items;
Expand Down Expand Up @@ -198,6 +199,7 @@ export default function AddonPage<T extends object>({ CardComponent, ...props }:
renderItem={({ item }: any) => <CardComponent item={item.obj} result={item} />}
/>
{props.installAction && <FloatingActionButton
positionBottom={bottomInset + 8}
icon={findAssetId("PlusLargeIcon")}
onPress={onInstallPress}
/>}
Expand Down
2 changes: 1 addition & 1 deletion src/metro/common/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const CompatButton = findByPropsLazy("Looks", "Colors", "Sizes");
export const HelpMessage = findByNameLazy("HelpMessage");

// React Native's included SafeAreaView only adds padding on iOS.
export const { SafeAreaView, SafeAreaProvider } = lazyDestructure(() => findByProps("useSafeAreaInsets"));
export const { SafeAreaView, SafeAreaProvider, useSafeAreaInsets } = lazyDestructure(() => findByProps("useSafeAreaInsets"));

// ActionSheet
export const ActionSheetRow = findProp("ActionSheetRow");
Expand Down
1 change: 1 addition & 0 deletions src/metro/common/types/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ interface FABProps {
icon: ImageSourcePropType | ReactNode;
style?: Style;
onPress: () => void;
positionBottom?: number;
}

export type FloatingActionButton = React.FC<FABProps>;
Expand Down

0 comments on commit 6f52993

Please sign in to comment.