Browse Source
Merge pull request #278 from henninghall/fix-fadeToColor--none
fix: fadeToColor "none" throws exception
master
Henning Hall
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
9 additions and
2 deletions
-
examples/detox/src/examples/Advanced.js
-
examples/detox/src/propPickers/FadeToColor.js
-
src/colorToHex.js
|
|
@ -173,7 +173,10 @@ export default class Advanced extends Component { |
|
|
|
{ |
|
|
|
name: 'fadeToColor', |
|
|
|
component: ( |
|
|
|
<FadeToColor onChange={() => this.props.setBackground(randomColor())} /> |
|
|
|
<FadeToColor |
|
|
|
onChange={() => this.props.setBackground(randomColor())} |
|
|
|
setNone={() => this.props.setBackground("none")} |
|
|
|
/> |
|
|
|
), |
|
|
|
}, |
|
|
|
{ |
|
|
|
|
|
@ -3,6 +3,9 @@ import { Button } from 'react-native' |
|
|
|
|
|
|
|
export default class extends Component { |
|
|
|
render() { |
|
|
|
return <Button title={'Change color'} onPress={this.props.onChange} /> |
|
|
|
return <> |
|
|
|
<Button title={'Change color'} onPress={this.props.onChange} /> |
|
|
|
<Button title={'Set "none"'} onPress={this.props.setNone} /> |
|
|
|
</> |
|
|
|
} |
|
|
|
} |
|
|
@ -1,5 +1,6 @@ |
|
|
|
export function colorToHex(c) { |
|
|
|
if (c === undefined) return c |
|
|
|
if (c === "none") return c |
|
|
|
if (c.includes('rgb')) return rgb2hex(c) |
|
|
|
if (c.includes('#')) { |
|
|
|
if (!isValidHex(c)) throw Error('Invalid color: ' + c) |
|
|
|