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

Feat: Allow user to close numeric keyboard on iOS #407

Merged
merged 4 commits into from
Jan 9, 2024
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
78 changes: 40 additions & 38 deletions src/screens/CreateTokenAmount.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React from 'react';
import { KeyboardAvoidingView, Text, View } from 'react-native';
import { Keyboard, KeyboardAvoidingView, Pressable, Text, View } from 'react-native';
import { get } from 'lodash';
import { connect } from 'react-redux';
import { t, jt } from 'ttag';
Expand Down Expand Up @@ -115,44 +115,46 @@ class CreateTokenAmount extends React.Component {

return (
<View style={{ flex: 1 }}>
<HathorHeader
title={t`CREATE TOKEN`}
onBackPress={() => this.props.navigation.goBack()}
onCancel={() => this.props.navigation.getParent().goBack()}
/>
<KeyboardAvoidingView behavior='padding' style={{ flex: 1 }} keyboardVerticalOffset={getKeyboardAvoidingViewTopDistance()}>
<View style={{ flex: 1, padding: 16, justifyContent: 'space-between' }}>
<View style={{ marginTop: 24 }}>
<InputLabel style={{ textAlign: 'center', marginBottom: 16 }}>
{t`Amount of ${this.name} (${this.symbol})`}
</InputLabel>
<AmountTextInput
ref={this.inputRef}
autoFocus
onAmountUpdate={this.onAmountChange}
value={this.state.amount}
/>
<Pressable style={{ flex: 1 }} onPress={() => Keyboard.dismiss()}>
<HathorHeader
title={t`CREATE TOKEN`}
onBackPress={() => this.props.navigation.goBack()}
onCancel={() => this.props.navigation.getParent().goBack()}
/>
<KeyboardAvoidingView behavior='padding' style={{ flex: 1 }} keyboardVerticalOffset={getKeyboardAvoidingViewTopDistance()}>
<View style={{ flex: 1, padding: 16, justifyContent: 'space-between' }}>
<View style={{ marginTop: 24 }}>
<InputLabel style={{ textAlign: 'center', marginBottom: 16 }}>
{t`Amount of ${this.name} (${this.symbol})`}
</InputLabel>
<AmountTextInput
ref={this.inputRef}
autoFocus
onAmountUpdate={this.onAmountChange}
value={this.state.amount}
/>
</View>
<View>
<InfoBox
items={[
<Text>{t`Deposit:`} <Strong style={amountStyle}>
{hathorLib.numberUtils.prettyValue(this.state.deposit)} HTR
</Strong></Text>,
<Text>
{jt`You have ${amountAvailableText} HTR available`}
</Text>
]}
/>
<NewHathorButton
title={t`Next`}
disabled={this.isButtonDisabled()}
onPress={this.onButtonPress}
/>
</View>
</View>
<View>
<InfoBox
items={[
<Text>{t`Deposit:`} <Strong style={amountStyle}>
{hathorLib.numberUtils.prettyValue(this.state.deposit)} HTR
</Strong></Text>,
<Text>
{jt`You have ${amountAvailableText} HTR available`}
</Text>
]}
/>
<NewHathorButton
title={t`Next`}
disabled={this.isButtonDisabled()}
onPress={this.onButtonPress}
/>
</View>
</View>
<OfflineBar style={{ position: 'relative' }} />
</KeyboardAvoidingView>
<OfflineBar style={{ position: 'relative' }} />
</KeyboardAvoidingView>
</Pressable>
</View>
);
}
Expand Down
28 changes: 15 additions & 13 deletions src/screens/Receive.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React from 'react';
import { Dimensions, Keyboard, View } from 'react-native';
import { Dimensions, Keyboard, Pressable, View } from 'react-native';
import { t } from 'ttag';

