-
Notifications
You must be signed in to change notification settings - Fork 35
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
1428/entropy screen changes #1446
Changes from 17 commits
52665cc
ffe1cb1
69f6df4
f8d10cd
78b4b1d
1b735d9
719b335
a0d8605
dd5e9b7
dd3b78d
be4dbd3
49ffeb2
eccb1df
483d544
febf557
7a1b2e9
77a2f9d
2909f92
768c5cb
185a9bf
785321c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react' | ||
import Svg, { Defs, G, Path } from 'react-native-svg' | ||
/* SVGR has dropped some elements not supported by react-native-svg: filter */ | ||
|
||
const SvgHandIcon = props => ( | ||
<Svg width={94} height={101} {...props}> | ||
<Defs></Defs> | ||
<G | ||
filter="url(#HandIcon_svg__a)" | ||
transform="translate(4 1.5)" | ||
fill="#FFEFDF" | ||
fillRule="nonzero" | ||
> | ||
<Path d="M86.144 69.365c-1.803-4.854-2.208-8.4-2.602-11.827-.531-4.621-1.079-9.402-5.003-16.748L67.786 20.66c-1.732-3.24-6.038-4.491-9.04-2.617-1.005.627-1.842 1.568-2.417 2.692-1.114-1.732-2.738-2.97-4.644-3.522-2.134-.619-4.362-.298-6.276.892-1.82 1.136-3.09 2.91-3.706 4.911-2.587-2.31-6.34-2.774-9.412-.854-1.788 1.115-3.101 2.873-3.73 4.982L14.324 5.506C10.136-.664 6.016.592 3.93 1.895 2.01 3.093.742 5 .36 7.269c-.353 2.086.062 4.375 1.194 6.488l22.892 40.197c.478.84 1.497 1.103 2.275.586.779-.519 1.022-1.618.542-2.458L4.393 11.927c-.713-1.338-.99-2.763-.779-4.018.209-1.235.89-2.243 1.97-2.917.745-.465 3.008-1.881 6.058 2.608L29.35 34.516c.511.776 1.497.983 2.243.469.743-.517.98-1.574.538-2.4a5.709 5.709 0 0 1-.496-4.07c.342-1.384 1.164-2.541 2.31-3.256 2.371-1.477 5.415-.6 6.782 1.963l1.647 3.086a.036.036 0 0 1 .007.01c.457.857 1.47 1.147 2.26.655.79-.493 1.062-1.586.605-2.442-1.368-2.562-.554-5.848 1.817-7.327a4.612 4.612 0 0 1 3.765-.536c1.282.372 2.35 1.258 3.012 2.5l2.477 4.633.005.011c.458.855 1.469 1.146 2.261.654.791-.493 1.062-1.586.606-2.442-.419-.781-.523-1.77-.285-2.71.238-.937.783-1.73 1.496-2.175 1.449-.904 3.687-.254 4.52 1.309l10.754 20.13c3.59 6.717 4.073 10.936 4.584 15.4.38 3.311.771 6.724 2.301 11.267l-32.004 19.97C44.98 82.727 36.459 75.92 25.2 68.963a199.17 199.17 0 0 0-3.612-2.18c-3.04-1.791-5.188-5.353-5.226-8.658-.016-1.502.42-3.578 2.597-4.935.793-.495 1.064-1.59.608-2.444-.459-.855-1.473-1.148-2.262-.654-2.779 1.736-4.29 4.603-4.25 8.075.05 4.611 2.844 9.335 6.95 11.757a192.98 192.98 0 0 1 3.552 2.142c11.573 7.152 20.128 14.083 25.425 20.6.323.397.78.608 1.242.608.283 0 .57-.079.828-.24L85.436 71.58c.713-.445 1.014-1.389.708-2.215z" /> | ||
</G> | ||
</Svg> | ||
) | ||
|
||
export default SvgHandIcon |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react' | ||
import Svg, { G, Path } from 'react-native-svg' | ||
|
||
const SvgSplashIcon = props => ( | ||
<Svg width={35} height={38} {...props}> | ||
<G fill="#FFEFDF" fillRule="nonzero"> | ||
<Path d="M10.497 14.371c.322.35.746.524 1.17.524.423 0 .846-.174 1.169-.524a1.89 1.89 0 0 0 0-2.528l-4.68-5.056c-.647-.7-1.694-.7-2.34 0a1.89 1.89 0 0 0 0 2.528l4.68 5.056zM28.042 14.897a1.59 1.59 0 0 0 1.17-.524l4.678-5.058c.647-.7.647-1.83 0-2.528-.645-.7-1.692-.7-2.339 0l-4.678 5.058a1.89 1.89 0 0 0 0 2.528c.322.348.746.524 1.17.524zM19.853 11.23c.914 0 1.655-.801 1.655-1.788V2.291c0-.987-.741-1.788-1.655-1.788-.913 0-1.654.8-1.654 1.788v7.15c0 .988.741 1.789 1.654 1.789zM9.928 21.957c0-.987-.742-1.788-1.655-1.788H1.654C.741 20.17 0 20.97 0 21.957s.741 1.788 1.654 1.788h6.62c.912 0 1.654-.801 1.654-1.788zM10.495 29.543L5.815 34.6c-.647.699-.647 1.83 0 2.528.323.35.746.523 1.17.523.423 0 .847-.173 1.17-.523l4.68-5.058c.644-.698.644-1.83 0-2.528a1.567 1.567 0 0 0-2.34 0z" /> | ||
</G> | ||
</Svg> | ||
) | ||
|
||
export default SvgSplashIcon |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import React, { useRef, useEffect } from 'react' | ||
import { StyleSheet, View, Animated } from 'react-native' | ||
import { HandIcon, SplashIcon } from 'src/resources/index' | ||
|
||
interface Props {} | ||
|
||
const styles = StyleSheet.create({ | ||
handPosition: { | ||
// TODO change to be % based | ||
top: -29, | ||
left: 8, | ||
}, | ||
splashPosition: { | ||
top: 0, | ||
left: 0, | ||
}, | ||
}) | ||
|
||
// TODO explain this better | ||
export const usePulseForBoth = () => { | ||
// We need two changing values to use for the opacity, | ||
const handPV = useRef(new Animated.Value(0)).current | ||
const splashPV = useRef(new Animated.Value(0)).current | ||
|
||
// here we define how these values change | ||
// in parallel, they change in sync | ||
const pulse = () => | ||
Animated.parallel([ | ||
// these sequences are made of individual time frames, here I'm just | ||
// making a list of timings which each move to the next value | ||
Animated.sequence( | ||
[1, 0, 1, 0, 0, 1, 0].map(n => | ||
Animated.timing(splashPV, { toValue: n }), | ||
), | ||
), | ||
Animated.sequence( | ||
[1, 1, 1, 0, 0, 1, 1].map(n => Animated.timing(handPV, { toValue: n })), | ||
), | ||
// this must have itself as a callback to loop | ||
]).start(pulse) | ||
|
||
// this is react hook magic, whatever functional component this is called in | ||
// will start the loop and clean up when it's lifetime is over | ||
useEffect(() => { | ||
const timeout = setTimeout(pulse, 0) | ||
return () => clearTimeout(timeout) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Late to the party, but this will not work because the timeout has already fired. The recursive callbacks ( |
||
}) | ||
|
||
// return your shiny new looping animated values | ||
return { handPV, splashPV } | ||
} | ||
|
||
export const HandAnimationComponent: React.FC<Props> = props => { | ||
const { handPV, splashPV } = usePulseForBoth() | ||
|
||
return ( | ||
<View> | ||
<Animated.View style={{ opacity: splashPV, ...styles.splashPosition }}> | ||
<SplashIcon /> | ||
</Animated.View> | ||
<Animated.View style={{ opacity: handPV, ...styles.handPosition }}> | ||
<HandIcon /> | ||
</Animated.View> | ||
</View> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,8 @@ interface State { | |
} | ||
|
||
// we are gonna collect some from the user and the rest from the OS | ||
const ENOUGH_ENTROPY_PROGRESS = 0.6 | ||
const ENOUGH_ENTROPY_PROGRESS = 0.3 | ||
const POST_COLLECTION_WAIT_TIME = 1000 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel that this wait time seems a bit unnatural - I'm not sure the best course of action though. Instantaneous is also a bit jumpy. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally the navigation would be a bit smoother. I don't think it's a matter of the timeout so much, and rather the animation used during navigation (or in this case the lack of one). Not entirely sure how to approach this / what the best course of action is. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We disabled the animations/transitions between the starting screens - this is probably a casualty of that. I would suggest lowering the timeout for now and then iterating on solutions to make it smoother in the future. |
||
|
||
export class EntropyContainer extends React.Component<Props, State> { | ||
private entropyGenerator!: EntropyGeneratorInterface | ||
|
@@ -42,7 +43,7 @@ export class EntropyContainer extends React.Component<Props, State> { | |
this.entropyGenerator = this.setUpEntropyGenerator() | ||
} | ||
|
||
private setUpEntropyGenerator(): EntropyGenerator { | ||
private setUpEntropyGenerator(): EntropyGeneratorInterface { | ||
return new EntropyGenerator() | ||
} | ||
|
||
|
@@ -71,6 +72,7 @@ export class EntropyContainer extends React.Component<Props, State> { | |
} | ||
const encodedEntropy = this.generateRandomString() | ||
this.setState({ encodedEntropy }) | ||
setTimeout(this.submitEntropy, POST_COLLECTION_WAIT_TIME) | ||
} | ||
} | ||
|
||
|
@@ -88,7 +90,6 @@ export class EntropyContainer extends React.Component<Props, State> { | |
<EntropyComponent | ||
addPoint={this.addPoint} | ||
progress={this.state.entropyProgress} | ||
submitEntropy={this.submitEntropy} | ||
/> | ||
</React.Fragment> | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this need to be % based? Because magic numbers seem hack-y?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think as long as there's a comment explaining that this is the position where the hand fits in the sparkly bit, it should be fine.