2021-10-09 14:29:40 +05:00
|
|
|
import Clipboard from '@react-native-clipboard/clipboard';
|
2021-07-07 11:13:43 +05:00
|
|
|
import absolutify from 'absolutify';
|
2022-01-24 11:51:28 +05:00
|
|
|
import React, { useEffect, useRef, useState } from 'react';
|
|
|
|
|
import { ScrollView } from 'react-native';
|
2021-01-08 12:30:20 +05:00
|
|
|
import {
|
|
|
|
|
ActivityIndicator,
|
2021-10-11 14:06:17 +05:00
|
|
|
Alert,
|
|
|
|
|
Keyboard,
|
2021-01-08 12:30:20 +05:00
|
|
|
KeyboardAvoidingView,
|
|
|
|
|
Platform,
|
2021-07-08 09:34:21 +05:00
|
|
|
SafeAreaView,
|
2021-10-26 12:28:35 +05:00
|
|
|
StatusBar,
|
2021-10-11 14:06:17 +05:00
|
|
|
Text,
|
|
|
|
|
TouchableOpacity,
|
2021-07-07 11:13:43 +05:00
|
|
|
useWindowDimensions,
|
2021-07-30 10:18:14 +05:00
|
|
|
View
|
2021-01-08 12:30:20 +05:00
|
|
|
} from 'react-native';
|
2022-01-24 11:51:28 +05:00
|
|
|
import Animated, { Easing, timing, useValue } from 'react-native-reanimated';
|
|
|
|
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
2021-10-09 14:29:40 +05:00
|
|
|
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
|
2021-07-07 11:13:43 +05:00
|
|
|
import WebView from 'react-native-webview';
|
|
|
|
|
import ShareExtension from 'rn-extensions-share';
|
2022-01-24 11:51:28 +05:00
|
|
|
import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../src/services/EventManager';
|
|
|
|
|
import { getElevation } from '../src/utils';
|
|
|
|
|
import { db } from '../src/utils/database';
|
2021-10-02 10:09:12 +05:00
|
|
|
import Storage from '../src/utils/storage';
|
2022-01-24 11:51:28 +05:00
|
|
|
import { sleep } from '../src/utils/TimeUtils';
|
|
|
|
|
import { Search } from './search';
|
|
|
|
|
import { useShareStore } from './store';
|
2022-01-04 11:27:20 +05:00
|
|
|
import isURL from 'validator/lib/isURL';
|
2022-01-24 11:51:28 +05:00
|
|
|
import { getLinkPreview } from 'link-preview-js';
|
2021-07-06 15:01:52 +05:00
|
|
|
|
2021-07-07 11:44:15 +05:00
|
|
|
const AnimatedKAV = Animated.createAnimatedComponent(KeyboardAvoidingView);
|
2021-07-08 09:34:21 +05:00
|
|
|
const AnimatedSAV = Animated.createAnimatedComponent(SafeAreaView);
|
2021-07-06 15:01:52 +05:00
|
|
|
async function sanitizeHtml(site) {
|
|
|
|
|
try {
|
|
|
|
|
let html = await fetch(site);
|
|
|
|
|
html = await html.text();
|
2021-10-09 14:29:40 +05:00
|
|
|
let siteHtml = html.replace(
|
2021-10-09 16:44:44 +05:00
|
|
|
/(?:<(script|button|input|textarea|style|link|head)(?:\s[^>]*)?>)\s*((?:(?!<\1)[\s\S])*)\s*(?:<\/\1>)/g,
|
2021-10-09 14:29:40 +05:00
|
|
|
''
|
|
|
|
|
);
|
2021-07-06 15:01:52 +05:00
|
|
|
return absolutify(siteHtml, site);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function makeHtmlFromUrl(url) {
|
2021-07-07 11:13:43 +05:00
|
|
|
return `<a style="overflow-wrap:anywhere;white-space:pre-wrap" href='${url}' target='_blank'>${url}</a>`;
|
2021-07-06 15:01:52 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function makeHtmlFromPlainText(text) {
|
2021-07-07 11:13:43 +05:00
|
|
|
if (!text) return '';
|
2021-12-03 10:00:03 +05:00
|
|
|
|
2021-12-09 01:02:21 +05:00
|
|
|
return `<p style="overflow-wrap:anywhere;white-space:pre-wrap" >${text.replace(
|
|
|
|
|
/(?:\r\n|\r|\n)/g,
|
|
|
|
|
'<br>'
|
|
|
|
|
)}</p>`;
|
2021-07-06 15:01:52 +05:00
|
|
|
}
|
|
|
|
|
|
2021-10-09 14:29:40 +05:00
|
|
|
function getBaseUrl(site) {
|
|
|
|
|
var url = site.split('/').slice(0, 3).join('/');
|
|
|
|
|
return url;
|
|
|
|
|
}
|
2022-01-17 19:02:41 +05:00
|
|
|
function absolutifyImgs(html, site) {
|
2022-01-24 11:51:28 +05:00
|
|
|
let { parse } = require('node-html-parser');
|
2022-01-17 19:02:41 +05:00
|
|
|
let parser = parse(html);
|
2021-10-09 14:29:40 +05:00
|
|
|
|
|
|
|
|
let images = parser.querySelectorAll('img');
|
|
|
|
|
for (var i = 0; i < images.length; i++) {
|
|
|
|
|
let img = images[i];
|
|
|
|
|
let url = getBaseUrl(site);
|
2022-01-17 19:02:41 +05:00
|
|
|
let src = img.getAttribute('src');
|
|
|
|
|
if (src.startsWith('/')) {
|
|
|
|
|
if (src.startsWith('//')) {
|
|
|
|
|
src = src.replace('//', 'https://');
|
2021-10-09 14:29:40 +05:00
|
|
|
} else {
|
2022-01-17 19:02:41 +05:00
|
|
|
src = url + src;
|
2021-10-09 14:29:40 +05:00
|
|
|
}
|
|
|
|
|
}
|
2022-01-17 19:02:41 +05:00
|
|
|
if (src.startsWith('data:')) {
|
|
|
|
|
src = '';
|
2021-10-09 16:44:44 +05:00
|
|
|
}
|
2022-01-17 19:02:41 +05:00
|
|
|
img.setAttribute('src', src);
|
2021-10-09 14:29:40 +05:00
|
|
|
}
|
2022-01-17 19:02:41 +05:00
|
|
|
return parser.outerHTML;
|
2021-10-09 14:29:40 +05:00
|
|
|
}
|
|
|
|
|
|
2021-07-07 08:46:29 +05:00
|
|
|
let defaultNote = {
|
|
|
|
|
title: null,
|
|
|
|
|
id: null,
|
|
|
|
|
content: {
|
|
|
|
|
type: 'tiny',
|
2021-07-30 10:18:14 +05:00
|
|
|
data: null
|
|
|
|
|
}
|
2021-07-07 08:46:29 +05:00
|
|
|
};
|
|
|
|
|
|
2021-10-08 12:22:47 +05:00
|
|
|
const modes = {
|
|
|
|
|
1: {
|
|
|
|
|
type: 'text',
|
|
|
|
|
title: 'Plain text',
|
|
|
|
|
icon: 'card-text-outline'
|
|
|
|
|
},
|
|
|
|
|
2: {
|
|
|
|
|
type: 'clip',
|
|
|
|
|
title: 'Web clip',
|
|
|
|
|
icon: 'web'
|
|
|
|
|
},
|
|
|
|
|
3: {
|
|
|
|
|
type: 'link',
|
|
|
|
|
title: 'Link',
|
|
|
|
|
icon: 'link'
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2022-01-24 11:51:28 +05:00
|
|
|
const NotesnookShare = ({ quicknote = false }) => {
|
2021-10-11 11:25:22 +05:00
|
|
|
const colors = useShareStore(state => state.colors);
|
2021-12-25 09:33:10 +05:00
|
|
|
const accent = useShareStore(state => state.accent);
|
|
|
|
|
|
2021-10-11 11:25:22 +05:00
|
|
|
const appendNote = useShareStore(state => state.appendNote);
|
2022-01-24 11:51:28 +05:00
|
|
|
const [note, setNote] = useState({ ...defaultNote });
|
2021-07-06 15:01:52 +05:00
|
|
|
const [loadingIntent, setLoadingIntent] = useState(true);
|
2021-07-07 08:46:29 +05:00
|
|
|
const [loading, setLoading] = useState(false);
|
2021-07-06 15:01:52 +05:00
|
|
|
const [floating, setFloating] = useState(false);
|
|
|
|
|
const [rawData, setRawData] = useState({
|
|
|
|
|
type: null,
|
2021-07-30 10:18:14 +05:00
|
|
|
value: null
|
2021-07-06 15:01:52 +05:00
|
|
|
});
|
2021-10-11 11:25:22 +05:00
|
|
|
const [mode, setMode] = useState(1);
|
|
|
|
|
const keyboardHeight = useRef(0);
|
2022-01-24 11:51:28 +05:00
|
|
|
const { width, height } = useWindowDimensions();
|
2021-07-07 08:46:29 +05:00
|
|
|
const webviewRef = useRef();
|
2021-07-07 11:44:15 +05:00
|
|
|
const opacity = useValue(0);
|
|
|
|
|
const translate = useValue(1000);
|
2022-01-24 11:51:28 +05:00
|
|
|
const insets = Platform.OS === 'android' ? { top: StatusBar.currentHeight } : useSafeAreaInsets();
|
2021-10-08 12:22:47 +05:00
|
|
|
const prevAnimation = useRef(null);
|
2021-10-11 11:25:22 +05:00
|
|
|
const [showSearch, setShowSearch] = useState(false);
|
2021-07-07 11:44:15 +05:00
|
|
|
|
|
|
|
|
const animate = (opacityV, translateV) => {
|
2021-10-08 12:22:47 +05:00
|
|
|
prevAnimation.current = translateV;
|
2021-07-08 09:34:21 +05:00
|
|
|
if (Platform.OS === 'ios') return;
|
2021-07-07 11:44:15 +05:00
|
|
|
timing(opacity, {
|
|
|
|
|
toValue: opacityV,
|
|
|
|
|
duration: 300,
|
2021-07-30 10:18:14 +05:00
|
|
|
easing: Easing.in(Easing.ease)
|
2021-07-07 11:44:15 +05:00
|
|
|
}).start();
|
|
|
|
|
timing(translate, {
|
|
|
|
|
toValue: translateV,
|
|
|
|
|
duration: 300,
|
2021-07-30 10:18:14 +05:00
|
|
|
easing: Easing.in(Easing.ease)
|
2021-07-07 11:44:15 +05:00
|
|
|
}).start();
|
|
|
|
|
};
|
2021-07-06 15:01:52 +05:00
|
|
|
|
2021-10-09 14:29:40 +05:00
|
|
|
const onKeyboardDidShow = event => {
|
2021-10-08 12:22:47 +05:00
|
|
|
let kHeight = event.endCoordinates.height;
|
2021-10-09 16:44:44 +05:00
|
|
|
keyboardHeight.current = kHeight;
|
2021-10-09 14:29:40 +05:00
|
|
|
};
|
2021-10-08 12:22:47 +05:00
|
|
|
|
|
|
|
|
const onKeyboardDidHide = () => {
|
2021-10-09 16:44:44 +05:00
|
|
|
keyboardHeight.current = 0;
|
2021-10-09 14:29:40 +05:00
|
|
|
};
|
2021-10-08 12:22:47 +05:00
|
|
|
|
2021-07-06 15:01:52 +05:00
|
|
|
useEffect(() => {
|
2021-12-25 09:33:10 +05:00
|
|
|
useShareStore.getState().setAccent();
|
2021-10-09 14:29:40 +05:00
|
|
|
let keyboardWillChangeFrame = Keyboard.addListener(
|
|
|
|
|
'keyboardWillChangeFrame',
|
|
|
|
|
onKeyboardWillChangeFrame
|
|
|
|
|
);
|
2022-01-24 11:51:28 +05:00
|
|
|
let keyboardDidShow = Keyboard.addListener('keyboardDidShow', onKeyboardDidShow);
|
|
|
|
|
let keyboardDidHide = Keyboard.addListener('keyboardDidHide', onKeyboardDidHide);
|
2021-07-06 15:01:52 +05:00
|
|
|
return () => {
|
2021-10-08 12:22:47 +05:00
|
|
|
keyboardWillChangeFrame?.remove();
|
|
|
|
|
keyboardDidShow?.remove();
|
|
|
|
|
keyboardDidHide?.remove();
|
2021-07-06 15:01:52 +05:00
|
|
|
};
|
2021-10-09 14:29:40 +05:00
|
|
|
}, []);
|
2021-07-06 15:01:52 +05:00
|
|
|
|
|
|
|
|
const onKeyboardWillChangeFrame = event => {
|
2021-07-08 09:34:21 +05:00
|
|
|
setFloating(event.endCoordinates.width !== width);
|
2021-07-06 15:01:52 +05:00
|
|
|
};
|
|
|
|
|
|
2021-10-09 14:29:40 +05:00
|
|
|
const showLinkPreview = async (note, link) => {
|
|
|
|
|
let _note = note;
|
|
|
|
|
_note.content.data = makeHtmlFromUrl(link);
|
2021-07-06 15:01:52 +05:00
|
|
|
try {
|
2021-07-07 08:46:29 +05:00
|
|
|
let preview = await getLinkPreview(link);
|
2022-01-17 19:02:41 +05:00
|
|
|
_note.title = preview.title;
|
2021-07-07 08:46:29 +05:00
|
|
|
} catch (e) {
|
|
|
|
|
console.log(e);
|
|
|
|
|
}
|
2021-10-09 14:29:40 +05:00
|
|
|
return note;
|
2021-07-06 15:01:52 +05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const loadData = async () => {
|
2021-01-08 12:30:20 +05:00
|
|
|
try {
|
2021-10-09 16:44:44 +05:00
|
|
|
defaultNote.content.data = null;
|
2022-01-24 11:51:28 +05:00
|
|
|
setNote({ ...defaultNote });
|
2021-01-08 12:30:20 +05:00
|
|
|
const data = await ShareExtension.data();
|
2021-10-08 12:22:47 +05:00
|
|
|
if (!data || data.length === 0) {
|
|
|
|
|
setRawData({
|
|
|
|
|
value: ''
|
|
|
|
|
});
|
|
|
|
|
setLoadingIntent(false);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-01-24 11:51:28 +05:00
|
|
|
let note = { ...defaultNote };
|
|
|
|
|
for (let item of data) {
|
2021-07-07 08:46:29 +05:00
|
|
|
if (item.type === 'text') {
|
|
|
|
|
setRawData(item);
|
2022-01-04 11:27:20 +05:00
|
|
|
if (isURL(item.value)) {
|
2021-10-09 14:29:40 +05:00
|
|
|
note = await showLinkPreview(note, item.value);
|
2021-07-07 08:46:29 +05:00
|
|
|
} else {
|
2021-10-09 14:29:40 +05:00
|
|
|
note.content.data = makeHtmlFromPlainText(item.value);
|
2021-07-07 08:46:29 +05:00
|
|
|
}
|
|
|
|
|
}
|
2021-02-09 16:32:27 +05:00
|
|
|
}
|
2022-01-24 11:51:28 +05:00
|
|
|
setNote({ ...note });
|
2021-07-07 08:46:29 +05:00
|
|
|
} catch (e) {}
|
|
|
|
|
setLoadingIntent(false);
|
|
|
|
|
};
|
2021-02-09 16:32:27 +05:00
|
|
|
|
2021-07-07 08:46:29 +05:00
|
|
|
useEffect(() => {
|
2021-12-09 01:33:23 +05:00
|
|
|
console.log('setting value in storage');
|
2021-07-07 08:46:29 +05:00
|
|
|
loadData();
|
2021-10-11 11:25:22 +05:00
|
|
|
useShareStore.getState().restoreAppendNote();
|
2021-10-08 12:22:47 +05:00
|
|
|
sleep(50).then(() => {
|
2021-07-07 11:44:15 +05:00
|
|
|
animate(1, 0);
|
2021-12-09 01:33:23 +05:00
|
|
|
sleep(500).then(r => {
|
2021-12-25 09:33:10 +05:00
|
|
|
Storage.write('shareExtensionOpened', 'opened');
|
2021-12-09 01:33:23 +05:00
|
|
|
});
|
2021-07-07 11:44:15 +05:00
|
|
|
});
|
2021-07-07 08:46:29 +05:00
|
|
|
}, []);
|
2021-04-21 12:30:58 +05:00
|
|
|
|
2021-07-07 11:44:15 +05:00
|
|
|
const close = async () => {
|
|
|
|
|
animate(0, 1000);
|
|
|
|
|
await sleep(300);
|
2022-01-24 11:51:28 +05:00
|
|
|
setNote({ ...defaultNote });
|
2021-07-30 10:18:14 +05:00
|
|
|
setLoadingIntent(true);
|
2021-10-11 14:06:17 +05:00
|
|
|
if (quicknote) {
|
|
|
|
|
ShareExtension.openURL('ShareMedia://MainApp');
|
|
|
|
|
} else {
|
|
|
|
|
ShareExtension.close();
|
|
|
|
|
}
|
2021-01-08 12:30:20 +05:00
|
|
|
};
|
|
|
|
|
|
2021-07-07 08:46:29 +05:00
|
|
|
const onLoad = () => {
|
2021-10-09 16:44:44 +05:00
|
|
|
postMessage(webviewRef, 'htmldiff', note.content?.data || '');
|
2021-11-02 13:23:35 +05:00
|
|
|
setTimeout(() => {
|
|
|
|
|
webviewRef.current?.injectJavaScript(`document
|
|
|
|
|
.querySelector('.htmldiff_div')
|
2021-11-02 13:28:37 +05:00
|
|
|
.setAttribute('contenteditable', 'true');`);
|
2021-12-09 01:13:09 +05:00
|
|
|
webviewRef.current?.injectJavaScript(`
|
2021-12-09 01:02:21 +05:00
|
|
|
pageTheme.colors = ${theme};
|
|
|
|
|
setTheme();
|
|
|
|
|
`);
|
2021-11-02 13:28:37 +05:00
|
|
|
}, 300);
|
2022-01-24 11:51:28 +05:00
|
|
|
let theme = { ...colors };
|
2021-07-07 08:46:29 +05:00
|
|
|
theme.factor = 1;
|
2021-12-09 01:02:21 +05:00
|
|
|
|
2021-07-07 08:46:29 +05:00
|
|
|
postMessage(webviewRef, 'theme', JSON.stringify(theme));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function postMessage(webview, type, value = null) {
|
|
|
|
|
let message = {
|
|
|
|
|
type: type,
|
2021-07-30 10:18:14 +05:00
|
|
|
value
|
2021-07-07 08:46:29 +05:00
|
|
|
};
|
|
|
|
|
webview.current?.postMessage(JSON.stringify(message));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const onPress = async () => {
|
2022-01-24 11:51:28 +05:00
|
|
|
let content = await getContent();
|
2021-10-09 14:29:40 +05:00
|
|
|
if (!content || content === '') {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-07-07 08:46:29 +05:00
|
|
|
setLoading(true);
|
2021-10-11 11:25:22 +05:00
|
|
|
await db.init();
|
|
|
|
|
await db.notes.init();
|
|
|
|
|
|
|
|
|
|
if (appendNote && !db.notes.note(appendNote.id)) {
|
|
|
|
|
useShareStore.getState().setAppendNote(null);
|
|
|
|
|
Alert.alert('The note you are trying to append to has been deleted.');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let _note;
|
|
|
|
|
if (appendNote && db.notes.note(appendNote.id)) {
|
|
|
|
|
let raw = await db.content.raw(appendNote.contentId);
|
|
|
|
|
_note = {
|
2021-10-09 14:29:40 +05:00
|
|
|
content: {
|
2021-10-11 11:25:22 +05:00
|
|
|
data: raw.data + '\n' + content,
|
2021-10-09 14:29:40 +05:00
|
|
|
type: 'tiny'
|
2021-10-11 11:25:22 +05:00
|
|
|
},
|
2021-12-25 14:09:01 +05:00
|
|
|
id: appendNote.id,
|
2022-01-17 19:02:41 +05:00
|
|
|
sessionId: Date.now()
|
2021-10-09 14:29:40 +05:00
|
|
|
};
|
2021-01-08 12:30:20 +05:00
|
|
|
} else {
|
2022-01-24 11:51:28 +05:00
|
|
|
_note = { ...note };
|
2021-10-11 11:25:22 +05:00
|
|
|
_note.content.data = content;
|
2021-12-25 14:09:01 +05:00
|
|
|
_note.sessionId = Date.now();
|
2021-01-08 12:30:20 +05:00
|
|
|
}
|
2021-10-11 11:25:22 +05:00
|
|
|
await db.notes.add(_note);
|
2021-01-08 12:30:20 +05:00
|
|
|
await Storage.write('notesAddedFromIntent', 'added');
|
2021-07-07 11:13:43 +05:00
|
|
|
close();
|
2021-10-11 11:25:22 +05:00
|
|
|
setLoading(false);
|
2021-01-08 12:30:20 +05:00
|
|
|
};
|
|
|
|
|
|
2021-10-09 16:44:44 +05:00
|
|
|
const sourceUri = 'Web.bundle/site/plaineditor.html';
|
2021-07-08 09:34:21 +05:00
|
|
|
|
|
|
|
|
const onShouldStartLoadWithRequest = request => {
|
|
|
|
|
if (request.url.includes('/site/plaineditor.html')) {
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2021-10-09 14:29:40 +05:00
|
|
|
const getContent = () => {
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
|
let oncontent = value => {
|
|
|
|
|
eUnSubscribeEvent('share_content_event', oncontent);
|
|
|
|
|
resolve(value);
|
|
|
|
|
};
|
|
|
|
|
eSubscribeEvent('share_content_event', oncontent);
|
|
|
|
|
webviewRef.current?.injectJavaScript(`(function() {
|
|
|
|
|
let html = document.querySelector(".htmldiff_div").innerHTML;
|
|
|
|
|
if (!html) {
|
|
|
|
|
html = '';
|
|
|
|
|
}
|
|
|
|
|
reactNativeEventHandler('tiny', html);
|
|
|
|
|
})();`);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const onMessage = event => {
|
|
|
|
|
if (!event) return;
|
|
|
|
|
let data = JSON.parse(event.nativeEvent.data);
|
|
|
|
|
if (data.type === 'tiny') {
|
|
|
|
|
eSendEvent('share_content_event', data.value);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
onLoad();
|
|
|
|
|
}, [note]);
|
|
|
|
|
|
2021-10-31 10:30:21 +05:00
|
|
|
const changeMode = async m => {
|
|
|
|
|
setMode(m);
|
2021-10-11 11:25:22 +05:00
|
|
|
|
2021-10-31 10:30:21 +05:00
|
|
|
setLoading(true);
|
|
|
|
|
try {
|
|
|
|
|
if (m === 2) {
|
|
|
|
|
let html = await sanitizeHtml(rawData.value);
|
|
|
|
|
html = await absolutifyImgs(html, rawData.value);
|
|
|
|
|
setNote(note => {
|
|
|
|
|
note.content.data = html;
|
2022-01-24 11:51:28 +05:00
|
|
|
return { ...note };
|
2021-10-31 10:30:21 +05:00
|
|
|
});
|
|
|
|
|
} else {
|
2022-01-04 11:27:20 +05:00
|
|
|
let html = isURL(rawData.value)
|
2021-10-31 10:30:21 +05:00
|
|
|
? makeHtmlFromUrl(rawData.value)
|
|
|
|
|
: makeHtmlFromPlainText(rawData.value);
|
|
|
|
|
setNote(note => {
|
|
|
|
|
note.content.data = html;
|
2022-01-24 11:51:28 +05:00
|
|
|
return { ...note };
|
2021-10-31 10:30:21 +05:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
} finally {
|
|
|
|
|
setLoading(false);
|
2021-10-11 11:25:22 +05:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const onPaste = async () => {
|
|
|
|
|
let text = await Clipboard.getString();
|
|
|
|
|
if (text) {
|
|
|
|
|
let content = await getContent();
|
|
|
|
|
setNote(note => {
|
|
|
|
|
note.content.data = content + '\n' + makeHtmlFromPlainText(text);
|
2022-01-24 11:51:28 +05:00
|
|
|
return { ...note };
|
2021-10-11 11:25:22 +05:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
2021-10-09 16:44:44 +05:00
|
|
|
|
2021-07-07 08:46:29 +05:00
|
|
|
return (
|
2021-07-08 09:34:21 +05:00
|
|
|
<AnimatedSAV
|
2021-07-07 08:46:29 +05:00
|
|
|
style={{
|
|
|
|
|
width: width > 500 ? 500 : width,
|
|
|
|
|
height: height,
|
2021-10-23 09:58:37 +05:00
|
|
|
opacity: Platform.OS !== 'ios' ? opacity : 1,
|
2021-10-26 12:28:35 +05:00
|
|
|
alignSelf: 'center'
|
2022-01-24 11:51:28 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2021-10-13 10:30:47 +05:00
|
|
|
{quicknote && !showSearch ? (
|
2021-10-23 09:44:59 +05:00
|
|
|
<View
|
2021-01-08 12:30:20 +05:00
|
|
|
style={{
|
2021-10-23 09:44:59 +05:00
|
|
|
width: '100%',
|
|
|
|
|
backgroundColor: colors.bg,
|
|
|
|
|
height: 50 + insets.top,
|
|
|
|
|
paddingTop: insets.top,
|
|
|
|
|
...getElevation(1),
|
|
|
|
|
marginTop: -insets.top,
|
|
|
|
|
flexDirection: 'row',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
justifyContent: 'space-between'
|
2022-01-24 11:51:28 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2021-10-23 09:44:59 +05:00
|
|
|
<Button
|
|
|
|
|
type="action"
|
|
|
|
|
icon="close"
|
|
|
|
|
iconColor={colors.pri}
|
|
|
|
|
onPress={() => {
|
|
|
|
|
if (showSearch) {
|
|
|
|
|
console.log('hide search');
|
|
|
|
|
setShowSearch(false);
|
|
|
|
|
animate(1, 0);
|
|
|
|
|
} else {
|
|
|
|
|
close();
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
style={{
|
|
|
|
|
width: 50,
|
|
|
|
|
height: 50,
|
|
|
|
|
marginBottom: 0
|
|
|
|
|
}}
|
|
|
|
|
iconSize={25}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<Text
|
|
|
|
|
style={{
|
|
|
|
|
color: colors.pri,
|
2021-11-02 11:23:12 +05:00
|
|
|
fontSize: 17,
|
2021-10-23 09:57:48 +05:00
|
|
|
fontFamily: 'OpenSans-Regular'
|
2022-01-24 11:51:28 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2021-10-23 09:44:59 +05:00
|
|
|
Quick note
|
|
|
|
|
</Text>
|
|
|
|
|
|
|
|
|
|
<Button
|
|
|
|
|
type="action"
|
|
|
|
|
icon="check"
|
2021-12-25 09:33:10 +05:00
|
|
|
iconColor={accent.color}
|
2021-10-23 09:44:59 +05:00
|
|
|
onPress={onPress}
|
|
|
|
|
style={{
|
|
|
|
|
width: 50,
|
|
|
|
|
height: 50,
|
|
|
|
|
marginBottom: 0
|
|
|
|
|
}}
|
|
|
|
|
iconSize={25}
|
|
|
|
|
/>
|
|
|
|
|
</View>
|
2021-10-11 14:06:17 +05:00
|
|
|
) : (
|
|
|
|
|
<TouchableOpacity
|
|
|
|
|
activeOpacity={1}
|
|
|
|
|
onPress={() => {
|
|
|
|
|
if (showSearch) {
|
|
|
|
|
console.log('hide search');
|
|
|
|
|
setShowSearch(false);
|
|
|
|
|
animate(1, 0);
|
|
|
|
|
} else {
|
|
|
|
|
close();
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
style={{
|
|
|
|
|
width: '100%',
|
|
|
|
|
height: '100%',
|
|
|
|
|
position: 'absolute'
|
2022-01-24 11:51:28 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2021-10-11 14:06:17 +05:00
|
|
|
<View
|
|
|
|
|
style={{
|
|
|
|
|
width: '100%',
|
|
|
|
|
height: '100%',
|
|
|
|
|
backgroundColor: 'white',
|
|
|
|
|
opacity: 0.01
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<View />
|
|
|
|
|
</TouchableOpacity>
|
|
|
|
|
)}
|
2021-07-07 08:46:29 +05:00
|
|
|
|
2021-12-03 09:34:44 +05:00
|
|
|
{showSearch ? (
|
2021-10-11 11:25:22 +05:00
|
|
|
<Search
|
2021-10-23 09:44:59 +05:00
|
|
|
quicknote={quicknote}
|
2021-10-11 11:25:22 +05:00
|
|
|
getKeyboardHeight={() => keyboardHeight.current}
|
|
|
|
|
close={() => {
|
|
|
|
|
setShowSearch(false);
|
|
|
|
|
animate(1, 0);
|
2021-10-09 16:44:44 +05:00
|
|
|
}}
|
|
|
|
|
/>
|
2021-12-03 09:34:44 +05:00
|
|
|
) : null}
|
2021-10-09 16:44:44 +05:00
|
|
|
|
2021-07-07 11:44:15 +05:00
|
|
|
<AnimatedKAV
|
2021-12-09 01:02:21 +05:00
|
|
|
enabled={!floating}
|
2021-10-08 12:22:47 +05:00
|
|
|
onLayout={event => {
|
|
|
|
|
if (prevAnimation.current === 0) return;
|
|
|
|
|
translate.setValue(event.nativeEvent.layout.height + 30);
|
|
|
|
|
}}
|
2021-07-07 08:46:29 +05:00
|
|
|
style={{
|
|
|
|
|
paddingVertical: 25,
|
2021-10-08 12:22:47 +05:00
|
|
|
backgroundColor: 'transparent',
|
2021-07-08 09:34:21 +05:00
|
|
|
marginBottom: insets.top,
|
2022-01-25 19:33:25 +05:00
|
|
|
display: showSearch ? 'none' : 'flex'
|
2021-07-07 08:46:29 +05:00
|
|
|
}}
|
2022-01-24 11:51:28 +05:00
|
|
|
behavior={Platform.OS === 'ios' ? 'padding' : null}
|
|
|
|
|
>
|
2021-10-09 14:29:40 +05:00
|
|
|
<View
|
|
|
|
|
style={{
|
|
|
|
|
maxHeight: '100%',
|
2021-12-09 01:02:21 +05:00
|
|
|
paddingHorizontal: 12
|
2022-01-24 11:51:28 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2021-10-31 10:30:21 +05:00
|
|
|
<ScrollView
|
|
|
|
|
horizontal
|
|
|
|
|
contentContainerStyle={{
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
height: 45
|
|
|
|
|
}}
|
2021-10-09 16:44:44 +05:00
|
|
|
style={{
|
|
|
|
|
width: '100%',
|
2022-01-25 19:33:25 +05:00
|
|
|
height: 35,
|
2021-10-09 16:44:44 +05:00
|
|
|
borderRadius: 10,
|
2021-10-31 10:30:21 +05:00
|
|
|
flexDirection: 'row'
|
2022-01-24 11:51:28 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2021-10-09 16:44:44 +05:00
|
|
|
<Button
|
2021-12-25 09:33:10 +05:00
|
|
|
color={appendNote ? colors.nav : accent.color}
|
2021-10-11 11:25:22 +05:00
|
|
|
onPress={() => {
|
|
|
|
|
useShareStore.getState().setAppendNote(null);
|
|
|
|
|
}}
|
2021-10-09 16:44:44 +05:00
|
|
|
icon="plus"
|
|
|
|
|
iconSize={18}
|
|
|
|
|
iconColor={!appendNote ? colors.light : colors.icon}
|
2021-10-11 11:25:22 +05:00
|
|
|
title="Create new note"
|
|
|
|
|
textColor={!appendNote ? colors.light : colors.icon}
|
|
|
|
|
type="rounded"
|
2022-01-25 19:33:25 +05:00
|
|
|
textStyle={{
|
|
|
|
|
fontSize: 13
|
|
|
|
|
}}
|
2021-10-09 16:44:44 +05:00
|
|
|
style={{
|
2021-10-11 14:06:17 +05:00
|
|
|
paddingHorizontal: 12,
|
2022-01-25 19:33:25 +05:00
|
|
|
...getElevation(1),
|
|
|
|
|
height: 35
|
2021-10-09 16:44:44 +05:00
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<Button
|
2021-12-25 09:33:10 +05:00
|
|
|
color={!appendNote ? colors.nav : accent.color}
|
2021-10-11 11:25:22 +05:00
|
|
|
onPress={() => {
|
|
|
|
|
setShowSearch(true);
|
|
|
|
|
animate(1, 1000);
|
|
|
|
|
}}
|
2021-10-09 16:44:44 +05:00
|
|
|
icon="text-short"
|
|
|
|
|
iconSize={18}
|
|
|
|
|
iconColor={appendNote ? colors.light : colors.icon}
|
2022-01-24 11:51:28 +05:00
|
|
|
title={`${appendNote ? appendNote.title.slice(0, 25) : 'Append to note'}`}
|
2021-10-11 11:25:22 +05:00
|
|
|
textColor={appendNote ? colors.light : colors.icon}
|
|
|
|
|
type="rounded"
|
2022-01-25 19:33:25 +05:00
|
|
|
textStyle={{
|
|
|
|
|
fontSize: 13
|
|
|
|
|
}}
|
2021-10-09 16:44:44 +05:00
|
|
|
style={{
|
2021-10-11 14:06:17 +05:00
|
|
|
paddingHorizontal: 12,
|
2022-01-25 19:33:25 +05:00
|
|
|
...getElevation(1),
|
|
|
|
|
height: 35
|
2021-10-09 16:44:44 +05:00
|
|
|
}}
|
|
|
|
|
/>
|
2021-10-31 10:30:21 +05:00
|
|
|
</ScrollView>
|
2021-10-09 16:44:44 +05:00
|
|
|
|
2021-01-08 12:30:20 +05:00
|
|
|
<View
|
|
|
|
|
style={{
|
2021-10-09 14:29:40 +05:00
|
|
|
width: '100%'
|
2022-01-24 11:51:28 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2021-11-02 13:28:37 +05:00
|
|
|
{!quicknote ? (
|
2021-10-13 10:30:47 +05:00
|
|
|
<Button
|
2021-12-25 09:33:10 +05:00
|
|
|
color={accent.color}
|
2021-10-13 10:30:47 +05:00
|
|
|
onPress={onPress}
|
|
|
|
|
loading={loading || loadingIntent}
|
|
|
|
|
icon="check"
|
2022-01-25 19:33:25 +05:00
|
|
|
iconSize={22}
|
2021-10-13 10:30:47 +05:00
|
|
|
iconColor={colors.light}
|
|
|
|
|
style={{
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
zIndex: 999,
|
|
|
|
|
...getElevation(10),
|
|
|
|
|
right: 24,
|
2022-01-25 19:33:25 +05:00
|
|
|
bottom: -25,
|
|
|
|
|
paddingHorizontal: 24,
|
|
|
|
|
height: 35,
|
|
|
|
|
borderRadius: 100
|
2021-10-13 10:30:47 +05:00
|
|
|
}}
|
|
|
|
|
/>
|
2021-11-02 13:28:37 +05:00
|
|
|
) : null}
|
2021-10-09 14:29:40 +05:00
|
|
|
|
2021-01-08 12:30:20 +05:00
|
|
|
<View
|
|
|
|
|
style={{
|
2021-10-09 14:29:40 +05:00
|
|
|
marginTop: 10,
|
|
|
|
|
minHeight: 100,
|
|
|
|
|
borderRadius: 10,
|
2021-10-23 09:44:59 +05:00
|
|
|
...getElevation(quicknote ? 1 : 5),
|
2021-10-26 12:28:35 +05:00
|
|
|
backgroundColor: colors.bg,
|
|
|
|
|
overflow: 'hidden'
|
2022-01-24 11:51:28 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2021-10-09 14:29:40 +05:00
|
|
|
<View
|
|
|
|
|
style={{
|
|
|
|
|
width: '100%',
|
|
|
|
|
height: height * 0.25,
|
2021-10-11 14:06:17 +05:00
|
|
|
paddingBottom: 15,
|
|
|
|
|
borderRadius: 10
|
2022-01-24 11:51:28 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2021-10-09 14:29:40 +05:00
|
|
|
<WebView
|
|
|
|
|
onLoad={onLoad}
|
|
|
|
|
ref={webviewRef}
|
2021-10-08 12:22:47 +05:00
|
|
|
style={{
|
2021-10-09 14:29:40 +05:00
|
|
|
width: '100%',
|
|
|
|
|
height: '100%',
|
2021-12-09 01:02:21 +05:00
|
|
|
borderRadius: 10,
|
2021-12-25 09:33:10 +05:00
|
|
|
backgroundColor: 'transparent'
|
2021-10-09 14:29:40 +05:00
|
|
|
}}
|
|
|
|
|
cacheMode="LOAD_DEFAULT"
|
|
|
|
|
domStorageEnabled={true}
|
|
|
|
|
scrollEnabled={true}
|
|
|
|
|
bounces={false}
|
|
|
|
|
allowFileAccess={true}
|
|
|
|
|
scalesPageToFit={true}
|
2022-01-24 11:51:28 +05:00
|
|
|
allowingReadAccessToURL={Platform.OS === 'android' ? true : null}
|
2021-10-09 14:29:40 +05:00
|
|
|
onMessage={onMessage}
|
|
|
|
|
onShouldStartLoadWithRequest={onShouldStartLoadWithRequest}
|
|
|
|
|
allowFileAccessFromFileURLs={true}
|
|
|
|
|
allowUniversalAccessFromFileURLs={true}
|
|
|
|
|
originWhitelist={['*']}
|
|
|
|
|
javaScriptEnabled={true}
|
|
|
|
|
cacheEnabled={true}
|
|
|
|
|
source={
|
|
|
|
|
Platform.OS === 'ios'
|
2022-01-24 11:51:28 +05:00
|
|
|
? { uri: sourceUri }
|
2021-10-09 14:29:40 +05:00
|
|
|
: {
|
|
|
|
|
uri: 'file:///android_asset/plaineditor.html',
|
|
|
|
|
baseUrl: 'file:///android_asset/'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
</View>
|
2021-10-08 12:22:47 +05:00
|
|
|
|
2021-10-11 11:25:22 +05:00
|
|
|
{appendNote ? (
|
|
|
|
|
<Text
|
|
|
|
|
style={{
|
|
|
|
|
fontSize: 11,
|
|
|
|
|
color: colors.gray,
|
|
|
|
|
fontFamily: 'OpenSans-Regular',
|
|
|
|
|
paddingHorizontal: 12,
|
|
|
|
|
marginBottom: 10,
|
|
|
|
|
flexWrap: 'wrap'
|
2022-01-24 11:51:28 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2021-10-11 11:25:22 +05:00
|
|
|
This shared note will be appended to{' '}
|
|
|
|
|
<Text
|
|
|
|
|
style={{
|
2021-12-25 09:33:10 +05:00
|
|
|
color: accent.color,
|
2021-10-11 11:25:22 +05:00
|
|
|
fontFamily: 'OpenSans-SemiBold'
|
2022-01-24 11:51:28 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2021-10-11 11:25:22 +05:00
|
|
|
"{appendNote.title}"
|
|
|
|
|
</Text>{' '}
|
|
|
|
|
. Click on "Create new note" to add to a new note instead.
|
|
|
|
|
</Text>
|
|
|
|
|
) : null}
|
|
|
|
|
|
2021-07-07 08:46:29 +05:00
|
|
|
<View
|
2021-01-08 12:30:20 +05:00
|
|
|
style={{
|
2021-10-09 14:29:40 +05:00
|
|
|
flexDirection: 'row',
|
|
|
|
|
paddingHorizontal: 12,
|
|
|
|
|
paddingRight: 80,
|
|
|
|
|
alignItems: 'center'
|
2022-01-24 11:51:28 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2022-01-04 11:27:20 +05:00
|
|
|
{rawData.value && isURL(rawData.value) ? (
|
2021-10-31 10:30:21 +05:00
|
|
|
<Button
|
|
|
|
|
color={mode == 2 ? colors.shade : colors.nav}
|
|
|
|
|
icon={modes[2].icon}
|
|
|
|
|
onPress={() => changeMode(2)}
|
|
|
|
|
title={modes[2].title}
|
|
|
|
|
iconSize={18}
|
2021-12-25 09:33:10 +05:00
|
|
|
iconColor={mode == 2 ? accent.color : colors.icon}
|
|
|
|
|
textColor={mode == 2 ? accent.color : colors.icon}
|
2021-10-31 10:30:21 +05:00
|
|
|
type="rounded"
|
2022-01-24 11:51:28 +05:00
|
|
|
style={{ paddingHorizontal: 12 }}
|
2021-10-31 10:30:21 +05:00
|
|
|
/>
|
2021-11-02 13:28:37 +05:00
|
|
|
) : null}
|
2021-10-08 12:22:47 +05:00
|
|
|
<Button
|
2021-10-31 10:30:21 +05:00
|
|
|
color={mode == 1 ? colors.shade : colors.nav}
|
|
|
|
|
icon={modes[1].icon}
|
|
|
|
|
onPress={() => changeMode(1)}
|
|
|
|
|
title={modes[1].title}
|
2021-10-09 14:29:40 +05:00
|
|
|
iconSize={18}
|
2021-12-25 09:33:10 +05:00
|
|
|
iconColor={mode == 1 ? accent.color : colors.icon}
|
|
|
|
|
textColor={mode == 1 ? accent.color : colors.icon}
|
2021-10-11 11:25:22 +05:00
|
|
|
type="rounded"
|
2022-01-24 11:51:28 +05:00
|
|
|
style={{ paddingHorizontal: 12 }}
|
2021-07-07 08:46:29 +05:00
|
|
|
/>
|
2021-02-09 16:32:27 +05:00
|
|
|
</View>
|
2021-07-07 08:46:29 +05:00
|
|
|
</View>
|
2021-10-09 14:29:40 +05:00
|
|
|
</View>
|
2021-10-13 10:30:47 +05:00
|
|
|
|
2021-10-09 14:29:40 +05:00
|
|
|
<View
|
|
|
|
|
style={{
|
2021-10-23 09:57:48 +05:00
|
|
|
height: Platform.isPad ? 150 : Platform.OS === 'ios' ? 110 : 40
|
2021-10-09 14:29:40 +05:00
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</View>
|
2021-07-07 11:44:15 +05:00
|
|
|
</AnimatedKAV>
|
2021-07-08 09:34:21 +05:00
|
|
|
</AnimatedSAV>
|
2021-07-07 08:46:29 +05:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2021-10-08 12:22:47 +05:00
|
|
|
const Button = ({
|
|
|
|
|
title,
|
|
|
|
|
onPress,
|
|
|
|
|
color,
|
|
|
|
|
loading,
|
|
|
|
|
style,
|
|
|
|
|
textStyle,
|
|
|
|
|
icon,
|
2021-10-11 14:06:17 +05:00
|
|
|
iconSize = 22,
|
2021-10-08 12:22:47 +05:00
|
|
|
type = 'button',
|
2021-10-11 11:25:22 +05:00
|
|
|
iconColor = 'gray',
|
2021-10-23 09:44:59 +05:00
|
|
|
textColor = 'white',
|
|
|
|
|
fontSize = 18
|
2021-10-08 12:22:47 +05:00
|
|
|
}) => {
|
|
|
|
|
const types = {
|
|
|
|
|
action: {
|
2021-10-11 11:25:22 +05:00
|
|
|
style: {
|
|
|
|
|
width: 60,
|
|
|
|
|
height: 60,
|
|
|
|
|
borderRadius: 100,
|
|
|
|
|
minWidth: 0,
|
|
|
|
|
paddingHorizontal: 0
|
|
|
|
|
},
|
|
|
|
|
textStyle: {}
|
2021-10-08 12:22:47 +05:00
|
|
|
},
|
|
|
|
|
button: {
|
2021-10-11 11:25:22 +05:00
|
|
|
style: {
|
|
|
|
|
height: 50,
|
|
|
|
|
borderRadius: 5,
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
flexDirection: 'row',
|
|
|
|
|
marginBottom: 10,
|
|
|
|
|
minWidth: 80,
|
|
|
|
|
paddingHorizontal: 20
|
|
|
|
|
},
|
|
|
|
|
textStyle: {}
|
|
|
|
|
},
|
|
|
|
|
rounded: {
|
|
|
|
|
style: {
|
|
|
|
|
marginRight: 15,
|
|
|
|
|
height: 30,
|
|
|
|
|
borderRadius: 100,
|
|
|
|
|
paddingHorizontal: 6,
|
|
|
|
|
marginTop: -2.5
|
|
|
|
|
},
|
|
|
|
|
textStyle: {
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
marginLeft: 5
|
|
|
|
|
}
|
2021-10-08 12:22:47 +05:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2021-07-07 08:46:29 +05:00
|
|
|
return (
|
|
|
|
|
<TouchableOpacity
|
|
|
|
|
onPress={onPress}
|
|
|
|
|
activeOpacity={0.8}
|
|
|
|
|
style={[
|
|
|
|
|
{
|
|
|
|
|
backgroundColor: color,
|
|
|
|
|
height: 50,
|
|
|
|
|
borderRadius: 5,
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
flexDirection: 'row',
|
|
|
|
|
marginBottom: 10,
|
2021-07-08 09:34:21 +05:00
|
|
|
minWidth: 80,
|
2021-07-30 10:18:14 +05:00
|
|
|
paddingHorizontal: 20
|
2021-07-07 08:46:29 +05:00
|
|
|
},
|
2021-10-11 11:25:22 +05:00
|
|
|
types[type].style,
|
2021-07-30 10:18:14 +05:00
|
|
|
style
|
2022-01-24 11:51:28 +05:00
|
|
|
]}
|
|
|
|
|
>
|
2021-12-03 09:21:41 +05:00
|
|
|
{loading ? <ActivityIndicator color={iconColor} /> : null}
|
2021-07-07 08:46:29 +05:00
|
|
|
|
2022-01-24 11:51:28 +05:00
|
|
|
{icon && !loading ? <Icon name={icon} size={iconSize} color={iconColor || 'white'} /> : null}
|
2021-10-08 12:22:47 +05:00
|
|
|
|
2021-12-03 09:21:41 +05:00
|
|
|
{title ? (
|
2021-10-08 12:22:47 +05:00
|
|
|
<Text
|
|
|
|
|
style={[
|
|
|
|
|
{
|
2021-10-23 09:44:59 +05:00
|
|
|
fontSize: fontSize || 18,
|
2021-10-13 10:30:47 +05:00
|
|
|
fontFamily: 'OpenSans-Regular',
|
2021-10-11 11:25:22 +05:00
|
|
|
color: textColor,
|
2021-10-08 12:22:47 +05:00
|
|
|
marginLeft: loading ? 10 : 0
|
|
|
|
|
},
|
2022-01-25 19:33:25 +05:00
|
|
|
types[type].textStyle,
|
|
|
|
|
textStyle
|
2022-01-24 11:51:28 +05:00
|
|
|
]}
|
|
|
|
|
>
|
2021-10-08 12:22:47 +05:00
|
|
|
{title}
|
|
|
|
|
</Text>
|
2021-12-03 09:21:41 +05:00
|
|
|
) : null}
|
2021-07-07 08:46:29 +05:00
|
|
|
</TouchableOpacity>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default NotesnookShare;
|