mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 06:59:31 +01:00
refactor Pressable Button
This commit is contained in:
@@ -27,15 +27,11 @@ export const ActionIcon = ({
|
|||||||
testID={testID}
|
testID={testID}
|
||||||
onPress={onPress}
|
onPress={onPress}
|
||||||
hitSlop={{top: top, left: left, right: right, bottom: bottom}}
|
hitSlop={{top: top, left: left, right: right, bottom: bottom}}
|
||||||
color="transparent"
|
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
selectedColor={colors.nav}
|
type="gray"
|
||||||
alpha={!colors.night ? -0.02 : 0.02}
|
|
||||||
opacity={1}
|
|
||||||
customStyle={{
|
customStyle={{
|
||||||
width: 40,
|
width: 40,
|
||||||
height: 40,
|
height: 40,
|
||||||
backgroundColor: disabled ? colors.bg : null,
|
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
borderRadius: 100,
|
borderRadius: 100,
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ export default class ActionSheet extends Component {
|
|||||||
this.isRecoiling = false;
|
this.isRecoiling = false;
|
||||||
this.targetId = null;
|
this.targetId = null;
|
||||||
this.offsetY = 0;
|
this.offsetY = 0;
|
||||||
|
this.borderRadius = new Animated.Value(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
waitAsync = (ms) =>
|
waitAsync = (ms) =>
|
||||||
@@ -574,6 +575,8 @@ export default class ActionSheet extends Component {
|
|||||||
translateY: this.transformValue,
|
translateY: this.transformValue,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
borderTopRightRadius:this.borderRadius,
|
||||||
|
borderTopLeftRadius:this.borderRadius
|
||||||
},
|
},
|
||||||
]}>
|
]}>
|
||||||
{gestureEnabled || headerAlwaysVisible ? (
|
{gestureEnabled || headerAlwaysVisible ? (
|
||||||
|
|||||||
@@ -43,13 +43,9 @@ export const ActionSheetColorsSection = ({item,close}) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<PressableButton
|
<PressableButton
|
||||||
color={RGB_Linear_Shade(
|
type="accent"
|
||||||
!colors.night ? -0.2 : 0.2,
|
accentColor={color.name.toLowerCase()}
|
||||||
hexToRGBA(color.value, 1),
|
testID={'icon-color-' + c}
|
||||||
)}
|
|
||||||
selectedColor={color.value}
|
|
||||||
alpha={!colors.night ? -0.1 : 0.1}
|
|
||||||
opacity={1}
|
|
||||||
key={color.value}
|
key={color.value}
|
||||||
onPress={async () => {
|
onPress={async () => {
|
||||||
await PremiumService.verify(async () => {
|
await PremiumService.verify(async () => {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import {Keyboard, Platform, View} from 'react-native';
|
|||||||
import Animated, {Easing} from 'react-native-reanimated';
|
import Animated, {Easing} 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 {notesnook} from '../../../e2e/test.ids';
|
||||||
import {useTracked} from '../../provider';
|
import {useTracked} from '../../provider';
|
||||||
import {DDS} from '../../services/DeviceDetection';
|
import {DDS} from '../../services/DeviceDetection';
|
||||||
import {getElevation, showContext} from '../../utils';
|
import {getElevation, showContext} from '../../utils';
|
||||||
@@ -10,7 +11,12 @@ import {normalize, SIZE} from '../../utils/SizeUtils';
|
|||||||
import {PressableButton} from '../PressableButton';
|
import {PressableButton} from '../PressableButton';
|
||||||
|
|
||||||
const translateY = new Animated.Value(0);
|
const translateY = new Animated.Value(0);
|
||||||
export const ContainerBottomButton = ({title, onPress, color,shouldShow =false}) => {
|
export const ContainerBottomButton = ({
|
||||||
|
title,
|
||||||
|
onPress,
|
||||||
|
color = 'accent',
|
||||||
|
shouldShow = false,
|
||||||
|
}) => {
|
||||||
const [state] = useTracked();
|
const [state] = useTracked();
|
||||||
const {colors} = state;
|
const {colors} = state;
|
||||||
const insets = useSafeAreaInsets();
|
const insets = useSafeAreaInsets();
|
||||||
@@ -59,9 +65,10 @@ export const ContainerBottomButton = ({title, onPress, color,shouldShow =false})
|
|||||||
],
|
],
|
||||||
}}>
|
}}>
|
||||||
<PressableButton
|
<PressableButton
|
||||||
testID={'container_bottom_btn'}
|
testID={notesnook.ids.default.addBtn}
|
||||||
color={color || colors.accent}
|
type="accent"
|
||||||
selectedColor={color || colors.accent}
|
accentColor={color || 'accent'}
|
||||||
|
accentText="light"
|
||||||
customStyle={{
|
customStyle={{
|
||||||
...getElevation(5),
|
...getElevation(5),
|
||||||
borderRadius: 100,
|
borderRadius: 100,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React, {Component} from 'react';
|
import React, {Component} from 'react';
|
||||||
import {Platform} from 'react-native';
|
import {Dimensions, Platform} from 'react-native';
|
||||||
import {
|
import {
|
||||||
eSendEvent,
|
eSendEvent,
|
||||||
eSubscribeEvent,
|
eSubscribeEvent,
|
||||||
@@ -48,6 +48,7 @@ import SortDialog from '../SortDialog';
|
|||||||
import JumpToDialog from '../JumpToDialog';
|
import JumpToDialog from '../JumpToDialog';
|
||||||
import {GetPremium, translatePrem} from '../ActionSheetComponent/GetPremium';
|
import {GetPremium, translatePrem} from '../ActionSheetComponent/GetPremium';
|
||||||
import {sleep} from '../../utils/TimeUtils';
|
import {sleep} from '../../utils/TimeUtils';
|
||||||
|
import { dHeight } from '../../utils';
|
||||||
|
|
||||||
export class DialogManager extends Component {
|
export class DialogManager extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -95,12 +96,7 @@ export class DialogManager extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
_hideActionSheet = () => {
|
_hideActionSheet = () => {
|
||||||
this.actionSheet._setModalVisible();
|
this.actionSheet._setModalVisible(false);
|
||||||
sleep(200).then(() => {
|
|
||||||
this.setState({
|
|
||||||
actionSheetVisible: false,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
_showMoveNote = () => {
|
_showMoveNote = () => {
|
||||||
@@ -313,10 +309,12 @@ export class DialogManager extends Component {
|
|||||||
ref={(ref) => (this.actionSheet = ref)}
|
ref={(ref) => (this.actionSheet = ref)}
|
||||||
containerStyle={{
|
containerStyle={{
|
||||||
backgroundColor: colors.bg,
|
backgroundColor: colors.bg,
|
||||||
width: DDS.isTab ? 500 : '100%',
|
width: DDS.isLargeTablet() ? 500 : '100%',
|
||||||
alignSelf: 'center',
|
alignSelf: 'center',
|
||||||
borderRadius: 10,
|
borderRadius: 10,
|
||||||
marginBottom: DDS.isTab ? 50 : 0,
|
marginBottom: DDS.isLargeTablet() ? 50 : 0,
|
||||||
|
borderBottomRightRadius: DDS.isLargeTablet() ? 10 : 1,
|
||||||
|
borderBottomLeftRadius: DDS.isLargeTablet() ? 10 : 1,
|
||||||
}}
|
}}
|
||||||
extraScroll={DDS.isTab ? 50 : 0}
|
extraScroll={DDS.isTab ? 50 : 0}
|
||||||
indicatorColor={
|
indicatorColor={
|
||||||
@@ -350,6 +348,9 @@ export class DialogManager extends Component {
|
|||||||
onClose={() => {
|
onClose={() => {
|
||||||
translatePrem.setValue(-800);
|
translatePrem.setValue(-800);
|
||||||
this.onActionSheetHide();
|
this.onActionSheetHide();
|
||||||
|
this.setState({
|
||||||
|
actionSheetVisible: false,
|
||||||
|
});
|
||||||
}}>
|
}}>
|
||||||
<ActionSheetComponent
|
<ActionSheetComponent
|
||||||
item={item}
|
item={item}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export const HeaderRightMenu = () => {
|
|||||||
<ActionIcon
|
<ActionIcon
|
||||||
onPress={async () => {
|
onPress={async () => {
|
||||||
Navigation.navigate('Search', {
|
Navigation.navigate('Search', {
|
||||||
menu:false
|
menu: false,
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
name="magnify"
|
name="magnify"
|
||||||
@@ -99,9 +99,10 @@ const styles = StyleSheet.create({
|
|||||||
},
|
},
|
||||||
rightBtn: {
|
rightBtn: {
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'flex-end',
|
alignItems: 'center',
|
||||||
height: 40,
|
height: 40,
|
||||||
width: 50,
|
width: 40,
|
||||||
|
marginLeft: 10,
|
||||||
paddingRight: 0,
|
paddingRight: 0,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -128,12 +128,7 @@ const JumpToDialog = () => {
|
|||||||
<PressableButton
|
<PressableButton
|
||||||
key={item.title}
|
key={item.title}
|
||||||
onPress={() => onPress(item, index)}
|
onPress={() => onPress(item, index)}
|
||||||
color={currentIndex === index ? colors.shade : 'transparent'}
|
type={currentIndex === index? 'shade' : 'gray'}
|
||||||
selectedColor={
|
|
||||||
currentIndex === index ? colors.accent : colors.nav
|
|
||||||
}
|
|
||||||
alpha={!colors.night ? -0.02 : 0.02}
|
|
||||||
opacity={currentIndex === index ? 0.12 : 1}
|
|
||||||
customStyle={{
|
customStyle={{
|
||||||
minWidth: '20%',
|
minWidth: '20%',
|
||||||
maxWidth: '46%',
|
maxWidth: '46%',
|
||||||
|
|||||||
@@ -73,12 +73,12 @@ const ColorItem = ({item, index}) => {
|
|||||||
return (
|
return (
|
||||||
<PressableButton
|
<PressableButton
|
||||||
key={item.id}
|
key={item.id}
|
||||||
color={
|
customColor={
|
||||||
headerTextState?.id === item.id && item.type === headerTextState?.type
|
headerTextState?.id === item.id && item.type === headerTextState?.type
|
||||||
? COLORS_NOTE[item.title]
|
? COLORS_NOTE[item.title]
|
||||||
: 'transparent'
|
: 'transparent'
|
||||||
}
|
}
|
||||||
selectedColor={COLORS_NOTE[item.title]}
|
customSelectedColor={COLORS_NOTE[item.title]}
|
||||||
alpha={!colors.night ? -0.02 : 0.02}
|
alpha={!colors.night ? -0.02 : 0.02}
|
||||||
opacity={0.12}
|
opacity={0.12}
|
||||||
onPress={() => onPress(item)}
|
onPress={() => onPress(item)}
|
||||||
|
|||||||
@@ -53,14 +53,11 @@ export const MenuListItem = ({item, index, noTextMode, testID}) => {
|
|||||||
testID={testID}
|
testID={testID}
|
||||||
key={item.name + index}
|
key={item.name + index}
|
||||||
onPress={_onPress}
|
onPress={_onPress}
|
||||||
color={
|
type={
|
||||||
headerTextState?.id === item.name.toLowerCase() + '_navigation'
|
headerTextState?.id === item.name.toLowerCase() + '_navigation'
|
||||||
? colors.shade
|
? 'shade'
|
||||||
: 'transparent'
|
: 'transparent'
|
||||||
}
|
}
|
||||||
selectedColor={colors.accent}
|
|
||||||
alpha={!colors.night ? -0.02 : 0.02}
|
|
||||||
opacity={0.12}
|
|
||||||
customStyle={{
|
customStyle={{
|
||||||
width: noTextMode ? 50 : '100%',
|
width: noTextMode ? 50 : '100%',
|
||||||
alignSelf: 'center',
|
alignSelf: 'center',
|
||||||
|
|||||||
@@ -4,7 +4,11 @@ import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
|
|||||||
import {useTracked} from '../../provider';
|
import {useTracked} from '../../provider';
|
||||||
import {Actions} from '../../provider/Actions';
|
import {Actions} from '../../provider/Actions';
|
||||||
import {DDS} from '../../services/DeviceDetection';
|
import {DDS} from '../../services/DeviceDetection';
|
||||||
import {eSendEvent, eSubscribeEvent, eUnSubscribeEvent} from '../../services/EventManager';
|
import {
|
||||||
|
eSendEvent,
|
||||||
|
eSubscribeEvent,
|
||||||
|
eUnSubscribeEvent,
|
||||||
|
} from '../../services/EventManager';
|
||||||
import Navigation from '../../services/Navigation';
|
import Navigation from '../../services/Navigation';
|
||||||
import {getElevation} from '../../utils';
|
import {getElevation} from '../../utils';
|
||||||
import {db} from '../../utils/DB';
|
import {db} from '../../utils/DB';
|
||||||
@@ -26,7 +30,6 @@ export const TagsSection = () => {
|
|||||||
dispatch({type: Actions.MENU_PINS});
|
dispatch({type: Actions.MENU_PINS});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
||||||
const onPress = (item) => {
|
const onPress = (item) => {
|
||||||
let params;
|
let params;
|
||||||
if (item.type === 'notebook') {
|
if (item.type === 'notebook') {
|
||||||
@@ -42,7 +45,6 @@ export const TagsSection = () => {
|
|||||||
type: item.type,
|
type: item.type,
|
||||||
});
|
});
|
||||||
rootNavigatorRef.current?.setParams(params);
|
rootNavigatorRef.current?.setParams(params);
|
||||||
|
|
||||||
} else if (item.type === 'tag') {
|
} else if (item.type === 'tag') {
|
||||||
params = params = {
|
params = params = {
|
||||||
title: item.title,
|
title: item.title,
|
||||||
@@ -118,8 +120,6 @@ const PinItem = ({item, index, onPress}) => {
|
|||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
const [headerTextState, setHeaderTextState] = useState(null);
|
const [headerTextState, setHeaderTextState] = useState(null);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const onHeaderStateChange = (event) => {
|
const onHeaderStateChange = (event) => {
|
||||||
if (event?.id === item.name) {
|
if (event?.id === item.name) {
|
||||||
setHeaderTextState(event);
|
setHeaderTextState(event);
|
||||||
@@ -162,14 +162,11 @@ const PinItem = ({item, index, onPress}) => {
|
|||||||
</BaseDialog>
|
</BaseDialog>
|
||||||
)}
|
)}
|
||||||
<PressableButton
|
<PressableButton
|
||||||
color={
|
type={
|
||||||
headerTextState?.id === item.id && headerTextState?.type === item.type
|
headerTextState?.id === item.id && headerTextState?.type === item.type
|
||||||
? colors.shade
|
? 'shade'
|
||||||
: 'transparent'
|
: 'transparent'
|
||||||
}
|
}
|
||||||
selectedColor={colors.accent}
|
|
||||||
alpha={!colors.night ? -0.02 : 0.02}
|
|
||||||
opacity={0.12}
|
|
||||||
onLongPress={() => setVisible(true)}
|
onLongPress={() => setVisible(true)}
|
||||||
onPress={() => onPress(item)}
|
onPress={() => onPress(item)}
|
||||||
customStyle={{
|
customStyle={{
|
||||||
@@ -226,53 +223,4 @@ const PinItem = ({item, index, onPress}) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
{tags
|
|
||||||
.filter((o) => o.noteIds.length > 1)
|
|
||||||
.slice(0, tags.length > 10 ? 10 : tags.length)
|
|
||||||
.map((item) => (
|
|
||||||
<PressableButton
|
|
||||||
key={item.id}
|
|
||||||
color={
|
|
||||||
currentScreen === item.title.toLowerCase()
|
|
||||||
? colors.shade
|
|
||||||
: 'transparent'
|
|
||||||
}
|
|
||||||
selectedColor={colors.accent}
|
|
||||||
alpha={!colors.night ? -0.02 : 0.02}
|
|
||||||
opacity={0.12}
|
|
||||||
onPress={() => onPress(item)}
|
|
||||||
customStyle={{
|
|
||||||
flexDirection: 'row',
|
|
||||||
justifyContent: 'flex-start',
|
|
||||||
alignItems: 'center',
|
|
||||||
width: '100%',
|
|
||||||
borderRadius: 0,
|
|
||||||
paddingHorizontal: 10,
|
|
||||||
height: 50,
|
|
||||||
}}>
|
|
||||||
<View
|
|
||||||
style={{
|
|
||||||
width: 35,
|
|
||||||
height: 35,
|
|
||||||
justifyContent: 'center',
|
|
||||||
alignItems: 'flex-start',
|
|
||||||
}}>
|
|
||||||
<Paragraph color={colors.accent} size={SIZE.md}>
|
|
||||||
#
|
|
||||||
</Paragraph>
|
|
||||||
</View>
|
|
||||||
<View
|
|
||||||
style={{
|
|
||||||
flexDirection: 'row',
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
alignItems: 'center',
|
|
||||||
width: '85%',
|
|
||||||
}}>
|
|
||||||
<Paragraph color={colors.heading}>{item.title}</Paragraph>
|
|
||||||
|
|
||||||
</View>
|
|
||||||
</PressableButton>
|
|
||||||
))}
|
|
||||||
*/
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import React, {useEffect, useState} from 'react';
|
import React, {useEffect, useState} from 'react';
|
||||||
import {timeSince} from "../../utils/TimeUtils";
|
import {timeSince} from '../../utils/TimeUtils';
|
||||||
import Paragraph from '../Typography/Paragraph';
|
import Paragraph from '../Typography/Paragraph';
|
||||||
|
|
||||||
export const TimeSince = ({time}) => {
|
export const TimeSince = ({time, style,updateFrequency=30000}) => {
|
||||||
const [timeAgo, setTimeAgo] = useState(null);
|
const [timeAgo, setTimeAgo] = useState(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -11,12 +11,12 @@ export const TimeSince = ({time}) => {
|
|||||||
let interval = setInterval(() => {
|
let interval = setInterval(() => {
|
||||||
t = timeSince(time);
|
t = timeSince(time);
|
||||||
setTimeAgo(t);
|
setTimeAgo(t);
|
||||||
}, 60000);
|
}, updateFrequency);
|
||||||
return () => {
|
return () => {
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
interval = null;
|
interval = null;
|
||||||
};
|
};
|
||||||
},[]);
|
}, [time,updateFrequency]);
|
||||||
|
|
||||||
return <Paragraph>{timeAgo}</Paragraph>;
|
return <Paragraph style={style}>{timeAgo}</Paragraph>;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -116,10 +116,7 @@ export const UserSection = ({noTextMode}) => {
|
|||||||
onPress={() => {
|
onPress={() => {
|
||||||
eSendEvent(eOpenLoginDialog);
|
eSendEvent(eOpenLoginDialog);
|
||||||
}}
|
}}
|
||||||
color={colors.accent}
|
type="shade"
|
||||||
selectedColor={colors.accent}
|
|
||||||
alpha={!colors.night ? -0.02 : 0.1}
|
|
||||||
opacity={0.12}
|
|
||||||
customStyle={{
|
customStyle={{
|
||||||
paddingVertical: 12,
|
paddingVertical: 12,
|
||||||
marginVertical: 5,
|
marginVertical: 5,
|
||||||
|
|||||||
@@ -224,12 +224,7 @@ const MoveNoteDialog = () => {
|
|||||||
onPress={() => {
|
onPress={() => {
|
||||||
setExpanded(item.id === expanded ? null : item.id);
|
setExpanded(item.id === expanded ? null : item.id);
|
||||||
}}
|
}}
|
||||||
color={expanded === item.id ? colors.shade : 'transparent'}
|
type={expanded === item.id ? 'shade' : 'transparent'}
|
||||||
selectedColor={
|
|
||||||
expanded === item.id ? colors.accent : colors.nav
|
|
||||||
}
|
|
||||||
alpha={colors.night ? 0.02 : -0.02}
|
|
||||||
opacity={expanded === item.id ? 0.12 : 1}
|
|
||||||
customStyle={{
|
customStyle={{
|
||||||
height: 50,
|
height: 50,
|
||||||
width: '100%',
|
width: '100%',
|
||||||
@@ -365,9 +360,7 @@ const MoveNoteDialog = () => {
|
|||||||
'success',
|
'success',
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
color="transparent"
|
type="gray"
|
||||||
selectedColor={colors.nav}
|
|
||||||
alpha={colors.night ? 0.02 : -0.02}
|
|
||||||
customStyle={{
|
customStyle={{
|
||||||
height: 50,
|
height: 50,
|
||||||
borderTopWidth: index === 0 ? 0 : 1,
|
borderTopWidth: index === 0 ? 0 : 1,
|
||||||
@@ -398,7 +391,7 @@ const MoveNoteDialog = () => {
|
|||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
paddingHorizontal: 12,
|
paddingHorizontal: 12,
|
||||||
width:"100%"
|
width: '100%',
|
||||||
}}>
|
}}>
|
||||||
<DialogButtons negativeTitle="Cancel" onPressNegative={close} />
|
<DialogButtons negativeTitle="Cancel" onPressNegative={close} />
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {TouchableOpacity, 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 {notesnook} from '../../../e2e/test.ids';
|
||||||
import {Actions} from '../../provider/Actions';
|
import {Actions} from '../../provider/Actions';
|
||||||
import Navigation from '../../services/Navigation';
|
import Navigation from '../../services/Navigation';
|
||||||
import {COLORS_NOTE} from '../../utils/Colors';
|
import {COLORS_NOTE} from '../../utils/Colors';
|
||||||
@@ -9,6 +10,7 @@ import { SIZE } from '../../utils/SizeUtils';
|
|||||||
import {timeSince} from '../../utils/TimeUtils';
|
import {timeSince} from '../../utils/TimeUtils';
|
||||||
import {ActionIcon} from '../ActionIcon';
|
import {ActionIcon} from '../ActionIcon';
|
||||||
import {ActionSheetEvent, updateEvent} from '../DialogManager/recievers';
|
import {ActionSheetEvent, updateEvent} from '../DialogManager/recievers';
|
||||||
|
import {TimeSince} from '../Menu/TimeSince';
|
||||||
import Heading from '../Typography/Heading';
|
import Heading from '../Typography/Heading';
|
||||||
import Paragraph from '../Typography/Paragraph';
|
import Paragraph from '../Typography/Paragraph';
|
||||||
|
|
||||||
@@ -191,15 +193,14 @@ export default class NoteItem extends React.Component {
|
|||||||
color="orange"
|
color="orange"
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
<Paragraph
|
|
||||||
color={colors.icon}
|
<TimeSince
|
||||||
size={SIZE.xs}
|
style={{fontSize: SIZE.xs, color: colors.icon}}
|
||||||
style={{
|
time={item.dateCreated}
|
||||||
textAlignVertical: 'center',
|
updateFrequency={
|
||||||
marginRight: 10,
|
Date.now() - item.dateCreated < 60000 ? 2000 : 60000
|
||||||
}}>
|
}
|
||||||
{timeSince(item.dateCreated)}
|
/>
|
||||||
</Paragraph>
|
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
@@ -253,6 +254,7 @@ export default class NoteItem extends React.Component {
|
|||||||
<ActionIcon
|
<ActionIcon
|
||||||
color={colors.heading}
|
color={colors.heading}
|
||||||
name="dots-horizontal"
|
name="dots-horizontal"
|
||||||
|
testID={notesnook.ids.note.menu}
|
||||||
size={SIZE.xl}
|
size={SIZE.xl}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
ActionSheetEvent(
|
ActionSheetEvent(
|
||||||
|
|||||||
@@ -26,16 +26,18 @@ export const PressableButton = ({
|
|||||||
noborder,
|
noborder,
|
||||||
accentColor = 'accent',
|
accentColor = 'accent',
|
||||||
accentText = 'light',
|
accentText = 'light',
|
||||||
|
customColor,
|
||||||
|
customSelectedColor
|
||||||
}) => {
|
}) => {
|
||||||
const [state] = useTracked();
|
const [state] = useTracked();
|
||||||
const {colors} = state;
|
const {colors} = state;
|
||||||
const selectedColor =
|
const selectedColor = customSelectedColor ||
|
||||||
colors[
|
colors[
|
||||||
type === 'accent'
|
type === 'accent'
|
||||||
? BUTTON_TYPES[type](accentColor, accentText).selected
|
? BUTTON_TYPES[type](accentColor, accentText).selected
|
||||||
: BUTTON_TYPES[type].selected
|
: BUTTON_TYPES[type].selected
|
||||||
];
|
];
|
||||||
const primaryColor =
|
const primaryColor = customColor ||
|
||||||
colors[
|
colors[
|
||||||
type === 'accent'
|
type === 'accent'
|
||||||
? BUTTON_TYPES[type](accentColor, accentText).primary
|
? BUTTON_TYPES[type](accentColor, accentText).primary
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ const SelectionWrapper = ({
|
|||||||
}
|
}
|
||||||
}, [selectedItemsList]);
|
}, [selectedItemsList]);
|
||||||
|
|
||||||
const onPressPin = async () => {
|
/* const onPressPin = async () => {
|
||||||
let func = async () => {
|
let func = async () => {
|
||||||
if (!item.id) return;
|
if (!item.id) return;
|
||||||
if (item.type === 'note') {
|
if (item.type === 'note') {
|
||||||
@@ -61,11 +61,11 @@ const SelectionWrapper = ({
|
|||||||
},
|
},
|
||||||
'Undo',
|
'Undo',
|
||||||
);
|
);
|
||||||
};
|
}; */
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PressableButton
|
<PressableButton
|
||||||
color={
|
customColor={
|
||||||
currentEditingNote === item.id
|
currentEditingNote === item.id
|
||||||
? item.type === 'note' && item.colors[0]
|
? item.type === 'note' && item.colors[0]
|
||||||
? COLORS_NOTE[item.colors[0]]
|
? COLORS_NOTE[item.colors[0]]
|
||||||
@@ -76,7 +76,7 @@ const SelectionWrapper = ({
|
|||||||
}
|
}
|
||||||
onLongPress={onLongPress}
|
onLongPress={onLongPress}
|
||||||
onPress={onPress}
|
onPress={onPress}
|
||||||
selectedColor={currentEditingNote ? colors.accent : colors.nav}
|
customSelectedColor={currentEditingNote ? colors.accent : colors.nav}
|
||||||
alpha={!colors.night ? -0.02 : 0.02}
|
alpha={!colors.night ? -0.02 : 0.02}
|
||||||
opacity={currentEditingNote ? 0.15 : 1}
|
opacity={currentEditingNote ? 0.15 : 1}
|
||||||
customStyle={{
|
customStyle={{
|
||||||
|
|||||||
@@ -155,6 +155,7 @@ class SortDialog extends React.Component {
|
|||||||
{Object.keys(SORT).map((item, index) => (
|
{Object.keys(SORT).map((item, index) => (
|
||||||
<PressableButton
|
<PressableButton
|
||||||
key={item}
|
key={item}
|
||||||
|
testID={'btn-' + item}
|
||||||
color={
|
color={
|
||||||
this.state.settings.sort === item
|
this.state.settings.sort === item
|
||||||
? colors.shade
|
? colors.shade
|
||||||
|
|||||||
@@ -6,6 +6,17 @@ export const ACCENT = {
|
|||||||
color: '#0560FF',
|
color: '#0560FF',
|
||||||
shade: '#0560FF12',
|
shade: '#0560FF12',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const COLORS_NOTE = {
|
||||||
|
red: '#f44336',
|
||||||
|
orange: '#FF9800',
|
||||||
|
yellow: '#FFD600',
|
||||||
|
green: '#4CAF50',
|
||||||
|
blue: '#2196F3',
|
||||||
|
purple: '#673AB7',
|
||||||
|
gray: '#9E9E9E',
|
||||||
|
};
|
||||||
|
|
||||||
const fixedColors = {
|
const fixedColors = {
|
||||||
accent: ACCENT.color,
|
accent: ACCENT.color,
|
||||||
shade: ACCENT.shade,
|
shade: ACCENT.shade,
|
||||||
@@ -18,6 +29,13 @@ const fixedColors = {
|
|||||||
successText: '#4F8A10',
|
successText: '#4F8A10',
|
||||||
warningBg: '#FEEFB3',
|
warningBg: '#FEEFB3',
|
||||||
warningText: '#9F6000',
|
warningText: '#9F6000',
|
||||||
|
red: '#f44336',
|
||||||
|
orange: '#FF9800',
|
||||||
|
yellow: '#FFD600',
|
||||||
|
green: '#4CAF50',
|
||||||
|
blue: '#2196F3',
|
||||||
|
purple: '#673AB7',
|
||||||
|
gray: '#9E9E9E',
|
||||||
};
|
};
|
||||||
export var COLOR_SCHEME = {
|
export var COLOR_SCHEME = {
|
||||||
...fixedColors,
|
...fixedColors,
|
||||||
@@ -54,15 +72,7 @@ export const COLOR_SCHEME_DARK = {
|
|||||||
sec: 'black',
|
sec: 'black',
|
||||||
light: '#ffffff',
|
light: '#ffffff',
|
||||||
};
|
};
|
||||||
export const COLORS_NOTE = {
|
|
||||||
red: '#f44336',
|
|
||||||
orange: '#FF9800',
|
|
||||||
yellow: '#FFD600',
|
|
||||||
green: '#4CAF50',
|
|
||||||
blue: '#2196F3',
|
|
||||||
purple: '#673AB7',
|
|
||||||
gray: '#9E9E9E',
|
|
||||||
};
|
|
||||||
|
|
||||||
export function setColorScheme(colors = COLOR_SCHEME, accent = ACCENT) {
|
export function setColorScheme(colors = COLOR_SCHEME, accent = ACCENT) {
|
||||||
COLOR_SCHEME = {...colors, accent: accent.color, shade: accent.shade};
|
COLOR_SCHEME = {...colors, accent: accent.color, shade: accent.shade};
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ export const BUTTON_TYPES = {
|
|||||||
accent: (themeColor, text) => ({
|
accent: (themeColor, text) => ({
|
||||||
primary: themeColor,
|
primary: themeColor,
|
||||||
text: text,
|
text: text,
|
||||||
selected: 'accent',
|
selected: themeColor,
|
||||||
}),
|
}),
|
||||||
inverted: {
|
inverted: {
|
||||||
primary: 'bg',
|
primary: 'bg',
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ import {hexToRGBA} from '../../utils/ColorUtils';
|
|||||||
import { db } from '../../utils/DB';
|
import { db } from '../../utils/DB';
|
||||||
import {
|
import {
|
||||||
eOnLoadNote,
|
eOnLoadNote,
|
||||||
eOpenPremiumDialog,
|
|
||||||
eShowGetPremium,
|
eShowGetPremium,
|
||||||
refreshNotesPage,
|
refreshNotesPage
|
||||||
} from '../../utils/Events';
|
} from '../../utils/Events';
|
||||||
import { MMKV } from '../../utils/mmkv';
|
import { MMKV } from '../../utils/mmkv';
|
||||||
import { sideMenuRef, tabBarRef } from '../../utils/Refs';
|
import { sideMenuRef, tabBarRef } from '../../utils/Refs';
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ export const Notes = ({route, navigation}) => {
|
|||||||
<ContainerBottomButton
|
<ContainerBottomButton
|
||||||
title="Create a new note"
|
title="Create a new note"
|
||||||
onPress={_onPressBottomButton}
|
onPress={_onPressBottomButton}
|
||||||
color={params.type == 'color' ? COLORS_NOTE[params.title] : null}
|
color={params.type == 'color' ? params.title : null}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -207,12 +207,8 @@ const CustomButton = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const [state] = useTracked();
|
const [state] = useTracked();
|
||||||
const {colors} = state;
|
const {colors} = state;
|
||||||
const [visible, setVisible] = useState(false);
|
|
||||||
return (
|
return (
|
||||||
<PressableButton
|
<PressableButton
|
||||||
color="transparent"
|
|
||||||
selectedColor={colors.nav}
|
|
||||||
alpha={!colors.night ? -0.02 : 0.02}
|
|
||||||
onPress={onPress}
|
onPress={onPress}
|
||||||
customStyle={{
|
customStyle={{
|
||||||
minHeight: 50,
|
minHeight: 50,
|
||||||
@@ -416,13 +412,9 @@ const SettingsUserSection = () => {
|
|||||||
paddingHorizontal: 0,
|
paddingHorizontal: 0,
|
||||||
}}>
|
}}>
|
||||||
<PressableButton
|
<PressableButton
|
||||||
color="transparent"
|
|
||||||
selectedColor={colors.nav}
|
|
||||||
alpha={!colors.night ? -0.02 : 0.1}
|
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
eSendEvent(eOpenLoginDialog);
|
eSendEvent(eOpenLoginDialog);
|
||||||
}}
|
}}
|
||||||
activeOpacity={opacity / 2}
|
|
||||||
customStyle={{
|
customStyle={{
|
||||||
paddingVertical: 12,
|
paddingVertical: 12,
|
||||||
width: '100%',
|
width: '100%',
|
||||||
@@ -550,7 +542,7 @@ const SettingsAppearanceSection = () => {
|
|||||||
].map((item) => (
|
].map((item) => (
|
||||||
<PressableButton
|
<PressableButton
|
||||||
key={item}
|
key={item}
|
||||||
color={
|
customColor={
|
||||||
colors.accent === item
|
colors.accent === item
|
||||||
? RGB_Linear_Shade(
|
? RGB_Linear_Shade(
|
||||||
!colors.night ? -0.2 : 0.2,
|
!colors.night ? -0.2 : 0.2,
|
||||||
@@ -558,7 +550,7 @@ const SettingsAppearanceSection = () => {
|
|||||||
)
|
)
|
||||||
: item
|
: item
|
||||||
}
|
}
|
||||||
selectedColor={item}
|
customSelectedColor={item}
|
||||||
alpha={!colors.night ? -0.1 : 0.1}
|
alpha={!colors.night ? -0.1 : 0.1}
|
||||||
opacity={1}
|
opacity={1}
|
||||||
onPress={async () => {
|
onPress={async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user