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

104 lines
2.8 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 01:55:05 +05:00
import Animated from 'react-native-reanimated';
2020-09-21 13:00:50 +05:00
import {Screen, ScreenContainer} from 'react-native-screens';
import {DialogManager} from './src/components/DialogManager';
import {Toast} from './src/components/Toast';
2020-05-06 01:55:05 +05:00
import {useTracked} from './src/provider';
2020-05-06 15:06:00 +05:00
import {NavigationStack} from './src/services/Navigator';
2020-05-14 14:49:09 +05:00
import {
EditorOpacity,
EditorPosition,
EditorScale,
2020-05-21 18:18:32 +05:00
EditorTranslateY,
2020-05-14 14:49:09 +05:00
} from './src/utils/animations';
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-09-15 11:24:15 +05:00
2020-09-21 13:00:50 +05:00
const AnimatedScreenContainer = Animated.createAnimatedComponent(
ScreenContainer,
);
2020-09-15 11:24:15 +05:00
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-05-14 14:49:09 +05:00
const [locked, setLocked] = useState(false);
2020-03-15 10:20:34 +05:00
useEffect(() => {
if (Platform.OS === 'android') {
StatusBar.setBackgroundColor('transparent');
StatusBar.setTranslucent(true);
}
2020-09-12 14:32:06 +05:00
StatusBar.setBarStyle(colors.night ? 'light-content' : 'dark-content');
2020-03-15 10:20:34 +05:00
}, []);
2020-05-06 15:06:00 +05:00
2020-03-15 10:20:34 +05:00
return (
2020-05-14 14:49:09 +05:00
<>
<Animatable.View
2020-09-28 09:50:12 +05:00
testID={"mobile_main_view"}
2020-05-14 14:49:09 +05:00
transition="backgroundColor"
duration={300}
2020-05-06 15:06:00 +05:00
style={{
2020-05-14 14:49:09 +05:00
width: '100%',
height: '100%',
flexDirection: 'row',
2020-03-15 10:20:34 +05:00
backgroundColor: colors.bg,
2020-05-14 14:49:09 +05:00
}}>
2020-09-21 13:00:50 +05:00
<View
2020-05-14 14:49:09 +05:00
style={{
2020-09-21 13:00:50 +05:00
width: DDS.isTab ? '70%' : '100%',
height: '100%',
2020-05-14 14:49:09 +05:00
backgroundColor: colors.bg,
2020-09-21 13:00:50 +05:00
}}>
<NavigationStack />
</View>
2020-05-14 14:49:09 +05:00
2020-09-15 11:24:15 +05:00
<AnimatedScreenContainer
2020-05-14 14:49:09 +05:00
ref={editorRef}
onResponderTerminationRequest={true}
onStartShouldSetResponderCapture={false}
onStartShouldSetResponder={false}
onMoveShouldSetResponder={false}
onMoveShouldSetResponderCapture={false}
2020-03-15 10:20:34 +05:00
style={{
2020-05-14 14:49:09 +05:00
width: '100%',
2020-03-15 10:20:34 +05:00
height: '100%',
2020-05-14 14:49:09 +05:00
alignSelf: 'flex-end',
position: 'absolute',
2020-03-15 10:20:34 +05:00
backgroundColor: colors.bg,
2020-05-14 14:49:09 +05:00
elevation: 10,
opacity: EditorOpacity,
transform: [
{
translateX: EditorPosition,
},
2020-05-21 18:18:32 +05:00
{
2020-09-21 13:00:50 +05:00
translateY: EditorTranslateY,
2020-05-21 18:18:32 +05:00
},
2020-05-14 14:49:09 +05:00
{
scaleX: EditorScale,
},
{
scaleY: EditorScale,
},
],
2020-05-06 01:55:05 +05:00
}}>
2020-09-21 13:00:50 +05:00
<Screen
2020-09-15 11:24:15 +05:00
active={1}
2020-09-21 13:00:50 +05:00
style={{
width: '100%',
height: '100%',
}}>
<Editor noMenu={false} />
2020-09-15 11:24:15 +05:00
</Screen>
</AnimatedScreenContainer>
2020-05-14 14:49:09 +05:00
</Animatable.View>
<Toast />
<DialogManager colors={colors} />
</>
2020-03-15 10:20:34 +05:00
);
};