2023-08-12 03:22:50 +00:00
|
|
|
import { ComponentProps, useMemo } from "react";
|
|
|
|
import { FAB, useTheme } from "react-native-paper";
|
|
|
|
import { CombinedDarkTheme, CombinedDefaultTheme } from "./App";
|
|
|
|
import { lightColors } from "./colors";
|
2022-07-08 02:59:19 +00:00
|
|
|
|
2022-12-29 00:57:19 +00:00
|
|
|
export default function AppFab(props: Partial<ComponentProps<typeof FAB>>) {
|
2023-08-12 03:22:50 +00:00
|
|
|
const { colors } = useTheme();
|
2022-10-31 08:32:33 +00:00
|
|
|
|
2022-11-30 01:32:42 +00:00
|
|
|
const fabColor = useMemo(
|
|
|
|
() =>
|
2023-06-27 03:16:59 +00:00
|
|
|
lightColors.map((color) => color.hex).includes(colors.primary)
|
2022-11-30 01:32:42 +00:00
|
|
|
? CombinedDarkTheme.colors.background
|
|
|
|
: CombinedDefaultTheme.colors.background,
|
2023-08-12 03:22:50 +00:00
|
|
|
[colors.primary]
|
|
|
|
);
|
2022-07-15 06:06:33 +00:00
|
|
|
|
2022-07-08 02:59:19 +00:00
|
|
|
return (
|
2022-07-15 06:06:33 +00:00
|
|
|
<FAB
|
2023-08-12 03:22:50 +00:00
|
|
|
icon="add"
|
|
|
|
testID="add"
|
2022-09-25 04:32:49 +00:00
|
|
|
color={fabColor}
|
2022-07-15 06:06:33 +00:00
|
|
|
style={{
|
2023-08-12 03:22:50 +00:00
|
|
|
position: "absolute",
|
2022-11-15 06:51:15 +00:00
|
|
|
right: 20,
|
|
|
|
bottom: 20,
|
2022-11-26 00:15:12 +00:00
|
|
|
backgroundColor: colors.primary,
|
2022-07-15 06:06:33 +00:00
|
|
|
}}
|
2022-09-26 01:38:25 +00:00
|
|
|
{...props}
|
2022-07-08 02:59:19 +00:00
|
|
|
/>
|
2023-08-12 03:22:50 +00:00
|
|
|
);
|
2022-07-08 02:59:19 +00:00
|
|
|
}
|