-
-
Notifications
You must be signed in to change notification settings - Fork 595
fix(iOS): prevent back button icon from "jumping" during pop animation when display mode minimal is set #2800
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
Changes from 2 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 |
|---|---|---|
|
|
@@ -631,12 +631,9 @@ + (void)updateViewController:(UIViewController *)vc | |
|
|
||
| auto shouldUseCustomBackBarButtonItem = !isBackTitleBlank || config.disableBackButtonMenu; | ||
|
|
||
| #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_14_0) && \ | ||
| __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_14_0 | ||
| if (@available(iOS 14.0, *)) { | ||
| prevItem.backButtonDisplayMode = config.backButtonDisplayMode; | ||
| } | ||
| #endif | ||
| // This has any effect only in case the `backBarButtonItem` is not set. | ||
| // We apply it before we configure the back item, because it might get overriden. | ||
| prevItem.backButtonDisplayMode = config.backButtonDisplayMode; | ||
|
Member
Author
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 don't need to wrap it inside ifdefs due to #2799 (min supported iOS version is 15.1 now |
||
|
|
||
| if (config.isBackTitleVisible) { | ||
| if ((config.backTitleFontFamily && | ||
|
|
@@ -666,11 +663,9 @@ + (void)updateViewController:(UIViewController *)vc | |
| // back button title should be not visible next to back button, | ||
| // but it should still appear in back menu (if one is enabled) | ||
|
|
||
| // When backBarButtonItem's title is null, back menu will use value | ||
| // of backButtonTitle | ||
| [backBarButtonItem setTitle:nil]; | ||
| shouldUseCustomBackBarButtonItem = YES; | ||
| prevItem.backButtonTitle = resolvedBackTitle; | ||
| prevItem.backButtonDisplayMode = UINavigationItemBackButtonDisplayModeMinimal; | ||
| shouldUseCustomBackBarButtonItem = NO; | ||
| } | ||
|
|
||
| // Prevent unnecessary assignment of backBarButtonItem if it is not customized, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,7 +82,9 @@ Boolean indicating whether to show the menu on longPress of iOS >= 14 back butto | |
|
|
||
| #### `backButtonDisplayMode` (iOS only) | ||
|
|
||
| Enum value indicating display mode of **default** back button. It works on iOS >= 14, and is used only when none of: `backTitleFontFamily`, `backTitleFontSize`, `disableBackButtonMenu` or `backTitle` is set. Otherwise, when the button is customized, under the hood we use iOS native `backButtonItem` which overrides `backButtonDisplayMode`. Read more [#2123](https://github.com/software-mansion/react-native-screens/pull/2123). Possible options: | ||
| Enum value indicating display mode of back button. It is used only when none of: `backTitleFontFamily`, `backTitleFontSize`, `disableBackButtonMenu`, `backTitle` and `backTitleVisible=false` is set. When the button is customized, under the hood we use iOS native `backButtonItem` which overrides `backButtonDisplayMode`. Read more [#2123](https://github.com/software-mansion/react-native-screens/pull/2123). The `backTitleVisible` forces `backButtonDisplayMode: minimal` and omits other values. Read more [#2800](https://github.com/software-mansion/react-native-screens/pull/2800) | ||
|
|
||
| Possible options: | ||
|
||
|
|
||
| - `default` – show given back button previous controller title, system generic or just icon based on available space | ||
| - `generic` – show given system generic or just icon based on available space | ||
|
|
@@ -128,7 +130,9 @@ Style object for header back title. Supported properties: | |
|
|
||
| #### `headerBackTitleVisible` (iOS only) | ||
|
|
||
| Whether the back button title should be visible or not. Defaults to `true`. | ||
| Whether the back button title should be visible. Defaults to `true`. | ||
|
|
||
| When set to `false` it works as a "kill switch": it enforces `backButtonDisplayMode=minimal` and ignores `backButtonDisplayMode`, `backTitleFontSize`, `backTitleFontFamily`, `disableBackButtonMenu`, and `backTitle` works only for back button menu. | ||
|
|
||
| #### `headerCenter` | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -544,6 +544,10 @@ export interface ScreenStackHeaderConfigProps extends ViewProps { | |
| backTitleFontSize?: number; | ||
| /** | ||
| * Whether the back button title should be visible or not. Defaults to `true`. | ||
| * | ||
| * When set to `false` it works as a "kill switch": it enforces `backButtonDisplayMode=minimal` and ignores `backButtonDisplayMode`, `backTitleFontSize`, `backTitleFontFamily`, `disableBackButtonMenu`. | ||
| * For `backTitle` it works only in back button menu. | ||
| * | ||
| * @platform ios | ||
| */ | ||
| backTitleVisible?: boolean; | ||
|
|
@@ -570,11 +574,13 @@ export interface ScreenStackHeaderConfigProps extends ViewProps { | |
| */ | ||
| disableBackButtonMenu?: boolean; | ||
| /** | ||
| * How the back button behaves by default (when not customized). Available on iOS>=14, and is used only when none of: `backTitleFontFamily`, `backTitleFontSize`, `disableBackButtonMenu` or `backTitle` is set. | ||
| * The following values are currently supported (they correspond to https://developer.apple.com/documentation/uikit/uinavigationitembackbuttondisplaymode?language=objc): | ||
| * - "default" – show given back button previous controller title, system generic or just icon based on available space | ||
| * - "generic" – show given system generic or just icon based on available space | ||
| * - "minimal" – show just an icon | ||
| * How the back button behaves. It is used only when none of: `backTitleFontFamily`, `backTitleFontSize`, `disableBackButtonMenu`, `backTitle` and `backTitleVisible=false` is set. | ||
| * To read more see [#2800](https://github.com/software-mansion/react-native-screens/pull/2800) and [#2800](https://github.com/software-mansion/react-native-screens/pull/2800). | ||
|
||
| * | ||
| * - `default` – show given back button previous controller title, system generic or just icon based on available space | ||
| * - `generic` – show given system generic or just icon based on available space | ||
| * - `minimal` – show just an icon | ||
| * | ||
| * @platform ios | ||
| */ | ||
| backButtonDisplayMode?: BackButtonDisplayMode; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.