|
@@ -270,12 +270,29 @@ const Menu: RefForwardingComponent<IMenuRef, IMenuProps> = ({
|
|
|
] = useState<null | number>(null);
|
|
] = useState<null | number>(null);
|
|
|
|
|
|
|
|
const [
|
|
const [
|
|
|
- isPActive,
|
|
|
|
|
- setIsPActive
|
|
|
|
|
- ] = useState(isPageActive(buttonItem));
|
|
|
|
|
|
|
+ ,
|
|
|
|
|
+ setNavStateTracker
|
|
|
|
|
+ ] = useState(Date.now());
|
|
|
|
|
|
|
|
const animatedCollabs = useRef(new Animated.Value(0)).current;
|
|
const animatedCollabs = useRef(new Animated.Value(0)).current;
|
|
|
|
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ if (!navigation || typeof navigation.addListener !== "function") return;
|
|
|
|
|
+
|
|
|
|
|
+ const unsubscribeState = navigation.addListener("state", () => {
|
|
|
|
|
+ setNavStateTracker(Date.now());
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ const unsubscribeFocus = navigation.addListener("focus", () => {
|
|
|
|
|
+ setNavStateTracker(Date.now());
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ return () => {
|
|
|
|
|
+ if (unsubscribeState) unsubscribeState();
|
|
|
|
|
+ if (unsubscribeFocus) unsubscribeFocus();
|
|
|
|
|
+ };
|
|
|
|
|
+ }, [navigation]);
|
|
|
|
|
+
|
|
|
if(buttonItem.isCollabsable) {
|
|
if(buttonItem.isCollabsable) {
|
|
|
useLayoutEffect(() => {
|
|
useLayoutEffect(() => {
|
|
|
if(measure === null) return;
|
|
if(measure === null) return;
|
|
@@ -298,6 +315,8 @@ const Menu: RefForwardingComponent<IMenuRef, IMenuProps> = ({
|
|
|
}, [isCollabs]);
|
|
}, [isCollabs]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ const isPActive = isPageActive(buttonItem);
|
|
|
|
|
+
|
|
|
return <View
|
|
return <View
|
|
|
key={`menu-button-${id}-${buttonIndex}`}
|
|
key={`menu-button-${id}-${buttonIndex}`}
|
|
|
>
|
|
>
|
|
@@ -330,6 +349,7 @@ const Menu: RefForwardingComponent<IMenuRef, IMenuProps> = ({
|
|
|
}
|
|
}
|
|
|
backgroundColor={isPActive ? "primary" : undefined}
|
|
backgroundColor={isPActive ? "primary" : undefined}
|
|
|
titleColor={isPActive ? "onPrimary" : undefined}
|
|
titleColor={isPActive ? "onPrimary" : undefined}
|
|
|
|
|
+ iconColor={isPActive ? "onPrimary" : undefined}
|
|
|
title={buttonItem.title}
|
|
title={buttonItem.title}
|
|
|
icon={buttonItem.icon}
|
|
icon={buttonItem.icon}
|
|
|
onPress={() => {
|
|
onPress={() => {
|
|
@@ -349,9 +369,7 @@ const Menu: RefForwardingComponent<IMenuRef, IMenuProps> = ({
|
|
|
if(buttonItem.props?.onPress) buttonItem.props.onPress();
|
|
if(buttonItem.props?.onPress) buttonItem.props.onPress();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- setIsPActive(isPageActive(buttonItem));
|
|
|
|
|
-
|
|
|
|
|
- // if(closeAction && !buttonItem.isCollabsable) closeAction();
|
|
|
|
|
|
|
+ if(closeAction && !buttonItem.isCollabsable) closeAction();
|
|
|
}}
|
|
}}
|
|
|
/>
|
|
/>
|
|
|
{
|
|
{
|