Skip to content

Commit

Permalink
Merge pull request #37 from Thinkmill/fix-30
Browse files Browse the repository at this point in the history
Fix for Modal Component crashing on Android
  • Loading branch information
Kevin Brown authored Mar 8, 2017
2 parents 8679650 + 64645ff commit f384d2d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
13 changes: 13 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,19 @@ dependencies {
compile "com.facebook.react:react-native:+" // From node_modules
}

repositories {
maven { url 'https://github.com/500px/500px-android-blur/raw/master/releases/' }
}

buildscript {
repositories {
maven { url 'https://github.com/500px/500px-android-blur/raw/master/releases/' }
}
dependencies {
classpath 'com.fivehundredpx:blurringview:1.0.0'
}
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
Expand Down
25 changes: 18 additions & 7 deletions app/components/Modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import {
Animated,
Dimensions,
Modal as RNModal,
Platform,
StyleSheet,
TouchableOpacity,
View,
} from 'react-native';
import { BlurView } from 'react-native-blur';

Expand Down Expand Up @@ -99,16 +101,25 @@ export default class Modal extends Component {
return { transform: transformAnimations };
};

// react-native-blur crashes the app on android. Not sure why.
// To replicate just swap the comments on these lines.
// const blurView = false
const blurView = Platform.OS === 'android'
? <View style={[styles.blur, { backgroundColor: 'rgba(0, 0, 0, 0.8)' }]}>
<TouchableOpacity onPress={this.onClose} style={styles.touchable} />
</View>
: <BlurView
blurAmount={blurAmount}
blurType={blurType}
style={styles.blur}
>
<TouchableOpacity onPress={this.onClose} style={styles.touchable} />
</BlurView>;

return (
<RNModal animationType="none" transparent visible>
<Animated.View style={[styles.blockout, blockoutDynamicStyles]}>
<BlurView
blurAmount={blurAmount}
blurType={blurType}
style={styles.blur}
>
<TouchableOpacity onPress={this.onClose} style={styles.touchable} />
</BlurView>
{blurView}
<Animated.View style={[style, getDialogDynamicStyles()]}>
{this.props.children}
</Animated.View>
Expand Down
1 change: 0 additions & 1 deletion app/scenes/Talk/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ export default class Talk extends Component {
});
};
toggleSpeakerModal = (data: Object) => {
console.log('data', data);
this.setState({
modalIsOpen: !this.state.modalIsOpen,
modalSpeaker: data,
Expand Down

0 comments on commit f384d2d

Please sign in to comment.