Skip to content

Commit

Permalink
views/AddNotes: add save icon in top right corner
Browse files Browse the repository at this point in the history
  • Loading branch information
kaloudis committed Jul 22, 2023
1 parent ad041e7 commit 2485f69
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
4 changes: 4 additions & 0 deletions assets/images/SVG/Save.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 22 additions & 9 deletions views/AddNotes.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { Keyboard, View } from 'react-native';
import { Keyboard, TouchableOpacity, View } from 'react-native';
import EncryptedStorage from 'react-native-encrypted-storage';
import { inject, observer } from 'mobx-react';

Expand All @@ -13,6 +13,8 @@ import { themeColor } from '../utils/ThemeUtils';
import NotesStore from '../stores/NotesStore';
import TextInput from '../components/TextInput';

import SaveIcon from '../assets/images/SVG/Save.svg';

interface AddNotesProps {
navigation: any;
NotesStore: NotesStore;
Expand Down Expand Up @@ -68,6 +70,23 @@ export default class AddNotes extends React.Component<
const { storeNoteKeys, removeNoteKeys } = NotesStore;
const { payment_hash, txid, getRPreimage, isNoteStored } = this.state;
const { notes } = this.state;

const saveNote = async () => {
const key: string =
'note-' + (payment_hash || txid || getRPreimage);
EncryptedStorage.setItem(key, notes);
await storeNoteKeys(key, notes);
navigation.goBack();
};

const SaveButton = () => (
<TouchableOpacity onPress={() => saveNote()}>
<SaveIcon
stroke={themeColor('text')}
fill={themeColor('secondary')}
/>
</TouchableOpacity>
);
return (
<Screen>
<View
Expand All @@ -92,6 +111,7 @@ export default class AddNotes extends React.Component<
fontSize: 20
}
}}
rightComponent={SaveButton}
navigation={navigation}
/>
<TextInput
Expand Down Expand Up @@ -137,14 +157,7 @@ export default class AddNotes extends React.Component<
'views.SendingLightning.AddANote'
)
}
onPress={async () => {
const key: string =
'note-' +
(payment_hash || txid || getRPreimage);
EncryptedStorage.setItem(key, notes);
await storeNoteKeys(key, notes);
navigation.goBack();
}}
onPress={() => saveNote()}
buttonStyle={{
padding: 15
}}
Expand Down

0 comments on commit 2485f69

Please sign in to comment.