mirror of
https://github.com/status-im/react-native-keychain.git
synced 2025-01-14 23:34:15 +00:00
Fix android related bugs in example app
This commit is contained in:
parent
a751670b92
commit
126c69266e
@ -1,6 +1,7 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import {
|
import {
|
||||||
KeyboardAvoidingView,
|
KeyboardAvoidingView,
|
||||||
|
Platform,
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
Text,
|
Text,
|
||||||
TextInput,
|
TextInput,
|
||||||
@ -18,11 +19,7 @@ export default class KeychainExample extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
save() {
|
save() {
|
||||||
Keychain.setSecurePassword(
|
Keychain.setGenericPassword(this.state.username, this.state.password)
|
||||||
'myService',
|
|
||||||
this.state.username,
|
|
||||||
this.state.password
|
|
||||||
)
|
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.setState({ status: 'Credentials saved!' });
|
this.setState({ status: 'Credentials saved!' });
|
||||||
})
|
})
|
||||||
@ -32,7 +29,7 @@ export default class KeychainExample extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
load() {
|
load() {
|
||||||
Keychain.getSecurePassword('myService')
|
Keychain.getGenericPassword()
|
||||||
.then(credentials => {
|
.then(credentials => {
|
||||||
if (credentials) {
|
if (credentials) {
|
||||||
this.setState({ ...credentials, status: 'Credentials loaded!' });
|
this.setState({ ...credentials, status: 'Credentials loaded!' });
|
||||||
@ -61,7 +58,10 @@ export default class KeychainExample extends Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<KeyboardAvoidingView behavior="padding" style={styles.container}>
|
<KeyboardAvoidingView
|
||||||
|
behavior={Platform.OS === 'ios' ? 'padding' : undefined}
|
||||||
|
style={styles.container}
|
||||||
|
>
|
||||||
<View style={styles.content}>
|
<View style={styles.content}>
|
||||||
<Text style={styles.title}>Keychain Example</Text>
|
<Text style={styles.title}>Keychain Example</Text>
|
||||||
<View style={styles.field}>
|
<View style={styles.field}>
|
||||||
@ -73,6 +73,7 @@ export default class KeychainExample extends Component {
|
|||||||
value={this.state.username}
|
value={this.state.username}
|
||||||
onChange={event =>
|
onChange={event =>
|
||||||
this.setState({ username: event.nativeEvent.text })}
|
this.setState({ username: event.nativeEvent.text })}
|
||||||
|
underlineColorAndroid="transparent"
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.field}>
|
<View style={styles.field}>
|
||||||
@ -84,6 +85,7 @@ export default class KeychainExample extends Component {
|
|||||||
value={this.state.password}
|
value={this.state.password}
|
||||||
onChange={event =>
|
onChange={event =>
|
||||||
this.setState({ password: event.nativeEvent.text })}
|
this.setState({ password: event.nativeEvent.text })}
|
||||||
|
underlineColorAndroid="transparent"
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
{!!this.state.status && (
|
{!!this.state.status && (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user