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

89 lines
2.5 KiB
JavaScript
Raw Normal View History

2020-05-06 15:06:00 +05:00
import React, {createRef, useEffect, useState} from 'react';
2020-05-06 01:55:05 +05:00
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 15:06:00 +05:00
import DrawerLayout from 'react-native-drawer-layout';
2020-05-06 01:55:05 +05:00
import Animated from 'react-native-reanimated';
import {Menu} from './src/components/Menu';
import {useTracked} from './src/provider';
2020-05-06 15:06:00 +05:00
import {NavigationStack} from './src/services/Navigator';
2020-05-06 01:55:05 +05:00
import {EditorOpacity, EditorPosition} from './src/utils/animations';
import {sideMenuRef} from './src/utils/refs';
2020-05-06 15:06:00 +05:00
import {DDS} from './src/utils/utils';
2020-03-15 10:20:34 +05:00
import Editor from './src/views/Editor';
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');
}
}, []);
2020-05-06 15:06:00 +05:00
2020-03-15 10:20:34 +05:00
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-05-06 15:06:00 +05:00
<DrawerLayout
2020-03-15 10:20:34 +05:00
ref={sideMenuRef}
2020-05-06 15:06:00 +05:00
style={{
2020-03-15 10:20:34 +05:00
opacity: 0,
backgroundColor: colors.bg,
}}
2020-05-06 15:06:00 +05:00
keyboardDismissMode="ondrag"
drawerWidth={300}
useNativeAnimations={true}
renderNavigationView={() => (
2020-03-15 10:20:34 +05:00
<Menu
hide={false}
colors={colors}
2020-05-06 15:06:00 +05:00
close={() => sideMenuRef.current?.closeDrawer()}
2020-03-15 10:20:34 +05:00
/>
2020-05-06 15:06:00 +05:00
)}>
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-05-06 15:06:00 +05:00
</DrawerLayout>
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
);
};