add word count

This commit is contained in:
ammarahm-ed
2020-04-25 11:28:20 +05:00
parent 513e185069
commit a8f8c76663
3 changed files with 45 additions and 21 deletions

View File

@@ -100,7 +100,7 @@ const SimpleList = ({
color: colors.accent,
fontSize: SIZE.xs,
}}>
Search Results for {searchResults.keyword}
Showing Results for {searchResults.keyword}
</Text>
<Text
onPress={() => {

View File

@@ -11,14 +11,15 @@ export default class InfoBar extends React.Component {
this.state = {
dateEdited: null,
saving: false,
length: 0,
};
this.dateCreated = null;
}
setDateEdited(id) {
console.log(id);
setDateEdited(id, length) {
this.setState(
{
saving: true,
length: length,
},
() => {
setTimeout(() => {
@@ -48,6 +49,20 @@ export default class InfoBar extends React.Component {
paddingLeft: this.props.noMenu ? 12 : 12 + 50,
zIndex: 999,
}}>
{this.state.length ? (
<Text
style={{
color: this.props.colors.icon,
fontSize: SIZE.xxs,
textAlignVertical: 'center',
fontFamily: WEIGHT.regular,
marginRight: 5,
}}>
{this.state.length + ' words •'}
</Text>
) : null}
{this.state.dateEdited ? (
<Text
onPress={() => {
simpleDialogEvent(TEMPLATE_INFO(this.dateCreated));
@@ -58,8 +73,9 @@ export default class InfoBar extends React.Component {
textAlignVertical: 'center',
fontFamily: WEIGHT.regular,
}}>
{timeConverter(this.state.dateEdited)}
{timeConverter(this.state.dateEdited)}
</Text>
) : null}
<View
style={{
@@ -69,9 +85,9 @@ export default class InfoBar extends React.Component {
}}>
{this.state.saving ? (
<ActivityIndicator
style={{width: 16, height: 16, marginLeft: 10}}
style={{width: 14, height: 14, marginLeft: 10}}
color="white"
size={16}
size={14}
/>
) : null}
<Text

View File

@@ -312,7 +312,10 @@ const Editor = ({noMenu}) => {
eSendEvent(refreshNotesPage);
}
InfoBarRef.current?.setDateEdited(db.notes.note(id).data.dateEdited);
InfoBarRef.current?.setDateEdited(
db.notes.note(id).data.dateEdited,
content?.text?.split(' ').length,
);
InfoBarRef.current?.setDateCreated(db.notes.note(id).data.dateCreated);
saveCounter++;
@@ -332,7 +335,10 @@ const Editor = ({noMenu}) => {
id: id,
});
}
InfoBarRef.current?.setDateEdited(db.notes.note(id).data.dateEdited);
InfoBarRef.current?.setDateEdited(
db.notes.note(id).data.dateEdited,
content?.text?.split(' ').length,
);
InfoBarRef.current?.setDateCreated(db.notes.note(id).data.dateCreated);
}
};
@@ -382,10 +388,12 @@ const Editor = ({noMenu}) => {
const updateEditor = async () => {
title = note.title;
id = note.id;
InfoBarRef.current?.setDateEdited(note.dateEdited);
InfoBarRef.current?.setDateCreated(note.dateCreated);
content = {...note.content};
saveCounter = 0;
InfoBarRef.current?.setDateCreated(note.dateCreated);
let text = await db.notes.note(id).text();
InfoBarRef.current?.setDateEdited(note.dateEdited, text.split(' ').length);
if (title !== null || title === '') {
post({