Files
notesnook/apps/mobile/index.mobile.js

89 lines
2.5 KiB
JavaScript
Raw Normal View History

2020-05-06 01:55:05 +05:00
import React, {createRef, useEffect} from 'react';
import {Platform, StatusBar, View} from 'react-native';
2020-03-15 11:03:35 +05:00
import * as Animatable from 'react-native-animatable';
2020-05-06 01:55:05 +05:00
import Animated from 'react-native-reanimated';
import {Menu} from './src/components/Menu';
2020-03-15 10:20:34 +05:00
import SideMenu from './src/components/SideMenu';
2020-05-06 01:55:05 +05:00
import {useTracked} from './src/provider';
import {EditorOpacity, EditorPosition} from './src/utils/animations';
import {sideMenuRef} from './src/utils/refs';
import {DDS, w} from './src/utils/utils';
2020-03-15 10:20:34 +05:00
import Editor from './src/views/Editor';
2020-05-06 01:55:05 +05:00
import {NavigationStack} from './src/services/Navigator';
2020-03-15 10:20:34 +05:00
2020-03-15 11:03:35 +05:00
const editorRef = createRef();
2020-03-15 10:20:34 +05:00
export const Initialize = () => {
const [state, dispatch] = useTracked();
2020-05-06 01:55:05 +05:00
const {colors} = state;
2020-03-15 10:20:34 +05:00
useEffect(() => {
if (Platform.OS === 'android') {
StatusBar.setBackgroundColor('transparent');
StatusBar.setTranslucent(true);
StatusBar.setBarStyle(colors.night ? 'light-content' : 'dark-content');
}
}, []);
return (
2020-03-15 11:03:35 +05:00
<Animatable.View
transition="backgroundColor"
duration={300}
style={{
width: '100%',
height: '100%',
flexDirection: 'row',
backgroundColor: colors.bg,
}}>
2020-03-15 10:20:34 +05:00
<SideMenu
ref={sideMenuRef}
bounceBackOnOverdraw={false}
contentContainerStyle={{
opacity: 0,
backgroundColor: colors.bg,
}}
menu={
<Menu
hide={false}
colors={colors}
close={() =>
sideMenuRef.current?.openMenu(!sideMenuRef.current?.isOpen)
}
/>
}
openMenuOffset={w / 1.5}>
2020-05-06 01:55:05 +05:00
<View
2020-03-15 10:20:34 +05:00
style={{
width: DDS.isTab ? '70%' : '100%',
height: '100%',
backgroundColor: colors.bg,
2020-05-06 01:55:05 +05:00
}}>
<NavigationStack />
</View>
2020-03-15 10:20:34 +05:00
</SideMenu>
2020-03-15 10:49:11 +05:00
2020-03-15 10:20:34 +05:00
<Animated.View
2020-03-15 11:03:35 +05:00
ref={editorRef}
2020-03-15 10:20:34 +05:00
onResponderTerminationRequest={true}
onStartShouldSetResponderCapture={false}
onStartShouldSetResponder={false}
onMoveShouldSetResponder={false}
onMoveShouldSetResponderCapture={false}
style={{
width: '100%',
height: '100%',
alignSelf: 'flex-end',
position: 'absolute',
backgroundColor: colors.bg,
elevation: 10,
2020-05-06 01:55:05 +05:00
opacity: EditorOpacity,
2020-03-15 10:20:34 +05:00
transform: [
{
translateX: EditorPosition,
},
],
}}>
<Editor noMenu={false} />
</Animated.View>
2020-03-15 11:03:35 +05:00
</Animatable.View>
2020-03-15 10:20:34 +05:00
);
};