This commit is contained in:
ammarahm-ed
2020-09-27 10:15:19 +05:00
parent c6d41746da
commit eca49fce33
37 changed files with 656 additions and 667 deletions

View File

@@ -120,13 +120,13 @@ const App = () => {
try { try {
await db.init(); await db.init();
let user = await db.user.get(); let user = await db.user.get();
console.log(user,"USER");
if (user) { if (user) {
dispatch({type: ACTIONS.USER, user: user}); dispatch({type: ACTIONS.USER, user: user});
startSyncer(); startSyncer();
} }
} catch (e) { } catch (e) {
error = e; error = e;
console.log(e.message);
} finally { } finally {
dispatch({type: ACTIONS.ALL}); dispatch({type: ACTIONS.ALL});
setInit(true); setInit(true);
@@ -155,10 +155,8 @@ const App = () => {
if (!settings || !settings.includes('fontScale')) { if (!settings || !settings.includes('fontScale')) {
settings = defaultState.settings; settings = defaultState.settings;
settings.fontScale = 1; settings.fontScale = 1;
console.log(settings, 'SETTINGS');
await MMKV.setStringAsync('settings', JSON.stringify(settings)); await MMKV.setStringAsync('settings', JSON.stringify(settings));
} }
console.log(e,"Initialize");
} finally { } finally {
let newColors = await getColorScheme(settings.useSystemTheme); let newColors = await getColorScheme(settings.useSystemTheme);
dispatch({type: ACTIONS.SETTINGS, settings: {...settings}}); dispatch({type: ACTIONS.SETTINGS, settings: {...settings}});

View File

@@ -1864,7 +1864,7 @@
} }
document.getElementById(dropdown).style.top = dropDownTop; document.getElementById(dropdown).style.top = dropDownTop;
document.getElementById(dropdown).style.left = left; document.getElementById(dropdown).style.left = left;
console.log(dropDownTop, left);
//dropdown.css('top', dropDownTop + 'px'); //dropdown.css('top', dropDownTop + 'px');
//dropdown.css('left', left + 'px'); //dropdown.css('left', left + 'px');
@@ -1876,7 +1876,6 @@
let downTop = let downTop =
currentTop - b.offsetHeight - height; currentTop - b.offsetHeight - height;
console.log(downTop, 'nat')
document.getElementById(dropdown).style.top = downTop + 20; document.getElementById(dropdown).style.top = downTop + 20;
document.getElementById(dropdown).style.left = left; document.getElementById(dropdown).style.left = left;

View File

@@ -1,6 +1,6 @@
import React, {useEffect, useState} from 'react'; import React, {useEffect, useState} from 'react';
import {Keyboard, Text, View} from 'react-native'; import {Keyboard, Text, View} from 'react-native';
import {useSafeArea} 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 {pv, SIZE, WEIGHT} from '../../common/common'; import {pv, SIZE, WEIGHT} from '../../common/common';
import {useTracked} from '../../provider'; import {useTracked} from '../../provider';
@@ -9,12 +9,10 @@ import {PressableButton} from '../PressableButton';
export const ContainerBottomButton = ({root}) => { export const ContainerBottomButton = ({root}) => {
const [state, dispatch] = useTracked(); const [state, dispatch] = useTracked();
const {colors} = state; const {colors,containerBottomButton} = state;
const [buttonHide, setButtonHide] = useState(false); const [buttonHide, setButtonHide] = useState(false);
const insets = useSafeArea(); const insets = useSafeAreaInsets();
let containerBottomButton = root
? state.containerBottomButton
: state.indContainerBottomButton;
useEffect(() => { useEffect(() => {
Keyboard.addListener('keyboardDidShow', () => { Keyboard.addListener('keyboardDidShow', () => {
setTimeout(() => { setTimeout(() => {

View File

@@ -1,12 +1,12 @@
import React from 'react'; import React from 'react';
import {KeyboardAvoidingView, Platform, SafeAreaView} from 'react-native'; import {KeyboardAvoidingView, Platform, SafeAreaView} from 'react-native';
import {useSafeArea} from 'react-native-safe-area-context'; import { useSafeAreaInsets} from 'react-native-safe-area-context';
import SelectionHeader from '../SelectionHeader'; import SelectionHeader from '../SelectionHeader';
import {ContainerBottomButton} from './ContainerBottomButton'; import {ContainerBottomButton} from './ContainerBottomButton';
import {ContainerTopSection} from './ContainerTopSection'; import {ContainerTopSection} from './ContainerTopSection';
export const Container = ({children,root}) => { export const Container = ({children,root}) => {
const insets = useSafeArea(); const insets = useSafeAreaInsets();
return ( return (
<KeyboardAvoidingView <KeyboardAvoidingView

View File

@@ -22,7 +22,7 @@ import {
eOpenSimpleDialog, eOpenSimpleDialog,
eOpenPremiumDialog, eOpenPremiumDialog,
eClosePremiumDialog, eClosePremiumDialog,
eOpenExportDialog eOpenExportDialog,
} from '../../services/events'; } from '../../services/events';
import {DDS, hexToRGBA} from '../../utils/utils'; import {DDS, hexToRGBA} from '../../utils/utils';
import ActionSheet from '../ActionSheet'; import ActionSheet from '../ActionSheet';
@@ -39,6 +39,8 @@ import LoginDialog from '../LoginDialog';
import PremiumDialog from '../Premium/PremiumDialog'; import PremiumDialog from '../Premium/PremiumDialog';
import ExportDialog from '../ExportDialog'; import ExportDialog from '../ExportDialog';
import RecoveryKeyDialog from '../RecoveryKeyDialog'; import RecoveryKeyDialog from '../RecoveryKeyDialog';
import PendingDialog from '../Premium/PendingDialog';
import PremiumStatusDialog from '../Premium/PremiumStatusDialog';
export class DialogManager extends Component { export class DialogManager extends Component {
constructor(props) { constructor(props) {
@@ -71,7 +73,7 @@ export class DialogManager extends Component {
); );
} }
_showActionSheet = data => { _showActionSheet = (data) => {
this.setState( this.setState(
{ {
actionSheetData: data, actionSheetData: data,
@@ -88,16 +90,15 @@ export class DialogManager extends Component {
}; };
_showMoveNote = () => { _showMoveNote = () => {
///this.moveNoteDialog.open(); ///this.moveNoteDialog.open();
}; };
_hideMoveNote = () => { _hideMoveNote = () => {
//eSendEvent(eCloseMoveNoteDialog) //eSendEvent(eCloseMoveNoteDialog)
// this.moveNoteDialog.close(); // this.moveNoteDialog.close();
}; };
loadNote = i => { loadNote = (i) => {
if (i && i.type === 'new') { if (i && i.type === 'new') {
this.setState({ this.setState({
item: {}, item: {},
@@ -110,7 +111,7 @@ export class DialogManager extends Component {
} }
}; };
showAddTopic = notebook => { showAddTopic = (notebook) => {
if (notebook) { if (notebook) {
this.setState({ this.setState({
item: notebook, item: notebook,
@@ -144,7 +145,7 @@ export class DialogManager extends Component {
eSubscribeEvent(eOpenLoginDialog, this.showLoginDialog); eSubscribeEvent(eOpenLoginDialog, this.showLoginDialog);
eSubscribeEvent(eCloseLoginDialog, this.hideLoginDialog); eSubscribeEvent(eCloseLoginDialog, this.hideLoginDialog);
eSubscribeEvent(eOpenPremiumDialog, this.showPremiumDialog); eSubscribeEvent(eOpenPremiumDialog, this.showPremiumDialog);
eSubscribeEvent(eClosePremiumDialog, this.hidePremiumDialog); eSubscribeEvent(eClosePremiumDialog, this.hidePremiumDialog);
} }
@@ -181,7 +182,6 @@ export class DialogManager extends Component {
hidePremiumDialog = () => { hidePremiumDialog = () => {
this.premiumDialog.close(); this.premiumDialog.close();
}; };
showLoginDialog = () => { showLoginDialog = () => {
//this.loginDialog.open(); //this.loginDialog.open();
@@ -191,21 +191,21 @@ export class DialogManager extends Component {
//this.loginDialog.close(); //this.loginDialog.close();
}; };
showAddNotebook = data => { showAddNotebook = (data) => {
this.setState( this.setState(
{ {
item: data.item ? data.item : {}, item: data.item ? data.item : {},
}, },
() => { () => {
this.addNotebooksDialog.open(); this.addNotebooksDialog.open();
}, },
); );
}; };
hideAddNotebook = () => { hideAddNotebook = () => {
this.addNotebooksDialog.close(); this.addNotebooksDialog.close();
}; };
_showSimpleDialog = data => { _showSimpleDialog = (data) => {
this.setState( this.setState(
{ {
simpleDialog: data, simpleDialog: data,
@@ -215,7 +215,7 @@ export class DialogManager extends Component {
}, },
); );
}; };
_hideSimpleDialog = data => { _hideSimpleDialog = (data) => {
this.simpleDialog.hide(); this.simpleDialog.hide();
}; };
@@ -255,22 +255,21 @@ export class DialogManager extends Component {
break; break;
} }
case 'movenote': { case 'movenote': {
// this._showMoveNote(); // this._showMoveNote();
break; break;
} }
case "premium": { case 'premium': {
eSendEvent(eOpenPremiumDialog); eSendEvent(eOpenPremiumDialog);
break; break;
} }
case "export": { case 'export': {
eSendEvent(eOpenExportDialog,[this.state.item]); eSendEvent(eOpenExportDialog, [this.state.item]);
break; break;
} }
} }
} }
this.show = null; this.show = null;
}; };
render() { render() {
let {colors} = this.props; let {colors} = this.props;
@@ -278,7 +277,7 @@ export class DialogManager extends Component {
return ( return (
<> <>
<ActionSheet <ActionSheet
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.isTab ? 500 : '100%',
@@ -313,7 +312,7 @@ export class DialogManager extends Component {
}}> }}>
<ActionSheetComponent <ActionSheetComponent
item={item} item={item}
setWillRefresh={value => { setWillRefresh={(value) => {
this.willRefresh = true; this.willRefresh = true;
}} }}
hasColors={actionSheetData.colors} hasColors={actionSheetData.colors}
@@ -323,7 +322,7 @@ export class DialogManager extends Component {
} }
rowItems={actionSheetData.rowItems} rowItems={actionSheetData.rowItems}
columnItems={actionSheetData.columnItems} columnItems={actionSheetData.columnItems}
close={value => { close={(value) => {
if (value) { if (value) {
this.show = value; this.show = value;
} }
@@ -333,7 +332,7 @@ export class DialogManager extends Component {
</ActionSheet> </ActionSheet>
<Dialog <Dialog
ref={ref => (this.simpleDialog = ref)} ref={(ref) => (this.simpleDialog = ref)}
item={item} item={item}
colors={colors} colors={colors}
template={simpleDialog} template={simpleDialog}
@@ -341,13 +340,10 @@ export class DialogManager extends Component {
<VaultDialog colors={colors} /> <VaultDialog colors={colors} />
<MoveNoteDialog <MoveNoteDialog colors={colors} />
colors={colors}
/>
<AddTopicDialog <AddTopicDialog
ref={ref => (this.addTopicsDialog = ref)} ref={(ref) => (this.addTopicsDialog = ref)}
toEdit={item.type === 'topic' ? item : null} toEdit={item.type === 'topic' ? item : null}
notebookID={ notebookID={
actionSheetData.extraData actionSheetData.extraData
@@ -357,19 +353,25 @@ export class DialogManager extends Component {
colors={colors} colors={colors}
/> />
<AddNotebookDialog <AddNotebookDialog
ref={ref => (this.addNotebooksDialog = ref)} ref={(ref) => (this.addNotebooksDialog = ref)}
toEdit={item} toEdit={item}
colors={colors} colors={colors}
/> />
<PremiumDialog ref={ref => this.premiumDialog = ref} colors={colors} /> <PremiumDialog
ref={(ref) => (this.premiumDialog = ref)}
colors={colors}
/>
<LoginDialog colors={colors} /> <LoginDialog colors={colors} />
<MergeEditor /> <MergeEditor />
<ExportDialog/> <ExportDialog />
<RecoveryKeyDialog colors={colors} /> <RecoveryKeyDialog colors={colors} />
<PendingDialog colors={colors} />
<PremiumStatusDialog />
</> </>
); );
} }

View File

@@ -145,7 +145,6 @@ const ExportDialog = () => {
done={complete} done={complete}
doneText={doneText} doneText={doneText}
onDone={() => { onDone={() => {
console.log(result.type, result.filePath);
FileViewer.open(result.filePath, { FileViewer.open(result.filePath, {
showOpenWithDialog: true, showOpenWithDialog: true,
showAppsSuggestions: true, showAppsSuggestions: true,

View File

@@ -1,13 +1,8 @@
import React from 'react'; import React from 'react';
import { import {ActivityIndicator, StyleSheet, Text, View} from 'react-native';
ActivityIndicator, import {ph, pv, SIZE, WEIGHT} from '../../common/common';
StyleSheet, import {useTracked} from '../../provider';
Text, import {Button} from '../Button';
View
} from 'react-native';
import { ph, pv, SIZE, WEIGHT } from '../../common/common';
import { useTracked } from '../../provider';
import { Button } from '../Button';
export const Loading = ({ export const Loading = ({
height = 150, height = 150,
@@ -32,13 +27,7 @@ export const Loading = ({
{doneText} {doneText}
</Text> </Text>
<Button <Button onPress={onDone} title="Open File" />
onPress={onDone}
title="Open File"
/>
</> </>
) : ( ) : (
<> <>
@@ -56,7 +45,7 @@ const styles = StyleSheet.create({
activityText: { activityText: {
fontSize: SIZE.sm, fontSize: SIZE.sm,
textAlign: 'center', textAlign: 'center',
marginBottom:10 marginBottom: 10,
}, },
activityContainer: { activityContainer: {
alignItems: 'center', alignItems: 'center',

View File

@@ -34,7 +34,6 @@ const LoginDialog = () => {
const [state, dispatch] = useTracked(); const [state, dispatch] = useTracked();
const colors = state.colors; const colors = state.colors;
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
const [animated, setAnimated] = useState(false);
const [status, setStatus] = useState('Logging you in'); const [status, setStatus] = useState('Logging you in');
const [loggingIn, setLoggingIn] = useState(false); const [loggingIn, setLoggingIn] = useState(false);
const [email, setEmail] = useState(null); const [email, setEmail] = useState(null);
@@ -71,8 +70,22 @@ const LoginDialog = () => {
} }
const close = () => { const close = () => {
_email.current?.clear();
_pass.current?.clear();
_passConfirm.current?.clear();
_username.current?.clear();
setVisible(false); setVisible(false);
setAnimated(false); setUsername(null);
setPassword(null);
setConfirmPassword(null);
setKey(null);
setLogin(true);
setModalVisible(false);
setUserConsent(false);
setEmail(false);
setLoggingIn(false);
}; };
const loginUser = async () => { const loginUser = async () => {
@@ -122,6 +135,7 @@ const LoginDialog = () => {
setLoggingIn(false); setLoggingIn(false);
} }
}; };
const validateInfo = () => { const validateInfo = () => {
if (!password || !email || !username || !passwordReEnter) { if (!password || !email || !username || !passwordReEnter) {
@@ -312,10 +326,7 @@ const LoginDialog = () => {
</Text> </Text>
<TouchableOpacity <TouchableOpacity
onPress={() => { onPress={() => {
DDS.isTab close();
? eSendEvent(eCloseLoginDialog)
: navigation.navigate('Home');
setModalVisible(false);
}} }}
activeOpacity={opacity} activeOpacity={opacity}
style={{ style={{
@@ -348,7 +359,7 @@ const LoginDialog = () => {
name="arrow-left" name="arrow-left"
size={SIZE.xxxl} size={SIZE.xxxl}
onPress={() => { onPress={() => {
setVisible(false); close();
}} }}
style={{ style={{
width: 50, width: 50,
@@ -459,6 +470,7 @@ const LoginDialog = () => {
borderRadius: 5, borderRadius: 5,
fontSize: SIZE.sm, fontSize: SIZE.sm,
fontFamily: WEIGHT.regular, fontFamily: WEIGHT.regular,
color: colors.pri,
}} }}
placeholder="Username (a-z _- 0-9)" placeholder="Username (a-z _- 0-9)"
placeholderTextColor={colors.icon} placeholderTextColor={colors.icon}
@@ -548,6 +560,7 @@ const LoginDialog = () => {
borderRadius: 5, borderRadius: 5,
fontSize: SIZE.sm, fontSize: SIZE.sm,
fontFamily: WEIGHT.regular, fontFamily: WEIGHT.regular,
color: colors.pri,
}} }}
placeholder="Email" placeholder="Email"
placeholderTextColor={colors.icon} placeholderTextColor={colors.icon}
@@ -648,6 +661,7 @@ const LoginDialog = () => {
fontFamily: WEIGHT.regular, fontFamily: WEIGHT.regular,
width: '85%', width: '85%',
maxWidth: '85%', maxWidth: '85%',
color: colors.pri,
}} }}
secureTextEntry={secureEntry} secureTextEntry={secureEntry}
placeholder="Password (6+ characters)" placeholder="Password (6+ characters)"
@@ -736,6 +750,7 @@ const LoginDialog = () => {
borderRadius: 5, borderRadius: 5,
fontSize: SIZE.sm, fontSize: SIZE.sm,
fontFamily: WEIGHT.regular, fontFamily: WEIGHT.regular,
color: colors.pri,
}} }}
secureTextEntry={secureEntry} secureTextEntry={secureEntry}
placeholder="Confirm Password" placeholder="Confirm Password"

View File

@@ -115,7 +115,7 @@ export const UserSection = ({noTextMode}) => {
}}> }}>
{syncing ? 'Syncing ' : 'Synced '} {syncing ? 'Syncing ' : 'Synced '}
{!syncing ? ( {!syncing ? (
user?.notesnook?.lastSynced !== 0 ? ( user?.notesnook?.lastSynced ? (
<TimeSince time={user.notesnook.lastSynced} /> <TimeSince time={user.notesnook.lastSynced} />
) : ( ) : (
'never' 'never'

View File

@@ -27,7 +27,6 @@ const MoveNoteDialog = () => {
const [state, dispatch] = useTracked(); const [state, dispatch] = useTracked();
const {notebooks, colors, selectedItemsList} = state; const {notebooks, colors, selectedItemsList} = state;
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
const [animated, setAnimated] = useState(false);
const [expanded, setExpanded] = useState(''); const [expanded, setExpanded] = useState('');
const [notebookInputFocused, setNotebookInputFocused] = useState(false); const [notebookInputFocused, setNotebookInputFocused] = useState(false);
const [topicInputFocused, setTopicInputFocused] = useState(false); const [topicInputFocused, setTopicInputFocused] = useState(false);
@@ -39,7 +38,6 @@ const MoveNoteDialog = () => {
const close = () => { const close = () => {
setVisible(false); setVisible(false);
setAnimated(false);
setExpanded(false); setExpanded(false);
newTopicTitle = null; newTopicTitle = null;
newNotebookTitle = null; newNotebookTitle = null;

View File

@@ -1,11 +1,10 @@
import React from 'react'; import React from 'react';
import {Dimensions, Text, TouchableOpacity, View} from 'react-native'; import { Dimensions, Text, 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 {ActionIcon} from '../ActionIcon'; import { ActionIcon } from '../ActionIcon';
import {ActionSheetEvent} from '../DialogManager/recievers'; 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;

View File

@@ -0,0 +1,103 @@
import React, {createRef} from 'react';
import {Text, View} from 'react-native';
import {SIZE, WEIGHT} from '../../common/common';
import {eSubscribeEvent, eUnSubscribeEvent} from '../../services/eventManager';
import {eClosePendingDialog, eOpenPendingDialog} from '../../services/events';
import {db, w} from '../../utils/utils';
import ActionSheet from '../ActionSheet';
import Seperator from '../Seperator';
const actionSheet = createRef();
class PendingDialog extends React.Component {
constructor(props) {
super(props);
this.state = {
user: null,
product: null,
};
}
async open() {
actionSheet.current?._setModalVisible(true);
let u = await db.user.get();
this.setState({
user: u && u.Id ? u : null,
});
}
close() {
actionSheet.current?._setModalVisible(false);
this.setState({
user: null,
});
}
async componentDidMount() {
eSubscribeEvent(eOpenPendingDialog, this.open.bind(this));
eSubscribeEvent(eClosePendingDialog, this.close.bind(this));
let u = await db.user.get();
this.setState({
user: u && u.Id ? u : null,
});
}
componentWillUnmount() {
eUnSubscribeEvent(eOpenPendingDialog, this.open);
eUnSubscribeEvent(eClosePendingDialog, this.close);
}
render() {
const {colors} = this.props;
return (
<ActionSheet
containerStyle={{
backgroundColor: colors.bg,
width: '100%',
alignSelf: 'center',
borderRadius: 10,
}}
gestureEnabled={true}
ref={actionSheet}
initialOffsetFromBottom={1}>
<View
style={{
width: w,
backgroundColor: colors.bg,
justifyContent: 'space-between',
paddingHorizontal: 12,
borderRadius: 10,
paddingTop: 10,
}}>
<Text
style={{
fontSize: SIZE.xxxl,
fontFamily: WEIGHT.bold,
color: colors.accent,
paddingBottom: 20,
paddingTop: 10,
alignSelf: 'center',
}}>
Thank you!
</Text>
<Seperator />
<Text
style={{
fontSize: SIZE.md,
fontFamily: WEIGHT.regular,
color: colors.pri,
width: '80%',
alignSelf: 'center',
textAlign: 'center',
}}>
We are processing your subscription. You account will be upgraded to
Notesnook Pro very soon.
</Text>
<Seperator />
</View>
</ActionSheet>
);
}
}
export default PendingDialog;

View File

@@ -4,8 +4,8 @@ import * as RNIap from 'react-native-iap';
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 {eSendEvent} from '../../services/eventManager'; import {eSendEvent} from '../../services/eventManager';
import {eOpenLoginDialog} from '../../services/events'; import {eOpenLoginDialog, eOpenPendingDialog} from '../../services/events';
import {db, h, itemSkus, w} from '../../utils/utils'; import {db, h, itemSkus, ToastEvent, w} from '../../utils/utils';
import ActionSheet from '../ActionSheet'; import ActionSheet from '../ActionSheet';
import {Button} from '../Button'; import {Button} from '../Button';
import Seperator from '../Seperator'; import Seperator from '../Seperator';
@@ -19,6 +19,12 @@ class PremiumDialog extends React.Component {
this.routeIndex = 0; this.routeIndex = 0;
this.count = 0; this.count = 0;
this.actionSheetRef = createRef(); this.actionSheetRef = createRef();
this.subsriptionSuccessListerner = RNIap.purchaseUpdatedListener(
this.onSuccessfulSubscription,
);
this.subsriptionErrorListener = RNIap.purchaseErrorListener(
this.onSubscriptionError,
);
} }
open() { open() {
@@ -37,7 +43,22 @@ class PremiumDialog extends React.Component {
product: prod[0], product: prod[0],
}); });
} }
componentDidUpdate() {}
onSuccessfulSubscription = (subscription: RNIap.SubscriptionPurchase) => {
const receipt = subscription.transactionReceipt;
if (receipt) {
this.close();
setTimeout(() => {
eSendEvent(eOpenPendingDialog);
}, 500);
}
};
onSubscriptionError = (error: RNIap.PurchaseError) => {
console.log(error.message, 'Error');
ToastEvent.show(error.message);
};
render() { render() {
const {colors} = this.props; const {colors} = this.props;
@@ -68,7 +89,7 @@ class PremiumDialog extends React.Component {
color: colors.heading, color: colors.heading,
paddingBottom: 20, paddingBottom: 20,
paddingTop: 10, paddingTop: 10,
alignSelf:'center' alignSelf: 'center',
}}> }}>
Notesnook Pro Notesnook Pro
</Text> </Text>
@@ -180,7 +201,9 @@ class PremiumDialog extends React.Component {
color: colors.pri, color: colors.pri,
fontFamily: WEIGHT.regular, fontFamily: WEIGHT.regular,
}}> }}>
Start your 14 Day Free Trial (no credit card needed) {this.state.user
? 'Cancel anytime in Subscriptions on Google Play'
: 'Start your 14 Day Trial for Free (no credit card needed)'}
</Text> </Text>
</Text> </Text>
<Text <Text
@@ -207,10 +230,16 @@ class PremiumDialog extends React.Component {
eSendEvent(eOpenLoginDialog); eSendEvent(eOpenLoginDialog);
}, 400); }, 400);
} else { } else {
// Request RNIap.requestSubscription(this.state.product.productId)
.then((r) => {})
.catch((e) => {
console.log(e);
});
} }
}} }}
title={this.state.user ? 'Buy Subscription' : 'Sign Up Now'} title={
this.state.user ? 'Subscribe to Notesnook Pro' : 'Sign Up Now'
}
height={50} height={50}
width="100%" width="100%"
/> />

View File

@@ -0,0 +1,136 @@
import React, {useEffect, useState} from 'react';
import {Modal, StyleSheet, Text, TouchableOpacity, View} from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import {ph, pv, SIZE, WEIGHT} from '../../common/common';
import {useTracked} from '../../provider';
import {DDS, getElevation} from '../../utils/utils';
import Seperator from '../Seperator';
const {
eSubscribeEvent,
eUnSubscribeEvent,
} = require('../../services/eventManager');
const {
eOpenPremiumStatusDialog,
eClosePremiumStatusDialog,
} = require('../../services/events');
const PremiumStatusDialog = () => {
const [state, dispatch] = useTracked();
const {colors, premiumUser} = state;
const [visible, setVisible] = useState(false);
useEffect(() => {
eSubscribeEvent(eOpenPremiumStatusDialog, open);
eSubscribeEvent(eClosePremiumStatusDialog, close);
return () => {
eUnSubscribeEvent(eOpenPremiumStatusDialog, open);
eUnSubscribeEvent(eClosePremiumStatusDialog, close);
};
}, []);
const open = (data) => {
setVisible(true);
};
const close = (data) => {
setVisible(false);
};
return (
<Modal
visible={visible}
transparent={true}
animated
animationType="fade"
onRequestClose={close}>
<View style={styles.wrapper}>
<TouchableOpacity onPress={close} style={styles.overlay} />
<View
style={[
{
width: DDS.isTab ? '40%' : '80%',
backgroundColor: colors.bg,
},
styles.container,
]}>
<View style={styles.headingContainer}>
<Text style={[{color: colors.accent}, styles.heading]}>
Notesnook Pro
</Text>
</View>
<Seperator />
<Text
style={{
color: colors.pri,
fontFamily: WEIGHT.regular,
fontSize: SIZE.sm,
textAlign: 'center',
width: '90%',
alignSelf: 'center',
}}>
Your account has been upgraded to Notesnook Pro successfully. Now
you can enjoy all premium features!
</Text>
<Seperator />
</View>
</View>
</Modal>
);
};
const styles = StyleSheet.create({
wrapper: {
width: '100%',
height: '100%',
backgroundColor: 'rgba(0,0,0,0.3)',
justifyContent: 'center',
alignItems: 'center',
},
container: {
...getElevation(5),
maxHeight: 350,
borderRadius: 5,
paddingHorizontal: ph,
paddingVertical: pv,
},
headingContainer: {
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
},
buttonContainer: {
justifyContent: 'space-between',
alignItems: 'center',
},
heading: {
fontFamily: WEIGHT.bold,
marginLeft: 5,
fontSize: SIZE.xxxl,
},
button: {
paddingVertical: pv,
paddingHorizontal: ph,
marginTop: 10,
borderRadius: 5,
width: '100%',
justifyContent: 'center',
alignItems: 'center',
borderWidth: 1,
flexDirection: 'row',
},
buttonText: {
fontFamily: WEIGHT.medium,
color: 'white',
fontSize: SIZE.sm,
marginLeft: 5,
},
overlay: {
width: '100%',
height: '100%',
position: 'absolute',
},
});
export default PremiumStatusDialog;

View File

@@ -32,9 +32,10 @@ class RecoveryKeyDialog extends React.Component {
async componentDidMount() { async componentDidMount() {
eSubscribeEvent(eOpenRecoveryKeyDialog, this.open); eSubscribeEvent(eOpenRecoveryKeyDialog, this.open);
let k = await db.user.key(); let k = await db.user.key();
if (k) { if (k) {
this.setState({ this.setState({
key: k, key: k.key,
}); });
} }
} }
@@ -47,7 +48,6 @@ class RecoveryKeyDialog extends React.Component {
saveQRCODE = () => { saveQRCODE = () => {
this.svg.current?.toDataURL((data) => { this.svg.current?.toDataURL((data) => {
console.log(data);
RNFetchBlob.fs RNFetchBlob.fs
.writeFile( .writeFile(
RNFetchBlob.fs.dirs.SDCardDir + RNFetchBlob.fs.dirs.SDCardDir +

View File

@@ -18,11 +18,10 @@ let timeoutAnimate = null;
let animating = false; let animating = false;
export const Search = (props) => { export const Search = (props) => {
const [state, dispatch] = useTracked(); const [state, dispatch] = useTracked();
const {colors, searchResults} = state; const {colors, searchResults,searchState} = state;
const [text, setText] = useState(''); const [text, setText] = useState('');
const [focus, setFocus] = useState(false); const [focus, setFocus] = useState(false);
let searchState = props.root ? state.searchState : state.indSearchState;
const _marginAnim = new Value(0); const _marginAnim = new Value(0);
const _opacity = new Value(1); const _opacity = new Value(1);

View File

@@ -19,7 +19,6 @@ export const SelectionHeader = () => {
selectionMode, selectionMode,
selectedItemsList, selectedItemsList,
currentScreen, currentScreen,
containerState,
premiumUser, premiumUser,
} = state; } = state;
const [selectAll, setSelectAll] = useState(false); const [selectAll, setSelectAll] = useState(false);
@@ -34,7 +33,7 @@ export const SelectionHeader = () => {
}).start(); }).start();
}, [selectionMode]); }, [selectionMode]);
return containerState.noSelectionHeader ? null : ( return (
<Animated.View <Animated.View
style={{ style={{
width: '100%', width: '100%',

View File

@@ -12,11 +12,8 @@ export const NotebookItemWrapper = ({
pinned = false, pinned = false,
}) => { }) => {
const [state, dispatch] = useTracked(); const [state, dispatch] = useTracked();
const {selectionMode, preventDefaultMargins} = state; const {selectionMode, preventDefaultMargins, headerState} = state;
let headerState = preventDefaultMargins let params = headerState.route.params || {};
? state.indHeaderState
: state.headerState;
let params = headerState.route.params ? headerState.route.params : {};
const style = useMemo(() => { const style = useMemo(() => {
return {width: selectionMode ? '90%' : '100%', marginHorizontal: 0}; return {width: selectionMode ? '90%' : '100%', marginHorizontal: 0};
@@ -77,8 +74,6 @@ export const NotebookItemWrapper = ({
item={item}> item={item}>
<NotebookItem <NotebookItem
hideMore={preventDefaultMargins} hideMore={preventDefaultMargins}
navigation={headerState.navigation}
route={headerState.route}
isTopic={item.type === 'topic'} isTopic={item.type === 'topic'}
customStyle={style} customStyle={style}
noteToMove={params.note} noteToMove={params.note}

View File

@@ -1,4 +1,5 @@
import React, {useEffect, useState} from 'react'; import React, {useEffect, useMemo, useState} from 'react';
import {StyleSheet} from 'react-native';
import {Dimensions, Platform, RefreshControl, Text, View} from 'react-native'; import {Dimensions, 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';
@@ -28,6 +29,7 @@ const SimpleList = ({
focused, focused,
customRefresh, customRefresh,
customRefreshing, customRefreshing,
refreshCallback,
}) => { }) => {
const [state, dispatch] = useTracked(); const [state, dispatch] = useTracked();
const {colors, selectionMode, user} = state; const {colors, selectionMode, user} = state;
@@ -56,7 +58,6 @@ const SimpleList = ({
/* for (var i = 0; i < 10000; i++) { /* for (var i = 0; i < 10000; i++) {
d = [...d,...data]; d = [...d,...data];
} */ } */
console.log(d, 'D');
setDataProvider( setDataProvider(
new DataProvider((r1, r2) => { new DataProvider((r1, r2) => {
return r1 !== r2; return r1 !== r2;
@@ -84,17 +85,12 @@ const SimpleList = ({
const RenderSectionHeader = ({item}) => ( const RenderSectionHeader = ({item}) => (
<Text <Text
style={{ style={[
fontFamily: WEIGHT.bold, {
fontSize: SIZE.xs + 1, color: colors.accent,
color: colors.accent, },
paddingHorizontal: 12, styles.sectionHeader,
width: '100%', ]}>
alignSelf: 'center',
marginTop: 15,
height: 18,
paddingBottom: 5,
}}>
{item.title} {item.title}
</Text> </Text>
); );
@@ -133,21 +129,21 @@ const SimpleList = ({
} else { } else {
setRefreshing(false); setRefreshing(false);
} }
if (refreshCallback) {
refreshCallback();
}
dispatch({type: ACTIONS.ALL}); dispatch({type: ACTIONS.ALL});
} }
}; };
const _ListEmptyComponent = ( const _ListEmptyComponent = (
<View <View
style={{ style={[
height: '100%', {
width: '100%', backgroundColor: colors.bg,
alignItems: 'center', },
alignSelf: 'center', styles.emptyList,
justifyContent: 'center', ]}>
opacity: 1,
backgroundColor: colors.bg,
}}>
<>{placeholder}</> <>{placeholder}</>
</View> </View>
); );
@@ -204,6 +200,22 @@ const SimpleList = ({
} }
}; };
const listStyle = useMemo(() => {
return {
height: '100%',
backgroundColor: colors.bg,
width: '100%',
paddingTop:
Platform.OS == 'ios'
? listData[0] && !selectionMode
? 115
: 115 - 60
: listData[0] && !selectionMode
? 155 - insets.top
: 155 - insets.top - 60,
};
}, []);
return !listData || listData.length === 0 ? ( return !listData || listData.length === 0 ? (
_ListEmptyComponent _ListEmptyComponent
) : ( ) : (
@@ -228,19 +240,7 @@ const SimpleList = ({
minHeight: '100%', minHeight: '100%',
}, },
}} }}
style={{ style={listStyle}
height: '100%',
backgroundColor: colors.bg,
width: '100%',
paddingTop:
Platform.OS == 'ios'
? listData[0] && !selectionMode
? 115
: 115 - 60
: listData[0] && !selectionMode
? 155 - insets.top
: 155 - insets.top - 60,
}}
/> />
); );
}; };
@@ -253,14 +253,7 @@ const SearchHeader = () => {
const searchResults = {...state.searchResults}; const searchResults = {...state.searchResults};
return ( return (
<View <View style={styles.searchHeader}>
style={{
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
paddingHorizontal: 12,
height: 40,
}}>
<Text <Text
style={{ style={{
fontFamily: WEIGHT.bold, fontFamily: WEIGHT.bold,
@@ -307,17 +300,7 @@ const LoginCard = ({type, data}) => {
} }
alpha={!colors.night ? -0.02 : 0.1} alpha={!colors.night ? -0.02 : 0.1}
opacity={0.12} opacity={0.12}
customStyle={{ customStyle={styles.loginCard}>
width: '100%',
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'flex-start',
paddingHorizontal: 12,
alignSelf: 'center',
height: 40,
borderRadius: 0,
position: 'relative',
}}>
<View <View
style={{ style={{
width: 25, width: 25,
@@ -330,10 +313,7 @@ const LoginCard = ({type, data}) => {
justifyContent: 'center', justifyContent: 'center',
}}> }}>
<Icon <Icon
style={{ style={styles.loginIcon}
textAlign: 'center',
textAlignVertical: 'center',
}}
name="account-outline" name="account-outline"
color="white" color="white"
size={SIZE.xs} size={SIZE.xs}
@@ -377,3 +357,46 @@ const ListHeaderComponent = ({type, data}) => {
<LoginCard type={type} data={data} /> <LoginCard type={type} data={data} />
); );
}; };
const styles = StyleSheet.create({
loginCard: {
width: '100%',
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'flex-start',
paddingHorizontal: 12,
alignSelf: 'center',
height: 40,
borderRadius: 0,
position: 'relative',
},
loginIcon: {
textAlign: 'center',
textAlignVertical: 'center',
},
searchHeader: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
paddingHorizontal: 12,
height: 40,
},
sectionHeader: {
fontFamily: WEIGHT.bold,
fontSize: SIZE.xs + 1,
paddingHorizontal: 12,
width: '100%',
alignSelf: 'center',
marginTop: 15,
height: 18,
paddingBottom: 5,
},
emptyList: {
height: '100%',
width: '100%',
alignItems: 'center',
alignSelf: 'center',
justifyContent: 'center',
opacity: 1,
},
});

View File

@@ -1,11 +1,9 @@
import React, {createRef} from 'react'; import React, { createRef } from 'react';
import {TouchableOpacity} from 'react-native'; import Menu, { MenuDivider, MenuItem } from 'react-native-material-menu';
import Menu, {MenuDivider, MenuItem} from 'react-native-material-menu'; import { SIZE, WEIGHT } from '../../common/common';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; import { useTracked } from '../../provider';
import {SIZE, WEIGHT} from '../../common/common'; import { ACTIONS } from '../../provider/actions';
import {useTracked} from '../../provider'; import { ActionIcon } from '../ActionIcon';
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();
@@ -13,6 +11,7 @@ export const HeaderMenu = () => {
return headerVerticalMenu ? ( return headerVerticalMenu ? (
<Menu <Menu
ref={menuRef} ref={menuRef}
animationDuration={200} animationDuration={200}
style={{ style={{

View File

@@ -1,22 +1,22 @@
import React from 'react'; import React from 'react';
import { Text } from 'react-native'; import {Text} from 'react-native';
import { SIZE, WEIGHT } from '../../common/common'; import {SIZE, WEIGHT} from '../../common/common';
import { useTracked } from '../../provider'; import {useTracked} from '../../provider';
export const HeaderTitle = ({root}) => { export const HeaderTitle = ({root}) => {
const [state, dispatch] = useTracked(); const [state, dispatch] = useTracked();
const {colors} = state; const {colors, headerTextState} = state;
let headerTextState = root ? state.headerTextState : state.indHeaderTextState;
const style = {
fontSize: SIZE.xl,
color: headerTextState.color || colors.heading,
fontFamily: WEIGHT.bold,
alignSelf: 'center',
};
return ( return (
<> <>
<Text <Text style={style}>
style={{
fontSize: SIZE.xl,
color: headerTextState.color ? headerTextState.color : colors.heading,
fontFamily: WEIGHT.bold,
alignSelf: 'center',
}}>
<Text <Text
style={{ style={{
color: colors.accent, color: colors.accent,

View File

@@ -1,20 +1,12 @@
import React from 'react'; import React from 'react';
import { import {ActivityIndicator, Platform, StyleSheet, View} from 'react-native';
ActivityIndicator,
Platform,
StyleSheet,
TouchableOpacity,
View,
} from 'react-native';
import * as Animatable from 'react-native-animatable'; import * as Animatable from 'react-native-animatable';
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 {SIZE} from '../../common/common'; import {SIZE} from '../../common/common';
import {useTracked} from '../../provider'; import {useTracked} from '../../provider';
import {eSendEvent} from '../../services/eventManager'; import {eSendEvent} from '../../services/eventManager';
import NavigationService from '../../services/NavigationService'; import NavigationService from '../../services/NavigationService';
import {useHideHeader} from '../../utils/hooks'; import {useHideHeader} from '../../utils/hooks';
import {sideMenuRef} from '../../utils/refs';
import {DDS, w} from '../../utils/utils'; import {DDS, w} from '../../utils/utils';
import {ActionIcon} from '../ActionIcon'; import {ActionIcon} from '../ActionIcon';
import {HeaderMenu} from './HeaderMenu'; import {HeaderMenu} from './HeaderMenu';
@@ -22,9 +14,7 @@ import {HeaderTitle} from './HeaderTitle';
export const Header = ({showSearch, root}) => { export const Header = ({showSearch, root}) => {
const [state, dispatch] = useTracked(); const [state, dispatch] = useTracked();
const {colors, syncing} = state; const {colors, syncing, headerState} = state;
let headerState = root ? state.headerState : state.indHeaderState;
const insets = useSafeAreaInsets(); const insets = useSafeAreaInsets();
const hideHeader = useHideHeader(); const hideHeader = useHideHeader();

View File

@@ -60,18 +60,13 @@ export const defaultState = {
canGoBack: true, canGoBack: true,
menu: false, menu: false,
verticalMenu: false, verticalMenu: false,
navigation: null,
headerColor: null, headerColor: null,
route: {},
}, },
headerTextState: { headerTextState: {
heading: 'Notes', heading: 'Notes',
color: null, color: null,
}, },
headerVerticalMenu: true, headerVerticalMenu: true,
containerState: {
noSelectionHeader: false,
},
searchState: { searchState: {
noSearch: false, noSearch: false,
data: [], data: [],
@@ -84,30 +79,5 @@ export const defaultState = {
bottomButtonOnPress: () => {}, bottomButtonOnPress: () => {},
bottomButtonText: 'Create a new note', bottomButtonText: 'Create a new note',
}, },
indHeaderState: {
heading: 'Home',
canGoBack: true,
menu: false,
verticalMenu: false,
navigation: null,
headerColor: null,
route: {},
},
indHeaderTextState: {
heading: 'Notes',
color: null,
},
indSearchState: {
noSearch: false,
data: [],
type: 'notes',
color: null,
placeholder: 'Search all notes',
},
indContainerBottomButton: {
visible: true,
bottomButtonOnPress: () => {},
bottomButtonText: 'Create a new note',
},
keyword: [], keyword: [],
}; };

View File

@@ -197,42 +197,22 @@ export const reducer = (state, action) => {
}; };
} }
case ACTIONS.HEADER_STATE: { case ACTIONS.HEADER_STATE: {
let header = action.state.ind let header = {
? {
...state.indHeaderState,
...action.state,
}
: {
...state.headerState, ...state.headerState,
...action.state, ...action.state,
}; };
return action.state.ind return {
? {
...state,
indHeaderState: {...header},
}
: {
...state, ...state,
headerState: header, headerState: header,
}; };
} }
case ACTIONS.SEARCH_STATE: { case ACTIONS.SEARCH_STATE: {
let stat = action.state.ind let stat = {
? {
...state.indSearchState,
...action.state,
}
: {
...state.searchState, ...state.searchState,
...action.state, ...action.state,
}; };
return action.state.ind return {
? {
...state,
indSearchState: stat,
}
: {
...state, ...state,
searchState: stat, searchState: stat,
}; };
@@ -244,21 +224,11 @@ export const reducer = (state, action) => {
}; };
} }
case ACTIONS.HEADER_TEXT_STATE: { case ACTIONS.HEADER_TEXT_STATE: {
let stat = action.state.ind let stat ={
? {
...state.indHeaderTextState,
...action.state,
}
: {
...state.headerTextState, ...state.headerTextState,
...action.state, ...action.state,
}; };
return action.state.ind return {
? {
...state,
indHeaderTextState: stat,
}
: {
...state, ...state,
headerTextState: stat, headerTextState: stat,
}; };
@@ -270,21 +240,11 @@ export const reducer = (state, action) => {
}; };
} }
case ACTIONS.CONTAINER_BOTTOM_BUTTON: { case ACTIONS.CONTAINER_BOTTOM_BUTTON: {
let containerBottomButton = action.state.ind let containerBottomButton = {
? {
...state.indContainerBottomButton,
...action.state,
}
: {
...state.containerBottomButton, ...state.containerBottomButton,
...action.state, ...action.state,
}; };
return action.state.ind return {
? {
...state,
indContainerBottomButton: containerBottomButton,
}
: {
...state, ...state,
containerBottomButton: containerBottomButton, containerBottomButton: containerBottomButton,
}; };

View File

@@ -90,4 +90,12 @@ export const eCloseExportDialog = '544';
export const eOpenRecoveryKeyDialog = '545'; export const eOpenRecoveryKeyDialog = '545';
export const eCloseRecoveryKeyDialog = '546'; export const eCloseRecoveryKeyDialog = '546';
export const eOpenPendingDialog = '547';
export const eClosePendingDialog = '548';
export const eOpenPremiumStatusDialog = '549';
export const eClosePremiumStatusDialog = '550';

View File

@@ -1,12 +1,12 @@
import he from 'he'; import he from 'he';
import { Platform } from 'react-native'; import {Platform} from 'react-native';
import 'react-native-get-random-values'; import 'react-native-get-random-values';
import RNHTMLtoPDF from 'react-native-html-to-pdf'; import RNHTMLtoPDF from 'react-native-html-to-pdf';
import MMKVStorage from 'react-native-mmkv-storage'; import MMKVStorage from 'react-native-mmkv-storage';
import { generateSecureRandom } from 'react-native-securerandom'; import {generateSecureRandom} from 'react-native-securerandom';
import Sodium from 'react-native-sodium'; import Sodium from 'react-native-sodium';
import RNFetchBlob from 'rn-fetch-blob'; import RNFetchBlob from 'rn-fetch-blob';
import { db, requestStoragePermission, ToastEvent } from './utils'; import {db, requestStoragePermission, ToastEvent} from './utils';
export const MMKV = new MMKVStorage.Loader().initialize(); export const MMKV = new MMKVStorage.Loader().initialize();
async function read(key, isArray = false) { async function read(key, isArray = false) {
let data; let data;
@@ -116,7 +116,7 @@ async function saveToMarkdown(note) {
RNFetchBlob.fs.dirs.SDCardDir + '/Notesnook/exported/Markdown/'; RNFetchBlob.fs.dirs.SDCardDir + '/Notesnook/exported/Markdown/';
await checkAndCreateDir(androidSavePath); await checkAndCreateDir(androidSavePath);
let markdown = await db.notes.note(note.id).export('md'); let markdown = await db.notes.note(note.id).export('md');
console.log(markdown);
let path = androidSavePath + note.title + '.md'; let path = androidSavePath + note.title + '.md';
await RNFetchBlob.fs.writeFile(path, markdown, 'utf8'); await RNFetchBlob.fs.writeFile(path, markdown, 'utf8');
@@ -132,7 +132,6 @@ async function saveToText(note) {
RNFetchBlob.fs.dirs.SDCardDir + '/Notesnook/exported/Text/'; RNFetchBlob.fs.dirs.SDCardDir + '/Notesnook/exported/Text/';
await checkAndCreateDir(androidSavePath); await checkAndCreateDir(androidSavePath);
let markdown = await db.notes.note(note.id).export('txt'); let markdown = await db.notes.note(note.id).export('txt');
console.log(markdown);
let path = androidSavePath + note.title + '.txt'; let path = androidSavePath + note.title + '.txt';
await RNFetchBlob.fs.writeFile(path, markdown, 'utf8'); await RNFetchBlob.fs.writeFile(path, markdown, 'utf8');
@@ -149,7 +148,7 @@ async function saveToHTML(note) {
RNFetchBlob.fs.dirs.SDCardDir + '/Notesnook/exported/Html/'; RNFetchBlob.fs.dirs.SDCardDir + '/Notesnook/exported/Html/';
await checkAndCreateDir(androidSavePath); await checkAndCreateDir(androidSavePath);
let markdown = await db.notes.note(note.id).export('html'); let markdown = await db.notes.note(note.id).export('html');
console.log(markdown);
let path = androidSavePath + note.title + '.html'; let path = androidSavePath + note.title + '.html';
await RNFetchBlob.fs.writeFile(path, markdown, 'utf8'); await RNFetchBlob.fs.writeFile(path, markdown, 'utf8');

View File

@@ -66,7 +66,6 @@ export async function requestStoragePermission() {
RESULTS.GRANTED && RESULTS.GRANTED &&
response['android.permission.WRITE_EXTERNAL_STORAGE'] === RESULTS.GRANTED; response['android.permission.WRITE_EXTERNAL_STORAGE'] === RESULTS.GRANTED;
} catch (err) { } catch (err) {
console.log(error);
} finally { } finally {
return granted; return granted;
} }

View File

@@ -1,32 +1,16 @@
import {useIsFocused} from '@react-navigation/native'; import { useIsFocused } from '@react-navigation/native';
import React, {useEffect, useState} from 'react'; import React, { useEffect, useState } from 'react';
import SimpleList from '../../components/SimpleList';
import {NoteItemWrapper} from '../../components/SimpleList/NoteItemWrapper';
import {useTracked} from '../../provider';
import {ACTIONS} from '../../provider/actions';
import {db, ToastEvent} from '../../utils/utils';
import { Placeholder } from '../../components/ListPlaceholders'; import { Placeholder } from '../../components/ListPlaceholders';
import SimpleList from '../../components/SimpleList';
import { NoteItemWrapper } from '../../components/SimpleList/NoteItemWrapper';
import { useTracked } from '../../provider';
import { ACTIONS } from '../../provider/actions';
export const Favorites = ({route, navigation}) => { export const Favorites = ({route, navigation}) => {
const [state, dispatch] = useTracked(); const [state, dispatch] = useTracked();
const {favorites} = state; const {favorites} = state;
const [refreshing, setRefreshing] = useState(false); const [refreshing, setRefreshing] = useState(false);
const isFocused = useIsFocused(); const isFocused = useIsFocused();
const _onRefresh = async () => {
setRefreshing(true);
try {
await db.sync();
dispatch({type: ACTIONS.FAVORITES});
dispatch({type: ACTIONS.USER});
setRefreshing(false);
ToastEvent.show('Sync Complete', 'success');
} catch (e) {
setRefreshing(false);
ToastEvent.show('Sync failed, network error', 'error');
}
};
useEffect(() => { useEffect(() => {
if (isFocused) { if (isFocused) {
dispatch({ dispatch({
@@ -35,9 +19,7 @@ export const Favorites = ({route, navigation}) => {
type: 'notes', type: 'notes',
menu: true, menu: true,
canGoBack: false, canGoBack: false,
route: route,
color: null, color: null,
navigation: navigation,
}, },
}); });
dispatch({ dispatch({
@@ -46,10 +28,6 @@ export const Favorites = ({route, navigation}) => {
visible: false, visible: false,
}, },
}); });
dispatch({
type: ACTIONS.HEADER_VERTICAL_MENU,
state: false,
});
dispatch({ dispatch({
type: ACTIONS.HEADER_TEXT_STATE, type: ACTIONS.HEADER_TEXT_STATE,
@@ -85,9 +63,11 @@ export const Favorites = ({route, navigation}) => {
<SimpleList <SimpleList
data={favorites} data={favorites}
type="notes" type="notes"
refreshCallback={() => {
dispatch({type: ACTIONS.FAVORITES});
}}
refreshing={refreshing} refreshing={refreshing}
focused={isFocused} focused={isFocused}
onRefresh={_onRefresh}
RenderItem={NoteItemWrapper} RenderItem={NoteItemWrapper}
placeholder={<Placeholder type="favorites" />} placeholder={<Placeholder type="favorites" />}
placeholderText="Notes you favorite appear here" placeholderText="Notes you favorite appear here"

View File

@@ -1,15 +1,11 @@
import {useIsFocused} from '@react-navigation/native'; import {useIsFocused} from '@react-navigation/native';
import React, {useEffect} from 'react'; import React, {useEffect} from 'react';
import {BackHandler} from 'react-native';
import {AddNotebookEvent} from '../../components/DialogManager/recievers'; import {AddNotebookEvent} from '../../components/DialogManager/recievers';
import {Placeholder} from '../../components/ListPlaceholders';
import SimpleList from '../../components/SimpleList'; import SimpleList from '../../components/SimpleList';
import {NotebookItemWrapper} from '../../components/SimpleList/NotebookItemWrapper'; import {NotebookItemWrapper} from '../../components/SimpleList/NotebookItemWrapper';
import {useTracked} from '../../provider'; import {useTracked} from '../../provider';
import {ACTIONS} from '../../provider/actions'; import {ACTIONS} from '../../provider/actions';
import {eSendEvent} from '../../services/eventManager';
import {eScrollEvent} from '../../services/events';
import NavigationService from '../../services/NavigationService';
import {Placeholder} from '../../components/ListPlaceholders';
export const Folders = ({route, navigation}) => { export const Folders = ({route, navigation}) => {
const [state, dispatch] = useTracked(); const [state, dispatch] = useTracked();
const {notebooks} = state; const {notebooks} = state;
@@ -23,9 +19,7 @@ export const Folders = ({route, navigation}) => {
type: 'notebooks', type: 'notebooks',
menu: true, menu: true,
canGoBack: false, canGoBack: false,
route: route,
color: null, color: null,
navigation: navigation,
}, },
}); });
dispatch({ dispatch({

View File

@@ -26,22 +26,13 @@ export const Home = ({route, navigation}) => {
type: 'notes', type: 'notes',
menu: true, menu: true,
canGoBack: false, canGoBack: false,
route: route,
color: null, color: null,
navigation: navigation,
}, },
}); });
dispatch({ dispatch({
type: ACTIONS.HEADER_VERTICAL_MENU, type: ACTIONS.HEADER_VERTICAL_MENU,
state: true, state: true,
}); });
dispatch({
type: ACTIONS.CONTAINER_BOTTOM_BUTTON,
state: {
bottomButtonText: 'Create a new Note',
},
});
dispatch({ dispatch({
type: ACTIONS.HEADER_TEXT_STATE, type: ACTIONS.HEADER_TEXT_STATE,
state: { state: {
@@ -68,8 +59,18 @@ export const Home = ({route, navigation}) => {
eSendEvent(eScrollEvent, 0); eSendEvent(eScrollEvent, 0);
dispatch({type: ACTIONS.COLORS}); dispatch({type: ACTIONS.COLORS});
dispatch({type: ACTIONS.NOTES}); dispatch({type: ACTIONS.NOTES});
dispatch({type: ACTIONS.PINNED}); } else {
dispatch({
type: ACTIONS.HEADER_VERTICAL_MENU,
state: false,
});
} }
return () => {
dispatch({
type: ACTIONS.HEADER_VERTICAL_MENU,
state: false,
});
};
}, [isFocused]); }, [isFocused]);
useEffect(() => { useEffect(() => {

View File

@@ -1,4 +1,4 @@
import {useIsFocused} from '@react-navigation/native'; /* import {useIsFocused} from '@react-navigation/native';
import React, {createRef, useEffect, useState} from 'react'; import React, {createRef, useEffect, useState} from 'react';
import { import {
ActivityIndicator, ActivityIndicator,
@@ -92,7 +92,7 @@ export const Login = ({route, navigation}) => {
try { try {
let res = await db.user.login(username.toLowerCase(), password); let res = await db.user.login(username.toLowerCase(), password);
console.log(res, username, password);
if (res) { if (res) {
setStatus('Fetching data...'); setStatus('Fetching data...');
} }
@@ -471,3 +471,4 @@ export const Login = ({route, navigation}) => {
}; };
export default Login; export default Login;
*/

View File

@@ -16,7 +16,7 @@ import NavigationService from '../../services/NavigationService';
import {db, ToastEvent} from '../../utils/utils'; import {db, ToastEvent} from '../../utils/utils';
export const Notebook = ({route, navigation}) => { export const Notebook = ({route, navigation}) => {
const [state, dispatch] = useTracked(); const [, dispatch] = useTracked();
const [topics, setTopics] = useState([]); const [topics, setTopics] = useState([]);
const [refreshing, setRefreshing] = useState(false); const [refreshing, setRefreshing] = useState(false);
@@ -52,9 +52,7 @@ export const Notebook = ({route, navigation}) => {
menu: false, menu: false,
canGoBack: true, canGoBack: true,
heading: params.title, heading: params.title,
route: route,
color: null, color: null,
navigation: navigation,
}, },
}); });
@@ -104,27 +102,16 @@ export const Notebook = ({route, navigation}) => {
} }
}, [topics, isFocused]); }, [topics, isFocused]);
const _onRefresh = async () => {
setRefreshing(true);
try {
await db.sync();
onLoad();
dispatch({type: ACTIONS.USER});
setRefreshing(false);
ToastEvent.show('Sync Complete', 'success');
} catch (e) {
setRefreshing(false);
ToastEvent.show('Sync failed, network error', 'error');
}
};
return ( return (
<SimpleList <SimpleList
data={topics} data={topics}
type="topics" type="topics"
customRefreshing={refreshing} refreshCallback={() => {
onLoad();
}}
focused={isFocused} focused={isFocused}
customRefresh={_onRefresh}
RenderItem={RenderItem} RenderItem={RenderItem}
placeholder={<></>} placeholder={<></>}
placeholderText="" placeholderText=""

View File

@@ -1,7 +1,9 @@
import {useIsFocused} from '@react-navigation/native'; import {useIsFocused} from '@react-navigation/native';
import React, {useEffect, useState} from 'react'; import React, {useEffect, useState} from 'react';
import {COLORS_NOTE} from '../../common/common';
import {Placeholder} from '../../components/ListPlaceholders';
import SimpleList from '../../components/SimpleList'; import SimpleList from '../../components/SimpleList';
import {NotebookItemWrapper} from '../../components/SimpleList/NotebookItemWrapper'; import {NoteItemWrapper} from '../../components/SimpleList/NoteItemWrapper';
import {useTracked} from '../../provider'; import {useTracked} from '../../provider';
import {ACTIONS} from '../../provider/actions'; import {ACTIONS} from '../../provider/actions';
import { import {
@@ -16,9 +18,6 @@ import {
} from '../../services/events'; } from '../../services/events';
import {openEditorAnimation} from '../../utils/animations'; import {openEditorAnimation} from '../../utils/animations';
import {db, DDS, editing, ToastEvent} from '../../utils/utils'; import {db, DDS, editing, ToastEvent} from '../../utils/utils';
import {NoteItemWrapper} from '../../components/SimpleList/NoteItemWrapper';
import {Placeholder} from '../../components/ListPlaceholders';
import {COLORS_NOTE} from '../../common/common';
export const Notes = ({route, navigation}) => { export const Notes = ({route, navigation}) => {
const [state, dispatch] = useTracked(); const [state, dispatch] = useTracked();
@@ -29,21 +28,14 @@ export const Notes = ({route, navigation}) => {
const isFocused = useIsFocused(); const isFocused = useIsFocused();
let params = route.params ? route.params : null; let params = route.params ? route.params : null;
useEffect(() => {
if (!params) {
params = {
title: 'Notes',
};
}
}, []);
useEffect(() => { useEffect(() => {
if (isFocused) { if (isFocused) {
if (!params) {
params = {
title: 'Notes',
};
}
init(); init();
dispatch({
type: ACTIONS.CURRENT_SCREEN,
screen: params.type === "color"? params.color.title : params.type,
});
} else { } else {
setNotes([]); setNotes([]);
editing.actionAfterFirstSave = { editing.actionAfterFirstSave = {
@@ -67,20 +59,19 @@ export const Notes = ({route, navigation}) => {
if (data) { if (data) {
params = data; params = data;
} }
let allNotes = [];
eSendEvent(eScrollEvent, 0); eSendEvent(eScrollEvent, 0);
if (params.type === 'tag') { if (params.type === 'tag') {
let notesInTag = db.notes.tagged(params.tag.title); allNotes = db.notes.tagged(params.tag.title);
setNotes([...notesInTag]);
} else if (params.type == 'color') { } else if (params.type == 'color') {
let notesInColors = db.notes.colored(params.color.title); allNotes = db.notes.colored(params.color.title);
setNotes([...notesInColors]);
} else { } else {
let allNotes = db.notebooks allNotes = db.notebooks
.notebook(params.notebookId) .notebook(params.notebookId)
.topics.topic(params.title).all; .topics.topic(params.title).all;
if (allNotes && allNotes.length > 0) { }
setNotes([...allNotes]); if (allNotes && allNotes.length > 0) {
} setNotes([...allNotes]);
} }
}; };
@@ -92,9 +83,8 @@ export const Notes = ({route, navigation}) => {
type: 'notes', type: 'notes',
menu: params.type === 'color' ? true : false, menu: params.type === 'color' ? true : false,
canGoBack: params.type === 'color' ? false : true, canGoBack: params.type === 'color' ? false : true,
route: route,
color: params.type == 'color' ? COLORS_NOTE[params.title] : null, color: params.type == 'color' ? COLORS_NOTE[params.title] : null,
navigation: navigation,
}, },
}); });
dispatch({ dispatch({
@@ -122,7 +112,7 @@ export const Notes = ({route, navigation}) => {
init(); init();
dispatch({ dispatch({
type: ACTIONS.CURRENT_SCREEN, type: ACTIONS.CURRENT_SCREEN,
screen: params.type === "color"? params.color.title : params.type, screen: params.type === 'color' ? params.color.title : params.type,
}); });
} else { } else {
setNotes([]); setNotes([]);
@@ -149,20 +139,6 @@ export const Notes = ({route, navigation}) => {
} }
}, [notes, isFocused]); }, [notes, isFocused]);
const _onRefresh = async () => {
setRefreshing(true);
try {
await db.sync();
init();
dispatch({type: ACTIONS.USER});
setRefreshing(false);
ToastEvent.show('Sync Complete', 'success');
} catch (e) {
setRefreshing(false);
ToastEvent.show('Sync failed, network error', 'error');
}
};
const _bottomBottomOnPress = () => { const _bottomBottomOnPress = () => {
if (params.type === 'tag') { if (params.type === 'tag') {
editing.actionAfterFirstSave = { editing.actionAfterFirstSave = {
@@ -184,19 +160,18 @@ export const Notes = ({route, navigation}) => {
if (DDS.isTab) { if (DDS.isTab) {
eSendEvent(eOnLoadNote, {type: 'new'}); eSendEvent(eOnLoadNote, {type: 'new'});
} else {
eSendEvent(eOnLoadNote, {type: 'new'});
openEditorAnimation();
} }
openEditorAnimation();
}; };
return ( return (
<SimpleList <SimpleList
data={notes} data={notes}
type="notes" type="notes"
customRefreshing={refreshing} refreshCallback={() => {
init();
}}
focused={isFocused} focused={isFocused}
customRefresh={_onRefresh}
RenderItem={NoteItemWrapper} RenderItem={NoteItemWrapper}
placeholder={<Placeholder type="notes" />} placeholder={<Placeholder type="notes" />}
placeholderText={`Add some notes to this" ${ placeholderText={`Add some notes to this" ${

View File

@@ -1,10 +1,8 @@
import {useIsFocused} from '@react-navigation/native'; import {useIsFocused} from '@react-navigation/native';
import React, {useEffect, useState} from 'react'; import React, {useEffect} from 'react';
import { import {
Appearance, Appearance,
Clipboard,
Linking, Linking,
Modal,
Platform, Platform,
ScrollView, ScrollView,
StatusBar, StatusBar,
@@ -13,8 +11,6 @@ import {
View, View,
} from 'react-native'; } from 'react-native';
import * as Animatable from 'react-native-animatable'; import * as Animatable from 'react-native-animatable';
import * as RNIap from 'react-native-iap';
import QRCode from 'react-native-qrcode-generator';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import { import {
ACCENT, ACCENT,
@@ -22,26 +18,29 @@ import {
COLOR_SCHEME_DARK, COLOR_SCHEME_DARK,
COLOR_SCHEME_LIGHT, COLOR_SCHEME_LIGHT,
opacity, opacity,
ph,
pv, pv,
setColorScheme, setColorScheme,
SIZE, SIZE,
WEIGHT, WEIGHT,
} from '../../common/common'; } from '../../common/common';
import {Button} from '../../components/Button';
import {PressableButton} from '../../components/PressableButton'; import {PressableButton} from '../../components/PressableButton';
import Seperator from '../../components/Seperator'; import Seperator from '../../components/Seperator';
import {Toast} from '../../components/Toast';
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 {eOpenLoginDialog, eResetApp} from '../../services/events'; import {
eOpenLoginDialog,
eOpenPremiumDialog,
eOpenRecoveryKeyDialog,
eResetApp,
} from '../../services/events';
import NavigationService from '../../services/NavigationService'; import NavigationService from '../../services/NavigationService';
import {MMKV} from '../../utils/storage'; import {MMKV} from '../../utils/storage';
import { import {
db, db,
DDS, DDS,
hexToRGBA, hexToRGBA,
itemSkus,
RGB_Linear_Shade, RGB_Linear_Shade,
setSetting, setSetting,
ToastEvent, ToastEvent,
@@ -51,17 +50,10 @@ import {
export const Settings = ({route, navigation}) => { export const Settings = ({route, navigation}) => {
const [state, dispatch] = useTracked(); const [state, dispatch] = useTracked();
const {colors, user, settings} = state; const {colors, user, settings} = state;
const [key, setKey] = useState('');
const [modalVisible, setModalVisible] = useState(false);
const [subscriptions, setSubscriptions] = useState([]);
const isFocused = useIsFocused(); const isFocused = useIsFocused();
let subsriptionSuccessListerner;
let subsriptionErrorListener;
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'); StatusBar.setBarStyle(colors.night ? 'light-content' : 'dark-content');
dispatch({type: ACTIONS.THEME, colors: newColors}); dispatch({type: ACTIONS.THEME, colors: newColors});
} }
@@ -72,43 +64,7 @@ export const Settings = ({route, navigation}) => {
} }
useEffect(() => { useEffect(() => {
RNIap.getSubscriptions(itemSkus).then((subs) => { console.log(user);
setSubscriptions(subs);
});
subsriptionSuccessListerner = RNIap.purchaseUpdatedListener(
onSuccessfulSubscription,
);
subsriptionErrorListener = RNIap.purchaseErrorListener(onSubscriptionError);
return () => {
if (subsriptionSuccessListerner) {
subsriptionSuccessListerner.remove();
subsriptionSuccessListerner = null;
}
if (subsriptionErrorListener) {
subsriptionErrorListener.remove();
subsriptionErrorListener = null;
}
};
}, []);
const onSuccessfulSubscription = (
subscription: RNIap.SubscriptionPurchase,
) => {
const receipt = subscription.transactionReceipt;
//console.log(JSON.stringify(subscription));
if (receipt) {
console.log(JSON.stringify(subscription));
}
};
const onSubscriptionError = (error: RNIap.PurchaseError) => {
console.log(error.message, 'Error');
ToastEvent.show(error.message);
};
useEffect(() => {
if (isFocused) { if (isFocused) {
dispatch({ dispatch({
type: ACTIONS.CONTAINER_BOTTOM_BUTTON, type: ACTIONS.CONTAINER_BOTTOM_BUTTON,
@@ -122,9 +78,7 @@ export const Settings = ({route, navigation}) => {
type: null, type: null,
menu: true, menu: true,
canGoBack: false, canGoBack: false,
route: route,
color: null, color: null,
navigation: navigation,
}, },
}); });
dispatch({ dispatch({
@@ -153,6 +107,15 @@ export const Settings = ({route, navigation}) => {
} }
}, [isFocused]); }, [isFocused]);
const getTimeLeft = (t1, t2) => {
let d1 = new Date(Date.now());
let d2 = new Date(t2);
let diff = d2.getTime() - d1.getTime();
diff = (diff / (1000 * 3600 * 24)).toFixed(0);
return diff;
};
const SectionHeader = ({title}) => ( const SectionHeader = ({title}) => (
<Text <Text
style={{ style={{
@@ -169,15 +132,14 @@ export const Settings = ({route, navigation}) => {
</Text> </Text>
); );
const Button = ({title, tagline, customComponent, onPress, key}) => ( const CustomButton = ({title, tagline, customComponent, onPress}) => (
<PressableButton <PressableButton
key={key}
color="transparent" color="transparent"
selectedColor={colors.nav} selectedColor={colors.nav}
alpha={!colors.night ? -0.02 : 0.02} alpha={!colors.night ? -0.02 : 0.02}
onPress={onPress} onPress={onPress}
customStyle={{ customStyle={{
height: 50, minHeight: 50,
justifyContent: 'space-between', justifyContent: 'space-between',
alignItems: 'center', alignItems: 'center',
paddingHorizontal: 12, paddingHorizontal: 12,
@@ -220,139 +182,6 @@ export const Settings = ({route, navigation}) => {
marginTop: Platform.OS == 'ios' ? 125 - 60 : 125 - 60, marginTop: Platform.OS == 'ios' ? 125 - 60 : 125 - 60,
}} }}
/> />
<Modal
animated={true}
animationType="fade"
visible={modalVisible}
transparent={true}>
<View
style={{
width: '100%',
height: '100%',
backgroundColor: 'rgba(0,0,0,0.3)',
}}>
<View
style={{
width: '100%',
backgroundColor: colors.bg,
height: '100%',
alignItems: 'center',
justifyContent: 'center',
}}>
<Text
style={{
fontFamily: WEIGHT.bold,
fontSize: SIZE.xl,
color: colors.pri,
marginBottom: 25,
}}>
Data Recovery Key
</Text>
<Text
style={{
fontFamily: WEIGHT.regular,
fontSize: SIZE.sm,
maxWidth: '85%',
textAlign: 'center',
color: colors.pri,
}}>
<Text
style={{
color: colors.errorText,
}}>
If you lose your password, you can recover your data only using
your recovery key.{' '}
</Text>
</Text>
<Text
style={{
fontFamily: WEIGHT.regular,
fontSize: SIZE.sm,
maxWidth: '85%',
textAlign: 'center',
marginTop: 25,
marginBottom: 10,
color: colors.pri,
}}>
Take a Sceenshot of QR-Code
</Text>
<QRCode value={key} size={200} bgColor="black" fgColor="white" />
<TouchableOpacity
activeOpacity={0.6}
onPress={() => {
Clipboard.setString(key);
ToastEvent.show('Recovery key copied!', 'success', 'local');
}}
style={{
flexDirection: 'row',
borderWidth: 1,
borderRadius: 5,
paddingVertical: 8,
paddingHorizontal: 10,
marginTop: 15,
alignItems: 'center',
borderColor: colors.nav,
}}>
<Text
numberOfLines={2}
style={{
fontFamily: WEIGHT.regular,
fontSize: SIZE.sm,
width: '85%',
maxWidth: '85%',
paddingRight: 10,
color: colors.icon,
}}>
{key}
</Text>
<Icon color={colors.accent} size={SIZE.lg} name="clipboard" />
</TouchableOpacity>
<Text
style={{
color: colors.icon,
fontSize: 10,
width: '85%',
maxWidth: '85%',
}}>
You can also save your recovery key from app settings on any
device.
</Text>
<TouchableOpacity
onPress={() => {
setModalVisible(false);
}}
activeOpacity={opacity}
style={{
paddingVertical: pv + 5,
paddingHorizontal: ph,
borderRadius: 5,
width: '90%',
marginTop: 20,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: colors.accent,
}}>
<Text
style={{
fontFamily: WEIGHT.medium,
color: 'white',
fontSize: SIZE.sm,
}}>
I have saved the key
</Text>
</TouchableOpacity>
</View>
</View>
<Toast context="local" />
</Modal>
<ScrollView <ScrollView
style={{ style={{
paddingHorizontal: 0, paddingHorizontal: 0,
@@ -365,83 +194,104 @@ export const Settings = ({route, navigation}) => {
}}> }}>
<View <View
style={{ style={{
justifyContent: 'space-between',
alignItems: 'center',
alignSelf: 'center', alignSelf: 'center',
flexDirection: 'row',
width: '100%', width: '100%',
paddingVertical: pv,
marginBottom: pv, marginBottom: pv,
marginTop: pv, marginTop: pv,
backgroundColor: colors.accent,
borderRadius: 5, borderRadius: 5,
padding: 5, padding: 10,
paddingHorizontal: 12, backgroundColor: colors.shade,
}}> }}>
<View <View
style={{ style={{
flexDirection: 'row', justifyContent: 'space-between',
justifyContent: 'center',
alignItems: 'center', alignItems: 'center',
flexDirection: 'row',
}}> }}>
<Icon size={SIZE.lg} color="white" name="account-outline" /> <View
style={{
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
}}>
<Icon
size={SIZE.md}
color={colors.accent}
name="account-outline"
/>
<Text
style={{
color: colors.heading,
marginLeft: 5,
fontFamily: WEIGHT.regular,
fontSize: SIZE.sm,
}}>
{user.username}
</Text>
</View>
<View
style={{
borderRadius: 5,
padding: 5,
paddingVertical: 2.5,
backgroundColor: 'white',
}}>
<Text
style={{
color: colors.accent,
fontFamily: WEIGHT.regular,
fontSize: SIZE.xs,
}}>
{user.notesnook.subscription.isTrial ? 'Trial' : 'Pro'}
</Text>
</View>
</View>
<Seperator />
<View>
{user.notesnook.subscription.isTrial ? (
<Text
style={{
color:
getTimeLeft(
user.notesnook.subscription.start,
user.notesnook.subscription.expiry,
) > 5
? colors.pri
: colors.errorText,
fontFamily: WEIGHT.regular,
fontSize: SIZE.xxl,
}}>
{getTimeLeft(
user.notesnook.subscription.start,
user.notesnook.subscription.expiry,
) + ' Days Remaining'}
</Text>
) : null}
<Text <Seperator />
style={{
color: 'white', <Button
marginLeft: 5, onPress={() => {
fontFamily: WEIGHT.regular, eSendEvent(eOpenPremiumDialog);
fontSize: SIZE.sm, }}
}}> width="100%"
{user.username} title="Get Notesnook Pro"
</Text> height={40}
</View> />
<View
style={{
borderRadius: 5,
padding: 5,
paddingVertical: 2.5,
backgroundColor: 'white',
}}>
<Text
style={{
color: colors.accent,
fontFamily: WEIGHT.regular,
fontSize: SIZE.xs,
}}>
Pro
</Text>
</View> </View>
{
// Ad code here
}
</View> </View>
</View> </View>
{[ {[
{ {
name: 'Data recovery key', name: 'Save Data Recovery Key',
func: async () => { func: async () => {
let k = await db.user.key(); eSendEvent(eOpenRecoveryKeyDialog);
setKey(k.key);
setModalVisible(true);
}, },
desc: desc:
'Generate a data recovery key to recovery your data if you lose it', 'We recommend you to get your data recovery key and store it safely. If you lose your password, you can recover your data using your recovery key.',
},
{
name: 'Subscription status',
func: () => {
RNIap.requestSubscription(
subscriptions[0].productId,
undefined,
undefined,
undefined,
user.Id,
)
.then((r) => {
console.log(r);
})
.catch((e) => console.log(e));
return;
},
desc: 'Current status of your subscription',
}, },
{ {
name: 'Logout', name: 'Logout',
@@ -449,14 +299,12 @@ export const Settings = ({route, navigation}) => {
await db.user.logout(); await db.user.logout();
dispatch({type: ACTIONS.USER, user: null}); dispatch({type: ACTIONS.USER, user: null});
dispatch({type: ACTIONS.CLEAR_ALL}); dispatch({type: ACTIONS.CLEAR_ALL});
//ToastEvent.show('Logged out, syncing disabled', 'success');
eSendEvent(eResetApp);
}, },
desc: desc:
'Logout of your account, this will clear everything and reset the app.', 'Logout of your account, this will clear everything and reset the app.',
}, },
].map((item) => ( ].map((item) => (
<Button <CustomButton
key={item.name} key={item.name}
title={item.name} title={item.name}
onPress={item.func} onPress={item.func}
@@ -627,7 +475,7 @@ export const Settings = ({route, navigation}) => {
))} ))}
</View> </View>
<Button <CustomButton
title="Use System Dark Mode" title="Use System Dark Mode"
tagline={ tagline={
settings.useSystemTheme settings.useSystemTheme
@@ -664,7 +512,7 @@ export const Settings = ({route, navigation}) => {
} }
/> />
<Button <CustomButton
title="Dark Mode" title="Dark Mode"
tagline={colors.night ? 'Turn off dark mode' : 'Turn on dark mode'} tagline={colors.night ? 'Turn off dark mode' : 'Turn on dark mode'}
onPress={() => { onPress={() => {
@@ -770,7 +618,7 @@ export const Settings = ({route, navigation}) => {
</View> </View>
{DDS.isTab ? ( {DDS.isTab ? (
<Button <CustomButton
title="Force portrait mode" title="Force portrait mode"
onPress={async () => { onPress={async () => {
await setSetting( await setSetting(
@@ -813,7 +661,7 @@ export const Settings = ({route, navigation}) => {
desc: 'Restore backup from your phone.', desc: 'Restore backup from your phone.',
}, },
].map((item) => ( ].map((item) => (
<Button <CustomButton
key={item.name} key={item.name}
title={item.name} title={item.name}
tagline={item.desc} tagline={item.desc}
@@ -895,7 +743,7 @@ export const Settings = ({route, navigation}) => {
</View> </View>
</View> </View>
<Button <CustomButton
title="Encrypted Backups" title="Encrypted Backups"
tagline="Encrypt your data before backup" tagline="Encrypt your data before backup"
onPress={async () => { onPress={async () => {
@@ -956,7 +804,7 @@ export const Settings = ({route, navigation}) => {
desc: 'You are using the latest version of our app.', desc: 'You are using the latest version of our app.',
}, },
].map((item) => ( ].map((item) => (
<Button <CustomButton
key={item.name} key={item.name}
title={item.name} title={item.name}
tagline={item.desc} tagline={item.desc}

View File

@@ -1,4 +1,4 @@
import {useIsFocused} from '@react-navigation/native'; /* import {useIsFocused} from '@react-navigation/native';
import React, {createRef, useEffect, useState} from 'react'; import React, {createRef, useEffect, useState} from 'react';
import { import {
ActivityIndicator, ActivityIndicator,
@@ -759,3 +759,4 @@ export const Signup = ({route, navigation}) => {
}; };
export default Signup; export default Signup;
*/

View File

@@ -1,13 +1,13 @@
import {useIsFocused} from '@react-navigation/native'; import { useIsFocused } from '@react-navigation/native';
import React, {useEffect} from 'react'; import React, { useEffect } from 'react';
import {Text, TouchableOpacity, View} from 'react-native'; import { Text } from 'react-native';
import {pv, SIZE, WEIGHT} from '../../common/common'; import { SIZE, WEIGHT } from '../../common/common';
import {Placeholder} from '../../components/ListPlaceholders'; import { Placeholder } from '../../components/ListPlaceholders';
import { PressableButton } from '../../components/PressableButton';
import SimpleList from '../../components/SimpleList'; import SimpleList from '../../components/SimpleList';
import {useTracked} from '../../provider'; import { useTracked } from '../../provider';
import {ACTIONS} from '../../provider/actions'; import { ACTIONS } from '../../provider/actions';
import NavigationService from '../../services/NavigationService'; import NavigationService from '../../services/NavigationService';
import {PressableButton} from '../../components/PressableButton';
export const Tags = ({route, navigation}) => { export const Tags = ({route, navigation}) => {
const [state, dispatch] = useTracked(); const [state, dispatch] = useTracked();
@@ -22,9 +22,7 @@ export const Tags = ({route, navigation}) => {
type: 'trash', type: 'trash',
menu: true, menu: true,
canGoBack: false, canGoBack: false,
route: route,
color: null, color: null,
navigation: navigation,
}, },
}); });
dispatch({ dispatch({

View File

@@ -1,17 +1,17 @@
import { useIsFocused } from '@react-navigation/native'; import {useIsFocused} from '@react-navigation/native';
import React, { useEffect } from 'react'; import React, {useEffect} from 'react';
import { simpleDialogEvent } from '../../components/DialogManager/recievers'; import {simpleDialogEvent} from '../../components/DialogManager/recievers';
import { TEMPLATE_EMPTY_TRASH } from '../../components/DialogManager/templates'; import {TEMPLATE_EMPTY_TRASH} from '../../components/DialogManager/templates';
import { Placeholder } from '../../components/ListPlaceholders'; import {Placeholder} from '../../components/ListPlaceholders';
import SimpleList from '../../components/SimpleList'; import SimpleList from '../../components/SimpleList';
import { NotebookItemWrapper } from '../../components/SimpleList/NotebookItemWrapper'; import {NotebookItemWrapper} from '../../components/SimpleList/NotebookItemWrapper';
import { NoteItemWrapper } from '../../components/SimpleList/NoteItemWrapper'; import {NoteItemWrapper} from '../../components/SimpleList/NoteItemWrapper';
import { useTracked } from '../../provider'; import {useTracked} from '../../provider';
import { ACTIONS } from '../../provider/actions'; import {ACTIONS} from '../../provider/actions';
export const Trash = ({route, navigation}) => { export const Trash = ({route, navigation}) => {
const [state, dispatch] = useTracked(); const [state, dispatch] = useTracked();
const {colors, selectionMode, trash} = state; const {trash} = state;
const isFocused = useIsFocused(); const isFocused = useIsFocused();
@@ -23,9 +23,7 @@ export const Trash = ({route, navigation}) => {
type: 'trash', type: 'trash',
menu: true, menu: true,
canGoBack: false, canGoBack: false,
route: route,
color: null, color: null,
navigation: navigation,
}, },
}); });
dispatch({ dispatch({