-
Notifications
You must be signed in to change notification settings - Fork 30
fix(components-native): Form respect safe area spacing #3078
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
base: master
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -33,7 +33,6 @@ import { useScrollToError } from "./hooks/useScrollToError"; | |
| import { FormSaveButton } from "./components/FormSaveButton"; | ||
| import { useSaveButtonPosition } from "./hooks/useSaveButtonPosition"; | ||
| import { FormCache } from "./components/FormCache/FormCache"; | ||
| import { useAtlantisFormContext } from "./context/AtlantisFormContext"; | ||
| import { IOSKeyboardAwareScrollViewSpacer } from "./components/IOSKeyboardAwareScrollViewSpacer/IOSKeyboardAwareScrollViewSpacer"; | ||
| import { InputAccessoriesProvider } from "../InputText"; | ||
| import { tokens } from "../utils/design"; | ||
|
|
@@ -179,8 +178,6 @@ function InternalForm<T extends FieldValues, S>({ | |
|
|
||
| const styles = useStyles(); | ||
|
|
||
| const { edgeToEdgeEnabled } = useAtlantisFormContext(); | ||
|
|
||
| return ( | ||
| <FormProvider {...formMethods}> | ||
| <> | ||
|
|
@@ -234,9 +231,7 @@ function InternalForm<T extends FieldValues, S>({ | |
| <View | ||
| style={[ | ||
| styles.fixedSaveButton, | ||
| (edgeToEdgeEnabled || Platform.OS !== "android") && { | ||
| marginBottom: paddingBottom, | ||
| }, | ||
| paddingBottom > 0 && { marginBottom: paddingBottom }, | ||
| ]} | ||
|
Comment on lines
233
to
235
|
||
| > | ||
| {renderStickySection ? ( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,11 @@ | ||
| import React, { type ReactElement, useMemo } from "react"; | ||
| import { View } from "react-native"; | ||
| import React, { type ReactNode } from "react"; | ||
| import { SafeAreaView } from "react-native-safe-area-context"; | ||
| import { useStyles } from "./FormBody.style"; | ||
| import { useScreenInformation } from "../../hooks/useScreenInformation"; | ||
| import type { FormActionBarProps } from "../FormActionBar"; | ||
| import { FormActionBar } from "../FormActionBar"; | ||
| import { tokens } from "../../../utils/design"; | ||
|
|
||
| interface FormBodyProps extends FormActionBarProps { | ||
| readonly children: ReactElement; | ||
| readonly children: ReactNode; | ||
| readonly shouldRenderActionBar?: boolean; | ||
| readonly saveButtonOffset?: number; | ||
| } | ||
|
Comment on lines
7
to
11
|
||
|
|
@@ -23,43 +21,32 @@ export function FormBody({ | |
| secondaryActions, | ||
| setSecondaryActionLoading, | ||
| setSaveButtonHeight, | ||
| saveButtonOffset, | ||
| }: FormBodyProps) { | ||
| const paddingBottom = useBottomPadding(); | ||
| const fullViewPadding = useMemo(() => ({ paddingBottom }), [paddingBottom]); | ||
| const styles = useStyles(); | ||
|
|
||
| return ( | ||
| <> | ||
| <View style={[styles.container]}> | ||
| {children} | ||
| {shouldRenderActionBar && ( | ||
| <FormActionBar | ||
| setSecondaryActionLoading={setSecondaryActionLoading} | ||
| keyboardHeight={keyboardHeight} | ||
| submit={submit} | ||
| isFormSubmitting={isFormSubmitting} | ||
| saveButtonLabel={saveButtonLabel} | ||
| renderStickySection={renderStickySection} | ||
| secondaryActions={secondaryActions} | ||
| setSaveButtonHeight={setSaveButtonHeight} | ||
| /> | ||
| )} | ||
| </View> | ||
|
|
||
| {shouldRenderActionBar && !saveButtonOffset && ( | ||
| <View | ||
| style={[fullViewPadding, styles.safeArea]} | ||
| testID="ATL-FormSafeArea" | ||
| <SafeAreaView | ||
| edges={["bottom"]} | ||
| style={[styles.container, styles.safeArea]} | ||
| testID="ATL-FormSafeArea" | ||
| > | ||
| {children} | ||
| {shouldRenderActionBar && ( | ||
| <FormActionBar | ||
| setSecondaryActionLoading={setSecondaryActionLoading} | ||
| keyboardHeight={keyboardHeight} | ||
| submit={submit} | ||
| isFormSubmitting={isFormSubmitting} | ||
| saveButtonLabel={saveButtonLabel} | ||
| renderStickySection={renderStickySection} | ||
| secondaryActions={secondaryActions} | ||
| setSaveButtonHeight={setSaveButtonHeight} | ||
| /> | ||
| )} | ||
| </> | ||
| </SafeAreaView> | ||
| ); | ||
| } | ||
|
|
||
| export function useBottomPadding(): number { | ||
| const { insets } = useScreenInformation(); | ||
| const extraBottomSpace = insets.bottom - tokens["space-base"]; | ||
|
|
||
| return extraBottomSpace >= 0 ? extraBottomSpace : 0; | ||
| return 0; | ||
| } | ||
|
Comment on lines
50
to
52
|
||
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.
Test description is grammatically incorrect; consider rephrasing for clarity (e.g., remove the extra “is”).