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(Button): Improved UX of the LinearGradient button #2587

Merged
merged 3 commits into from
Sep 20, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/buttons/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ class Button extends Component {
...attributes
} = this.props;

// Refactor to Pressable
const TouchableComponentInternal = TouchableComponent
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be changed to:

const TouchableComponentInternal = TouchableComponent || 
  Platform.select(...);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@flyingcircle thanks for the feedback :)

? TouchableComponent
: Platform.select({
android: linearGradientProps
? TouchableOpacity
: TouchableNativeFeedback,
default: TouchableOpacity,
});

const titleStyle = StyleSheet.flatten([
styles.title(type, theme),
passedTitleStyle,
Expand Down Expand Up @@ -103,7 +113,7 @@ class Button extends Component {
raised && !disabled && styles.raised(type),
])}
>
<TouchableComponent
<TouchableComponentInternal
onPress={this.handleOnPress}
delayPressIn={0}
activeOpacity={0.3}
Expand Down Expand Up @@ -157,7 +167,7 @@ class Button extends Component {
]),
})}
</ViewComponent>
</TouchableComponent>
</TouchableComponentInternal>
</View>
);
}
Expand Down Expand Up @@ -190,10 +200,6 @@ Button.propTypes = {
Button.defaultProps = {
title: '',
iconRight: false,
TouchableComponent: Platform.select({
android: TouchableNativeFeedback,
default: TouchableOpacity,
}),
onPress: () => console.log('Please attach a method to this component'),
type: 'solid',
buttonStyle: {
Expand Down
9 changes: 1 addition & 8 deletions src/buttons/__tests__/__snapshots__/Button.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -530,14 +530,7 @@ exports[`Button Component should apply values from theme 1`] = `
onStartShouldSetResponder={[Function]}
style={
Object {
"opacity": Object {
"_animation": null,
"_children": Array [],
"_listeners": Object {},
"_offset": 0,
"_startingValue": 1,
"_value": 1,
},
"opacity": 1,
}
}
>
Expand Down