|
|
@@ -5,13 +5,17 @@ import {animated,easings} from "@react-spring/web";
|
|
|
import {useState,useEffect} from "react";
|
|
|
import {useSpring, useSpringRef} from "@react-spring/core";
|
|
|
import {sleep} from "@utils/helpers";
|
|
|
+import {useThemeProvider} from "@contexts/themeContext";
|
|
|
+import CSSTransition from "react-transition-group/CSSTransition";
|
|
|
const i18n=global.i18n;
|
|
|
|
|
|
-const SubScreen=({open,onClose,children,route,timeout,header})=>{
|
|
|
+const SubScreen=({open,onClose,children,route,timeout=500,level=0,header,...props})=>{
|
|
|
// const [subOpen,setSubOpen]=useState(open);
|
|
|
// console.log(header)
|
|
|
const subOpen=open;
|
|
|
const duration=timeout;
|
|
|
+ const {setIsOpenSub}=useThemeProvider();
|
|
|
+ if (level===0)setIsOpenSub(subOpen);
|
|
|
// const duration=50;
|
|
|
|
|
|
const delayClose=()=>{
|
|
|
@@ -25,15 +29,15 @@ const SubScreen=({open,onClose,children,route,timeout,header})=>{
|
|
|
// };
|
|
|
// },[])
|
|
|
|
|
|
- const showAni=useSpring({
|
|
|
- // ref: spref,
|
|
|
- from: {transform: 'translateX(100%) translateZ(0px)'},
|
|
|
- transform:subOpen?'translateX(0%) translateZ(0px)':'translateX(100%) translateZ(0px)',
|
|
|
- config: {
|
|
|
- easing: easings.linear,
|
|
|
- duration:duration
|
|
|
- },
|
|
|
- });
|
|
|
+ // const showAni=useSpring({
|
|
|
+ // // ref: spref,
|
|
|
+ // from: {transform: 'translateX(100%) translateZ(0px)',transition:`transform ${timeout}ms cubic-bezier(0, 0, 0.2, 1) 0ms`},
|
|
|
+ // transform:subOpen?'translateX(0%) translateZ(0px)':'translateX(100%) translateZ(0px)',
|
|
|
+ // config: {
|
|
|
+ // // easing: easings.linear,
|
|
|
+ // duration:duration
|
|
|
+ // },
|
|
|
+ // });
|
|
|
const renderHeader=()=>{
|
|
|
let title=route?route.title:"";
|
|
|
return (
|
|
|
@@ -63,27 +67,32 @@ const SubScreen=({open,onClose,children,route,timeout,header})=>{
|
|
|
)
|
|
|
}
|
|
|
const renderContent=()=>{
|
|
|
- // addExtraChildProps(children);
|
|
|
- // let list=children.length==null?[children]:children;
|
|
|
- // // {children}
|
|
|
return (
|
|
|
<div className={styles.content}>
|
|
|
{children}
|
|
|
- {/*{renderComp?renderComp({close}):(<></>)}*/}
|
|
|
</div>
|
|
|
)
|
|
|
}
|
|
|
return (
|
|
|
- <animated.div className={styles.subscreen} style={showAni}>
|
|
|
- {renderBar()}
|
|
|
- {renderContent()}
|
|
|
- </animated.div>
|
|
|
+ <CSSTransition timeout={timeout} {...props} classNames={{
|
|
|
+ enter: styles.subscreen_enter,
|
|
|
+ enterActive: styles.subscreen_enter_active,
|
|
|
+ exit: styles.subscreen_exit,
|
|
|
+ exitActive: styles.subscreen_exit_active,
|
|
|
+ }}>
|
|
|
+ {/*<animated.div className={styles.subscreen} style={showAni}>*/}
|
|
|
+ {/*<animated.div className={styles.subscreen}>*/}
|
|
|
+ <div className={styles.subscreen}>
|
|
|
+ {renderBar()}
|
|
|
+ {renderContent()}
|
|
|
+ </div>
|
|
|
+ {/*</animated.div>*/}
|
|
|
+ </CSSTransition>
|
|
|
)
|
|
|
}
|
|
|
SubScreen.propTypes = {
|
|
|
open: PropTypes.bool.isRequired,
|
|
|
onClose: PropTypes.func.isRequired,
|
|
|
- // children: PropTypes.node.isRequired
|
|
|
}
|
|
|
|
|
|
export default SubScreen
|