mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-22 22:49:45 +01:00
improve note items design
This commit is contained in:
@@ -54,36 +54,7 @@ export default class NoteItem extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
_onPress = async () => {
|
||||||
let {
|
|
||||||
colors,
|
|
||||||
item,
|
|
||||||
customStyle,
|
|
||||||
onLongPress,
|
|
||||||
isTrash,
|
|
||||||
pinned,
|
|
||||||
index,
|
|
||||||
} = this.props;
|
|
||||||
return (
|
|
||||||
<View
|
|
||||||
style={[
|
|
||||||
{
|
|
||||||
paddingVertical: pv,
|
|
||||||
justifyContent: 'flex-start',
|
|
||||||
alignItems: 'center',
|
|
||||||
flexDirection: 'row',
|
|
||||||
maxWidth: '100%',
|
|
||||||
paddingRight: 6,
|
|
||||||
alignSelf: 'center',
|
|
||||||
borderBottomWidth: 1,
|
|
||||||
borderBottomColor: colors.nav,
|
|
||||||
},
|
|
||||||
customStyle ? customStyle : {},
|
|
||||||
]}>
|
|
||||||
<TouchableOpacity
|
|
||||||
activeOpacity={0.8}
|
|
||||||
onLongPress={() => onLongPress()}
|
|
||||||
onPress={async () => {
|
|
||||||
if (item.conflicted) {
|
if (item.conflicted) {
|
||||||
eSendEvent(eShowMergeDialog, item);
|
eSendEvent(eShowMergeDialog, item);
|
||||||
|
|
||||||
@@ -105,12 +76,31 @@ export default class NoteItem extends React.Component {
|
|||||||
eSendEvent(eOnLoadNote, item);
|
eSendEvent(eOnLoadNote, item);
|
||||||
openEditorAnimation();
|
openEditorAnimation();
|
||||||
}
|
}
|
||||||
}}
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
let {colors, item, customStyle, isTrash} = this.props;
|
||||||
|
return (
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
{
|
||||||
|
justifyContent: 'flex-start',
|
||||||
|
alignItems: 'center',
|
||||||
|
flexDirection: 'row',
|
||||||
|
maxWidth: '100%',
|
||||||
|
paddingRight: 6,
|
||||||
|
alignSelf: 'center',
|
||||||
|
borderBottomWidth: 1,
|
||||||
|
height: 100,
|
||||||
|
borderBottomColor: colors.nav,
|
||||||
|
},
|
||||||
|
customStyle ? customStyle : {},
|
||||||
|
]}>
|
||||||
|
<View
|
||||||
style={{
|
style={{
|
||||||
paddingLeft: 0,
|
paddingLeft: 0,
|
||||||
width: '95%',
|
width: '95%',
|
||||||
}}>
|
}}>
|
||||||
<>
|
|
||||||
<Text
|
<Text
|
||||||
numberOfLines={1}
|
numberOfLines={1}
|
||||||
style={{
|
style={{
|
||||||
@@ -250,8 +240,7 @@ export default class NoteItem extends React.Component {
|
|||||||
) : null}
|
) : null}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</>
|
</View>
|
||||||
</TouchableOpacity>
|
|
||||||
|
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={{
|
style={{
|
||||||
|
|||||||
@@ -8,112 +8,48 @@ 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';
|
||||||
|
import Seperator from '../Seperator';
|
||||||
|
|
||||||
export const NotebookItem = ({
|
export const NotebookItem = ({
|
||||||
item,
|
item,
|
||||||
index,
|
|
||||||
hideMore = false,
|
hideMore = false,
|
||||||
topic,
|
|
||||||
isTopic = false,
|
isTopic = false,
|
||||||
isMove = false,
|
|
||||||
noteToMove = null,
|
|
||||||
notebookID,
|
notebookID,
|
||||||
numColumns,
|
numColumns,
|
||||||
isTrash,
|
isTrash,
|
||||||
customStyle,
|
customStyle,
|
||||||
onLongPress,
|
|
||||||
navigation,
|
|
||||||
selectionMode,
|
|
||||||
pinned,
|
|
||||||
}) => {
|
}) => {
|
||||||
const [state, dispatch] = useTracked();
|
const [state, dispatch] = useTracked();
|
||||||
const {colors, selectedItemsList} = state;
|
const {colors, selectedItemsList} = state;
|
||||||
|
|
||||||
const navigate = () => {
|
|
||||||
if (selectionMode) {
|
|
||||||
onLongPress();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isTopic) {
|
|
||||||
NavigationService.navigate('Notes', {
|
|
||||||
...item,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
dispatch({
|
|
||||||
type: ACTIONS.HEADER_TEXT_STATE,
|
|
||||||
state: {
|
|
||||||
heading: hideMore ? 'Move to topic' : item.title,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
dispatch({
|
|
||||||
type: ACTIONS.HEADER_STATE,
|
|
||||||
state: {
|
|
||||||
canGoBack: true,
|
|
||||||
menu: false,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
dispatch({
|
|
||||||
type: ACTIONS.CONTAINER_BOTTOM_BUTTON,
|
|
||||||
state: {
|
|
||||||
bottomButtonText: 'Add new topic',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
hideMore
|
|
||||||
? navigation.navigate('Notebook', {
|
|
||||||
notebook: item,
|
|
||||||
title: hideMore ? 'Move to topic' : item.title,
|
|
||||||
isMove: isMove,
|
|
||||||
hideMore: hideMore,
|
|
||||||
root: false,
|
|
||||||
})
|
|
||||||
: NavigationService.navigate('Notebook', {
|
|
||||||
notebook: item,
|
|
||||||
title: hideMore ? 'Select a topic' : item.title,
|
|
||||||
isMove: isMove,
|
|
||||||
hideMore: hideMore,
|
|
||||||
root: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
{
|
{
|
||||||
paddingVertical: isTopic ? pv / 2 : pv,
|
height: isTopic ? 80 : 120,
|
||||||
justifyContent: 'flex-start',
|
justifyContent: 'space-between',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
paddingRight: 6,
|
paddingRight: 6,
|
||||||
alignSelf: 'center',
|
alignSelf: 'center',
|
||||||
borderBottomWidth: 1,
|
borderBottomWidth: 1,
|
||||||
borderBottomColor: colors.nav,
|
borderBottomColor: colors.nav,
|
||||||
|
width: '100%',
|
||||||
},
|
},
|
||||||
customStyle,
|
customStyle,
|
||||||
]}>
|
]}>
|
||||||
<View
|
<View
|
||||||
style={{
|
|
||||||
flexDirection: 'row',
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
alignItems: 'center',
|
|
||||||
width: '100%',
|
|
||||||
}}>
|
|
||||||
<TouchableOpacity
|
|
||||||
activeOpacity={0.8}
|
|
||||||
style={{
|
style={{
|
||||||
width: hideMore ? '80%' : '90%',
|
width: hideMore ? '80%' : '90%',
|
||||||
maxWidth: hideMore ? '80%' : '90%',
|
maxWidth: hideMore ? '80%' : '90%',
|
||||||
minHeight: 50,
|
minHeight: 50,
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
}}
|
}}>
|
||||||
onLongPress={onLongPress}
|
|
||||||
onPress={navigate}>
|
|
||||||
<Text
|
<Text
|
||||||
numberOfLines={1}
|
numberOfLines={1}
|
||||||
style={{
|
style={{
|
||||||
fontFamily: WEIGHT.bold,
|
fontFamily: WEIGHT.bold,
|
||||||
fontSize: SIZE.sm + 1,
|
fontSize: SIZE.md,
|
||||||
color: colors.heading,
|
color: colors.heading,
|
||||||
maxWidth: '100%',
|
maxWidth: '100%',
|
||||||
}}>
|
}}>
|
||||||
@@ -144,12 +80,12 @@ export const NotebookItem = ({
|
|||||||
maxWidth: '80%',
|
maxWidth: '80%',
|
||||||
flexWrap: 'wrap',
|
flexWrap: 'wrap',
|
||||||
}}>
|
}}>
|
||||||
{item && item.topics
|
{item && item.topics ? (
|
||||||
? item.topics.slice(1, 4).map((topic) => (
|
item.topics.slice(1, 4).map((topic) => (
|
||||||
<View
|
<View
|
||||||
key={topic.dateCreated.toString() + topic.title}
|
key={topic.dateCreated.toString() + topic.title}
|
||||||
style={{
|
style={{
|
||||||
borderRadius: 5,
|
borderRadius: 2.5,
|
||||||
backgroundColor: colors.accent,
|
backgroundColor: colors.accent,
|
||||||
paddingHorizontal: ph / 1.5,
|
paddingHorizontal: ph / 1.5,
|
||||||
paddingVertical: pv / 3,
|
paddingVertical: pv / 3,
|
||||||
@@ -168,7 +104,18 @@ export const NotebookItem = ({
|
|||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
))
|
))
|
||||||
: null}
|
) : (
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
color: colors.icon,
|
||||||
|
fontFamily: WEIGHT.regular,
|
||||||
|
fontSize: SIZE.xxs,
|
||||||
|
paddingVertical: pv / 3,
|
||||||
|
maxWidth: '100%',
|
||||||
|
}}>
|
||||||
|
This notebook has no topics.
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@@ -209,6 +156,18 @@ export const NotebookItem = ({
|
|||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
marginTop: 5,
|
marginTop: 5,
|
||||||
}}>
|
}}>
|
||||||
|
{isTrash ? null : (
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
color: colors.icon,
|
||||||
|
fontSize: SIZE.xxs,
|
||||||
|
textAlignVertical: 'center',
|
||||||
|
fontFamily: WEIGHT.regular,
|
||||||
|
}}>
|
||||||
|
{new Date(item.dateCreated).toDateString().substring(4)}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
<Seperator half />
|
||||||
<Text
|
<Text
|
||||||
style={{
|
style={{
|
||||||
color: colors.icon,
|
color: colors.icon,
|
||||||
@@ -217,26 +176,13 @@ export const NotebookItem = ({
|
|||||||
fontFamily: WEIGHT.regular,
|
fontFamily: WEIGHT.regular,
|
||||||
}}>
|
}}>
|
||||||
{item && item.totalNotes && item.totalNotes > 1
|
{item && item.totalNotes && item.totalNotes > 1
|
||||||
? item.totalNotes + ' notes'
|
? item.totalNotes + ' Notes'
|
||||||
: item.totalNotes === 1
|
: item.totalNotes === 1
|
||||||
? item.totalNotes + ' note'
|
? item.totalNotes + ' Note'
|
||||||
: '0 notes'}
|
: '0 Notes'}
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
{isTopic || isTrash ? null : (
|
|
||||||
<Text
|
|
||||||
style={{
|
|
||||||
color: colors.accent,
|
|
||||||
marginLeft: 10,
|
|
||||||
fontSize: SIZE.xxs,
|
|
||||||
textAlignVertical: 'center',
|
|
||||||
fontFamily: WEIGHT.regular,
|
|
||||||
}}>
|
|
||||||
{new Date(item.dateCreated).toDateString().substring(4)}
|
|
||||||
</Text>
|
|
||||||
)}
|
|
||||||
</View>
|
</View>
|
||||||
</TouchableOpacity>
|
</View>
|
||||||
{hideMore ||
|
{hideMore ||
|
||||||
(item.title === 'General' && item.type === 'topic') ? null : (
|
(item.title === 'General' && item.type === 'topic') ? null : (
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
@@ -259,11 +205,7 @@ export const NotebookItem = ({
|
|||||||
notebookID: notebookID,
|
notebookID: notebookID,
|
||||||
});
|
});
|
||||||
}}>
|
}}>
|
||||||
<Icon
|
<Icon name="dots-horizontal" size={SIZE.lg} color={colors.heading} />
|
||||||
name="dots-horizontal"
|
|
||||||
size={SIZE.lg}
|
|
||||||
color={colors.heading}
|
|
||||||
/>
|
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@@ -291,6 +233,5 @@ export const NotebookItem = ({
|
|||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ export const PressableButton = ({
|
|||||||
children,
|
children,
|
||||||
onPress,
|
onPress,
|
||||||
customStyle,alpha=-0.1,
|
customStyle,alpha=-0.1,
|
||||||
opacity=1
|
opacity=1,
|
||||||
|
onLongPress
|
||||||
}) => {
|
}) => {
|
||||||
|
|
||||||
|
|
||||||
@@ -19,6 +20,7 @@ export const PressableButton = ({
|
|||||||
<Pressable
|
<Pressable
|
||||||
activeOpacity={opacity}
|
activeOpacity={opacity}
|
||||||
onPress={onPress}
|
onPress={onPress}
|
||||||
|
onLongPress={onLongPress}
|
||||||
style={({pressed}) => [
|
style={({pressed}) => [
|
||||||
{
|
{
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import { ACTIONS } from '../../provider/actions';
|
|||||||
import {eSendEvent} from '../../services/eventManager';
|
import {eSendEvent} from '../../services/eventManager';
|
||||||
import {
|
import {
|
||||||
eOpenMoveNoteDialog,
|
eOpenMoveNoteDialog,
|
||||||
|
eOpenPremiumDialog,
|
||||||
eOpenPremiumDialog, eOpenSimpleDialog
|
eOpenSimpleDialog,
|
||||||
} from '../../services/events';
|
} 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';
|
||||||
@@ -35,10 +35,9 @@ export const SelectionHeader = () => {
|
|||||||
Animated.timing(translateY, {
|
Animated.timing(translateY, {
|
||||||
duration: 300,
|
duration: 300,
|
||||||
toValue: selectionMode ? 0 : -150,
|
toValue: selectionMode ? 0 : -150,
|
||||||
easing:Easing.in(Easing.ease)
|
easing: Easing.in(Easing.ease),
|
||||||
}).start();
|
}).start();
|
||||||
},[selectionMode])
|
}, [selectionMode]);
|
||||||
|
|
||||||
|
|
||||||
return containerState.noSelectionHeader ? null : (
|
return containerState.noSelectionHeader ? null : (
|
||||||
<Animated.View
|
<Animated.View
|
||||||
@@ -127,10 +126,10 @@ export const SelectionHeader = () => {
|
|||||||
dispatch({type: ACTIONS.CLEAR_SELECTION});
|
dispatch({type: ACTIONS.CLEAR_SELECTION});
|
||||||
eSendEvent(eOpenMoveNoteDialog);
|
eSendEvent(eOpenMoveNoteDialog);
|
||||||
}}>
|
}}>
|
||||||
<Icon color={colors.icon} 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',
|
||||||
@@ -168,9 +167,9 @@ export const SelectionHeader = () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}}>
|
}}>
|
||||||
<Icon color={colors.icon} name={'star'} size={SIZE.xl - 3} />
|
<Icon color={colors.heading} name={'star'} size={SIZE.xl - 3} />
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
)}
|
)} */}
|
||||||
|
|
||||||
{currentScreen === 'trash' ? null : (
|
{currentScreen === 'trash' ? null : (
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
@@ -185,7 +184,7 @@ export const SelectionHeader = () => {
|
|||||||
eSendEvent(eOpenSimpleDialog, TEMPLATE_DELETE('item'));
|
eSendEvent(eOpenSimpleDialog, TEMPLATE_DELETE('item'));
|
||||||
return;
|
return;
|
||||||
}}>
|
}}>
|
||||||
<Icon color={colors.icon} name={'delete'} size={SIZE.xl - 3} />
|
<Icon color={colors.heading} name={'delete'} size={SIZE.xl - 3} />
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@@ -214,7 +213,7 @@ export const SelectionHeader = () => {
|
|||||||
}
|
}
|
||||||
}}>
|
}}>
|
||||||
<Icon
|
<Icon
|
||||||
color={colors.icon}
|
color={colors.heading}
|
||||||
name="delete-restore"
|
name="delete-restore"
|
||||||
size={SIZE.xl - 3}
|
size={SIZE.xl - 3}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import {TouchableWithoutFeedback, View} from 'react-native';
|
import { TouchableOpacity, View } from 'react-native';
|
||||||
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
|
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
|
||||||
import { SIZE } from '../../common/common';
|
import { SIZE } from '../../common/common';
|
||||||
import { useTracked } from '../../provider';
|
import { useTracked } from '../../provider';
|
||||||
import { ACTIONS } from '../../provider/actions';
|
import { ACTIONS } from '../../provider/actions';
|
||||||
import { getElevation } from '../../utils/utils';
|
import { getElevation } from '../../utils/utils';
|
||||||
|
import { PressableButton } from '../PressableButton';
|
||||||
|
|
||||||
const SelectionWrapper = ({
|
const SelectionWrapper = ({
|
||||||
children,
|
children,
|
||||||
@@ -13,13 +14,15 @@ const SelectionWrapper = ({
|
|||||||
index,
|
index,
|
||||||
background,
|
background,
|
||||||
pinned,
|
pinned,
|
||||||
|
onLongPress,
|
||||||
|
onPress
|
||||||
}) => {
|
}) => {
|
||||||
const [state, dispatch] = useTracked();
|
const [state, dispatch] = useTracked();
|
||||||
const {colors, selectionMode, selectedItemsList} = state;
|
const {colors, selectionMode, selectedItemsList} = state;
|
||||||
const [selected, setSelected] = useState(false);
|
const [selected, setSelected] = useState(false);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let exists = selectedItemsList.filter(
|
let exists = selectedItemsList.filter(
|
||||||
o => o.dateCreated === item.dateCreated,
|
(o) => o.dateCreated === item.dateCreated,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (exists[0]) {
|
if (exists[0]) {
|
||||||
@@ -33,9 +36,25 @@ const SelectionWrapper = ({
|
|||||||
}
|
}
|
||||||
}, [selectedItemsList]);
|
}, [selectedItemsList]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View
|
<PressableButton
|
||||||
style={{
|
color={currentEditingNote === item.dateCreated || pinned
|
||||||
|
? colors.shade
|
||||||
|
: background
|
||||||
|
? background
|
||||||
|
: 'transparent'
|
||||||
|
}
|
||||||
|
onLongPress={onLongPress}
|
||||||
|
onPress={onPress}
|
||||||
|
selectedColor={currentEditingNote === item.dateCreated || pinned? colors.accent : colors.nav}
|
||||||
|
alpha={!colors.night ? -0.02 : 0.02}
|
||||||
|
opacity={ currentEditingNote === item.dateCreated || pinned? 0.12 : 1}
|
||||||
|
customStyle={{
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
justifyContent: 'space-between',
|
justifyContent: 'space-between',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
@@ -47,12 +66,6 @@ const SelectionWrapper = ({
|
|||||||
: index === 0 && pinned && selectionMode
|
: index === 0 && pinned && selectionMode
|
||||||
? 30
|
? 30
|
||||||
: 0,
|
: 0,
|
||||||
backgroundColor:
|
|
||||||
currentEditingNote === item.dateCreated || pinned
|
|
||||||
? colors.shade
|
|
||||||
: background
|
|
||||||
? background
|
|
||||||
: 'transparent',
|
|
||||||
}}>
|
}}>
|
||||||
{pinned ? (
|
{pinned ? (
|
||||||
<View
|
<View
|
||||||
@@ -63,7 +76,7 @@ const SelectionWrapper = ({
|
|||||||
backgroundColor: colors.accent,
|
backgroundColor: colors.accent,
|
||||||
borderRadius: 100,
|
borderRadius: 100,
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
left: 20,
|
right: 20,
|
||||||
top: -15,
|
top: -15,
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
@@ -89,28 +102,30 @@ const SelectionWrapper = ({
|
|||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
paddingRight: 8,
|
paddingRight: 8,
|
||||||
}}>
|
}}>
|
||||||
<TouchableWithoutFeedback
|
<TouchableOpacity
|
||||||
|
activeOpacity={1}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
dispatch({type: ACTIONS.SELECTED_ITEMS, item: item});
|
dispatch({type: ACTIONS.SELECTED_ITEMS, item: item});
|
||||||
}}
|
}}
|
||||||
style={{
|
style={{
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
|
height: 70,
|
||||||
}}>
|
}}>
|
||||||
<Icon
|
<Icon
|
||||||
size={SIZE.lg}
|
size={SIZE.lg}
|
||||||
color={colors.accent}
|
color={selected ? colors.accent : colors.icon}
|
||||||
name={
|
name={
|
||||||
selected
|
selected
|
||||||
? 'check-circle-outline'
|
? 'check-circle-outline'
|
||||||
: 'checkbox-blank-circle-outline'
|
: 'checkbox-blank-circle-outline'
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</TouchableWithoutFeedback>
|
</TouchableOpacity>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{children}
|
{children}
|
||||||
</View>
|
</PressableButton>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,52 +1,77 @@
|
|||||||
import React from 'react';
|
import React, {useMemo} from 'react';
|
||||||
import NoteItem from '../../components/NoteItem';
|
import NoteItem from '../../components/NoteItem';
|
||||||
import SelectionWrapper from '../../components/SelectionWrapper';
|
import SelectionWrapper from '../../components/SelectionWrapper';
|
||||||
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 {eShowMergeDialog, eOnLoadNote} from '../../services/events';
|
||||||
|
import {simpleDialogEvent} from '../DialogManager/recievers';
|
||||||
|
import {TEMPLATE_TRASH} from '../DialogManager/templates';
|
||||||
|
import {openEditorAnimation} from '../../utils/animations';
|
||||||
|
|
||||||
|
export const NoteItemWrapper = ({
|
||||||
export const NoteItemWrapper = ({item,index,isTrash = false, pinned = false }) => {
|
item,
|
||||||
|
index,
|
||||||
|
isTrash = false,
|
||||||
|
pinned = false,
|
||||||
|
}) => {
|
||||||
const [state, dispatch] = useTracked();
|
const [state, dispatch] = useTracked();
|
||||||
const {colors, currentEditingNote, selectionMode} = state;
|
const {colors, currentEditingNote, selectionMode} = state;
|
||||||
|
|
||||||
return <SelectionWrapper
|
const style = useMemo(() => {
|
||||||
|
return {width: selectionMode ? '90%' : '100%', marginHorizontal: 0};
|
||||||
|
}, [selectionMode]);
|
||||||
|
|
||||||
|
const onLongPress = () => {
|
||||||
|
if (!selectionMode) {
|
||||||
|
dispatch({type: ACTIONS.SELECTION_MODE, enabled: true});
|
||||||
|
}
|
||||||
|
dispatch({type: ACTIONS.SELECTED_ITEMS, item: item});
|
||||||
|
};
|
||||||
|
|
||||||
|
const onPress = async () => {
|
||||||
|
if (item.conflicted) {
|
||||||
|
eSendEvent(eShowMergeDialog, item);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (selectionMode) {
|
||||||
|
onLongPress();
|
||||||
|
return;
|
||||||
|
} else if (item.locked) {
|
||||||
|
openVault(item, true, true, false, true, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (DDS.isTab) {
|
||||||
|
eSendEvent(eOnLoadNote, item);
|
||||||
|
} else if (isTrash) {
|
||||||
|
simpleDialogEvent(TEMPLATE_TRASH(item.type));
|
||||||
|
} else {
|
||||||
|
eSendEvent(eOnLoadNote, item);
|
||||||
|
openEditorAnimation();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<SelectionWrapper
|
||||||
index={index}
|
index={index}
|
||||||
pinned={pinned}
|
pinned={pinned}
|
||||||
|
onLongPress={onLongPress}
|
||||||
|
onPress={onPress}
|
||||||
currentEditingNote={
|
currentEditingNote={
|
||||||
currentEditingNote === item.id ? currentEditingNote : null
|
currentEditingNote === item.id ? currentEditingNote : null
|
||||||
}
|
}
|
||||||
item={item}>
|
item={item}>
|
||||||
<NoteItem
|
<NoteItem
|
||||||
colors={colors}
|
colors={colors}
|
||||||
pinned={pinned}
|
customStyle={style}
|
||||||
customStyle={pinned? {
|
|
||||||
width: selectionMode ? '90%' : '100%',
|
|
||||||
marginHorizontal: 0,
|
|
||||||
paddingTop: 10,
|
|
||||||
paddingRight: 6,
|
|
||||||
marginBottom: 5,
|
|
||||||
marginTop: 15,
|
|
||||||
borderBottomWidth: 0,
|
|
||||||
} :{
|
|
||||||
width: selectionMode ? '90%' : '100%',
|
|
||||||
marginHorizontal: 0,
|
|
||||||
}}
|
|
||||||
currentEditingNote={
|
currentEditingNote={
|
||||||
currentEditingNote === item.id ? currentEditingNote : null
|
currentEditingNote === item.id ? currentEditingNote : null
|
||||||
}
|
}
|
||||||
selectionMode={selectionMode}
|
selectionMode={selectionMode}
|
||||||
onLongPress={() => {
|
|
||||||
if (!selectionMode) {
|
|
||||||
dispatch({type: ACTIONS.SELECTION_MODE, enabled: true});
|
|
||||||
}
|
|
||||||
dispatch({type: ACTIONS.SELECTED_ITEMS, item: item});
|
|
||||||
}}
|
|
||||||
update={() => {
|
|
||||||
dispatch({type: ACTIONS.NOTES});
|
|
||||||
}}
|
|
||||||
item={item}
|
item={item}
|
||||||
index={index}
|
|
||||||
isTrash={isTrash}
|
isTrash={isTrash}
|
||||||
/>
|
/>
|
||||||
</SelectionWrapper>
|
</SelectionWrapper>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,38 +1,28 @@
|
|||||||
import React from 'react';
|
import React, {useMemo} from 'react';
|
||||||
import {NotebookItem} from '../../components/NotebookItem';
|
import {NotebookItem} from '../../components/NotebookItem';
|
||||||
import SelectionWrapper from '../../components/SelectionWrapper';
|
import SelectionWrapper from '../../components/SelectionWrapper';
|
||||||
import {useTracked} from '../../provider';
|
import {useTracked} from '../../provider';
|
||||||
import {ACTIONS} from '../../provider/actions';
|
import {ACTIONS} from '../../provider/actions';
|
||||||
|
import NavigationService from '../../services/NavigationService';
|
||||||
|
|
||||||
export const NotebookItemWrapper = ({item, index,isTrash = false, pinned = false}) => {
|
export const NotebookItemWrapper = ({
|
||||||
|
item,
|
||||||
|
index,
|
||||||
|
isTrash = false,
|
||||||
|
pinned = false,
|
||||||
|
}) => {
|
||||||
const [state, dispatch] = useTracked();
|
const [state, dispatch] = useTracked();
|
||||||
const {selectionMode, preventDefaultMargins} = state;
|
const {selectionMode, preventDefaultMargins} = state;
|
||||||
let headerState = preventDefaultMargins? state.indHeaderState : state.headerState;
|
let headerState = preventDefaultMargins
|
||||||
|
? state.indHeaderState
|
||||||
|
: state.headerState;
|
||||||
let params = headerState.route.params ? headerState.route.params : {};
|
let params = headerState.route.params ? headerState.route.params : {};
|
||||||
|
|
||||||
|
const style = useMemo(() => {
|
||||||
|
return {width: selectionMode ? '90%' : '100%', marginHorizontal: 0};
|
||||||
|
}, [selectionMode]);
|
||||||
|
|
||||||
return (
|
const onLongPress = () => {
|
||||||
<SelectionWrapper pinned={pinned} index={index} item={item}>
|
|
||||||
<NotebookItem
|
|
||||||
hideMore={preventDefaultMargins}
|
|
||||||
navigation={headerState.navigation}
|
|
||||||
route={headerState.route}
|
|
||||||
pinned={pinned}
|
|
||||||
customStyle={pinned? {
|
|
||||||
width: selectionMode ? '90%' : '100%',
|
|
||||||
marginHorizontal: 0,
|
|
||||||
paddingTop: 10,
|
|
||||||
paddingRight: 6,
|
|
||||||
marginBottom: 5,
|
|
||||||
marginTop: 15,
|
|
||||||
borderBottomWidth: 0,
|
|
||||||
} :{
|
|
||||||
width: selectionMode ? '90%' : '100%',
|
|
||||||
marginHorizontal: 0,
|
|
||||||
}}
|
|
||||||
isMove={preventDefaultMargins}
|
|
||||||
selectionMode={selectionMode}
|
|
||||||
onLongPress={() => {
|
|
||||||
if (!selectionMode) {
|
if (!selectionMode) {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.SELECTION_MODE,
|
type: ACTIONS.SELECTION_MODE,
|
||||||
@@ -44,7 +34,69 @@ export const NotebookItemWrapper = ({item, index,isTrash = false, pinned = false
|
|||||||
type: ACTIONS.SELECTED_ITEMS,
|
type: ACTIONS.SELECTED_ITEMS,
|
||||||
item: item,
|
item: item,
|
||||||
});
|
});
|
||||||
}}
|
};
|
||||||
|
|
||||||
|
const onPress = () => {
|
||||||
|
if (selectionMode) {
|
||||||
|
onLongPress();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (item.type === 'topic') {
|
||||||
|
NavigationService.navigate('Notes', {
|
||||||
|
...item,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
dispatch({
|
||||||
|
type: ACTIONS.HEADER_TEXT_STATE,
|
||||||
|
state: {
|
||||||
|
heading: preventDefaultMargins ? 'Move to topic' : item.title,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
dispatch({
|
||||||
|
type: ACTIONS.HEADER_STATE,
|
||||||
|
state: {
|
||||||
|
canGoBack: true,
|
||||||
|
menu: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
dispatch({
|
||||||
|
type: ACTIONS.CONTAINER_BOTTOM_BUTTON,
|
||||||
|
state: {
|
||||||
|
bottomButtonText: 'Add new topic',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
preventDefaultMargins
|
||||||
|
? navigation.navigate('Notebook', {
|
||||||
|
notebook: item,
|
||||||
|
title: preventDefaultMargins ? 'Move to topic' : item.title,
|
||||||
|
isMove: preventDefaultMargins,
|
||||||
|
hideMore: preventDefaultMargins,
|
||||||
|
root: preventDefaultMargins ? false : true,
|
||||||
|
})
|
||||||
|
: NavigationService.navigate('Notebook', {
|
||||||
|
notebook: item,
|
||||||
|
title: preventDefaultMargins ? 'Select a topic' : item.title,
|
||||||
|
isMove: preventDefaultMargins,
|
||||||
|
hideMore: preventDefaultMargins,
|
||||||
|
root: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<SelectionWrapper
|
||||||
|
onLongPress={onLongPress}
|
||||||
|
pinned={pinned}
|
||||||
|
index={index}
|
||||||
|
onPress={onPress}
|
||||||
|
item={item}>
|
||||||
|
<NotebookItem
|
||||||
|
hideMore={preventDefaultMargins}
|
||||||
|
navigation={headerState.navigation}
|
||||||
|
route={headerState.route}
|
||||||
|
isTopic={item.type === "topic"}
|
||||||
|
customStyle={style}
|
||||||
noteToMove={params.note}
|
noteToMove={params.note}
|
||||||
item={item}
|
item={item}
|
||||||
index={index}
|
index={index}
|
||||||
|
|||||||
@@ -6,25 +6,23 @@ import {
|
|||||||
SectionList,
|
SectionList,
|
||||||
Text,
|
Text,
|
||||||
View,
|
View,
|
||||||
TouchableOpacity,
|
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
|
import * as Animatable from 'react-native-animatable';
|
||||||
import {useSafeArea} from 'react-native-safe-area-context';
|
import {useSafeArea} from 'react-native-safe-area-context';
|
||||||
import {SIZE, WEIGHT, opacity, pv} from '../../common/common';
|
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
|
||||||
|
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 {
|
||||||
eClearSearch,
|
eClearSearch,
|
||||||
eScrollEvent,
|
|
||||||
eOpenLoginDialog,
|
eOpenLoginDialog,
|
||||||
|
eScrollEvent,
|
||||||
} from '../../services/events';
|
} from '../../services/events';
|
||||||
import {db, ToastEvent, DDS} from '../../utils/utils';
|
|
||||||
import * as Animatable from 'react-native-animatable';
|
|
||||||
import {PinnedItemList} from './PinnedItemList';
|
|
||||||
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
|
|
||||||
import NavigationService from '../../services/NavigationService';
|
import NavigationService from '../../services/NavigationService';
|
||||||
import {Placeholder} from '../ListPlaceholders';
|
import {db, DDS, ToastEvent} from '../../utils/utils';
|
||||||
import {PressableButton} from '../PressableButton';
|
import {PressableButton} from '../PressableButton';
|
||||||
|
import {PinnedItemList} from './PinnedItemList';
|
||||||
const sectionListRef = createRef();
|
const sectionListRef = createRef();
|
||||||
|
|
||||||
const AnimatedFlatlist = Animatable.createAnimatableComponent(FlatList);
|
const AnimatedFlatlist = Animatable.createAnimatableComponent(FlatList);
|
||||||
|
|||||||
Reference in New Issue
Block a user