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

91 lines
2.6 KiB
JavaScript
Raw Normal View History

import React, { useEffect, createRef } from 'react';
2020-03-15 10:20:34 +05:00
import Animated from 'react-native-reanimated';
import { Menu } from './src/components/Menu';
2020-03-15 11:03:35 +05:00
import * as Animatable from 'react-native-animatable';
2020-03-15 10:20:34 +05:00
import SideMenu from './src/components/SideMenu';
import { 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';
import { useTracked } from './src/provider';
import { StatusBar, Platform } from 'react-native';
import { AppContainer } from './src/services/AppContainer';
import NavigationService from './src/services/NavigationService';
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();
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}>
<AppContainer
style={{
width: DDS.isTab ? '70%' : '100%',
height: '100%',
backgroundColor: colors.bg,
}}
ref={navigatorRef => {
NavigationService.setTopLevelNavigator(navigatorRef);
}}
/>
</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,
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
);
};