2019-12-04 11:29:40 +05:00
|
|
|
import React, {useState, useEffect} from 'react';
|
2019-11-17 16:02:19 +05:00
|
|
|
import NavigationService, {
|
|
|
|
|
AppContainer,
|
|
|
|
|
} from './src/services/NavigationService';
|
2019-11-23 06:25:22 +05:00
|
|
|
import {
|
|
|
|
|
StatusBar,
|
|
|
|
|
View,
|
|
|
|
|
SafeAreaView,
|
|
|
|
|
TouchableOpacity,
|
|
|
|
|
DeviceEventEmitter,
|
|
|
|
|
Platform,
|
2019-12-04 11:29:40 +05:00
|
|
|
Text,
|
2019-11-23 06:25:22 +05:00
|
|
|
} from 'react-native';
|
2019-12-04 11:29:40 +05:00
|
|
|
import {COLOR_SCHEME, SIZE, opacity, WEIGHT, pv, ph} from './src/common/common';
|
2019-11-17 17:48:56 +05:00
|
|
|
import Icon from 'react-native-vector-icons/Ionicons';
|
|
|
|
|
import ActionButton from 'react-native-action-button';
|
2019-11-28 21:40:37 +05:00
|
|
|
import Storage from 'notes-core/api/database';
|
2019-11-27 21:44:52 +05:00
|
|
|
import StorageInterface from './src/utils/storage';
|
2019-11-29 11:31:43 +05:00
|
|
|
import * as Animatable from 'react-native-animatable';
|
2019-12-04 19:38:19 +05:00
|
|
|
import {h, w} from './src/utils/utils';
|
2019-12-04 11:29:40 +05:00
|
|
|
import {Toast} from './src/components/Toast';
|
2019-12-04 11:40:59 +05:00
|
|
|
import {Menu} from './src/components/Menu';
|
2019-12-04 19:38:19 +05:00
|
|
|
import SideMenu from 'react-native-side-menu';
|
2019-11-15 01:17:59 +05:00
|
|
|
const App = () => {
|
2019-11-17 17:48:56 +05:00
|
|
|
const [colors, setColors] = useState(COLOR_SCHEME);
|
2019-11-23 06:25:22 +05:00
|
|
|
const [fab, setFab] = useState(true);
|
2019-11-29 11:31:43 +05:00
|
|
|
const [sidebar, setSidebar] = useState('30%');
|
2019-12-04 19:38:19 +05:00
|
|
|
const [isOpen, setOpen] = useState(false);
|
|
|
|
|
const [disableGestures, setDisableGesture] = useState(false);
|
2019-11-17 16:02:19 +05:00
|
|
|
useEffect(() => {
|
2019-12-04 11:29:40 +05:00
|
|
|
if (Platform.OS === 'android') {
|
|
|
|
|
StatusBar.setBackgroundColor('transparent');
|
|
|
|
|
StatusBar.setTranslucent(true);
|
|
|
|
|
StatusBar.setBarStyle('dark-content');
|
|
|
|
|
}
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
2019-11-29 11:31:43 +05:00
|
|
|
DeviceEventEmitter.addListener('openSidebar', () => {
|
|
|
|
|
setSidebar('30%');
|
|
|
|
|
});
|
|
|
|
|
DeviceEventEmitter.addListener('closeSidebar', () => {
|
|
|
|
|
setSidebar('0%');
|
|
|
|
|
});
|
2019-12-04 19:38:19 +05:00
|
|
|
DeviceEventEmitter.addListener('disableGesture', () => {
|
|
|
|
|
setDisableGesture(true);
|
|
|
|
|
});
|
|
|
|
|
DeviceEventEmitter.addListener('enableGesture', () => {
|
|
|
|
|
setDisableGesture(false);
|
|
|
|
|
});
|
2019-11-29 11:31:43 +05:00
|
|
|
|
2019-11-23 06:25:22 +05:00
|
|
|
return () => {
|
2019-11-29 11:31:43 +05:00
|
|
|
DeviceEventEmitter.removeListener('openSidebar', () => {
|
|
|
|
|
setSidebar('30%');
|
|
|
|
|
});
|
|
|
|
|
DeviceEventEmitter.removeListener('closeSidebar', () => {
|
|
|
|
|
setSidebar('0%');
|
|
|
|
|
});
|
2019-12-04 19:38:19 +05:00
|
|
|
DeviceEventEmitter.removeListener('disableGesture', () => {
|
|
|
|
|
setDisableGesture(true);
|
|
|
|
|
});
|
|
|
|
|
DeviceEventEmitter.removeListener('enableGesture', () => {
|
|
|
|
|
setDisableGesture(false);
|
|
|
|
|
});
|
2019-11-23 06:25:22 +05:00
|
|
|
};
|
2019-11-29 11:31:43 +05:00
|
|
|
}, []);
|
|
|
|
|
|
2019-12-04 11:29:40 +05:00
|
|
|
useEffect(() => {
|
|
|
|
|
DeviceEventEmitter.addListener('hide', () => {
|
|
|
|
|
setFab(false);
|
|
|
|
|
});
|
|
|
|
|
DeviceEventEmitter.addListener('show', () => {
|
|
|
|
|
setFab(true);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
DeviceEventEmitter.removeListener('hide', () => {
|
|
|
|
|
setFab(false);
|
|
|
|
|
});
|
|
|
|
|
DeviceEventEmitter.removeListener('show', () => {
|
|
|
|
|
setFab(true);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
}, []);
|
|
|
|
|
|
2019-11-17 16:02:19 +05:00
|
|
|
return (
|
2019-11-29 11:31:43 +05:00
|
|
|
<View
|
|
|
|
|
style={{
|
|
|
|
|
width: '100%',
|
|
|
|
|
height: '100%',
|
|
|
|
|
flexDirection: 'row',
|
|
|
|
|
}}>
|
2019-11-30 19:56:40 +05:00
|
|
|
{Platform.isPad ? (
|
2019-12-04 19:38:19 +05:00
|
|
|
<>
|
|
|
|
|
<Animatable.View
|
|
|
|
|
transition="width"
|
|
|
|
|
duration={200}
|
|
|
|
|
style={{
|
|
|
|
|
width: sidebar,
|
|
|
|
|
}}>
|
|
|
|
|
<Menu
|
|
|
|
|
colors={colors}
|
|
|
|
|
close={() => {
|
|
|
|
|
setSidebar('0%');
|
|
|
|
|
}}
|
|
|
|
|
/>{' '}
|
|
|
|
|
: undefined
|
|
|
|
|
</Animatable.View>
|
|
|
|
|
<AppContainer
|
|
|
|
|
style={{
|
|
|
|
|
width: Platform.isPad ? '70%' : '100%',
|
|
|
|
|
height: '100%',
|
|
|
|
|
}}
|
|
|
|
|
ref={navigatorRef => {
|
|
|
|
|
NavigationService.setTopLevelNavigator(navigatorRef);
|
2019-11-30 19:56:40 +05:00
|
|
|
}}
|
2019-12-04 19:38:19 +05:00
|
|
|
/>
|
|
|
|
|
</>
|
2019-11-30 19:56:40 +05:00
|
|
|
) : (
|
2019-12-04 19:38:19 +05:00
|
|
|
<SideMenu
|
|
|
|
|
isOpen={isOpen}
|
|
|
|
|
disableGestures={disableGestures}
|
|
|
|
|
bounceBackOnOverdraw={false}
|
|
|
|
|
onChange={args => {
|
|
|
|
|
setOpen(args);
|
|
|
|
|
}}
|
|
|
|
|
menu={<Menu colors={colors} close={() => setOpen(false)} />}
|
|
|
|
|
openMenuOffset={w / 1.5}>
|
|
|
|
|
<AppContainer
|
|
|
|
|
style={{
|
|
|
|
|
width: Platform.isPad ? '70%' : '100%',
|
|
|
|
|
height: '100%',
|
|
|
|
|
}}
|
|
|
|
|
ref={navigatorRef => {
|
|
|
|
|
NavigationService.setTopLevelNavigator(navigatorRef);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</SideMenu>
|
2019-12-04 11:29:40 +05:00
|
|
|
)}
|
2019-11-30 19:56:40 +05:00
|
|
|
|
2019-12-04 11:29:40 +05:00
|
|
|
<Toast />
|
|
|
|
|
|
2019-12-04 19:38:19 +05:00
|
|
|
{/* {fab ? (
|
2019-11-23 06:25:22 +05:00
|
|
|
<ActionButton elevation={5} buttonColor={colors.accent}>
|
|
|
|
|
<ActionButton.Item
|
|
|
|
|
buttonColor="#9b59b6"
|
|
|
|
|
textStyle={{
|
|
|
|
|
fontFamily: WEIGHT.regular,
|
2019-11-17 17:48:56 +05:00
|
|
|
color: 'white',
|
|
|
|
|
}}
|
2019-11-23 06:25:22 +05:00
|
|
|
title=""
|
|
|
|
|
hideShadow={true}
|
2019-11-29 11:31:43 +05:00
|
|
|
onPress={() => {
|
|
|
|
|
NavigationService.navigate('Editor');
|
|
|
|
|
}}>
|
2019-11-23 06:25:22 +05:00
|
|
|
<Icon
|
|
|
|
|
name="md-create"
|
|
|
|
|
style={{
|
|
|
|
|
fontSize: 20,
|
|
|
|
|
height: 22,
|
|
|
|
|
color: 'white',
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</ActionButton.Item>
|
|
|
|
|
<ActionButton.Item
|
|
|
|
|
textStyle={{
|
|
|
|
|
fontFamily: WEIGHT.regular,
|
2019-11-17 17:48:56 +05:00
|
|
|
color: 'white',
|
|
|
|
|
}}
|
2019-11-23 06:25:22 +05:00
|
|
|
hideShadow={true}
|
|
|
|
|
buttonColor="#3498db"
|
|
|
|
|
title=""
|
|
|
|
|
onPress={() => {
|
|
|
|
|
NavigationService.navigate('ListsEditor');
|
|
|
|
|
}}>
|
|
|
|
|
<Icon
|
|
|
|
|
name="ios-list"
|
|
|
|
|
style={{
|
|
|
|
|
fontSize: 20,
|
|
|
|
|
height: 22,
|
|
|
|
|
color: 'white',
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</ActionButton.Item>
|
|
|
|
|
</ActionButton>
|
|
|
|
|
) : (
|
2019-12-04 11:29:40 +05:00
|
|
|
undefined
|
2019-12-04 19:38:19 +05:00
|
|
|
)} */}
|
2019-11-29 11:31:43 +05:00
|
|
|
</View>
|
2019-11-15 01:17:59 +05:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default App;
|
2019-11-27 21:44:52 +05:00
|
|
|
|
|
|
|
|
export const storage = new Storage(StorageInterface);
|