fix: crash due to missing import

This commit is contained in:
ammarahm-ed
2020-01-14 15:48:14 +05:00
parent e9dee651f9
commit b31f7f47d0
8 changed files with 433 additions and 472 deletions

View File

@@ -27,6 +27,7 @@ import ActionSheet from '../../components/ActionSheet';
import {ActionSheetComponent} from '../../components/ActionSheetComponent';
import {VaultDialog} from '../../components/VaultDialog';
import NavigationService from '../../services/NavigationService';
import {useIsFocused} from 'react-navigation-hooks';
const w = Dimensions.get('window').width;
const h = Dimensions.get('window').height;
@@ -39,10 +40,6 @@ let timer = null;
let note = {};
const Editor = ({navigation}) => {
if (!isFocused) {
console.log('block rerender');
return <></>;
} else {
// Global State
const {colors} = useAppContext();
@@ -68,6 +65,7 @@ const Editor = ({navigation}) => {
let customNote = null;
let actionSheet;
let show;
const isFocused = useIsFocused();
// FUNCTIONS
const post = value => EditorWebView.postMessage(value);
@@ -324,6 +322,10 @@ const Editor = ({navigation}) => {
EditorWebView.reload();
}, [colors]);
if (!isFocused) {
console.log('block rerender');
return <></>;
} else {
return DDS.isTab ? (
<View
style={{

View File

@@ -9,6 +9,7 @@ import NoteItem from '../../components/NoteItem';
import {NotebookItem} from '../../components/NotebookItem';
import {FavoritesPlaceHolder} from '../../components/ListPlaceholders';
import Container from '../../components/Container';
import {useIsFocused} from 'react-navigation-hooks';
export const Favorites = ({navigation}) => {
// Global State
@@ -29,10 +30,6 @@ export const Favorites = ({navigation}) => {
// Variables
let isFocused = useIsFocused();
if (!isFocused) {
console.log('block rerender');
return <></>;
} else {
let offsetY = 0;
let countUp = 1;
let countDown = 0;
@@ -58,7 +55,10 @@ export const Favorites = ({navigation}) => {
offsetY = y;
};
// Render
if (!isFocused) {
console.log('block rerender');
return <></>;
} else {
return (
<Container noBottomButton={true}>
<Animatable.View

View File

@@ -13,6 +13,7 @@ import Container from '../../components/Container';
import SelectionHeader from '../../components/SelectionHeader';
import SelectionWrapper from '../../components/SelectionWrapper';
import {w} from '../../utils/utils';
import {useIsFocused} from 'react-navigation-hooks';
export const Folders = ({navigation}) => {
const {
@@ -29,10 +30,6 @@ export const Folders = ({navigation}) => {
let isFocused = useIsFocused();
if (!isFocused) {
console.log('block rerender');
return <></>;
} else {
const params = navigation.state.params;
let offsetY = 0;
let countUp = 0;
@@ -55,7 +52,11 @@ export const Folders = ({navigation}) => {
}
offsetY = y;
};
console.log('rerendering folders');
if (!isFocused) {
console.log('block rerender');
return <></>;
} else {
return (
<Container
bottomButtonText="Add a new notebook"

View File

@@ -26,10 +26,6 @@ export const Home = ({navigation}) => {
// Variables
let isFocused = useIsFocused();
if (!isFocused) {
console.log('block rerender');
return <></>;
} else {
let offsetY = 0;
let countUp = 1;
let countDown = 0;
@@ -56,13 +52,7 @@ export const Home = ({navigation}) => {
if (searchResult && searchResult.length > 0) {
setSearchResults([...searchResult]);
} else {
ToastEvent.show(
'No search results found',
'error',
3000,
() => {},
'',
);
ToastEvent.show('No search results found', 'error', 3000, () => {}, '');
}
}
};
@@ -99,6 +89,10 @@ export const Home = ({navigation}) => {
offsetY = y;
};
if (!isFocused) {
console.log('block rerender');
return <></>;
} else {
// Render
console.log('rerendering home');
return (

View File

@@ -19,10 +19,6 @@ export const Notebook = ({navigation}) => {
let isFocused = useIsFocused();
if (!isFocused) {
console.log('block rerender');
return <></>;
} else {
// State
// Variables
@@ -34,6 +30,10 @@ export const Notebook = ({navigation}) => {
// Functions
if (!isFocused) {
console.log('block rerender');
return <></>;
} else {
// Render
return (
<Container

View File

@@ -1,30 +1,12 @@
import React, {useEffect, useState} from 'react';
import {
Text,
TouchableOpacity,
Dimensions,
KeyboardAvoidingView,
} from 'react-native';
import {
SIZE,
ph,
pv,
opacity,
WEIGHT,
onThemeUpdate,
clearThemeUpdateListener,
} from '../../common/common';
import Icon from 'react-native-vector-icons/Feather';
import {Header} from '../../components/header';
import {Search} from '../../components/SearchInput';
import {useForceUpdate} from '../ListsEditor';
import {NotesList} from '../../components/NotesList';
import {AnimatedSafeAreaView} from '../Home';
import {db} from '../../../App';
import * as Animatable from 'react-native-animatable';
import {useAppContext} from '../../provider/useAppContext';
import {w} from '../../utils/utils';
import Container from '../../components/Container';
import {useIsFocused} from 'react-navigation-hooks';
export const Notes = ({navigation}) => {
const {colors} = useAppContext();
@@ -32,14 +14,9 @@ export const Notes = ({navigation}) => {
const [margin, setMargin] = useState(200);
const [buttonHide, setButtonHide] = useState(false);
const [notes, setNotes] = useState([]);
const forceUpdate = useForceUpdate();
let isFocused = useIsFocused();
if (!isFocused) {
console.log('block rerender');
return <></>;
} else {
let params = navigation.state ? navigation.state.params : null;
let offsetY = 0;
let countUp = 0;
@@ -47,16 +24,6 @@ export const Notes = ({navigation}) => {
let headerHeight = 0;
let searchHeight = 0;
let marginSet = false;
useEffect(() => {
onThemeUpdate(() => {
forceUpdate();
});
return () => {
clearThemeUpdateListener(() => {
forceUpdate();
});
};
}, []);
useEffect(() => {
if (!params) {
@@ -72,7 +39,10 @@ export const Notes = ({navigation}) => {
setNotes(allNotes);
}
}, []);
if (!isFocused) {
console.log('block rerender');
return <></>;
} else {
return (
<Container
bottomButtonText="Create a new note"

View File

@@ -19,7 +19,6 @@ import Icon from 'react-native-vector-icons/Feather';
import {Header} from '../../components/header';
import {FlatList} from 'react-native-gesture-handler';
import AsyncStorage from '@react-native-community/async-storage';
import {AnimatedSafeAreaView} from '../Home';
import {useAppContext} from '../../provider/useAppContext';
import {useIsFocused} from 'react-navigation-hooks';
import Container from '../../components/Container';

View File

@@ -1,12 +1,6 @@
import React, {useEffect, useState} from 'react';
import {
Text,
TouchableOpacity,
SafeAreaView,
FlatList,
View,
} from 'react-native';
import {SIZE, ph, pv, opacity, WEIGHT} from '../../common/common';
import {Text, FlatList, View} from 'react-native';
import {SIZE, WEIGHT} from '../../common/common';
import Icon from 'react-native-vector-icons/Feather';
import {Header} from '../../components/header';
import NoteItem from '../../components/NoteItem';
@@ -18,6 +12,7 @@ import {ToastEvent, w} from '../../utils/utils';
import {TrashPlaceHolder} from '../../components/ListPlaceholders';
import Container from '../../components/Container';
import SelectionHeader from '../../components/SelectionHeader';
import {useIsFocused} from 'react-navigation-hooks';
export const Trash = ({navigation}) => {
const {