Skip to content

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

improve share extension ui

ammarahm-ed87ba82409b5f
diff --git a/apps/mobile/NotesnookShare.js b/apps/mobile/NotesnookShare.js
index f9137a859..800953b84 100644
--- a/apps/mobile/NotesnookShare.js
+++ b/apps/mobile/NotesnookShare.js
@@ -12,7 +12,7 @@ import {
TextInput,
TouchableOpacity,
useWindowDimensions,
- View,
+ View
} from 'react-native';
import Animated, {Easing, timing, useValue} from 'react-native-reanimated';
import WebView from 'react-native-webview';
@@ -36,13 +36,13 @@ async function sanitizeHtml(site) {
'img',
'style',
'head',
- 'link',
+ 'link'
]),
allowedClasses: true,
allowVulnerableTags: true,
allowedAttributes: false,
allowProtocolRelative: true,
- allowedSchemes: false,
+ allowedSchemes: false
});
return absolutify(siteHtml, site);
} catch (e) {
@@ -64,8 +64,8 @@ let defaultNote = {
id: null,
content: {
type: 'tiny',
- data: null,
- },
+ data: null
+ }
};
let editorContentValue = null;
@@ -74,7 +74,7 @@ const NotesnookShare = () => {
const [colors, setColors] = useState(
Appearance.getColorScheme() === 'dark'
? COLOR_SCHEME_DARK
- : COLOR_SCHEME_LIGHT,
+ : COLOR_SCHEME_LIGHT
);
const [note, setNote] = useState(defaultNote);
const [loadingIntent, setLoadingIntent] = useState(true);
@@ -82,7 +82,7 @@ const NotesnookShare = () => {
const [floating, setFloating] = useState(false);
const [rawData, setRawData] = useState({
type: null,
- value: null,
+ value: null
});
const textInputRef = useRef();
const titleInputRef = useRef();
@@ -91,7 +91,7 @@ const NotesnookShare = () => {
const opacity = useValue(0);
const translate = useValue(1000);
const insets = {
- top: Platform.OS === 'ios' ? 30 : 0,
+ top: Platform.OS === 'ios' ? 30 : 0
};
const animate = (opacityV, translateV) => {
@@ -99,12 +99,12 @@ const NotesnookShare = () => {
timing(opacity, {
toValue: opacityV,
duration: 300,
- easing: Easing.in(Easing.ease),
+ easing: Easing.in(Easing.ease)
}).start();
timing(translate, {
toValue: translateV,
duration: 300,
- easing: Easing.in(Easing.ease),
+ easing: Easing.in(Easing.ease)
}).start();
};
@@ -113,7 +113,7 @@ const NotesnookShare = () => {
return () => {
Keyboard.removeListener(
'keyboardWillChangeFrame',
- onKeyboardWillChangeFrame,
+ onKeyboardWillChangeFrame
);
};
});
@@ -174,10 +174,10 @@ const NotesnookShare = () => {
}, []);
const close = async () => {
- setNote(defaultNote);
- setLoadingIntent(true);
animate(0, 1000);
await sleep(300);
+ setNote(defaultNote);
+ setLoadingIntent(true);
ShareExtension.close();
};
@@ -191,7 +191,7 @@ const NotesnookShare = () => {
function postMessage(webview, type, value = null) {
let message = {
type: type,
- value,
+ value
};
webview.current?.postMessage(JSON.stringify(message));
}
@@ -235,8 +235,9 @@ const NotesnookShare = () => {
width: width > 500 ? 500 : width,
height: height,
justifyContent: 'flex-end',
- opacity: Platform.OS !== 'ios' ? opacity : 1,
+ opacity: Platform.OS !== 'ios' ? opacity : 1
}}>
+
<TouchableOpacity
activeOpacity={1}
onPress={() => {
@@ -245,13 +246,13 @@ const NotesnookShare = () => {
style={{
width: '100%',
height: '100%',
- position: 'absolute',
+ position: 'absolute'
}}>
<View
style={{
width: '100%',
height: '100%',
- backgroundColor: 'rgba(0,0,0,0.01)',
+ backgroundColor: 'rgba(0,0,0,0.01)'
}}
/>
</TouchableOpacity>
@@ -266,18 +267,29 @@ const NotesnookShare = () => {
marginBottom: insets.top,
transform: [
{
- translateY: Platform.OS !== 'ios' ? translate : 0,
- },
- ],
+ translateY: Platform.OS !== 'ios' ? translate : 0
+ }
+ ]
}}
behavior="padding">
+ <View
+ style={{
+ width:50,
+ height:6,
+ borderRadius:100,
+ backgroundColor:colors.nav,
+ alignSelf:'center',
+ position:'absolute',
+ marginTop:15
+ }}
+ />
{loadingIntent ? (
<View
style={{
height: 150,
width: '100%',
justifyContent: 'center',
- alignItems: 'center',
+ alignItems: 'center'
}}>
<ActivityIndicator color={colors.accent} />
@@ -285,7 +297,7 @@ const NotesnookShare = () => {
style={{
color: colors.pri,
fontSize: SIZE.md,
- marginTop: 5,
+ marginTop: 5
}}>
Parsing Data...
</Text>
@@ -294,28 +306,27 @@ const NotesnookShare = () => {
<>
<View
style={{
- maxHeight: '100%',
+ maxHeight: '100%'
}}>
<View
style={{
- flexDirection: 'row',
- alignItems: 'center',
borderBottomWidth: 1,
borderBottomColor: colors.nav,
- paddingHorizontal: 12,
- justifyContent: 'space-between',
+ paddingHorizontal: 12
}}>
<TextInput
ref={titleInputRef}
style={{
fontSize: 25,
- fontWeight: 'bold',
+ fontFamily:
+ Platform.OS === 'android' ? 'Roboto-Medium' : null,
+ fontWeight: Platform.OS === 'ios' ? '600' : null,
color: colors.pri,
flexGrow: 1,
- maxWidth: '100%',
+ maxWidth: '100%'
}}
placeholderTextColor={colors.icon}
- value={note?.title}
+ defaultValue={note?.title}
onChangeText={v =>
setNote(_note => {
_note.title = v;
@@ -329,10 +340,75 @@ const NotesnookShare = () => {
placeholder="Note title"
/>
</View>
+
+ <View
+ style={{
+ flexDirection: 'row',
+ alignItems: 'center',
+ marginVertical: 10,
+ borderBottomWidth: 1,
+ borderBottomColor: colors.nav
+ }}>
+ {[
+ {
+ title: 'Plain text',
+ onPress: () => {
+ let html = validator.isURL(rawData.value)
+ ? makeHtmlFromUrl(rawData.value)
+ : makeHtmlFromPlainText(rawData.value);
+ setNote(note => {
+ note.content.data = html;
+ return note;
+ });
+ onLoad();
+ }
+ },
+ ...[
+ validator.isURL(rawData.value)
+ ? {
+ title: 'Clip webpage',
+ onPress: async () => {
+ let html = await sanitizeHtml(rawData.value);
+ setNote(note => {
+ note.content.data = html;
+ return note;
+ });
+ onLoad();
+ }
+ }
+ : null
+ ]
+ ].map(
+ (item, index) =>
+ item && (
+ <Button
+ title={item.title}
+ color={colors.nav}
+ textStyle={{
+ color: colors.icon,
+ fontWeight: 'normal',
+ fontSize: 14,
+ fontFamily:null
+ }}
+ onPress={item.onPress}
+ style={{
+ borderWidth: 0.5,
+ borderRadius: 100,
+ borderColor: colors.icon,
+ height: 30,
+ marginRight: 10,
+ marginLeft: index === 0 ? 12 : 0,
+ paddingHorizontal: 12
+ }}
+ />
+ )
+ )}
+ </View>
+
<View
style={{
height: height * 0.25,
- width: '100%',
+ width: '100%'
}}>
<WebView
onLoad={onLoad}
@@ -340,7 +416,7 @@ const NotesnookShare = () => {
style={{
width: '100%',
height: '100%',
- backgroundColor: 'transparent',
+ backgroundColor: 'transparent'
}}
cacheMode="LOAD_DEFAULT"
domStorageEnabled={true}
@@ -362,7 +438,7 @@ const NotesnookShare = () => {
? {uri: sourceUri}
: {
uri: 'file:///android_asset/plaineditor.html',
- baseUrl: 'file:///android_asset/',
+ baseUrl: 'file:///android_asset/'
}
}
/>
@@ -374,16 +450,15 @@ const NotesnookShare = () => {
fontSize: 15,
color: colors.pri,
marginBottom: 10,
- width: '95%',
+ width: '100%',
maxHeight: '70%',
padding: 12,
backgroundColor: colors.nav,
alignSelf: 'center',
- borderRadius: 5,
marginTop: 10,
minHeight: 80,
paddingTop: 12,
- paddingBottom: 12,
+ paddingBottom: 12
}}
placeholderTextColor={colors.icon}
onChangeText={v => (editorContentValue = v)}
@@ -398,52 +473,21 @@ const NotesnookShare = () => {
<View
style={{
paddingHorizontal: 12,
- flexDirection: 'row',
- justifyContent: validator.isURL(rawData.value)
- ? 'space-between'
- : 'flex-end',
}}>
- <Button
- style={{
- width: null,
- paddingHorizontal: 10,
- backgroundColor: colors.nav,
- marginRight: 10,
- }}
- textStyle={{
- color: colors.icon,
- }}
- title="Cancel"
- onPress={close}
- />
- {validator.isURL(rawData.value) && (
- <Button
- title="Clip Webpage"
- color={colors.accent}
- style={{
- marginRight: 10,
- }}
- onPress={async () => {
- let html = await sanitizeHtml(rawData.value);
- setNote(note => {
- note.content.data = html;
- return note;
- });
- onLoad();
- }}
- />
- )}
<Button
title={loading ? 'Saving note' : 'Save note'}
color={colors.accent}
onPress={onPress}
loading={loading}
+ style={{
+ width: '100%'
+ }}
/>
</View>
<View
style={{
- height: 25,
+ height: 10
}}
/>
</View>
@@ -469,21 +513,22 @@ const Button = ({title, onPress, color, loading, style, textStyle}) => {
flexDirection: 'row',
marginBottom: 10,
minWidth: 80,
- paddingHorizontal: 20,
+ paddingHorizontal: 20
},
- style,
+ style
]}>
{loading && <ActivityIndicator color="white" />}
<Text
style={[
{
- fontSize: 15,
- fontWeight: 'bold',
+ fontSize: 18,
+ fontFamily: Platform.OS === 'android' ? 'Roboto-Medium' : null,
+ fontWeight: Platform.OS === 'ios' ? '600' : null,
color: 'white',
- marginLeft: loading ? 10 : 0,
+ marginLeft: loading ? 10 : 0
},
- textStyle,
+ textStyle
]}>
{title}
</Text>