import { TabBar, TabView } from 'react-native-tab-view';
Expand Down Expand Up @@ -102,18 +102,20 @@ class ReceiveScreen extends React.Component {

return (
<View style={{ flex: 1 }}>
<HathorHeader
title={t`RECEIVE`}
withBorder
/>
<TabView
renderTabBar={(props) => renderTabBar(props)}
navigationState={this.state}
renderScene={this.renderScene}
onIndexChange={this.handleIndexChange}
initialLayout={{ width: Dimensions.get('window').width }}
/>
<OfflineBar />
<Pressable style={{ flex: 1 }} onPress={() => Keyboard.dismiss()}>
<HathorHeader
title={t`RECEIVE`}
withBorder
/>
<TabView
renderTabBar={(props) => renderTabBar(props)}
navigationState={this.state}
renderScene={this.renderScene}
onIndexChange={this.handleIndexChange}
initialLayout={{ width: Dimensions.get('window').width }}
/>
<OfflineBar />
</Pressable>
</View>
);
}
Expand Down
85 changes: 46 additions & 39 deletions src/screens/SendAmountInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@

import React from 'react';
import {
KeyboardAvoidingView, StyleSheet, Text, View,
Keyboard,
KeyboardAvoidingView,
Pressable,
StyleSheet,
Text,
View,
} from 'react-native';
import { connect } from 'react-redux';
import { getStatusBarHeight } from 'react-native-status-bar-height';
Expand Down Expand Up @@ -143,46 +148,48 @@ class SendAmountInput extends React.Component {
const tokenNameUpperCase = this.state.token.name.toUpperCase();
return (
<View style={{ flex: 1 }}>
<HathorHeader
withBorder
title={t`SEND ${tokenNameUpperCase}`}
onBackPress={() => this.props.navigation.goBack()}
/>
<KeyboardAvoidingView behavior='padding' style={{ flex: 1 }} keyboardVerticalOffset={getStatusBarHeight()}>
<View style={{ flex: 1, padding: 16, justifyContent: 'space-between' }}>
<View>
<View style={{
flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', marginTop: 40,
}}
>
{renderGhostElement()}
<AmountTextInput
ref={this.inputRef}
autoFocus
onAmountUpdate={this.onAmountChange}
value={this.state.amount}
allowOnlyInteger={this.isNFT()}
style={{ flex: 1 }} // we need this so the placeholder doesn't break in android
// devices after erasing the text
// https://github.com/facebook/react-native/issues/30666
/>
{IS_MULTI_TOKEN
? <TokenBox onPress={this.onTokenBoxPress} label={this.state.token.symbol} />
: renderGhostElement()}
<Pressable style={{ flex: 1 }} onPress={() => Keyboard.dismiss()}>
<HathorHeader
withBorder
title={t`SEND ${tokenNameUpperCase}`}
onBackPress={() => this.props.navigation.goBack()}
/>
<KeyboardAvoidingView behavior='padding' style={{ flex: 1 }} keyboardVerticalOffset={getStatusBarHeight()}>
<View style={{ flex: 1, padding: 16, justifyContent: 'space-between' }}>
<View>
<View style={{
flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', marginTop: 40,
}}
>
{renderGhostElement()}
<AmountTextInput
ref={this.inputRef}
autoFocus
onAmountUpdate={this.onAmountChange}
value={this.state.amount}
allowOnlyInteger={this.isNFT()}
style={{ flex: 1 }} // we need this so the placeholder doesn't break in android
// devices after erasing the text
// https://github.com/facebook/react-native/issues/30666
/>
{IS_MULTI_TOKEN
? <TokenBox onPress={this.onTokenBoxPress} label={this.state.token.symbol} />
: renderGhostElement()}
</View>
<InputLabel style={{ textAlign: 'center', marginTop: 8 }}>
{getAvailableString()}
</InputLabel>
<Text style={styles.error}>{this.state.error}</Text>
</View>
<InputLabel style={{ textAlign: 'center', marginTop: 8 }}>
{getAvailableString()}
</InputLabel>
<Text style={styles.error}>{this.state.error}</Text>
<NewHathorButton
title={t`Next`}
disabled={this.isButtonDisabled()}
onPress={this.onButtonPress}
/>
</View>
<NewHathorButton
title={t`Next`}
disabled={this.isButtonDisabled()}
onPress={this.onButtonPress}
/>
</View>
<OfflineBar style={{ position: 'relative' }} />
</KeyboardAvoidingView>
<OfflineBar style={{ position: 'relative' }} />
</KeyboardAvoidingView>
</Pressable>
</View>
);
}
Expand Down
Loading