-
Notifications
You must be signed in to change notification settings - Fork 369
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
[Wallet][ReDesign] QR Code / Scan screens #4017
Conversation
…n prompt work nicely with the animation
oh wow that slide action! 🤩 |
const [wasFocused, setWasFocused] = useState(isFocused) | ||
const [isPartiallyVisible, setIsPartiallyVisible] = useState(false) | ||
const cameraPermission = useAsync(check, [ | ||
Platform.select({ ios: PERMISSIONS.IOS.CAMERA, default: PERMISSIONS.ANDROID.CAMERA }), |
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 default? and not android?
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.
yes I feel you, TypeScript complains otherwise because Platform.select
return type would also contain undefined
. Which is not accepted by the check
function.
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.
ahh.
[position] | ||
) | ||
|
||
const animatedStyle = useMemo(() => { |
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.
one thing ive been thinking about is defining big hooks like this outside the component and then just calling them.
at best its more performant (no proof) at worst it keeps the voice in my head that functions should be 10 lines or less feeling less ignored.
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.
yes, kinda torn with this too, I'd say it depends, sometimes it's good to have all the context in a "big" function.
Here the function is still relatively short.
@@ -9,7 +9,14 @@ import { TransactionDataInput } from 'src/send/SendAmount' | |||
import { ReviewProps } from 'src/transactions/TransactionReview' | |||
import { TransferConfirmationCardProps } from 'src/transactions/TransferConfirmationCard' | |||
|
|||
// tslint:disable-next-line | |||
// Typed nested navigator params | |||
type NestedNavigatorParams<ParamList> = { |
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.
bravo
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.
Thanks! Had to think carefully about this 🤯 😄
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.
Looks great!! Just a few questions
}, | ||
(qrCode) => qrCode.data | ||
const onBarCodeDetected = useCallback( | ||
memoize( |
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.
Does this work? Or do we create a new memoized function on each render?
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.
yeah im not sure i get why its memoized.
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.
Yes not very obvious on the first look indeed.
It does create a new memoized version on each render, but only the first memoized version is returned, unless [scanIsForSecureSend, transactionData]
change.
We could think calling memoize
on each render seems heavy, but it's not very different from creating a new function in a standard useCallback
call.
See https://github.com/lodash/lodash/blob/master/memoize.js#L43-L60
export default function QRScanner({ route }: Props) { | ||
const dispatch = useDispatch() | ||
const { t } = useTranslation(Namespaces.sendFlow7) | ||
const inset = useSafeArea() |
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'm wondering if this would work better as an HOC instead of getting the inset and manually using it in margins like we do here.
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'm not sure I get the concern here.
I initially used SafeAreaView
, but it was causing a visual glitch in the animation because of its use of onLayout
.
}) | ||
|
||
const onPressClose = () => { | ||
navigation.dangerouslyGetParent()?.goBack() |
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.
Is this method... dangerous?
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.
Good question 😄
From the docs:
Reason why the function is called dangerouslyGetParent is to warn developers against overusing it to eg. get parent of parent and other hard-to-follow patterns.
@@ -7,7 +7,7 @@ import { Screens } from 'src/navigator/Screens' | |||
|
|||
export function QRCodeIcon() { | |||
const onQrCodePress = React.useCallback(() => { | |||
navigate(Screens.QRScanner) | |||
navigate(Screens.QRNavigator, { screen: Screens.QRScanner }) |
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.
Is screen
the default screen here? If so, maybe rename it?
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.
No, default screen is QRCode
} | ||
|
||
// unstyled Touchable Text, good for making other Text Buttons such as TopBarButton | ||
export default function BoarderlessButton(props: Props) { | ||
const { onPress, style, children, disabled, testID } = props | ||
const { style, children, ...rest } = props |
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.
Nit: I believe passThroughProps
is a common convention for rest
here
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.
Agreed 👍
@@ -0,0 +1,36 @@ | |||
patch-package |
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.
Is there a github issue open on the repo with this issue? If not, should we open one? Or use a diff lib we don't have to patch?
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.
Very good concern, cut a few corners to avoid spending too much time on this here.
I plan to open a PR on react-native-tab-view
.
The lib itself is very solid, I've used it in a bunch of past projects and a lot of effort has been put into it to provide native feeling for this.
It was created by @satya164 which is also one of the creator of of react-navigation
.
Description
This implements the QR code scan redesign.
Note:
Other changes
Touchable
props types to accept all props fromTouchableWithoutFeedback
(accessibility, testID, etc)Tested
Related issues
Backwards compatibility
Yes.