2020-11-20 01:20:34 +05:00
|
|
|
import React from 'react';
|
2020-11-23 17:33:14 +05:00
|
|
|
import {ActivityIndicator, StyleSheet, View} from 'react-native';
|
2020-12-01 22:52:01 +05:00
|
|
|
import { notesnook } from '../../../e2e/test.ids';
|
2020-11-20 01:20:34 +05:00
|
|
|
import {useTracked} from '../../provider';
|
|
|
|
|
import {DDS} from '../../services/DeviceDetection';
|
2020-11-26 16:22:32 +05:00
|
|
|
import Navigation from '../../services/Navigation';
|
2020-11-20 01:20:34 +05:00
|
|
|
import {dWidth} from '../../utils';
|
|
|
|
|
import {SIZE} from '../../utils/SizeUtils';
|
|
|
|
|
import {ActionIcon} from '../ActionIcon';
|
2020-11-23 17:33:14 +05:00
|
|
|
import {Button} from '../Button';
|
2020-11-20 01:20:34 +05:00
|
|
|
|
|
|
|
|
export const HeaderRightMenu = () => {
|
2020-11-23 17:33:14 +05:00
|
|
|
const [state] = useTracked();
|
|
|
|
|
const {colors, containerBottomButton, currentScreen, syncing} = state;
|
2020-11-20 01:20:34 +05:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<View style={styles.rightBtnContainer}>
|
2020-11-23 17:33:14 +05:00
|
|
|
{syncing && <ActivityIndicator size={SIZE.xl} color={colors.accent} />}
|
|
|
|
|
|
2020-11-20 01:20:34 +05:00
|
|
|
<ActionIcon
|
|
|
|
|
onPress={async () => {
|
2020-12-01 17:51:39 +05:00
|
|
|
Navigation.navigate('Search', {
|
|
|
|
|
menu: false,
|
2020-11-26 16:22:32 +05:00
|
|
|
});
|
2020-11-20 01:20:34 +05:00
|
|
|
}}
|
2020-12-01 22:52:01 +05:00
|
|
|
testID={notesnook.ids.default.header.buttons.left}
|
2020-11-20 01:20:34 +05:00
|
|
|
name="magnify"
|
|
|
|
|
size={SIZE.xxxl}
|
|
|
|
|
color={colors.pri}
|
|
|
|
|
customStyle={styles.rightBtn}
|
|
|
|
|
/>
|
2020-11-23 17:33:14 +05:00
|
|
|
|
2020-11-20 01:20:34 +05:00
|
|
|
{DDS.isLargeTablet() && containerBottomButton.onPress ? (
|
|
|
|
|
<Button
|
2020-11-23 17:33:14 +05:00
|
|
|
onPress={() => {
|
|
|
|
|
containerBottomButton.onPress();
|
2020-11-20 01:20:34 +05:00
|
|
|
}}
|
2020-12-01 22:52:01 +05:00
|
|
|
testID={notesnook.ids.default.addBtn}
|
2020-11-23 17:33:14 +05:00
|
|
|
icon={currentScreen === 'trash' ? 'delete' : 'plus'}
|
2020-11-20 01:20:34 +05:00
|
|
|
iconSize={SIZE.xl}
|
|
|
|
|
type="shade"
|
|
|
|
|
style={{
|
|
|
|
|
marginLeft: 20,
|
2020-11-23 17:33:14 +05:00
|
|
|
width: 60,
|
|
|
|
|
height: 35,
|
2020-11-20 01:20:34 +05:00
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
) : null}
|
|
|
|
|
</View>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
|
container: {
|
|
|
|
|
flexDirection: 'row',
|
|
|
|
|
zIndex: 11,
|
|
|
|
|
height: 50,
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
paddingHorizontal: 12,
|
|
|
|
|
width: '100%',
|
|
|
|
|
},
|
|
|
|
|
loadingContainer: {
|
|
|
|
|
alignSelf: 'center',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
zIndex: 999,
|
|
|
|
|
left: dWidth / 2 - 20,
|
|
|
|
|
top: -20,
|
|
|
|
|
width: 40,
|
|
|
|
|
height: 40,
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
},
|
|
|
|
|
loadingInnerContainer: {
|
|
|
|
|
width: 40,
|
|
|
|
|
height: 20,
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
zIndex: 10,
|
|
|
|
|
top: 0,
|
|
|
|
|
},
|
|
|
|
|
leftBtnContainer: {
|
|
|
|
|
flexDirection: 'row',
|
|
|
|
|
justifyContent: 'flex-start',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
left: 12,
|
|
|
|
|
},
|
|
|
|
|
leftBtn: {
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
height: 40,
|
|
|
|
|
width: 40,
|
|
|
|
|
borderRadius: 100,
|
|
|
|
|
marginLeft: -5,
|
|
|
|
|
marginRight: 25,
|
|
|
|
|
},
|
|
|
|
|
rightBtnContainer: {
|
|
|
|
|
flexDirection: 'row',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
right: 12,
|
|
|
|
|
},
|
|
|
|
|
rightBtn: {
|
|
|
|
|
justifyContent: 'center',
|
2020-12-01 17:51:39 +05:00
|
|
|
alignItems: 'center',
|
2020-11-20 01:20:34 +05:00
|
|
|
height: 40,
|
2020-12-01 17:51:39 +05:00
|
|
|
width: 40,
|
|
|
|
|
marginLeft: 10,
|
2020-11-20 01:20:34 +05:00
|
|
|
paddingRight: 0,
|
|
|
|
|
},
|
|
|
|
|
});
|