minor ui fixes

This commit is contained in:
ammarahm-ed
2020-01-20 16:24:01 +05:00
parent a8883f13be
commit ebb39757b4
6 changed files with 130 additions and 129 deletions

View File

@@ -12,7 +12,7 @@ import Icon from 'react-native-vector-icons/Feather';
import {db, DDS} from '../../../App'; import {db, DDS} from '../../../App';
import {opacity, ph, pv, SIZE, WEIGHT} from '../../common/common'; import {opacity, ph, pv, SIZE, WEIGHT} from '../../common/common';
import {ACTIONS} from '../../provider'; import {ACTIONS} from '../../provider';
import {getElevation, ToastEvent, timeSince} from '../../utils/utils'; import {getElevation, ToastEvent} from '../../utils/utils';
import {updateEvent} from '../DialogManager'; import {updateEvent} from '../DialogManager';
let refs = []; let refs = [];

View File

@@ -17,6 +17,10 @@ export const AnimatedSafeAreaView = Animatable.createAnimatableComponent(
SafeAreaView, SafeAreaView,
); );
const AnimatedTouchableOpacity = Animatable.createAnimatableComponent(
TouchableOpacity,
);
export const Container = ({ export const Container = ({
children, children,
bottomButtonOnPress, bottomButtonOnPress,
@@ -31,21 +35,25 @@ export const Container = ({
useEffect(() => { useEffect(() => {
Keyboard.addListener('keyboardDidShow', () => { Keyboard.addListener('keyboardDidShow', () => {
setButtonHide(true); setTimeout(() => {
setButtonHide(true);
}, 300);
}); });
Keyboard.addListener('keyboardDidHide', () => { Keyboard.addListener('keyboardDidHide', () => {
setTimeout(() => { setTimeout(() => {
setButtonHide(false); setButtonHide(false);
}, 100); }, 300);
}); });
return () => { return () => {
Keyboard.removeListener('keyboardDidShow', () => { Keyboard.removeListener('keyboardDidShow', () => {
setButtonHide(true); setTimeout(() => {
setButtonHide(true);
}, 300);
}); });
Keyboard.removeListener('keyboardDidHide', () => { Keyboard.removeListener('keyboardDidHide', () => {
setTimeout(() => { setTimeout(() => {
setButtonHide(false); setButtonHide(false);
}, 100); }, 300);
}); });
}; };
}, []); }, []);
@@ -67,8 +75,11 @@ export const Container = ({
}}> }}>
{children} {children}
{buttonHide || noBottomButton ? null : ( {noBottomButton ? null : (
<TouchableOpacity <AnimatedTouchableOpacity
transition={['translateY', 'opacity']}
useNativeDriver={true}
duration={250}
onPress={bottomButtonOnPress} onPress={bottomButtonOnPress}
activeOpacity={opacity} activeOpacity={opacity}
style={{ style={{
@@ -83,6 +94,12 @@ export const Container = ({
position: 'absolute', position: 'absolute',
zIndex: 10, zIndex: 10,
bottom: 10, bottom: 10,
opacity: buttonHide ? 0 : 1,
transform: [
{
translateY: buttonHide ? 200 : 0,
},
],
}}> }}>
<View <View
style={{ style={{
@@ -104,7 +121,7 @@ export const Container = ({
{' ' + bottomButtonText} {' ' + bottomButtonText}
</Text> </Text>
</View> </View>
</TouchableOpacity> </AnimatedTouchableOpacity>
)} )}
</KeyboardAvoidingView> </KeyboardAvoidingView>
</AnimatedSafeAreaView> </AnimatedSafeAreaView>

View File

@@ -6,6 +6,7 @@ import {
Text, Text,
TouchableOpacity, TouchableOpacity,
View, View,
DeviceEventEmitter,
} from 'react-native'; } from 'react-native';
import FastStorage from 'react-native-fast-storage'; import FastStorage from 'react-native-fast-storage';
import Icon from 'react-native-vector-icons/Feather'; import Icon from 'react-native-vector-icons/Feather';
@@ -30,6 +31,8 @@ export const Menu = ({close = () => {}, hide, update = () => {}}) => {
// todo // todo
let overlayRef;
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(newColors.night ? 'light-content' : 'dark-content'); StatusBar.setBarStyle(newColors.night ? 'light-content' : 'dark-content');
@@ -116,6 +119,19 @@ export const Menu = ({close = () => {}, hide, update = () => {}}) => {
marginTop: Platform.OS == 'ios' ? 0 : StatusBar.currentHeight - 10, marginTop: Platform.OS == 'ios' ? 0 : StatusBar.currentHeight - 10,
}} }}
/> />
<View
ref={ref => (overlayRef = ref)}
onLayout={() => {
DeviceEventEmitter.emit('sendOverlayViewRef', {ref: overlayRef});
}}
style={{
height: '100%',
width: '100%',
position: 'absolute',
zIndex: 999,
backgroundColor: colors.bg,
}}
/>
<ScrollView <ScrollView
contentContainerStyle={{minHeight: '80%'}} contentContainerStyle={{minHeight: '80%'}}

View File

@@ -106,6 +106,7 @@ export const NotebookItem = ({
{item && item.topics {item && item.topics
? item.topics.slice(1, 4).map(topic => ( ? item.topics.slice(1, 4).map(topic => (
<View <View
key={topic.dateCreated.toString() + topic.title}
style={{ style={{
borderRadius: 5, borderRadius: 5,
backgroundColor: colors.accent, backgroundColor: colors.accent,
@@ -167,18 +168,14 @@ export const NotebookItem = ({
alignItems: 'center', alignItems: 'center',
marginTop: 5, marginTop: 5,
}}> }}>
<Icon {item.favorite ? (
style={{width: 30}} <Icon
name="lock" style={{width: 30}}
size={SIZE.xs} name="star"
color={colors.icon} size={SIZE.xs}
/> color={colors.icon}
<Icon />
style={{width: 30}} ) : null}
name="star"
size={SIZE.xs}
color={colors.icon}
/>
<Text <Text
style={{ style={{

View File

@@ -20,11 +20,9 @@ import {
TEMPLATE_EXIT, TEMPLATE_EXIT,
} from '../../components/DialogManager'; } from '../../components/DialogManager';
import {EditorMenu} from '../../components/EditorMenu'; import {EditorMenu} from '../../components/EditorMenu';
import {useTracked} from '../../provider'; import {useTracked, ACTIONS} from '../../provider';
import {SideMenuEvent} from '../../utils/utils'; import {SideMenuEvent} from '../../utils/utils';
import {AnimatedSafeAreaView} from '../Home'; import {AnimatedSafeAreaView} from '../Home';
const w = Dimensions.get('window').width;
const h = Dimensions.get('window').height;
let EditorWebView; let EditorWebView;
let note = {}; let note = {};
@@ -37,20 +35,9 @@ const Editor = ({navigation}) => {
const [state, dispatch] = useTracked(); const [state, dispatch] = useTracked();
const {colors} = state; const {colors} = state;
///
const updateDB = () => {};
// Local State // Local State
const [sidebar, setSidebar] = useState(DDS.isTab ? true : false); const [sidebar, setSidebar] = useState(DDS.isTab ? true : false);
const [noteProps, setNoteProps] = useState({
tags: [],
locked: false,
pinned: false,
favorite: false,
colors: [],
});
// FUNCTIONS // FUNCTIONS
const post = value => EditorWebView.postMessage(value); const post = value => EditorWebView.postMessage(value);
@@ -72,8 +59,7 @@ const Editor = ({navigation}) => {
timer = null; timer = null;
onChange(evt.nativeEvent.data); onChange(evt.nativeEvent.data);
timer = setTimeout(() => { timer = setTimeout(() => {
saveNote(noteProps, true); saveNote(true);
console.log('saved');
}, 1000); }, 1000);
} }
}; };
@@ -103,8 +89,8 @@ const Editor = ({navigation}) => {
}, },
dateCreated: timestamp, dateCreated: timestamp,
}); });
updateDB();
if (lockNote && noteProps.locked) { if (lockNote && db.getNote(timestamp).locked) {
db.lockNote(timestamp, 'password'); db.lockNote(timestamp, 'password');
} }
}; };
@@ -118,15 +104,6 @@ const Editor = ({navigation}) => {
}; };
const updateEditor = () => { const updateEditor = () => {
let props = {
tags: note.tags,
colors: note.colors,
pinned: note.pinned,
favorite: note.favorite,
locked: note.locked,
};
setNoteProps({...props});
post(JSON.stringify(note.content.delta)); post(JSON.stringify(note.content.delta));
post( post(
JSON.stringify({ JSON.stringify({

View File

@@ -12,98 +12,92 @@ const h = Dimensions.get('window').height;
export const Tags = ({navigation}) => { export const Tags = ({navigation}) => {
const [state, dispatch] = useTracked(); const [state, dispatch] = useTracked();
const {colors} = state; const {colors} = state;
let isFocused = useIsFocused();
if (!isFocused) { return (
console.log('block rerender'); <SafeAreaView
return <></>; style={{
} else { height: '100%',
return ( backgroundColor: colors.bg,
<SafeAreaView }}>
style={{ <Header canGoBack={false} heading="Tags" menu={true} />
height: '100%',
backgroundColor: colors.bg,
}}>
<Header canGoBack={false} heading="Tags" menu={true} />
<View style={{width: '90%', alignSelf: 'center', height: '100%'}}> <View style={{width: '90%', alignSelf: 'center', height: '100%'}}>
<FlatList <FlatList
style={{ style={{
height: '100%', height: '100%',
}} }}
contentContainerStyle={{ contentContainerStyle={{
height: '100%', height: '100%',
}} }}
data={[]} data={[]}
ListEmptyComponent={ ListEmptyComponent={
<View <View
style={{
height: '80%',
width: '100%',
alignItems: 'center',
alignSelf: 'center',
justifyContent: 'center',
opacity: 0.8,
}}>
<TagsPlaceHolder colors={colors} />
<Text
style={{ style={{
height: '80%', fontSize: SIZE.md,
width: '100%', color: colors.icon,
alignItems: 'center',
alignSelf: 'center',
justifyContent: 'center',
opacity: 0.8,
}}> }}>
<TagsPlaceHolder colors={colors} /> Tags added to notes appear here
<Text </Text>
style={{ <Text
fontSize: SIZE.md,
color: colors.icon,
}}>
Tags added to notes appear here
</Text>
<Text
style={{
fontSize: SIZE.sm,
color: colors.icon,
marginTop: 20,
}}>
No tags found
</Text>
</View>
}
renderItem={({item, index}) => (
<View
style={{ style={{
flexDirection: 'row', fontSize: SIZE.sm,
justifyContent: 'flex-start', color: colors.icon,
alignItems: 'center', marginTop: 20,
margin: 5, }}>
paddingVertical: pv, No tags found
borderBottomWidth: 1.5, </Text>
borderBottomColor: colors.navbg, </View>
}
renderItem={({item, index}) => (
<View
style={{
flexDirection: 'row',
justifyContent: 'flex-start',
alignItems: 'center',
margin: 5,
paddingVertical: pv,
borderBottomWidth: 1.5,
borderBottomColor: colors.navbg,
}}>
<Text
style={{
fontFamily: WEIGHT.regular,
fontSize: SIZE.md,
color: colors.pri,
}}> }}>
<Text <Text
style={{ style={{
fontFamily: WEIGHT.regular, color: colors.accent,
fontSize: SIZE.md,
color: colors.pri,
}}> }}>
<Text #
style={{
color: colors.accent,
}}>
#
</Text>
{item.slice(1)}
{'\n'}
<Text
style={{
fontSize: SIZE.xs,
color: colors.icon,
}}>
10 notes
</Text>
</Text> </Text>
</View> {item.slice(1)}
)}
/> {'\n'}
</View> <Text
</SafeAreaView> style={{
); fontSize: SIZE.xs,
} color: colors.icon,
}}>
10 notes
</Text>
</Text>
</View>
)}
/>
</View>
</SafeAreaView>
);
}; };
Tags.navigationOptions = { Tags.navigationOptions = {