mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-22 14:39:34 +01:00
ui updates
This commit is contained in:
@@ -71,8 +71,6 @@ export const ActionSheetComponent = ({
|
|||||||
|
|
||||||
function changeColorScheme(colors = COLOR_SCHEME, accent = ACCENT) {
|
function changeColorScheme(colors = COLOR_SCHEME, accent = ACCENT) {
|
||||||
let newColors = setColorScheme(colors, accent);
|
let newColors = setColorScheme(colors, accent);
|
||||||
StatusBar.setBarStyle(colors.night ? 'light-content' : 'dark-content');
|
|
||||||
|
|
||||||
dispatch({type: Actions.THEME, colors: newColors});
|
dispatch({type: Actions.THEME, colors: newColors});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { ActivityIndicator, StyleSheet, Text } from 'react-native';
|
import {ActivityIndicator, StyleSheet, Text} from 'react-native';
|
||||||
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
|
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
|
||||||
import { useTracked } from '../../provider';
|
import {useTracked} from '../../provider';
|
||||||
import { PressableButton } from '../PressableButton';
|
import {PressableButton} from '../PressableButton';
|
||||||
import {ph, pv, SIZE, WEIGHT} from "../../utils/SizeUtils";
|
import {ph, pv, SIZE, WEIGHT} from '../../utils/SizeUtils';
|
||||||
|
|
||||||
export const Button = ({
|
export const Button = ({
|
||||||
height = 40,
|
height = 40,
|
||||||
@@ -14,11 +14,12 @@ export const Button = ({
|
|||||||
title = '',
|
title = '',
|
||||||
icon,
|
icon,
|
||||||
color = 'accent',
|
color = 'accent',
|
||||||
fontSize=SIZE.sm
|
fontSize = SIZE.sm,
|
||||||
|
iconColor = 'white',
|
||||||
}) => {
|
}) => {
|
||||||
const [state, dispatch] = useTracked();
|
const [state, dispatch] = useTracked();
|
||||||
const {colors} = state;
|
const {colors} = state;
|
||||||
const usedColor = 'accent' ? colors.accent : color;
|
const usedColor = color === 'accent' ? colors.accent : colors[color];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PressableButton
|
<PressableButton
|
||||||
@@ -28,7 +29,7 @@ export const Button = ({
|
|||||||
alpha={grayed ? (!colors.night ? -0.04 : 0.04) : -0.1}
|
alpha={grayed ? (!colors.night ? -0.04 : 0.04) : -0.1}
|
||||||
customStyle={{
|
customStyle={{
|
||||||
height: height,
|
height: height,
|
||||||
width: width? width : null,
|
width: width ? width : null,
|
||||||
paddingVertical: pv,
|
paddingVertical: pv,
|
||||||
paddingHorizontal: ph,
|
paddingHorizontal: ph,
|
||||||
borderRadius: 5,
|
borderRadius: 5,
|
||||||
@@ -44,12 +45,15 @@ export const Button = ({
|
|||||||
style={{
|
style={{
|
||||||
marginRight: 5,
|
marginRight: 5,
|
||||||
}}
|
}}
|
||||||
color={grayed ? colors.icon : 'white'}
|
color={grayed ? colors.icon : colors[iconColor]}
|
||||||
size={SIZE.lg}
|
size={SIZE.lg}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
<Text
|
<Text
|
||||||
style={[styles.buttonText, {color: grayed ? colors.icon : 'white',fontSize:fontSize}]}>
|
style={[
|
||||||
|
styles.buttonText,
|
||||||
|
{color: grayed ? colors.icon : colors[iconColor], fontSize: fontSize},
|
||||||
|
]}>
|
||||||
{title}
|
{title}
|
||||||
</Text>
|
</Text>
|
||||||
</PressableButton>
|
</PressableButton>
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ export const ContainerBottomButton = ({title, onPress, color}) => {
|
|||||||
<Icon
|
<Icon
|
||||||
name={title === 'Clear all trash' ? 'delete' : 'plus'}
|
name={title === 'Clear all trash' ? 'delete' : 'plus'}
|
||||||
color="white"
|
color="white"
|
||||||
size={SIZE.xl}
|
size={SIZE.xxl}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
</PressableButton>
|
</PressableButton>
|
||||||
|
|||||||
@@ -24,12 +24,12 @@ export const HeaderMenu = () => {
|
|||||||
}}>
|
}}>
|
||||||
<Text
|
<Text
|
||||||
style={{
|
style={{
|
||||||
fontSize: SIZE.xs + 1,
|
fontSize: SIZE.sm,
|
||||||
fontFamily: WEIGHT.regular,
|
fontFamily: WEIGHT.regular,
|
||||||
color: colors.pri,
|
color: colors.pri,
|
||||||
marginRight: 5,
|
marginRight: 5,
|
||||||
height: 30,
|
height: 35,
|
||||||
textAlignVertical: 'bottom',
|
textAlignVertical:'center'
|
||||||
}}>
|
}}>
|
||||||
{settings.sort.slice(0, 1).toUpperCase() +
|
{settings.sort.slice(0, 1).toUpperCase() +
|
||||||
settings.sort.slice(1, settings.sort.length)}
|
settings.sort.slice(1, settings.sort.length)}
|
||||||
@@ -40,7 +40,7 @@ export const HeaderMenu = () => {
|
|||||||
settings.sortOrder === 'asc' ? 'sort-ascending' : 'sort-descending'
|
settings.sortOrder === 'asc' ? 'sort-ascending' : 'sort-descending'
|
||||||
}
|
}
|
||||||
style={{
|
style={{
|
||||||
textAlignVertical: 'bottom',
|
textAlignVertical:'center',
|
||||||
height: 30,
|
height: 30,
|
||||||
}}
|
}}
|
||||||
size={SIZE.md}
|
size={SIZE.md}
|
||||||
|
|||||||
@@ -7,9 +7,10 @@ import {
|
|||||||
TAG_SVG,
|
TAG_SVG,
|
||||||
FAV_SVG,
|
FAV_SVG,
|
||||||
TRASH_SVG,
|
TRASH_SVG,
|
||||||
|
SETTINGS_SVG,
|
||||||
} from '../../assets/images/assets';
|
} from '../../assets/images/assets';
|
||||||
import { useTracked } from '../../provider';
|
import {useTracked} from '../../provider';
|
||||||
export const Placeholder = ({type}) => {
|
export const Placeholder = ({type, w, h}) => {
|
||||||
const [state, dispatch] = useTracked();
|
const [state, dispatch] = useTracked();
|
||||||
const {colors} = state;
|
const {colors} = state;
|
||||||
const getSVG = () => {
|
const getSVG = () => {
|
||||||
@@ -24,14 +25,16 @@ export const Placeholder = ({type}) => {
|
|||||||
return FAV_SVG(colors.accent);
|
return FAV_SVG(colors.accent);
|
||||||
case 'trash':
|
case 'trash':
|
||||||
return TRASH_SVG(colors.accent);
|
return TRASH_SVG(colors.accent);
|
||||||
|
case 'settings':
|
||||||
|
return SETTINGS_SVG(colors.accent);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
height: 250,
|
height: w || 250,
|
||||||
width: 250,
|
width: h || 250,
|
||||||
}}>
|
}}>
|
||||||
<SvgXml xml={getSVG()} width="100%" height="100%" />
|
<SvgXml xml={getSVG()} width="100%" height="100%" />
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import React, {useEffect} from 'react';
|
import React, {useEffect} from 'react';
|
||||||
import {Text, TouchableOpacity, View} from 'react-native';
|
import {Text, View} from 'react-native';
|
||||||
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 {refreshNotesPage} from '../../utils/Events';
|
|
||||||
import NavigationService from '../../services/Navigation';
|
import NavigationService from '../../services/Navigation';
|
||||||
import {opacity, SIZE, WEIGHT} from '../../utils/SizeUtils';
|
import {refreshNotesPage} from '../../utils/Events';
|
||||||
|
import {SIZE, WEIGHT} from '../../utils/SizeUtils';
|
||||||
import {PressableButton} from '../PressableButton';
|
import {PressableButton} from '../PressableButton';
|
||||||
|
|
||||||
export const TagsSection = () => {
|
export const TagsSection = () => {
|
||||||
@@ -33,7 +33,7 @@ export const TagsSection = () => {
|
|||||||
heading: item.title,
|
heading: item.title,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
NavigationService.navigate('Notes', params);
|
NavigationService.navigate('NotesPage', params);
|
||||||
eSendEvent(refreshNotesPage, params);
|
eSendEvent(refreshNotesPage, params);
|
||||||
NavigationService.closeDrawer();
|
NavigationService.closeDrawer();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ export const Menu = ({close = () => {}, hide, noTextMode = false}) => {
|
|||||||
|
|
||||||
function changeColorScheme(colors = COLOR_SCHEME, accent = ACCENT) {
|
function changeColorScheme(colors = COLOR_SCHEME, accent = ACCENT) {
|
||||||
let newColors = setColorScheme(colors, accent);
|
let newColors = setColorScheme(colors, accent);
|
||||||
StatusBar.setBarStyle(colors.night ? 'light-content' : 'dark-content');
|
|
||||||
dispatch({type: Actions.THEME, colors: newColors});
|
dispatch({type: Actions.THEME, colors: newColors});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ export const NotebookItem = ({
|
|||||||
item.topics.slice(1, 3).map((topic) => (
|
item.topics.slice(1, 3).map((topic) => (
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
NavigationService.navigate('Notes', {
|
NavigationService.navigate('NotesPage', {
|
||||||
...topic,
|
...topic,
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
|
|||||||
100
apps/mobile/src/components/SimpleList/ListHeaderComponent.js
Normal file
100
apps/mobile/src/components/SimpleList/ListHeaderComponent.js
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
import React, {useEffect} from 'react';
|
||||||
|
import {Text, View} from 'react-native';
|
||||||
|
import {useTracked} from '../../provider';
|
||||||
|
import {normalize, SIZE} from '../../utils/SizeUtils';
|
||||||
|
import Heading from '../Typography/Heading';
|
||||||
|
import {Placeholder} from '../ListPlaceholders';
|
||||||
|
import {eScrollEvent} from '../../utils/Events';
|
||||||
|
import {eSubscribeEvent, eUnSubscribeEvent} from '../../services/EventManager';
|
||||||
|
import Animated from 'react-native-reanimated';
|
||||||
|
import {dWidth} from '../../utils';
|
||||||
|
import {MessageCard} from './MessageCard';
|
||||||
|
import Paragraph from '../Typography/Paragraph';
|
||||||
|
|
||||||
|
const opacity = new Animated.Value(1);
|
||||||
|
export const ListHeaderComponent = ({
|
||||||
|
type,
|
||||||
|
data,
|
||||||
|
messageCard = true,
|
||||||
|
title,
|
||||||
|
paragraph,
|
||||||
|
color
|
||||||
|
}) => {
|
||||||
|
const [state] = useTracked();
|
||||||
|
const {colors, headerTextState} = state;
|
||||||
|
|
||||||
|
const onScroll = async (y) => {
|
||||||
|
if (y > 25) {
|
||||||
|
let o = y / 125;
|
||||||
|
o = 1 - o;
|
||||||
|
console.log(o);
|
||||||
|
opacity.setValue(o);
|
||||||
|
} else {
|
||||||
|
opacity.setValue(1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
eSubscribeEvent(eScrollEvent, onScroll);
|
||||||
|
return () => {
|
||||||
|
eUnSubscribeEvent(eScrollEvent, onScroll);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Animated.View
|
||||||
|
style={{
|
||||||
|
minHeight: 200,
|
||||||
|
padding: 12,
|
||||||
|
backgroundColor:color || colors.shade,
|
||||||
|
opacity: opacity,
|
||||||
|
}}>
|
||||||
|
{messageCard && <MessageCard />}
|
||||||
|
|
||||||
|
{/* <Icon style={{
|
||||||
|
position:'absolute',
|
||||||
|
right:0,
|
||||||
|
}} name="home" color={colors.bg} size={SIZE.xxxl * 4} /> */}
|
||||||
|
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
right: 0,
|
||||||
|
paddingRight: 12,
|
||||||
|
opacity: 0.5,
|
||||||
|
bottom: 0,
|
||||||
|
paddingHorizontal: 12,
|
||||||
|
position: 'absolute',
|
||||||
|
}}>
|
||||||
|
<Placeholder w={normalize(150)} h={normalize(150)} type={type} />
|
||||||
|
</View>
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
position: 'absolute',
|
||||||
|
bottom: 0,
|
||||||
|
paddingHorizontal: 12,
|
||||||
|
paddingBottom: 12,
|
||||||
|
}}>
|
||||||
|
<Heading
|
||||||
|
style={{marginBottom: paragraph ? -10 : 0}}
|
||||||
|
size={SIZE.xxxl * 1.5}
|
||||||
|
color={headerTextState.color}>
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
color: colors.accent,
|
||||||
|
}}>
|
||||||
|
{headerTextState.heading.slice(0, 1) === '#' ? '#' : null}
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
{title
|
||||||
|
? title
|
||||||
|
: headerTextState.heading.slice(0, 1) === '#'
|
||||||
|
? headerTextState.heading.slice(1)
|
||||||
|
: headerTextState.heading}
|
||||||
|
</Heading>
|
||||||
|
{paragraph && (
|
||||||
|
<Paragraph color={colors.icon}> {'\n' + paragraph}</Paragraph>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
</Animated.View>
|
||||||
|
);
|
||||||
|
};
|
||||||
56
apps/mobile/src/components/SimpleList/MessageCard.js
Normal file
56
apps/mobile/src/components/SimpleList/MessageCard.js
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Text, TouchableOpacity, View } from 'react-native';
|
||||||
|
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
|
||||||
|
import { useTracked } from '../../provider';
|
||||||
|
import { COLORS_NOTE } from '../../utils/Colors';
|
||||||
|
import { SIZE } from '../../utils/SizeUtils';
|
||||||
|
|
||||||
|
export const MessageCard = ({data}) => {
|
||||||
|
const [state] = useTracked();
|
||||||
|
const {colors, selectionMode, currentScreen, messageBoardState} = state;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View>
|
||||||
|
{!messageBoardState.visible || selectionMode ? null : (
|
||||||
|
<TouchableOpacity
|
||||||
|
activeOpacity={0.7}
|
||||||
|
onPress={messageBoardState.onPress}
|
||||||
|
style={{
|
||||||
|
flexDirection: 'row',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'flex-start',
|
||||||
|
position: 'absolute',
|
||||||
|
right: 0,
|
||||||
|
top: 0,
|
||||||
|
}}>
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
flexDirection: 'row',
|
||||||
|
alignItems: 'center',
|
||||||
|
}}>
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
color: COLORS_NOTE[currentScreen]
|
||||||
|
? COLORS_NOTE[currentScreen]
|
||||||
|
: colors.accent,
|
||||||
|
fontSize: SIZE.sm,
|
||||||
|
marginRight: 10,
|
||||||
|
}}>
|
||||||
|
{messageBoardState.actionText}
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
<Icon
|
||||||
|
name="arrow-right"
|
||||||
|
size={SIZE.sm}
|
||||||
|
color={
|
||||||
|
COLORS_NOTE[currentScreen]
|
||||||
|
? COLORS_NOTE[currentScreen]
|
||||||
|
: colors.accent
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
</TouchableOpacity>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -22,6 +22,11 @@ import {COLORS_NOTE} from '../../utils/Colors';
|
|||||||
import {SIZE, WEIGHT} from '../../utils/SizeUtils';
|
import {SIZE, WEIGHT} from '../../utils/SizeUtils';
|
||||||
import {db} from '../../utils/DB';
|
import {db} from '../../utils/DB';
|
||||||
import {HeaderMenu} from '../Header/HeaderMenu';
|
import {HeaderMenu} from '../Header/HeaderMenu';
|
||||||
|
import Heading from '../Typography/Heading';
|
||||||
|
import {ListHeaderComponent} from './ListHeaderComponent';
|
||||||
|
import Paragraph from '../Typography/Paragraph';
|
||||||
|
import {Button} from '../Button';
|
||||||
|
import Seperator from '../Seperator';
|
||||||
|
|
||||||
const header = {
|
const header = {
|
||||||
type: 'MAIN_HEADER',
|
type: 'MAIN_HEADER',
|
||||||
@@ -38,9 +43,10 @@ const SimpleList = ({
|
|||||||
sortMenuButton,
|
sortMenuButton,
|
||||||
scrollRef,
|
scrollRef,
|
||||||
jumpToDialog,
|
jumpToDialog,
|
||||||
|
placeholderData,
|
||||||
}) => {
|
}) => {
|
||||||
const [state, dispatch] = useTracked();
|
const [state, dispatch] = useTracked();
|
||||||
const {colors, selectionMode, messageBoardState} = state;
|
const {colors, selectionMode} = state;
|
||||||
const searchResults = {...state.searchResults};
|
const searchResults = {...state.searchResults};
|
||||||
const [refreshing, setRefreshing] = useState(false);
|
const [refreshing, setRefreshing] = useState(false);
|
||||||
const [dataProvider, setDataProvider] = useState(
|
const [dataProvider, setDataProvider] = useState(
|
||||||
@@ -53,7 +59,6 @@ const SimpleList = ({
|
|||||||
const listData = data;
|
const listData = data;
|
||||||
const dataType = type;
|
const dataType = type;
|
||||||
const _onScroll = (event) => {
|
const _onScroll = (event) => {
|
||||||
console.log(event.nativeEvent);
|
|
||||||
if (!event) return;
|
if (!event) return;
|
||||||
let y = event.nativeEvent.contentOffset.y;
|
let y = event.nativeEvent.contentOffset.y;
|
||||||
eSendEvent(eScrollEvent, y);
|
eSendEvent(eScrollEvent, y);
|
||||||
@@ -76,7 +81,7 @@ const SimpleList = ({
|
|||||||
width: '100%',
|
width: '100%',
|
||||||
justifyContent: 'space-between',
|
justifyContent: 'space-between',
|
||||||
paddingHorizontal: 12,
|
paddingHorizontal: 12,
|
||||||
height: 30,
|
height: 35,
|
||||||
}}>
|
}}>
|
||||||
<Text
|
<Text
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
@@ -89,9 +94,8 @@ const SimpleList = ({
|
|||||||
styles.sectionHeader,
|
styles.sectionHeader,
|
||||||
{
|
{
|
||||||
color: colors.accent,
|
color: colors.accent,
|
||||||
height: 30,
|
height: 35,
|
||||||
minWidth: 60,
|
minWidth: 60,
|
||||||
textAlignVertical: 'bottom',
|
|
||||||
},
|
},
|
||||||
]}>
|
]}>
|
||||||
{item.title}
|
{item.title}
|
||||||
@@ -146,10 +150,29 @@ const SimpleList = ({
|
|||||||
style={[
|
style={[
|
||||||
{
|
{
|
||||||
backgroundColor: colors.bg,
|
backgroundColor: colors.bg,
|
||||||
|
height: '100%',
|
||||||
},
|
},
|
||||||
styles.emptyList,
|
|
||||||
]}>
|
]}>
|
||||||
<>{placeholder}</>
|
<ListHeaderComponent type={type} />
|
||||||
|
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
flexGrow: 1,
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
}}>
|
||||||
|
<Heading>{placeholderData.heading}</Heading>
|
||||||
|
<Paragraph color={colors.icon}>{placeholderData.paragraph}</Paragraph>
|
||||||
|
<Seperator />
|
||||||
|
{placeholderData.button && <Button
|
||||||
|
onPress={placeholderData.action}
|
||||||
|
color="bg"
|
||||||
|
title={placeholderData.button}
|
||||||
|
icon="plus"
|
||||||
|
iconColor="accent"
|
||||||
|
fontSize={SIZE.md}
|
||||||
|
/> }
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -181,14 +204,11 @@ const SimpleList = ({
|
|||||||
break;
|
break;
|
||||||
case 'header':
|
case 'header':
|
||||||
dim.width = width;
|
dim.width = width;
|
||||||
dim.height = 30 * fontScale;
|
dim.height = 35 * fontScale;
|
||||||
break;
|
break;
|
||||||
case 'MAIN_HEADER':
|
case 'MAIN_HEADER':
|
||||||
dim.width = width;
|
dim.width = width;
|
||||||
dim.height =
|
dim.height = 200;
|
||||||
!messageBoardState.visible || !listData[0] || selectionMode
|
|
||||||
? 0
|
|
||||||
: 40 * fontScale;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dim.width = width;
|
dim.width = width;
|
||||||
@@ -223,6 +243,7 @@ const SimpleList = ({
|
|||||||
dataProvider={dataProvider}
|
dataProvider={dataProvider}
|
||||||
rowRenderer={_renderRow}
|
rowRenderer={_renderRow}
|
||||||
onScroll={_onScroll}
|
onScroll={_onScroll}
|
||||||
|
canChangeSize={true}
|
||||||
renderFooter={() => <View style={{height: 400}} />}
|
renderFooter={() => <View style={{height: 400}} />}
|
||||||
scrollViewProps={{
|
scrollViewProps={{
|
||||||
refreshControl: (
|
refreshControl: (
|
||||||
@@ -249,7 +270,6 @@ const SimpleList = ({
|
|||||||
height: '100%',
|
height: '100%',
|
||||||
backgroundColor: colors.bg,
|
backgroundColor: colors.bg,
|
||||||
width: '100%',
|
width: '100%',
|
||||||
paddingTop: 10,
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@@ -257,77 +277,7 @@ const SimpleList = ({
|
|||||||
|
|
||||||
export default SimpleList;
|
export default SimpleList;
|
||||||
|
|
||||||
const MessageCard = ({data}) => {
|
|
||||||
const [state] = useTracked();
|
|
||||||
const {colors, selectionMode, currentScreen, messageBoardState} = state;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<View>
|
|
||||||
{!messageBoardState.visible || !data[0] || selectionMode ? null : (
|
|
||||||
<PressableButton
|
|
||||||
onPress={messageBoardState.onPress}
|
|
||||||
color={
|
|
||||||
COLORS_NOTE[currentScreen]
|
|
||||||
? COLORS_NOTE[currentScreen]
|
|
||||||
: colors.shade
|
|
||||||
}
|
|
||||||
selectedColor={
|
|
||||||
COLORS_NOTE[currentScreen]
|
|
||||||
? COLORS_NOTE[currentScreen]
|
|
||||||
: colors.accent
|
|
||||||
}
|
|
||||||
alpha={!colors.night ? -0.02 : 0.1}
|
|
||||||
opacity={0.12}
|
|
||||||
customStyle={styles.loginCard}>
|
|
||||||
<View
|
|
||||||
style={{
|
|
||||||
width: 25,
|
|
||||||
backgroundColor: COLORS_NOTE[currentScreen]
|
|
||||||
? COLORS_NOTE[currentScreen]
|
|
||||||
: colors.accent,
|
|
||||||
height: 25,
|
|
||||||
borderRadius: 100,
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center',
|
|
||||||
}}>
|
|
||||||
<Icon
|
|
||||||
style={styles.loginIcon}
|
|
||||||
name={messageBoardState.icon}
|
|
||||||
color="white"
|
|
||||||
size={SIZE.xs}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
<View
|
|
||||||
style={{
|
|
||||||
marginLeft: 10,
|
|
||||||
}}>
|
|
||||||
<Text
|
|
||||||
style={{
|
|
||||||
fontFamily: WEIGHT.regular,
|
|
||||||
color: colors.icon,
|
|
||||||
fontSize: SIZE.xxs - 1,
|
|
||||||
}}>
|
|
||||||
{messageBoardState.message}
|
|
||||||
</Text>
|
|
||||||
<Text
|
|
||||||
style={{
|
|
||||||
color: COLORS_NOTE[currentScreen]
|
|
||||||
? COLORS_NOTE[currentScreen]
|
|
||||||
: colors.accent,
|
|
||||||
fontSize: SIZE.xxs,
|
|
||||||
}}>
|
|
||||||
{messageBoardState.actionText}
|
|
||||||
</Text>
|
|
||||||
</View>
|
|
||||||
</PressableButton>
|
|
||||||
)}
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const ListHeaderComponent = ({type, data}) => {
|
|
||||||
return <MessageCard type={type} data={data} />;
|
|
||||||
};
|
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
loginCard: {
|
loginCard: {
|
||||||
@@ -354,7 +304,7 @@ const styles = StyleSheet.create({
|
|||||||
},
|
},
|
||||||
sectionHeader: {
|
sectionHeader: {
|
||||||
fontFamily: WEIGHT.bold,
|
fontFamily: WEIGHT.bold,
|
||||||
fontSize: SIZE.xs + 1,
|
fontSize: SIZE.sm,
|
||||||
alignSelf: 'center',
|
alignSelf: 'center',
|
||||||
textAlignVertical: 'center',
|
textAlignVertical: 'center',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ class SortDialog extends React.Component {
|
|||||||
<Seperator/>
|
<Seperator/>
|
||||||
{
|
{
|
||||||
Object.keys(SORT).map((item, index) => <PressableButton
|
Object.keys(SORT).map((item, index) => <PressableButton
|
||||||
|
key={item}
|
||||||
color={this.state.settings.sort === item ? colors.shade : "transparent"}
|
color={this.state.settings.sort === item ? colors.shade : "transparent"}
|
||||||
onPress={async () => {
|
onPress={async () => {
|
||||||
await setSetting(this.state.settings, 'sort', item);
|
await setSetting(this.state.settings, 'sort', item);
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ const Paragraph = ({color, size, style, ...restProps}) => {
|
|||||||
fontFamily: WEIGHT.regular,
|
fontFamily: WEIGHT.regular,
|
||||||
fontSize: size || SIZE.sm,
|
fontSize: size || SIZE.sm,
|
||||||
color: color || colors.pri,
|
color: color || colors.pri,
|
||||||
|
fontWeight:'400'
|
||||||
},
|
},
|
||||||
style,
|
style,
|
||||||
]}></Text>
|
]}></Text>
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ export const NavigatorStack = () => {
|
|||||||
headerShown: false,
|
headerShown: false,
|
||||||
cardStyleInterpolator: forFade,
|
cardStyleInterpolator: forFade,
|
||||||
}}>
|
}}>
|
||||||
<Stack.Screen name="Home" component={Home} />
|
<Stack.Screen name="Notes" component={Home} />
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
initialParams={{
|
initialParams={{
|
||||||
title: 'Notebooks',
|
title: 'Notebooks',
|
||||||
@@ -86,7 +86,7 @@ export const NavigatorStack = () => {
|
|||||||
/>
|
/>
|
||||||
<Stack.Screen name="Favorites" component={Favorites} />
|
<Stack.Screen name="Favorites" component={Favorites} />
|
||||||
<Stack.Screen name="Trash" component={Trash} />
|
<Stack.Screen name="Trash" component={Trash} />
|
||||||
<Stack.Screen name="Notes" component={Notes} />
|
<Stack.Screen name="NotesPage" component={Notes} />
|
||||||
<Stack.Screen name="Tags" component={Tags} />
|
<Stack.Screen name="Tags" component={Tags} />
|
||||||
<Stack.Screen name="Notebook" component={Notebook} />
|
<Stack.Screen name="Notebook" component={Notebook} />
|
||||||
<Stack.Screen name="Settings" component={Settings} />
|
<Stack.Screen name="Settings" component={Settings} />
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ export const itemSkus = Platform.select({
|
|||||||
|
|
||||||
export const MenuItemsList = [
|
export const MenuItemsList = [
|
||||||
{
|
{
|
||||||
name: 'Home',
|
name: 'Notes',
|
||||||
icon: 'home-variant-outline',
|
icon: 'home-variant-outline',
|
||||||
close: true,
|
close: true,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,263 +1,282 @@
|
|||||||
import React, {createRef, useEffect, useState} from 'react';
|
import React, {useEffect, useState} from 'react';
|
||||||
import {BackHandler, Keyboard, Platform, StatusBar, View,} from 'react-native';
|
import {BackHandler, Keyboard, Platform, StatusBar, View} from 'react-native';
|
||||||
import {ActionIcon} from '../../components/ActionIcon';
|
import {ActionIcon} from '../../components/ActionIcon';
|
||||||
import {ActionSheetEvent, simpleDialogEvent,} from '../../components/DialogManager/recievers';
|
|
||||||
import {TEMPLATE_EXIT_FULLSCREEN, TEMPLATE_NEW_NOTE,} from '../../components/DialogManager/Templates';
|
|
||||||
import {useTracked} from '../../provider';
|
|
||||||
import {eSendEvent, eSubscribeEvent, eUnSubscribeEvent, ToastEvent,} from '../../services/EventManager';
|
|
||||||
import {eClearEditor, eCloseFullscreenEditor, eOnLoadNote, eOpenFullscreenEditor,} from '../../utils/Events';
|
|
||||||
import {exitEditorAnimation} from '../../utils/Animations';
|
|
||||||
import {editing} from '../../utils';
|
|
||||||
import {
|
import {
|
||||||
checkNote,
|
ActionSheetEvent,
|
||||||
clearEditor,
|
simpleDialogEvent,
|
||||||
clearTimer,
|
} from '../../components/DialogManager/recievers';
|
||||||
EditorWebView,
|
import {
|
||||||
getNote,
|
TEMPLATE_EXIT_FULLSCREEN,
|
||||||
isNotedEdited,
|
TEMPLATE_NEW_NOTE,
|
||||||
loadNote,
|
} from '../../components/DialogManager/Templates';
|
||||||
post,
|
import {useTracked} from '../../provider';
|
||||||
textInput,
|
|
||||||
} from './Functions';
|
|
||||||
import {normalize} from '../../utils/SizeUtils';
|
|
||||||
import {DDS} from '../../services/DeviceDetection';
|
import {DDS} from '../../services/DeviceDetection';
|
||||||
import HistoryComponent from "./HistoryComponent";
|
import {
|
||||||
|
eSendEvent,
|
||||||
|
eSubscribeEvent,
|
||||||
|
eUnSubscribeEvent,
|
||||||
|
ToastEvent,
|
||||||
|
} from '../../services/EventManager';
|
||||||
|
import {editing} from '../../utils';
|
||||||
|
import {exitEditorAnimation} from '../../utils/Animations';
|
||||||
|
import {
|
||||||
|
eClearEditor,
|
||||||
|
eCloseFullscreenEditor,
|
||||||
|
eOnLoadNote,
|
||||||
|
eOpenFullscreenEditor,
|
||||||
|
} from '../../utils/Events';
|
||||||
|
import {normalize} from '../../utils/SizeUtils';
|
||||||
|
import {
|
||||||
|
checkNote,
|
||||||
|
clearEditor,
|
||||||
|
clearTimer,
|
||||||
|
EditorWebView,
|
||||||
|
getNote,
|
||||||
|
isNotedEdited,
|
||||||
|
loadNote,
|
||||||
|
post,
|
||||||
|
textInput,
|
||||||
|
} from './Functions';
|
||||||
|
import HistoryComponent from './HistoryComponent';
|
||||||
|
|
||||||
let handleBack;
|
let handleBack;
|
||||||
let tapCount = 0;
|
let tapCount = 0;
|
||||||
|
|
||||||
const EditorHeader = ({noMenu}) => {
|
const EditorHeader = ({noMenu}) => {
|
||||||
const [state] = useTracked();
|
const [state] = useTracked();
|
||||||
const {colors, premiumUser} = state;
|
const {colors, premiumUser} = state;
|
||||||
const [fullscreen, setFullscreen] = useState(false);
|
const [fullscreen, setFullscreen] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let c = {...colors};
|
||||||
|
c.factor = normalize(1);
|
||||||
|
post('theme', colors);
|
||||||
|
}, [colors.bg]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!DDS.isTab) return;
|
||||||
|
if (noMenu) {
|
||||||
|
post('nomenu', true);
|
||||||
|
} else {
|
||||||
|
post('nomenu', false);
|
||||||
|
}
|
||||||
|
}, [noMenu]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let c = {...colors};
|
eSubscribeEvent(eOnLoadNote, load);
|
||||||
c.factor = normalize(1);
|
eSubscribeEvent(eCloseFullscreenEditor, closeFullscreen);
|
||||||
post('theme', colors);
|
eSubscribeEvent(eClearEditor, onCallClear);
|
||||||
}, [colors.bg]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
return () => {
|
||||||
if (!DDS.isTab) return;
|
eUnSubscribeEvent(eClearEditor, onCallClear);
|
||||||
if (noMenu) {
|
eUnSubscribeEvent(eCloseFullscreenEditor, closeFullscreen);
|
||||||
post('nomenu', true);
|
eUnSubscribeEvent(eOnLoadNote, load);
|
||||||
} else {
|
|
||||||
post('nomenu', false);
|
|
||||||
}
|
|
||||||
}, [noMenu]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
eSubscribeEvent(eOnLoadNote, load);
|
|
||||||
eSubscribeEvent(eCloseFullscreenEditor, closeFullscreen);
|
|
||||||
eSubscribeEvent(eClearEditor, onCallClear);
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
eUnSubscribeEvent(eClearEditor, onCallClear);
|
|
||||||
eUnSubscribeEvent(eCloseFullscreenEditor, closeFullscreen);
|
|
||||||
eUnSubscribeEvent(eOnLoadNote, load);
|
|
||||||
|
|
||||||
};
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!noMenu && DDS.isTab) {
|
|
||||||
handleBack = BackHandler.addEventListener('hardwareBackPress', () => {
|
|
||||||
simpleDialogEvent(TEMPLATE_EXIT_FULLSCREEN());
|
|
||||||
editing.isFullscreen = false;
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
clearTimer();
|
|
||||||
if (handleBack) {
|
|
||||||
handleBack.remove();
|
|
||||||
handleBack = null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}, [noMenu]);
|
|
||||||
|
|
||||||
const load = async (item) => {
|
|
||||||
Keyboard.addListener("keyboardDidShow",() => {
|
|
||||||
post("keyboard")
|
|
||||||
})
|
|
||||||
await loadNote(item);
|
|
||||||
if (item.type === 'new') {
|
|
||||||
textInput.current?.focus();
|
|
||||||
post('focusTitle');
|
|
||||||
Platform.OS === 'android' ? EditorWebView.current?.requestFocus() : null;
|
|
||||||
}
|
|
||||||
if (!DDS.isTab) {
|
|
||||||
handleBack = BackHandler.addEventListener(
|
|
||||||
'hardwareBackPress',
|
|
||||||
_onHardwareBackPress,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
const onCallClear = async () => {
|
useEffect(() => {
|
||||||
if (editing.currentlyEditing) {
|
if (!noMenu && DDS.isTab) {
|
||||||
exitEditorAnimation();
|
handleBack = BackHandler.addEventListener('hardwareBackPress', () => {
|
||||||
}
|
simpleDialogEvent(TEMPLATE_EXIT_FULLSCREEN());
|
||||||
await clearEditor();
|
editing.isFullscreen = false;
|
||||||
};
|
return true;
|
||||||
const closeFullscreen = () => {
|
});
|
||||||
setFullscreen(false);
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
clearTimer();
|
||||||
|
if (handleBack) {
|
||||||
|
handleBack.remove();
|
||||||
|
handleBack = null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
}, [noMenu]);
|
||||||
|
|
||||||
useEffect(() => {
|
const load = async (item) => {
|
||||||
EditorWebView.current?.reload();
|
Keyboard.addListener('keyboardDidShow', () => {
|
||||||
}, [premiumUser]);
|
post('keyboard');
|
||||||
|
});
|
||||||
|
await loadNote(item);
|
||||||
|
if (item.type === 'new') {
|
||||||
|
textInput.current?.focus();
|
||||||
|
post('focusTitle');
|
||||||
|
Platform.OS === 'android' ? EditorWebView.current?.requestFocus() : null;
|
||||||
|
}
|
||||||
|
if (!DDS.isTab) {
|
||||||
|
handleBack = BackHandler.addEventListener(
|
||||||
|
'hardwareBackPress',
|
||||||
|
_onHardwareBackPress,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const _onHardwareBackPress = async () => {
|
const onCallClear = async () => {
|
||||||
if (editing.currentlyEditing) {
|
if (editing.currentlyEditing) {
|
||||||
if (tapCount > 0) {
|
exitEditorAnimation();
|
||||||
await _onBackPress();
|
}
|
||||||
return true;
|
await clearEditor();
|
||||||
} else {
|
};
|
||||||
tapCount = 1;
|
const closeFullscreen = () => {
|
||||||
setTimeout(() => {
|
setFullscreen(false);
|
||||||
tapCount = 0;
|
};
|
||||||
}, 3000);
|
|
||||||
ToastEvent.show('Press back again to exit editor', 'success');
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const _onBackPress = async () => {
|
useEffect(() => {
|
||||||
editing.currentlyEditing = true;
|
EditorWebView.current?.reload();
|
||||||
if (DDS.isTab && !DDS.isSmallTab) {
|
}, [premiumUser]);
|
||||||
simpleDialogEvent(TEMPLATE_EXIT_FULLSCREEN());
|
|
||||||
} else {
|
|
||||||
exitEditorAnimation();
|
|
||||||
|
|
||||||
if (checkNote() && isNotedEdited()) {
|
const _onHardwareBackPress = async () => {
|
||||||
ToastEvent.show('Note Saved!', 'success');
|
if (editing.currentlyEditing) {
|
||||||
}
|
if (tapCount > 0) {
|
||||||
await clearEditor();
|
await _onBackPress();
|
||||||
Keyboard.removeListener("keyboardDidShow",() => {
|
return true;
|
||||||
post("keyboard")
|
} else {
|
||||||
})
|
tapCount = 1;
|
||||||
if (handleBack) {
|
setTimeout(() => {
|
||||||
handleBack.remove();
|
tapCount = 0;
|
||||||
handleBack = null;
|
}, 3000);
|
||||||
}
|
ToastEvent.show('Press back again to exit editor', 'success');
|
||||||
}
|
return true;
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
const _onBackPress = async () => {
|
||||||
<>
|
editing.currentlyEditing = true;
|
||||||
{noMenu || DDS.isPhone || DDS.isSmallTab ? (
|
if (DDS.isTab && !DDS.isSmallTab) {
|
||||||
<View />
|
simpleDialogEvent(TEMPLATE_EXIT_FULLSCREEN());
|
||||||
) : (
|
} else {
|
||||||
<ActionIcon
|
exitEditorAnimation();
|
||||||
name="arrow-left"
|
eSendEvent('historyEvent', {
|
||||||
color={colors.heading}
|
undo: 0,
|
||||||
onPress={_onBackPress}
|
redo: 0,
|
||||||
bottom={5}
|
});
|
||||||
iconStyle={{
|
|
||||||
textAlignVertical: 'center',
|
|
||||||
}}
|
|
||||||
customStyle={{
|
|
||||||
marginLeft: -5,
|
|
||||||
position: 'absolute',
|
|
||||||
marginTop:
|
|
||||||
Platform.OS === 'ios' ? 0 : StatusBar.currentHeight + 5,
|
|
||||||
zIndex: 11,
|
|
||||||
left: 0,
|
|
||||||
justifyContent: 'center',
|
|
||||||
alignItems: 'center',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<View
|
if (checkNote() && isNotedEdited()) {
|
||||||
style={{
|
ToastEvent.show('Note Saved!', 'success');
|
||||||
flexDirection: 'row',
|
}
|
||||||
width: DDS.isTab && !DDS.isSmallTab ? '30%' : '100%',
|
await clearEditor();
|
||||||
height: 50,
|
Keyboard.removeListener('keyboardDidShow', () => {
|
||||||
justifyContent: 'space-between',
|
post('keyboard');
|
||||||
alignItems: 'center',
|
});
|
||||||
paddingHorizontal: 12,
|
if (handleBack) {
|
||||||
position: DDS.isTab && !DDS.isSmallTab ? 'absolute' : 'relative',
|
handleBack.remove();
|
||||||
backgroundColor: colors.bg,
|
handleBack = null;
|
||||||
right: 0,
|
}
|
||||||
marginTop: Platform.OS === 'ios' ? 0 : StatusBar.currentHeight,
|
}
|
||||||
zIndex: 10,
|
};
|
||||||
}}>
|
|
||||||
{DDS.isTab && !DDS.isSmallTab ? (
|
|
||||||
<View />
|
|
||||||
) : (
|
|
||||||
<ActionIcon
|
|
||||||
name="arrow-left"
|
|
||||||
color={colors.heading}
|
|
||||||
onPress={_onBackPress}
|
|
||||||
bottom={5}
|
|
||||||
customStyle={{
|
|
||||||
marginLeft: -5,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<View
|
return (
|
||||||
style={{
|
<>
|
||||||
flexDirection: 'row',
|
{noMenu || DDS.isPhone || DDS.isSmallTab ? (
|
||||||
}}>
|
<View />
|
||||||
<ActionIcon
|
) : (
|
||||||
name="plus"
|
<ActionIcon
|
||||||
color={colors.heading}
|
name="arrow-left"
|
||||||
customStyle={{
|
color={colors.heading}
|
||||||
marginLeft: 10,
|
onPress={_onBackPress}
|
||||||
}}
|
bottom={5}
|
||||||
onPress={() => {
|
iconStyle={{
|
||||||
simpleDialogEvent(TEMPLATE_NEW_NOTE);
|
textAlignVertical: 'center',
|
||||||
}}
|
}}
|
||||||
/>
|
customStyle={{
|
||||||
{DDS.isTab && !DDS.isSmallTab && !fullscreen ? (
|
marginLeft: -5,
|
||||||
<ActionIcon
|
position: 'absolute',
|
||||||
name="fullscreen"
|
marginTop: Platform.OS === 'ios' ? 0 : StatusBar.currentHeight + 5,
|
||||||
color={colors.heading}
|
zIndex: 11,
|
||||||
customStyle={{
|
left: 0,
|
||||||
marginLeft: 10,
|
justifyContent: 'center',
|
||||||
}}
|
alignItems: 'center',
|
||||||
onPress={() => {
|
}}
|
||||||
eSendEvent(eOpenFullscreenEditor);
|
/>
|
||||||
setFullscreen(true);
|
)}
|
||||||
editing.isFullscreen = true;
|
|
||||||
post(
|
|
||||||
JSON.stringify({
|
|
||||||
type: 'nomenu',
|
|
||||||
value: false,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
) : null}
|
|
||||||
|
|
||||||
<HistoryComponent/>
|
<View
|
||||||
|
style={{
|
||||||
|
flexDirection: 'row',
|
||||||
|
width: DDS.isTab && !DDS.isSmallTab ? '30%' : '100%',
|
||||||
|
height: 50,
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
alignItems: 'center',
|
||||||
|
paddingHorizontal: 12,
|
||||||
|
position: DDS.isTab && !DDS.isSmallTab ? 'absolute' : 'relative',
|
||||||
|
backgroundColor: colors.bg,
|
||||||
|
right: 0,
|
||||||
|
marginTop: Platform.OS === 'ios' ? 0 : StatusBar.currentHeight,
|
||||||
|
zIndex: 10,
|
||||||
|
}}>
|
||||||
|
{DDS.isTab && !DDS.isSmallTab ? (
|
||||||
|
<View />
|
||||||
|
) : (
|
||||||
|
<ActionIcon
|
||||||
|
name="arrow-left"
|
||||||
|
color={colors.heading}
|
||||||
|
onPress={_onBackPress}
|
||||||
|
bottom={5}
|
||||||
|
customStyle={{
|
||||||
|
marginLeft: -5,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
<ActionIcon
|
<View
|
||||||
name="dots-horizontal"
|
style={{
|
||||||
color={colors.heading}
|
flexDirection: 'row',
|
||||||
customStyle={{
|
}}>
|
||||||
marginLeft: 10,
|
<ActionIcon
|
||||||
}}
|
name="plus"
|
||||||
onPress={() => {
|
color={colors.accent}
|
||||||
ActionSheetEvent(
|
customStyle={{
|
||||||
getNote(),
|
marginLeft: 10,
|
||||||
true,
|
borderRadius: 5,
|
||||||
true,
|
}}
|
||||||
['Add to', 'Share', 'Export', 'Delete'],
|
onPress={() => {
|
||||||
['Dark Mode', 'Add to Vault', 'Pin', 'Favorite'],
|
simpleDialogEvent(TEMPLATE_NEW_NOTE);
|
||||||
);
|
}}
|
||||||
}}
|
/>
|
||||||
/>
|
|
||||||
</View>
|
{DDS.isTab && !DDS.isSmallTab && !fullscreen ? (
|
||||||
</View></>
|
<ActionIcon
|
||||||
);
|
name="fullscreen"
|
||||||
|
color={colors.heading}
|
||||||
|
customStyle={{
|
||||||
|
marginLeft: 10,
|
||||||
|
}}
|
||||||
|
onPress={() => {
|
||||||
|
eSendEvent(eOpenFullscreenEditor);
|
||||||
|
setFullscreen(true);
|
||||||
|
editing.isFullscreen = true;
|
||||||
|
post(
|
||||||
|
JSON.stringify({
|
||||||
|
type: 'nomenu',
|
||||||
|
value: false,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
<HistoryComponent />
|
||||||
|
|
||||||
|
<ActionIcon
|
||||||
|
name="dots-horizontal"
|
||||||
|
color={colors.heading}
|
||||||
|
customStyle={{
|
||||||
|
marginLeft: 10,
|
||||||
|
}}
|
||||||
|
onPress={() => {
|
||||||
|
ActionSheetEvent(
|
||||||
|
getNote(),
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
['Add to', 'Share', 'Export', 'Delete'],
|
||||||
|
['Dark Mode', 'Add to Vault', 'Pin', 'Favorite'],
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default EditorHeader;
|
export default EditorHeader;
|
||||||
|
|||||||
@@ -166,6 +166,8 @@ export const _onMessage = async (evt) => {
|
|||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
timer = null;
|
timer = null;
|
||||||
if (message === 'loaded') {
|
if (message === 'loaded') {
|
||||||
|
} else if (JSON.parse(message).type === 'history') {
|
||||||
|
eSendEvent('historyEvent', JSON.parse(message));
|
||||||
} else if (message !== '' && message !== 'loaded') {
|
} else if (message !== '' && message !== 'loaded') {
|
||||||
onChange(message);
|
onChange(message);
|
||||||
timer = setTimeout(() => {
|
timer = setTimeout(() => {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import React, {useState} from 'react';
|
import React, {useEffect, useState} from 'react';
|
||||||
import {ActionIcon} from '../../components/ActionIcon';
|
import {ActionIcon} from '../../components/ActionIcon';
|
||||||
import {useTracked} from '../../provider';
|
import {useTracked} from '../../provider';
|
||||||
|
import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager';
|
||||||
import {post,} from './Functions';
|
import {post,} from './Functions';
|
||||||
|
|
||||||
|
|
||||||
@@ -12,26 +13,42 @@ const HistoryComponent = () => {
|
|||||||
redo:0
|
redo:0
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const onHistoryChange = (data) => {
|
||||||
|
setHistoryState(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
eSubscribeEvent('historyEvent',onHistoryChange);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
eUnSubscribeEvent('historyEvent',onHistoryChange);
|
||||||
|
}
|
||||||
|
},[])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
name="undo-variant"
|
name="undo"
|
||||||
|
disabled={historyState.undo === 0}
|
||||||
color={colors.heading}
|
color={colors.heading}
|
||||||
customStyle={{
|
customStyle={{
|
||||||
marginLeft: 10,
|
marginLeft: 10,
|
||||||
}}
|
}}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
|
if (historyState.undo === 0) return;
|
||||||
post('undo');
|
post('undo');
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
name="redo-variant"
|
name="redo"
|
||||||
|
disabled={historyState.redo=== 0}
|
||||||
color={colors.heading}
|
color={colors.heading}
|
||||||
customStyle={{
|
customStyle={{
|
||||||
marginLeft: 10,
|
marginLeft: 10,
|
||||||
}}
|
}}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
|
if (historyState.redo === 0) return;
|
||||||
post('redo');
|
post('redo');
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user