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

Fade in images + bugfixes #385

Merged
merged 9 commits into from
Feb 15, 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
10 changes: 10 additions & 0 deletions app/components/AccountInput/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ class AccountInput extends Component {
* Callback triggered when the input is focused
*/
onFocus: PropTypes.func,
/**
* Callback triggered when the input is blurred
*/
onBlur: PropTypes.func,
/**
* Placeholder text to show inside this input
*/
Expand All @@ -127,6 +131,11 @@ class AccountInput extends Component {
onFocus && onFocus();
};

onBlur = () => {
const { onBlur, value } = this.props;
onBlur && onBlur(value);
};

selectAccount(account) {
this.onChange(account.address);
}
Expand Down Expand Up @@ -198,6 +207,7 @@ class AccountInput extends Component {
spellCheck={false}
style={styles.input}
value={value}
onBlur={this.onBlur}
/>
<TouchableOpacity onPress={this.scan} style={styles.qrCodeButton}>
<Icon name="qrcode" size={Platform.OS === 'android' ? 28 : 28} />
Expand Down
6 changes: 6 additions & 0 deletions app/components/AssetIcon/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

exports[`AssetIcon should render correctly 1`] = `
<MyImage
fadeIn={true}
placeholderStyle={
Object {
"backgroundColor": "#FFFFFF",
}
}
source={
Object {
"uri": "https://raw.githubusercontent.com/MetaMask/eth-contract-metadata/master/images/metamark.svg",
Expand Down
11 changes: 10 additions & 1 deletion app/components/AssetIcon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { StyleSheet } from 'react-native';
import Image from 'react-native-remote-svg';
import PropTypes from 'prop-types';
import getAssetLogoPath from '../../util/assets';
import { colors } from '../../styles/common';

const styles = StyleSheet.create({
logo: {
Expand Down Expand Up @@ -38,6 +39,14 @@ export default class AssetIcon extends Component {
const { logo, customStyle } = this.props;
if (!logo) return;
const uri = getAssetLogoPath(logo);
return logo ? <Image source={{ uri }} style={[styles.logo, customStyle]} /> : null;

return logo ? (
<Image
fadeIn
placeholderStyle={{ backgroundColor: colors.white }}
source={{ uri }}
style={[styles.logo, customStyle]}
/>
) : null;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ exports[`CollectibleImage should render correctly 1`] = `
}
>
<MyImage
fadeIn={true}
placeholderStyle={
Object {
"backgroundColor": "#FFFFFF",
}
}
source={
Object {
"uri": "IMAGE",
Expand Down
3 changes: 3 additions & 0 deletions app/components/CollectibleImage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import { StyleSheet, View } from 'react-native';
import Image from 'react-native-remote-svg';
import Identicon from '../Identicon';
import { colors } from '../../styles/common';

const styles = StyleSheet.create({
listWrapper: {
Expand Down Expand Up @@ -57,6 +58,8 @@ export default class CollectibleImage extends Component {
<View style={renderFull ? styles.fullWrapper : [styles.listWrapper, containerStyle]}>
{image && image.length !== 0 ? (
<Image
fadeIn
placeholderStyle={{ backgroundColor: colors.white }}
source={{ uri: image }}
style={renderFull ? styles.fullImage : [styles.listImage, iconStyle]}
/>
Expand Down
26 changes: 15 additions & 11 deletions app/components/Identicon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Image } from 'react-native';
import { toDataUrl } from '../../util/blockies.js';
import FadeIn from 'react-native-fade-in-image';
import { colors } from '../../styles/common.js';

/**
* UI component that renders an Identicon
Expand Down Expand Up @@ -36,17 +38,19 @@ export default class IdenticonComponent extends Component {
const { diameter, address, customStyle } = this.props;

return address ? (
<Image
source={{ uri: toDataUrl(address) }}
style={[
{
height: diameter,
width: diameter,
borderRadius: diameter / 2
},
customStyle
]}
/>
<FadeIn placeholderStyle={{ backgroundColor: colors.white }}>
<Image
source={{ uri: toDataUrl(address) }}
style={[
{
height: diameter,
width: diameter,
borderRadius: diameter / 2
},
customStyle
]}
/>
</FadeIn>
) : null;
};
}
10 changes: 9 additions & 1 deletion app/components/NetworkList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,15 @@ export class NetworkList extends Component {
NetworkController.setProviderType(type);
setTimeout(() => {
this.props.onClose(false);
InteractionManager.runAfterInteractions(() => Engine.refreshTransactionHistory());
InteractionManager.runAfterInteractions(() => {
const { AssetsDetectionController, AccountTrackerController } = Engine.context;
const actions = [
AssetsDetectionController.detectAssets(),
AccountTrackerController.refresh(),
Engine.refreshTransactionHistory()
];
Promise.all(actions);
});
}, 300);
};

Expand Down
5 changes: 4 additions & 1 deletion app/components/Tokens/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import ActionSheet from 'react-native-actionsheet';
import { renderFromTokenMinimalUnit, balanceToFiat } from '../../util/number';
import Engine from '../../core/Engine';
import AssetElement from '../AssetElement';
import FadeIn from 'react-native-fade-in-image';

const styles = StyleSheet.create({
wrapper: {
Expand Down Expand Up @@ -154,7 +155,9 @@ export default class Tokens extends PureComponent {
return (
<AssetElement onPress={this.onItemPress} onLongPress={this.showRemoveMenu} asset={item}>
{item.symbol === 'ETH' ? (
<Image source={ethLogo} style={styles.ethLogo} />
<FadeIn placeholderStyle={{ backgroundColor: colors.white }}>
<Image source={ethLogo} style={styles.ethLogo} />
</FadeIn>
) : (
<TokenImage asset={item} containerStyle={styles.ethLogo} />
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ exports[`TransactionEdit should render correctly 1`] = `
</Text>
</View>
<Connect(AccountInput)
onBlur={[Function]}
onChange={[Function]}
onFocus={[Function]}
placeholder="Recipient Address"
Expand Down
1 change: 1 addition & 0 deletions app/components/TransactionEdit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ class TransactionEdit extends Component {
</View>
<AccountInput
onChange={this.updateToAddress}
onBlur={this.updateToAddress}
onFocus={this.onFocusToAddress}
placeholder={strings('transaction.recipient_address')}
showQRScanner={this.onScanSuccess}
Expand Down
5 changes: 5 additions & 0 deletions app/components/WebsiteIcon/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ exports[`WebsiteIcon should render correctly 1`] = `
<View>
<View>
<FadeIn
placeholderStyle={
Object {
"backgroundColor": "#FFFFFF",
}
}
useNativeDriver={true}
>
<Component
Expand Down
2 changes: 1 addition & 1 deletion app/components/WebsiteIcon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default class WebsiteIcon extends Component {
<View>
{!renderIconUrlError && (
<View style={viewStyle}>
<FadeIn>
<FadeIn placeholderStyle={{ backgroundColor: colors.white }}>
<Image source={apiLogoUrl} style={style} onError={this.onRenderIconUrlError} />
</FadeIn>
</View>
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ useScreens();

// List of warnings that we're ignoring
YellowBox.ignoreWarnings([
'Function components cannot be given refs.',
'Task orphaned for request',
'Module RNOS requires',
'use RCT_EXPORT_MODULE',
Expand Down
5 changes: 2 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"react-native-progress": "^3.5.0",
"react-native-qrcode-svg": "^5.1.1",
"react-native-randombytes": "^3.5.0",
"react-native-remote-svg": "^1.4.0",
"react-native-remote-svg": "github:brunobar79/react-native-remote-svg#92ebf7d079a6174e4451a47d372fe2335308c65e",
"react-native-screens": "^1.0.0-alpha.21",
"react-native-scrollable-tab-view": "github:estebanmino/react-native-scrollable-tab-view#master",
"react-native-settings-list": "^1.8.0",
Expand Down