Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix keyboard aware scroll view related problem #291

Merged
merged 5 commits into from
Jul 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="stateAlwaysHidden|adjustPan">
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
1 change: 1 addition & 0 deletions src/components/AccountSeed.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export default class AccountSeed extends Component {
style={[styles.input, invalidStyles]}
multiline
autoCapitalize="none"
textAlignVertical="top"
Tbaut marked this conversation as resolved.
Show resolved Hide resolved
onSelectionChange={this.handleCursorPosition}
{...this.props}
/>
Expand Down
31 changes: 31 additions & 0 deletions src/components/KeyboardScrollView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from 'react';
import { Keyboard, Platform } from 'react-native';
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';

class KeyboardScrollView extends React.Component {
render() {
const defaultProps = { enableAutomaticScroll: true };
return Platform.select({
ios: (
<KeyboardAwareScrollView
keyboardDismissMode="interactive"
keyboardShouldPersistTaps="handled"
{...defaultProps}
{...this.props}
/>
),
android: (
<KeyboardAwareScrollView
keyboardDismissMode="on-drag"
onScrollEndDrag={Keyboard.dismiss}
keyboardShouldPersistTaps="handled"
enableOnAndroid
{...defaultProps}
{...this.props}
/>
)
});
}
}

export default KeyboardScrollView;
96 changes: 45 additions & 51 deletions src/screens/AccountNew.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,19 @@
'use strict';

import React from 'react';
import { StyleSheet, ScrollView, Text, View } from 'react-native';
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view'
import { StyleSheet, Text, View } from 'react-native';
import { Subscribe } from 'unstated';

import colors from '../colors';
import AccountIconChooser from '../components/AccountIconChooser';
import Background from '../components/Background';
import Button from '../components/Button';
import TextInput from '../components/TextInput';
import TouchableItem from '../components/TouchableItem';
import { NETWORK_LIST } from '../constants';
import AccountsStore from '../stores/AccountsStore';
import { validateSeed } from '../util/account';
import NetworkButton from '../components/NetworkButton';
import KeyboardScrollView from '../components/KeyboardScrollView';

export default class AccountNew extends React.Component {
static navigationOptions = {
Expand All @@ -48,62 +47,57 @@ export default class AccountNew extends React.Component {

class AccountNewView extends React.Component {
render() {
const { accounts } = this.props;
const { accounts, navigation } = this.props;
const selected = accounts.getNew();
const network = NETWORK_LIST[selected.networkKey];
if (!selected) {
return null;
}
return (
<View style={styles.body}>
<KeyboardAwareScrollView>
<KeyboardScrollView style={{ padding: 20 }}>
<Background />
<ScrollView
style={{ padding: 20 }}
keyboardDismissMode="on-drag"
keyboardShouldPersistTaps="always"
containerStyle={styles.bodyContainer}
>
<View style={styles.top}>
<Text style={styles.titleTop}>CREATE ACCOUNT</Text>
<Text style={styles.title}>CHOOSE NETWORK</Text>
<NetworkButton network={network}/>
<Text style={[styles.title, { marginTop: 20 }]}>
CHOOSE AN IDENTICON
</Text>
<AccountIconChooser
value={selected && selected.seed && selected.address}
onSelect={({ address, bip39, seed }) => {
accounts.updateNew({ address, seed, validBip39Seed: bip39 });
}}
/>
<Text style={styles.title}>ACCOUNT NAME</Text>
<TextInput
onChangeText={name => accounts.updateNew({ name })}
value={selected && selected.name}
placeholder="Enter a new account name"
/>
</View>
<View style={styles.bottom}>
<Text style={styles.hintText}>
On the next step you will be asked to backup your account, get pen
and paper ready
</Text>
<Button
buttonStyles={styles.nextStep}
title="Next Step"
disabled={ !validateSeed(selected.seed, selected.validBip39Seed).valid }
onPress={() => {
validateSeed(selected.seed, selected.validBip39Seed).valid &&
this.props.navigation.navigate('AccountBackup', {
isNew: true,
isWelcome: this.props.navigation.getParam('isWelcome')
});
}}
/>
</View>
</ScrollView>
</KeyboardAwareScrollView>
<View style={styles.top}>
<Text style={styles.titleTop}>CREATE ACCOUNT</Text>
<Text style={styles.title}>CHOOSE NETWORK</Text>
<NetworkButton network={network} />
<Text style={[styles.title, { marginTop: 20 }]}>
CHOOSE AN IDENTICON
</Text>
<AccountIconChooser
value={selected && selected.seed && selected.address}
onSelect={({ address, bip39, seed }) => {
accounts.updateNew({ address, seed, validBip39Seed: bip39 });
}}
/>
<Text style={styles.title}>ACCOUNT NAME</Text>
<TextInput
onChangeText={name => accounts.updateNew({ name })}
value={selected && selected.name}
placeholder="Enter a new account name"
/>
</View>
<View style={styles.bottom}>
<Text style={styles.hintText}>
On the next step you will be asked to backup your account, get pen
and paper ready
</Text>
<Button
buttonStyles={styles.nextStep}
title="Next Step"
disabled={
!validateSeed(selected.seed, selected.validBip39Seed).valid
}
onPress={() => {
validateSeed(selected.seed, selected.validBip39Seed).valid &&
navigation.navigate('AccountBackup', {
isNew: true,
isWelcome: navigation.getParam('isWelcome')
});
}}
/>
</View>
</KeyboardScrollView>
</View>
);
}
Expand Down
Loading