Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

add Pro button to menu

ammarahm-ed30e5a0e8fb37
diff --git a/apps/mobile/src/components/Menu/index.js b/apps/mobile/src/components/Menu/index.js
index 65f7394ba..eda265d9a 100644
--- a/apps/mobile/src/components/Menu/index.js
+++ b/apps/mobile/src/components/Menu/index.js
@@ -5,7 +5,7 @@ import {useSafeAreaInsets} from 'react-native-safe-area-context';
import {notesnook} from '../../../e2e/test.ids';
import {useTracked} from '../../provider';
import {Actions} from '../../provider/Actions';
-import { useSettingStore } from '../../provider/stores';
+import {useSettingStore, useUserStore} from '../../provider/stores';
import {DDS} from '../../services/DeviceDetection';
import {DrawerScale} from '../../utils/Animations';
import {
@@ -13,9 +13,9 @@ import {
COLOR_SCHEME,
COLOR_SCHEME_DARK,
COLOR_SCHEME_LIGHT,
- setColorScheme,
+ setColorScheme
} from '../../utils/Colors';
-import {MenuItemsList} from '../../utils/index';
+import {MenuItemsList, SUBSCRIPTION_STATUS} from '../../utils/index';
import {MMKV} from '../../utils/mmkv';
import {ColorSection} from './ColorSection';
import {MenuListItem} from './MenuListItem';
@@ -26,10 +26,9 @@ export const Menu = React.memo(
() => {
const [state, dispatch] = useTracked();
const {colors} = state;
-
const deviceMode = useSettingStore(state => state.deviceMode);
-
const insets = useSafeAreaInsets();
+ const user = useUserStore(state => state.user);
const noTextMode = false;
function changeColorScheme(colors = COLOR_SCHEME, accent = ACCENT) {
let newColors = setColorScheme(colors, accent);
@@ -51,13 +50,13 @@ export const Menu = React.memo(
},
switch: true,
on: !!colors.night,
- close: false,
+ close: false
},
{
name: 'Settings',
icon: 'cog-outline',
- close: true,
- },
+ close: true
+ }
];
return (
@@ -65,7 +64,7 @@ export const Menu = React.memo(
style={{
height: '100%',
width: '100%',
- backgroundColor: colors.nav,
+ backgroundColor: colors.nav
}}>
<Animated.View
style={{
@@ -77,66 +76,69 @@ export const Menu = React.memo(
borderRadius: 10,
transform: [
{
- scale: deviceMode !== 'mobile' ? 1 : DrawerScale,
- },
- ],
+ scale: deviceMode !== 'mobile' ? 1 : DrawerScale
+ }
+ ]
}}>
<FlatList
alwaysBounceVertical={false}
contentContainerStyle={{
- flexGrow: 1,
+ flexGrow: 1
}}
style={{
height: '100%',
width: '100%',
- paddingHorizontal:12
+ paddingHorizontal: 12
}}
showsVerticalScrollIndicator={false}
data={[0]}
keyExtractor={() => 'mainMenuView'}
renderItem={() => (
<>
- {MenuItemsList.map((item, index) => (
- <MenuListItem
- key={item.name}
- item={item}
- testID={item.name}
- index={index}
- />
- ))}
+ {MenuItemsList.map((item, index) =>
+ item.name === 'Notesnook Pro' &&
+ (user?.subscription?.type === SUBSCRIPTION_STATUS.TRIAL ||
+ user?.subscription?.type ===
+ SUBSCRIPTION_STATUS.BASIC) ? null : (
+ <MenuListItem
+ key={item.name}
+ item={item}
+ testID={item.name}
+ index={index}
+ />
+ )
+ )}
<ColorSection noTextMode={noTextMode} />
<TagsSection />
</>
)}
/>
<View
- style={{
- paddingHorizontal:12
- }}
- >
- {BottomItemsList.slice(DDS.isLargeTablet() ? 0 : 1, 2).map(
- (item, index) => (
- <MenuListItem
- testID={
- item.name == 'Night mode'
- ? notesnook.ids.menu.nightmode
- : item.name
- }
- key={item.name}
- item={item}
- index={index}
- ignore={true}
- rightBtn={DDS.isLargeTablet() ? null : BottomItemsList[0]}
- />
- ),
- )}
+ style={{
+ paddingHorizontal: 12
+ }}>
+ {BottomItemsList.slice(DDS.isLargeTablet() ? 0 : 1, 2).map(
+ (item, index) => (
+ <MenuListItem
+ testID={
+ item.name == 'Night mode'
+ ? notesnook.ids.menu.nightmode
+ : item.name
+ }
+ key={item.name}
+ item={item}
+ index={index}
+ ignore={true}
+ rightBtn={DDS.isLargeTablet() ? null : BottomItemsList[0]}
+ />
+ )
+ )}
</View>
-
<View
style={{
width: '100%',
- paddingHorizontal: 0,
+ paddingHorizontal: 0
}}>
<UserSection noTextMode={noTextMode} />
</View>
@@ -144,5 +146,5 @@ export const Menu = React.memo(
</View>
);
},
- () => true,
+ () => true
);
diff --git a/apps/mobile/src/utils/index.js b/apps/mobile/src/utils/index.js
index 6de7bc7dd..1a7b45b9b 100755
--- a/apps/mobile/src/utils/index.js
+++ b/apps/mobile/src/utils/index.js
@@ -11,7 +11,7 @@ import {useSettingStore} from '../provider/stores';
import {eSendEvent} from '../services/EventManager';
import Navigation from '../services/Navigation';
import * as ackeeTracker from './ackee';
-import {refreshNotesPage} from './Events';
+import {eOpenPremiumDialog, refreshNotesPage} from './Events';
import {MMKV} from './mmkv';
import {tabBarRef} from './Refs';
import {SIZE} from './SizeUtils';
@@ -256,6 +256,13 @@ export const MenuItemsList = [
name: 'Trash',
icon: 'delete-outline',
close: true
+ },
+ {
+ name: 'Notesnook Pro',
+ icon: 'crown',
+ func:() => {
+ eSendEvent(eOpenPremiumDialog);
+ }
}
];