mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 06:59:31 +01:00
cleanup
This commit is contained in:
@@ -27,7 +27,11 @@ import {
|
|||||||
import {useTracked} from '../../provider';
|
import {useTracked} from '../../provider';
|
||||||
import {ACTIONS} from '../../provider/actions';
|
import {ACTIONS} from '../../provider/actions';
|
||||||
import {eSendEvent, openVault} from '../../services/eventManager';
|
import {eSendEvent, openVault} from '../../services/eventManager';
|
||||||
import {eOpenLoginDialog, eOpenMoveNoteDialog, refreshNotesPage} from '../../services/events';
|
import {
|
||||||
|
eOpenLoginDialog,
|
||||||
|
eOpenMoveNoteDialog,
|
||||||
|
refreshNotesPage,
|
||||||
|
} from '../../services/events';
|
||||||
import NavigationService from '../../services/NavigationService';
|
import NavigationService from '../../services/NavigationService';
|
||||||
import {MMKV} from '../../utils/storage';
|
import {MMKV} from '../../utils/storage';
|
||||||
import {
|
import {
|
||||||
@@ -214,8 +218,7 @@ export const ActionSheetComponent = ({
|
|||||||
close();
|
close();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
eSendEvent(eOpenMoveNoteDialog);
|
eSendEvent(eOpenMoveNoteDialog);
|
||||||
},400)
|
}, 400);
|
||||||
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
|
|||||||
import {ph, pv, SIZE, WEIGHT} from '../../common/common';
|
import {ph, pv, SIZE, WEIGHT} from '../../common/common';
|
||||||
import {useTracked} from '../../provider';
|
import {useTracked} from '../../provider';
|
||||||
import {ACTIONS} from '../../provider/actions';
|
import {ACTIONS} from '../../provider/actions';
|
||||||
|
import NavigationService from '../../services/NavigationService';
|
||||||
import {db, ToastEvent} from '../../utils/utils';
|
import {db, ToastEvent} from '../../utils/utils';
|
||||||
import {Button} from '../Button';
|
import {Button} from '../Button';
|
||||||
import {ActionSheetEvent, moveNoteHideEvent} from '../DialogManager/recievers';
|
import {ActionSheetEvent, moveNoteHideEvent} from '../DialogManager/recievers';
|
||||||
@@ -80,7 +81,12 @@ export const NotebookItem = ({
|
|||||||
}}>
|
}}>
|
||||||
{item && item.topics ? (
|
{item && item.topics ? (
|
||||||
item.topics.slice(1, 4).map((topic) => (
|
item.topics.slice(1, 4).map((topic) => (
|
||||||
<View
|
<TouchableOpacity
|
||||||
|
onPress={() => {
|
||||||
|
NavigationService.navigate('Notes', {
|
||||||
|
...topic,
|
||||||
|
});
|
||||||
|
}}
|
||||||
key={topic.dateCreated.toString() + topic.title}
|
key={topic.dateCreated.toString() + topic.title}
|
||||||
style={{
|
style={{
|
||||||
borderRadius: 2.5,
|
borderRadius: 2.5,
|
||||||
@@ -100,7 +106,7 @@ export const NotebookItem = ({
|
|||||||
}}>
|
}}>
|
||||||
{topic.title}
|
{topic.title}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</TouchableOpacity>
|
||||||
))
|
))
|
||||||
) : (
|
) : (
|
||||||
<Text
|
<Text
|
||||||
|
|||||||
@@ -1,20 +1,15 @@
|
|||||||
import React, {useState, useEffect} from 'react';
|
import React, {useEffect, useState} from 'react';
|
||||||
import {Platform, StatusBar, Text, TouchableOpacity, View} from 'react-native';
|
import {Text, TouchableOpacity, View} from 'react-native';
|
||||||
import * as Animatable from 'react-native-animatable';
|
import Animated, {Easing, useValue} from 'react-native-reanimated';
|
||||||
import {useSafeAreaInsets} from 'react-native-safe-area-context';
|
import {useSafeAreaInsets} from 'react-native-safe-area-context';
|
||||||
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
|
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
|
||||||
import {SIZE, WEIGHT} from '../../common/common';
|
import {SIZE, WEIGHT} from '../../common/common';
|
||||||
import {useTracked} from '../../provider';
|
import {useTracked} from '../../provider';
|
||||||
import {ACTIONS} from '../../provider/actions';
|
import {ACTIONS} from '../../provider/actions';
|
||||||
import {eSendEvent} from '../../services/eventManager';
|
import {eSendEvent} from '../../services/eventManager';
|
||||||
import {
|
import {eOpenMoveNoteDialog, eOpenSimpleDialog} from '../../services/events';
|
||||||
eOpenMoveNoteDialog,
|
|
||||||
eOpenPremiumDialog,
|
|
||||||
eOpenSimpleDialog,
|
|
||||||
} from '../../services/events';
|
|
||||||
import {db, ToastEvent} from '../../utils/utils';
|
import {db, ToastEvent} from '../../utils/utils';
|
||||||
import {TEMPLATE_DELETE} from '../DialogManager/templates';
|
import {TEMPLATE_DELETE} from '../DialogManager/templates';
|
||||||
import Animated, {useValue, Easing} from 'react-native-reanimated';
|
|
||||||
|
|
||||||
export const SelectionHeader = () => {
|
export const SelectionHeader = () => {
|
||||||
// State
|
// State
|
||||||
@@ -44,7 +39,7 @@ export const SelectionHeader = () => {
|
|||||||
style={{
|
style={{
|
||||||
width: '100%',
|
width: '100%',
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
height:50,
|
height: 50,
|
||||||
backgroundColor: colors.bg,
|
backgroundColor: colors.bg,
|
||||||
marginTop: insets.top,
|
marginTop: insets.top,
|
||||||
justifyContent: 'flex-end',
|
justifyContent: 'flex-end',
|
||||||
@@ -126,7 +121,7 @@ export const SelectionHeader = () => {
|
|||||||
<Icon color={colors.heading} name={'plus'} size={SIZE.xl} />
|
<Icon color={colors.heading} name={'plus'} size={SIZE.xl} />
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
)}
|
)}
|
||||||
{/* {currentScreen === 'trash' || currentScreen === 'notebooks' ? null : (
|
{/* {currentScreen === 'trash' || currentScreen === 'notebooks' ? null : (
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={{
|
style={{
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
|
|||||||
@@ -41,37 +41,31 @@ export const NotebookItemWrapper = ({
|
|||||||
onLongPress();
|
onLongPress();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (item.type === 'topic') {
|
dispatch({
|
||||||
NavigationService.navigate('Notes', {
|
type: ACTIONS.HEADER_TEXT_STATE,
|
||||||
...item,
|
state: {
|
||||||
});
|
heading: item.title,
|
||||||
} else {
|
},
|
||||||
dispatch({
|
});
|
||||||
type: ACTIONS.HEADER_TEXT_STATE,
|
dispatch({
|
||||||
state: {
|
type: ACTIONS.HEADER_STATE,
|
||||||
heading: item.title,
|
state: {
|
||||||
},
|
canGoBack: true,
|
||||||
});
|
menu: false,
|
||||||
dispatch({
|
},
|
||||||
type: ACTIONS.HEADER_STATE,
|
});
|
||||||
state: {
|
dispatch({
|
||||||
canGoBack: true,
|
type: ACTIONS.CONTAINER_BOTTOM_BUTTON,
|
||||||
menu: false,
|
state: {
|
||||||
},
|
bottomButtonText: 'Add new topic',
|
||||||
});
|
},
|
||||||
dispatch({
|
});
|
||||||
type: ACTIONS.CONTAINER_BOTTOM_BUTTON,
|
|
||||||
state: {
|
|
||||||
bottomButtonText: 'Add new topic',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
NavigationService.navigate('Notebook', {
|
NavigationService.navigate('Notebook', {
|
||||||
notebook: item,
|
notebook: item,
|
||||||
title: item.title,
|
title: item.title,
|
||||||
root: true,
|
root: true,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import {
|
|||||||
eOnNewTopicAdded,
|
eOnNewTopicAdded,
|
||||||
eScrollEvent,
|
eScrollEvent,
|
||||||
} from '../../services/events';
|
} from '../../services/events';
|
||||||
|
import NavigationService from '../../services/NavigationService';
|
||||||
import {db, ToastEvent, w} from '../../utils/utils';
|
import {db, ToastEvent, w} from '../../utils/utils';
|
||||||
|
|
||||||
export const Notebook = ({route, navigation}) => {
|
export const Notebook = ({route, navigation}) => {
|
||||||
@@ -45,10 +46,6 @@ export const Notebook = ({route, navigation}) => {
|
|||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleBackPress = () => {
|
|
||||||
navigation.goBack();
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isFocused) {
|
if (isFocused) {
|
||||||
onLoad();
|
onLoad();
|
||||||
@@ -110,13 +107,6 @@ export const Notebook = ({route, navigation}) => {
|
|||||||
}
|
}
|
||||||
}, [topics, isFocused]);
|
}, [topics, isFocused]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
eSubscribeEvent(eMoveNoteDialogNavigateBack, handleBackPress);
|
|
||||||
return () => {
|
|
||||||
eUnSubscribeEvent(eMoveNoteDialogNavigateBack, handleBackPress);
|
|
||||||
};
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const _onRefresh = async () => {
|
const _onRefresh = async () => {
|
||||||
setRefreshing(true);
|
setRefreshing(true);
|
||||||
try {
|
try {
|
||||||
@@ -157,31 +147,36 @@ const RenderItem = ({item, index}) => {
|
|||||||
let params = headerState.route.params ? headerState.route.params : {};
|
let params = headerState.route.params ? headerState.route.params : {};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SelectionWrapper item={item}>
|
<SelectionWrapper
|
||||||
|
onPress={() => {
|
||||||
|
NavigationService.navigate('Notes', {
|
||||||
|
...item,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
onLongPress={() => {
|
||||||
|
if (!selectionMode) {
|
||||||
|
dispatch({
|
||||||
|
type: ACTIONS.SELECTION_MODE,
|
||||||
|
enabled: !selectionMode,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
dispatch({
|
||||||
|
type: ACTIONS.SELECTED_ITEMS,
|
||||||
|
item: item,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
item={item}>
|
||||||
<NotebookItem
|
<NotebookItem
|
||||||
hideMore={preventDefaultMargins}
|
hideMore={preventDefaultMargins}
|
||||||
isTopic={true}
|
isTopic={true}
|
||||||
customStyle={{
|
customStyle={{
|
||||||
width: selectionMode ? w - 74 : '100%',
|
width: '100%',
|
||||||
marginHorizontal: 0,
|
marginHorizontal: 0,
|
||||||
}}
|
}}
|
||||||
selectionMode={selectionMode}
|
selectionMode={selectionMode}
|
||||||
onLongPress={() => {
|
|
||||||
if (!selectionMode) {
|
|
||||||
dispatch({
|
|
||||||
type: ACTIONS.SELECTION_MODE,
|
|
||||||
enabled: !selectionMode,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
dispatch({
|
|
||||||
type: ACTIONS.SELECTED_ITEMS,
|
|
||||||
item: item,
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
noteToMove={params.note}
|
noteToMove={params.note}
|
||||||
notebookID={params.notebook?.id}
|
notebookID={params.notebook?.id}
|
||||||
isMove={preventDefaultMargins}
|
isMove={preventDefaultMargins}
|
||||||
refresh={() => {}}
|
|
||||||
item={item}
|
item={item}
|
||||||
index={index}
|
index={index}
|
||||||
colors={colors}
|
colors={colors}
|
||||||
|
|||||||
Reference in New Issue
Block a user