|
|
@@ -25,8 +25,8 @@ import stylesheet, {
|
|
|
} from "./stylesheet";
|
|
|
import MenuButton from "./components/menuButton";
|
|
|
import {
|
|
|
- NCoreUIKitMenu,
|
|
|
- NCoreUIKitTheme
|
|
|
+ NCoreUIKitTheme,
|
|
|
+ NCoreUIKitMenu
|
|
|
} from "../../core/hooks";
|
|
|
import type {
|
|
|
RefForwardingComponent
|
|
|
@@ -37,9 +37,9 @@ import {
|
|
|
import {
|
|
|
Portal
|
|
|
} from "../../helpers/portalize";
|
|
|
-import Modal from "../modal";
|
|
|
import Seperator from "../seperator";
|
|
|
import SiteLogo from "../siteLogo";
|
|
|
+import Modal from "../modal";
|
|
|
|
|
|
const Menu: RefForwardingComponent<IMenuRef, IMenuProps> = ({
|
|
|
isWorkWithSafeAreaView = true,
|
|
|
@@ -115,7 +115,27 @@ const Menu: RefForwardingComponent<IMenuRef, IMenuProps> = ({
|
|
|
}, [measures]);
|
|
|
|
|
|
useEffect(() => {
|
|
|
- if(isCollapse !== undefined) setIsActive(isCollapse);
|
|
|
+ if(isCollapse !== undefined) {
|
|
|
+ if(isCollapse) {
|
|
|
+ setIsActive(isCollapse);
|
|
|
+ } else {
|
|
|
+ if(onClose) onClose({
|
|
|
+ id
|
|
|
+ });
|
|
|
+
|
|
|
+ if(isWorkWithAnimation) {
|
|
|
+ closeAnimation(() => setIsActive(isCollapse));
|
|
|
+ } else {
|
|
|
+ animatedX.setValue(measures! * -1);
|
|
|
+
|
|
|
+ setIsActive(isCollapse);
|
|
|
+
|
|
|
+ if(onClosed) onClosed({
|
|
|
+ id
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}, [isCollapse]);
|
|
|
|
|
|
useLayoutEffect(() => {
|
|
|
@@ -133,23 +153,6 @@ const Menu: RefForwardingComponent<IMenuRef, IMenuProps> = ({
|
|
|
id
|
|
|
});
|
|
|
}
|
|
|
- } else {
|
|
|
- if(onClose) onClose({
|
|
|
- id
|
|
|
- });
|
|
|
-
|
|
|
- if(!isWorkWithModal) {
|
|
|
-
|
|
|
- if(isWorkWithAnimation) {
|
|
|
- closeAnimation();
|
|
|
- } else {
|
|
|
- animatedX.setValue(measures! * -1);
|
|
|
-
|
|
|
- if(onClosed) onClosed({
|
|
|
- id
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
}, [
|
|
|
isOpacityVisible,
|
|
|
@@ -165,18 +168,16 @@ const Menu: RefForwardingComponent<IMenuRef, IMenuProps> = ({
|
|
|
id
|
|
|
});
|
|
|
|
|
|
- if(isWorkWithModal) {
|
|
|
- if(isWorkWithAnimation) {
|
|
|
- closeAnimation();
|
|
|
- } else {
|
|
|
- animatedX.setValue(measures! * -1);
|
|
|
-
|
|
|
- if(onClosed) onClosed({
|
|
|
- id
|
|
|
- });
|
|
|
- }
|
|
|
+ if(isWorkWithAnimation) {
|
|
|
+ closeAnimation(() => setIsActive(false));
|
|
|
} else {
|
|
|
+ animatedX.setValue(measures! * -1);
|
|
|
+
|
|
|
setIsActive(false);
|
|
|
+
|
|
|
+ if(onClosed) onClosed({
|
|
|
+ id
|
|
|
+ });
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -197,7 +198,7 @@ const Menu: RefForwardingComponent<IMenuRef, IMenuProps> = ({
|
|
|
});
|
|
|
};
|
|
|
|
|
|
- const closeAnimation = () => {
|
|
|
+ const closeAnimation = (callback?: () => void) => {
|
|
|
Animated.timing(animatedX, {
|
|
|
useNativeDriver: Platform.OS !== "web",
|
|
|
toValue: measures! * -1,
|
|
|
@@ -207,6 +208,8 @@ const Menu: RefForwardingComponent<IMenuRef, IMenuProps> = ({
|
|
|
finished
|
|
|
}) => {
|
|
|
if(finished) {
|
|
|
+ if(callback) callback();
|
|
|
+
|
|
|
if(onClosed) onClosed({
|
|
|
id
|
|
|
});
|