mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 15:09:33 +01:00
replace icons with Pressable
This commit is contained in:
@@ -1,24 +1,37 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {Text, 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 {PressableButton} from '../PressableButton';
|
||||||
|
|
||||||
|
export const ActionIcon = ({
|
||||||
|
onPress,
|
||||||
|
name,
|
||||||
|
color,
|
||||||
|
customStyle,
|
||||||
|
size = SIZE.xxxl,
|
||||||
|
iconStyle={}
|
||||||
|
}) => {
|
||||||
|
const [state, dispatch] = useTracked();
|
||||||
|
const {colors} = state;
|
||||||
|
|
||||||
export const ActionIcon = ({onPress, name, color, customStyle}) => {
|
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity
|
<PressableButton
|
||||||
onPress={onPress}
|
onPress={onPress}
|
||||||
style={[
|
hitSlop={{top: 30, left: 30, right: 30, bottom: 30}}
|
||||||
{
|
color="transparent"
|
||||||
width: 50,
|
selectedColor={colors.nav}
|
||||||
|
alpha={!colors.night ? -0.02 : 0.02}
|
||||||
|
opacity={1}
|
||||||
|
customStyle={{
|
||||||
|
width: 40,
|
||||||
height: 40,
|
height: 40,
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'flex-end',
|
alignItems: 'center',
|
||||||
paddingRight: 12,
|
borderRadius:100,
|
||||||
zIndex: 800,
|
...customStyle,
|
||||||
},
|
}}>
|
||||||
customStyle,
|
<Icon name={name} style={iconStyle} color={color} size={size} />
|
||||||
]}>
|
</PressableButton>
|
||||||
<Icon name={name} color={color} size={SIZE.xxxl} />
|
|
||||||
</TouchableOpacity>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Dimensions, Text, TouchableOpacity, View } from 'react-native';
|
import {Dimensions, Text, TouchableOpacity, View} from 'react-native';
|
||||||
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
|
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
|
||||||
import { ph, SIZE, WEIGHT } from '../../common/common';
|
import {ph, SIZE, WEIGHT} from '../../common/common';
|
||||||
import { timeSince } from '../../utils/utils';
|
import {timeSince} from '../../utils/utils';
|
||||||
import { ActionSheetEvent } from '../DialogManager/recievers';
|
import {ActionIcon} from '../ActionIcon';
|
||||||
|
import {ActionSheetEvent} from '../DialogManager/recievers';
|
||||||
|
import {PressableButton} from '../PressableButton';
|
||||||
|
|
||||||
const w = Dimensions.get('window').width;
|
const w = Dimensions.get('window').width;
|
||||||
const h = Dimensions.get('window').height;
|
const h = Dimensions.get('window').height;
|
||||||
@@ -59,19 +61,19 @@ export default class NoteItem extends React.Component {
|
|||||||
justifyContent: 'flex-start',
|
justifyContent: 'flex-start',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
maxWidth: '100%',
|
width: '100%',
|
||||||
paddingRight: 6,
|
paddingRight: 6,
|
||||||
alignSelf: 'center',
|
alignSelf: 'center',
|
||||||
borderBottomWidth: 1,
|
borderBottomWidth: 1,
|
||||||
height: 100,
|
height: 100,
|
||||||
borderBottomColor:item.pinned? 'transparent': colors.nav,
|
borderBottomColor: item.pinned ? 'transparent' : colors.nav,
|
||||||
},
|
},
|
||||||
customStyle ? customStyle : {},
|
customStyle ? customStyle : {},
|
||||||
]}>
|
]}>
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
paddingLeft: 0,
|
paddingLeft: 0,
|
||||||
width: '95%',
|
width: '92%',
|
||||||
}}>
|
}}>
|
||||||
<Text
|
<Text
|
||||||
numberOfLines={1}
|
numberOfLines={1}
|
||||||
@@ -214,12 +216,10 @@ export default class NoteItem extends React.Component {
|
|||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<TouchableOpacity
|
<ActionIcon
|
||||||
style={{
|
color={colors.heading}
|
||||||
justifyContent: 'center',
|
name="dots-horizontal"
|
||||||
minHeight: 70,
|
size={SIZE.xl}
|
||||||
alignItems: 'center',
|
|
||||||
}}
|
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
ActionSheetEvent(
|
ActionSheetEvent(
|
||||||
item,
|
item,
|
||||||
@@ -230,9 +230,15 @@ export default class NoteItem extends React.Component {
|
|||||||
: ['Add to', 'Share', 'Export', 'Delete', 'Copy'],
|
: ['Add to', 'Share', 'Export', 'Delete', 'Copy'],
|
||||||
isTrash ? [] : ['Pin', 'Favorite', 'Add to Vault'],
|
isTrash ? [] : ['Pin', 'Favorite', 'Add to Vault'],
|
||||||
);
|
);
|
||||||
}}>
|
}}
|
||||||
<Icon name="dots-horizontal" size={SIZE.lg} color={colors.heading} />
|
customStyle={{
|
||||||
</TouchableOpacity>
|
justifyContent: 'center',
|
||||||
|
height: 35,
|
||||||
|
width: 35,
|
||||||
|
borderRadius: 100,
|
||||||
|
alignItems: 'center',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Text, TouchableOpacity, View } from 'react-native';
|
import {Text, TouchableOpacity, View} from 'react-native';
|
||||||
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
|
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 NavigationService from '../../services/NavigationService';
|
import NavigationService from '../../services/NavigationService';
|
||||||
import { ActionSheetEvent } from '../DialogManager/recievers';
|
import {ActionSheetEvent} from '../DialogManager/recievers';
|
||||||
import Seperator from '../Seperator';
|
import Seperator from '../Seperator';
|
||||||
|
|
||||||
export const NotebookItem = ({
|
export const NotebookItem = ({
|
||||||
@@ -30,7 +30,7 @@ export const NotebookItem = ({
|
|||||||
paddingRight: 6,
|
paddingRight: 6,
|
||||||
alignSelf: 'center',
|
alignSelf: 'center',
|
||||||
borderBottomWidth: 1,
|
borderBottomWidth: 1,
|
||||||
borderBottomColor:item.pinned? 'transparent': colors.nav,
|
borderBottomColor: item.pinned ? 'transparent' : colors.nav,
|
||||||
width: '100%',
|
width: '100%',
|
||||||
},
|
},
|
||||||
customStyle,
|
customStyle,
|
||||||
@@ -185,12 +185,10 @@ export const NotebookItem = ({
|
|||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
{item.title === 'General' && item.type === 'topic' ? null : (
|
{item.title === 'General' && item.type === 'topic' ? null : (
|
||||||
<TouchableOpacity
|
<ActionIcon
|
||||||
style={{
|
color={colors.heading}
|
||||||
justifyContent: 'center',
|
name="dots-horizontal"
|
||||||
minHeight: 70,
|
size={SIZE.xl}
|
||||||
alignItems: 'center',
|
|
||||||
}}
|
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
let rowItems = isTrash
|
let rowItems = isTrash
|
||||||
? ['Restore', 'Remove']
|
? ['Restore', 'Remove']
|
||||||
@@ -204,9 +202,15 @@ export const NotebookItem = ({
|
|||||||
ActionSheetEvent(item, false, false, rowItems, columnItems, {
|
ActionSheetEvent(item, false, false, rowItems, columnItems, {
|
||||||
notebookID: notebookID,
|
notebookID: notebookID,
|
||||||
});
|
});
|
||||||
}}>
|
}}
|
||||||
<Icon name="dots-horizontal" size={SIZE.lg} color={colors.heading} />
|
customStyle={{
|
||||||
</TouchableOpacity>
|
justifyContent: 'center',
|
||||||
|
height: 35,
|
||||||
|
width: 35,
|
||||||
|
borderRadius: 100,
|
||||||
|
alignItems: 'center',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -14,9 +14,11 @@ export const PressableButton = ({
|
|||||||
alpha = -0.1,
|
alpha = -0.1,
|
||||||
opacity = 1,
|
opacity = 1,
|
||||||
onLongPress,
|
onLongPress,
|
||||||
|
hitSlop
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<Pressable
|
<Pressable
|
||||||
|
hitSlop={hitSlop}
|
||||||
activeOpacity={opacity}
|
activeOpacity={opacity}
|
||||||
onPress={onPress}
|
onPress={onPress}
|
||||||
onLongPress={onLongPress}
|
onLongPress={onLongPress}
|
||||||
|
|||||||
@@ -1,12 +1,5 @@
|
|||||||
import React, {useEffect, useState} from 'react';
|
import React, {useEffect, useState} from 'react';
|
||||||
import {
|
import {Dimensions, Platform, RefreshControl, Text, View} from 'react-native';
|
||||||
Dimensions,
|
|
||||||
LayoutAnimation,
|
|
||||||
Platform,
|
|
||||||
RefreshControl,
|
|
||||||
Text,
|
|
||||||
View,
|
|
||||||
} from 'react-native';
|
|
||||||
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 {DataProvider, LayoutProvider, RecyclerListView} from 'recyclerlistview';
|
import {DataProvider, LayoutProvider, RecyclerListView} from 'recyclerlistview';
|
||||||
@@ -19,7 +12,7 @@ import {
|
|||||||
eOpenLoginDialog,
|
eOpenLoginDialog,
|
||||||
eScrollEvent,
|
eScrollEvent,
|
||||||
} from '../../services/events';
|
} from '../../services/events';
|
||||||
import {db, hexToRGBA, RGB_Linear_Shade, ToastEvent} from '../../utils/utils';
|
import {db, ToastEvent} from '../../utils/utils';
|
||||||
import {PressableButton} from '../PressableButton';
|
import {PressableButton} from '../PressableButton';
|
||||||
let {width, height} = Dimensions.get('window');
|
let {width, height} = Dimensions.get('window');
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import React, { createRef } from 'react';
|
import React, {createRef} from 'react';
|
||||||
import { TouchableOpacity } from 'react-native';
|
import {TouchableOpacity} from 'react-native';
|
||||||
import Menu, { MenuDivider, MenuItem } from 'react-native-material-menu';
|
import Menu, {MenuDivider, MenuItem} from 'react-native-material-menu';
|
||||||
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 {ActionIcon} from '../ActionIcon';
|
||||||
const menuRef = createRef();
|
const menuRef = createRef();
|
||||||
export const HeaderMenu = () => {
|
export const HeaderMenu = () => {
|
||||||
const [state, dispatch] = useTracked();
|
const [state, dispatch] = useTracked();
|
||||||
@@ -19,18 +20,23 @@ export const HeaderMenu = () => {
|
|||||||
backgroundColor: colors.bg,
|
backgroundColor: colors.bg,
|
||||||
}}
|
}}
|
||||||
button={
|
button={
|
||||||
<TouchableOpacity
|
<ActionIcon
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
menuRef.current?.show();
|
menuRef.current?.show();
|
||||||
}}
|
}}
|
||||||
style={{
|
name="dots-vertical"
|
||||||
|
size={SIZE.xl}
|
||||||
|
color={colors.pri}
|
||||||
|
customStyle={{
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'flex-end',
|
alignItems: 'flex-end',
|
||||||
height: 40,
|
height: 40,
|
||||||
width: 50,
|
width: 40,
|
||||||
}}>
|
marginLeft: 10,
|
||||||
<Icon name="dots-vertical" size={SIZE.xl} color={colors.heading} />
|
borderRadius: 100,
|
||||||
</TouchableOpacity>
|
backgroundColor: 'white',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
}>
|
}>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
textStyle={{
|
textStyle={{
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import NavigationService from '../../services/NavigationService';
|
|||||||
import {useHideHeader} from '../../utils/hooks';
|
import {useHideHeader} from '../../utils/hooks';
|
||||||
import {sideMenuRef} from '../../utils/refs';
|
import {sideMenuRef} from '../../utils/refs';
|
||||||
import {DDS, w} from '../../utils/utils';
|
import {DDS, w} from '../../utils/utils';
|
||||||
|
import {ActionIcon} from '../ActionIcon';
|
||||||
import {HeaderMenu} from './HeaderMenu';
|
import {HeaderMenu} from './HeaderMenu';
|
||||||
import {HeaderTitle} from './HeaderTitle';
|
import {HeaderTitle} from './HeaderTitle';
|
||||||
|
|
||||||
@@ -68,19 +69,16 @@ export const Header = ({showSearch, root}) => {
|
|||||||
|
|
||||||
<View style={styles.leftBtnContainer}>
|
<View style={styles.leftBtnContainer}>
|
||||||
{!DDS.isTab ? (
|
{!DDS.isTab ? (
|
||||||
<TouchableOpacity
|
<ActionIcon
|
||||||
hitSlop={{top: 20, bottom: 20, left: 50, right: 40}}
|
customStyle={styles.leftBtn}
|
||||||
onPress={onLeftButtonPress}
|
onPress={onLeftButtonPress}
|
||||||
style={styles.leftBtn}>
|
|
||||||
<Icon
|
|
||||||
style={{
|
|
||||||
marginLeft: headerState.canGoBack ? -5 : 0,
|
|
||||||
}}
|
|
||||||
color={colors.heading}
|
|
||||||
name={headerState.canGoBack ? 'arrow-left' : 'menu'}
|
name={headerState.canGoBack ? 'arrow-left' : 'menu'}
|
||||||
size={SIZE.xxxl}
|
size={SIZE.xxxl}
|
||||||
|
color={colors.pri}
|
||||||
|
iconStyle={{
|
||||||
|
marginLeft: headerState.canGoBack ? -5 : 0,
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</TouchableOpacity>
|
|
||||||
) : undefined}
|
) : undefined}
|
||||||
|
|
||||||
{Platform.OS === 'android' ? <HeaderTitle root={root} /> : null}
|
{Platform.OS === 'android' ? <HeaderTitle root={root} /> : null}
|
||||||
@@ -95,15 +93,17 @@ export const Header = ({showSearch, root}) => {
|
|||||||
style={{
|
style={{
|
||||||
opacity: hideHeader ? 1 : 0,
|
opacity: hideHeader ? 1 : 0,
|
||||||
}}>
|
}}>
|
||||||
<TouchableOpacity
|
<ActionIcon
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
if (!hideHeader) return;
|
if (!hideHeader) return;
|
||||||
setHideHeader(false);
|
setHideHeader(false);
|
||||||
eSendEvent('showSearch');
|
eSendEvent('showSearch');
|
||||||
}}
|
}}
|
||||||
style={styles.rightBtn}>
|
name="magnify"
|
||||||
<Icon name={'magnify'} size={SIZE.xl} color={colors.pri} />
|
size={SIZE.xl}
|
||||||
</TouchableOpacity>
|
color={colors.pri}
|
||||||
|
style={styles.rightBtn}
|
||||||
|
/>
|
||||||
</Animatable.View>
|
</Animatable.View>
|
||||||
|
|
||||||
<HeaderMenu />
|
<HeaderMenu />
|
||||||
@@ -150,9 +150,12 @@ const styles = StyleSheet.create({
|
|||||||
},
|
},
|
||||||
leftBtn: {
|
leftBtn: {
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'flex-start',
|
alignItems: 'center',
|
||||||
height: 40,
|
height: 40,
|
||||||
width: 60,
|
width: 40,
|
||||||
|
borderRadius: 100,
|
||||||
|
marginLeft: -5,
|
||||||
|
marginRight: 25,
|
||||||
},
|
},
|
||||||
rightBtnContainer: {
|
rightBtnContainer: {
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
|
|||||||
@@ -174,6 +174,7 @@ const Editor = ({noMenu}) => {
|
|||||||
height: 50,
|
height: 50,
|
||||||
justifyContent: 'space-between',
|
justifyContent: 'space-between',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
|
paddingHorizontal: 12,
|
||||||
}}>
|
}}>
|
||||||
{noMenu ? null : (
|
{noMenu ? null : (
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
@@ -182,7 +183,6 @@ const Editor = ({noMenu}) => {
|
|||||||
onPress={_onBackPress}
|
onPress={_onBackPress}
|
||||||
customStyle={{
|
customStyle={{
|
||||||
marginLeft: -5,
|
marginLeft: -5,
|
||||||
paddingLeft: 12,
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -194,6 +194,9 @@ const Editor = ({noMenu}) => {
|
|||||||
<ActionIcon
|
<ActionIcon
|
||||||
name="plus"
|
name="plus"
|
||||||
color={colors.heading}
|
color={colors.heading}
|
||||||
|
customStyle={{
|
||||||
|
marginLeft: 10,
|
||||||
|
}}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
simpleDialogEvent(TEMPLATE_NEW_NOTE);
|
simpleDialogEvent(TEMPLATE_NEW_NOTE);
|
||||||
}}
|
}}
|
||||||
@@ -202,6 +205,9 @@ const Editor = ({noMenu}) => {
|
|||||||
<ActionIcon
|
<ActionIcon
|
||||||
name="fullscreen"
|
name="fullscreen"
|
||||||
color={colors.heading}
|
color={colors.heading}
|
||||||
|
customStyle={{
|
||||||
|
marginLeft: 10,
|
||||||
|
}}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
eSendEvent(eOpenFullscreenEditor);
|
eSendEvent(eOpenFullscreenEditor);
|
||||||
setFullscreen(true);
|
setFullscreen(true);
|
||||||
@@ -219,6 +225,9 @@ const Editor = ({noMenu}) => {
|
|||||||
<ActionIcon
|
<ActionIcon
|
||||||
name="undo-variant"
|
name="undo-variant"
|
||||||
color={colors.heading}
|
color={colors.heading}
|
||||||
|
customStyle={{
|
||||||
|
marginLeft: 10,
|
||||||
|
}}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
post('undo');
|
post('undo');
|
||||||
}}
|
}}
|
||||||
@@ -226,6 +235,9 @@ const Editor = ({noMenu}) => {
|
|||||||
<ActionIcon
|
<ActionIcon
|
||||||
name="redo-variant"
|
name="redo-variant"
|
||||||
color={colors.heading}
|
color={colors.heading}
|
||||||
|
customStyle={{
|
||||||
|
marginLeft: 10,
|
||||||
|
}}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
post('redo');
|
post('redo');
|
||||||
}}
|
}}
|
||||||
@@ -234,6 +246,9 @@ const Editor = ({noMenu}) => {
|
|||||||
<ActionIcon
|
<ActionIcon
|
||||||
name="dots-horizontal"
|
name="dots-horizontal"
|
||||||
color={colors.heading}
|
color={colors.heading}
|
||||||
|
customStyle={{
|
||||||
|
marginLeft: 10,
|
||||||
|
}}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
ActionSheetEvent(
|
ActionSheetEvent(
|
||||||
getNote(),
|
getNote(),
|
||||||
|
|||||||
Reference in New Issue
Block a user