Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WALLET-413: Remove button animation #19

Merged
merged 3 commits into from
Aug 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 4 additions & 24 deletions app/(tabs)/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import { faBell } from "@fortawesome/free-solid-svg-icons/faBell";
import { faUser } from "@fortawesome/free-solid-svg-icons/faUser";
import { useSession } from "@/hooks/session";
import {
Animated,
Dimensions,
StyleSheet,
TouchableOpacity,
Expand Down Expand Up @@ -73,8 +72,6 @@ export default function TabLayout() {
},
});

const rotation = useRef(new Animated.Value(0)).current;

const [menuVisible, setMenuVisible] = useState(false);
const [menuPosition, setMenuPosition] = useState({ x: 0, y: 0 });
const [positionType, setPositionType] = useState<
Expand All @@ -95,16 +92,9 @@ export default function TabLayout() {
const rightHeaderAddButtonRef = useRef(null);
const toggleMenu = (
type: "topMiddle" | "bottomLeft" | "bottomMiddle" = "topMiddle",
buttonRef: MutableRefObject<null> = rightHeaderAddButtonRef,
animated = false
buttonRef: MutableRefObject<null> = rightHeaderAddButtonRef
) => {
if (buttonRef && buttonRef.current) {
if (animated)
Animated.timing(rotation, {
toValue: menuVisible ? 0 : 1,
duration: 300,
useNativeDriver: true,
}).start(() => {});
(
buttonRef.current as unknown as {
measure: (
Expand Down Expand Up @@ -134,14 +124,6 @@ export default function TabLayout() {
);
}
};
const rotateInterpolate = rotation.interpolate({
inputRange: [0, 1],
outputRange: ["0deg", "45deg"],
});

const animatedStyle = {
transform: [{ rotate: rotateInterpolate }],
};

if (!session) {
return <Redirect href="/login" />;
Expand Down Expand Up @@ -198,12 +180,10 @@ export default function TabLayout() {
<TouchableOpacity
ref={rightHeaderAddButtonRef}
onPress={() =>
toggleMenu("bottomLeft", rightHeaderAddButtonRef, true)
toggleMenu("bottomLeft", rightHeaderAddButtonRef)
}
>
<Animated.View style={animatedStyle}>
<FontAwesome6 size={32} name="circle-plus" />
</Animated.View>
<FontAwesome6 size={32} name="circle-plus" />
</TouchableOpacity>
),
headerRightContainerStyle: { paddingRight: 16 },
Expand Down Expand Up @@ -270,7 +250,7 @@ export default function TabLayout() {
</Tabs>
<PopupMenu
visible={menuVisible}
onClose={() => toggleMenu("topMiddle", rightHeaderAddButtonRef, true)}
onClose={() => toggleMenu("topMiddle", rightHeaderAddButtonRef)}
position={menuPosition}
positionType={positionType}
/>
Expand Down