-
Notifications
You must be signed in to change notification settings - Fork 585
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(auth2): Remove KeyboardAvoidingView to get around iOS 17 bug #10896
Changes from all commits
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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import { Box, Flex, useTheme } from "@artsy/palette-mobile" | ||
import { AuthContext } from "app/Scenes/Onboarding/Auth2/AuthContext" | ||
import { MotiView } from "moti" | ||
import { Dimensions, KeyboardAvoidingView, Platform } from "react-native" | ||
import { Dimensions } from "react-native" | ||
import { Easing } from "react-native-reanimated" | ||
import { useSafeAreaInsets } from "react-native-safe-area-context" | ||
|
||
const HEIGHT = { | ||
LoginWelcomeStep: 320, | ||
|
@@ -20,6 +21,7 @@ export const AuthModal: React.FC = ({ children }) => { | |
const { isModalExpanded, isMounted, currentScreen } = AuthContext.useStoreState((state) => state) | ||
|
||
const { space } = useTheme() | ||
const insets = useSafeAreaInsets() | ||
|
||
const screenHeight = Dimensions.get("window").height | ||
|
||
|
@@ -34,44 +36,40 @@ export const AuthModal: React.FC = ({ children }) => { | |
const translateY = (() => { | ||
// Position the modal in the center of the screen, minus some padding | ||
if (isModalExpanded) { | ||
return 0 | ||
return insets.top + space(6) | ||
} | ||
|
||
return screenHeight / 2 - height / 2 - space(6) | ||
return screenHeight - height - insets.bottom | ||
})() | ||
|
||
return ( | ||
<KeyboardAvoidingView | ||
style={{ flex: 1 }} | ||
behavior={Platform.OS === "ios" ? "padding" : "height"} | ||
> | ||
<Box flex={1} height="100%" justifyContent="center"> | ||
<MotiView | ||
from={{ | ||
translateY: isModalExpanded ? 0 : screenHeight, | ||
}} | ||
animate={{ | ||
translateY, | ||
}} | ||
transition={{ | ||
type: "timing", | ||
duration: isModalExpanded ? 800 : 600, | ||
delay: isMounted ? 0 : 500, | ||
easing: Easing.out(Easing.exp), | ||
}} | ||
style={{ | ||
width: "100%", | ||
backgroundColor: "white", | ||
borderRadius: space(2), | ||
overflow: "hidden", | ||
position: "relative", | ||
}} | ||
> | ||
<Flex justifyContent="center" p={1}> | ||
{children} | ||
</Flex> | ||
</MotiView> | ||
</Box> | ||
</KeyboardAvoidingView> | ||
<Box flex={1} height="100%"> | ||
<MotiView | ||
from={{ | ||
translateY: isModalExpanded ? 0 : screenHeight, | ||
}} | ||
animate={{ | ||
translateY, | ||
}} | ||
transition={{ | ||
type: "timing", | ||
duration: isModalExpanded ? 800 : 600, | ||
delay: isMounted ? 0 : 500, | ||
easing: Easing.out(Easing.exp), | ||
}} | ||
style={{ | ||
width: "100%", | ||
backgroundColor: "white", | ||
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. nit: backgroundColor: color("white100"), 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. Will update in next pr, gonna send out a beta for this one. |
||
borderRadius: space(2), | ||
overflow: "hidden", | ||
position: "relative", | ||
}} | ||
> | ||
<Flex justifyContent="center" p={1}> | ||
{children} | ||
</Flex> | ||
</MotiView> | ||
</Box> | ||
// </KeyboardAvoidingView> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,14 +12,15 @@ import { useRecaptcha } from "app/Components/Recaptcha/Recaptcha" | |
import { AuthContext } from "app/Scenes/Onboarding/Auth2/AuthContext" | ||
import { useAuthNavigation } from "app/Scenes/Onboarding/Auth2/hooks/useAuthNavigation" | ||
import { useInputAutofocus } from "app/Scenes/Onboarding/Auth2/hooks/useInputAutofocus" | ||
import { waitForSubmit } from "app/Scenes/Onboarding/Auth2/utils/waitForSubmit" | ||
import { AuthPromiseRejectType, AuthPromiseResolveType } from "app/store/AuthModel" | ||
import { GlobalStore } from "app/store/GlobalStore" | ||
import { navigate } from "app/system/navigation/navigate" | ||
import { osMajorVersion } from "app/utils/platformUtil" | ||
import { Formik, useFormikContext } from "formik" | ||
import { MotiView } from "moti" | ||
import React, { useRef, useState } from "react" | ||
import { Alert, Image, InteractionManager, Keyboard, Platform } from "react-native" | ||
import { Alert, Image, InteractionManager, Platform } from "react-native" | ||
import { Easing } from "react-native-reanimated" | ||
import * as Yup from "yup" | ||
|
||
interface LoginEmailFormValues { | ||
|
@@ -47,8 +48,6 @@ export const LoginWelcomeStep: React.FC = () => { | |
.required("Email field is required"), | ||
})} | ||
onSubmit={async ({ email }, { resetForm }) => { | ||
Keyboard.dismiss() | ||
|
||
// FIXME | ||
if (!token) { | ||
Alert.alert("Something went wrong. Please try again, or contact [email protected]") | ||
|
@@ -57,8 +56,6 @@ export const LoginWelcomeStep: React.FC = () => { | |
|
||
const res = await GlobalStore.actions.auth.verifyUser({ email, recaptchaToken: token }) | ||
|
||
await waitForSubmit() | ||
|
||
if (res === "user_exists") { | ||
navigation.navigate({ name: "LoginPasswordStep", params: { email } }) | ||
} else if (res === "user_does_not_exist") { | ||
|
@@ -119,6 +116,7 @@ const LoginWelcomeStepForm: React.FC = () => { | |
autoCapitalize="none" | ||
autoComplete="email" | ||
autoCorrect={false} | ||
blurOnSubmit={false} | ||
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 see most of the places you removed the Keyboard.dismiss and added this prop as false, can you explain what it does now? (just curious) 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. Keeps the keyboard up, so that as we transition from screen to screen things aren't jumping around. Before it worked fine because we could use the keyboard avoiding view, and then use flexbox to vertically center in the screen. User would submit, keyboard would slide down, things would fetch, screen would transition. But with the quicktype bar, this broke the UX in a number of different ways. So now just keep things up and persistent from screen to screen. 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. It doesn't feel as nice any more having everything at that fixed position, but at least it doesn't feel broken! 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. it's a good compromise! |
||
error={errors.email} | ||
placeholderTextColor={color("black30")} | ||
ref={emailRef} | ||
|
@@ -135,15 +133,25 @@ const LoginWelcomeStepForm: React.FC = () => { | |
onSubmitEditing={handleSubmit} | ||
/> | ||
|
||
<Flex display={isModalExpanded ? "flex" : "none"}> | ||
<MotiView | ||
from={{ opacity: isModalExpanded ? 0 : 1 }} | ||
animate={{ opacity: isModalExpanded ? 1 : 0 }} | ||
transition={{ type: "timing", duration: 400, easing: Easing.linear }} | ||
style={{ display: isModalExpanded ? "flex" : "none" }} | ||
> | ||
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. Just adds a little smooth transition between the social login options and the email only input step |
||
<Spacer y={2} /> | ||
|
||
<Button block width="100%" onPress={handleSubmit} loading={isSubmitting}> | ||
Continue | ||
</Button> | ||
</Flex> | ||
</MotiView> | ||
|
||
<Flex display={isModalExpanded ? "none" : "flex"}> | ||
<MotiView | ||
from={{ opacity: isModalExpanded ? 1 : 0 }} | ||
animate={{ opacity: isModalExpanded ? 0 : 1 }} | ||
transition={{ type: "timing", duration: 400, easing: Easing.linear }} | ||
style={{ display: isModalExpanded ? "none" : "flex" }} | ||
> | ||
<Spacer y={2} /> | ||
|
||
<SocialLoginButtons /> | ||
|
@@ -160,7 +168,7 @@ const LoginWelcomeStepForm: React.FC = () => { | |
Privacy Policy | ||
</LinkText> | ||
</Text> | ||
</Flex> | ||
</MotiView> | ||
</Flex> | ||
) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/** | ||
* Slight delay to smooth out keyboard transitions between submission steps | ||
*/ | ||
export const waitForSubmit = async (delay = 1500) => { | ||
export const waitForSubmit = async (delay = 1000) => { | ||
return new Promise((resolve: any) => setTimeout(resolve, delay)) | ||
} |
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.
shouldn't we memoize 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.
ditto!
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.
much better, using
useMemo
i was like... on geez. Updated in here: #10898