@react-navigation/elements 2.0.0-rc.9 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/{Background.cjs → Background.js} +1 -1
- package/lib/commonjs/{Button.cjs → Button.js} +3 -3
- package/lib/commonjs/Header/{Header.cjs → Header.js} +114 -42
- package/lib/commonjs/Header/Header.js.map +1 -0
- package/lib/commonjs/Header/{HeaderBackButton.cjs → HeaderBackButton.js} +45 -58
- package/lib/commonjs/Header/HeaderBackButton.js.map +1 -0
- package/lib/commonjs/Header/{HeaderBackContext.cjs → HeaderBackContext.js} +2 -2
- package/lib/commonjs/Header/{HeaderBackground.cjs → HeaderBackground.js} +1 -1
- package/lib/commonjs/Header/{HeaderButton.cjs → HeaderButton.js} +2 -2
- package/lib/commonjs/Header/{HeaderHeightContext.cjs → HeaderHeightContext.js} +2 -2
- package/lib/commonjs/Header/HeaderIcon.js +44 -0
- package/lib/commonjs/Header/HeaderIcon.js.map +1 -0
- package/lib/commonjs/Header/HeaderSearchBar.js +267 -0
- package/lib/commonjs/Header/HeaderSearchBar.js.map +1 -0
- package/lib/commonjs/Header/{HeaderShownContext.cjs → HeaderShownContext.js} +2 -2
- package/lib/commonjs/Header/{HeaderTitle.cjs → HeaderTitle.js} +1 -1
- package/lib/commonjs/Header/{getDefaultHeaderHeight.cjs → getDefaultHeaderHeight.js} +1 -1
- package/lib/commonjs/Header/{getHeaderTitle.cjs → getHeaderTitle.js} +1 -1
- package/lib/commonjs/Header/{useHeaderHeight.cjs → useHeaderHeight.js} +2 -2
- package/lib/commonjs/Label/{Label.cjs → Label.js} +2 -2
- package/lib/commonjs/Label/{getLabel.cjs → getLabel.js} +1 -1
- package/lib/commonjs/{MaskedView.android.cjs → MaskedView.android.js} +2 -2
- package/lib/commonjs/{MaskedView.ios.cjs → MaskedView.ios.js} +2 -2
- package/lib/commonjs/{MaskedView.cjs → MaskedView.js} +1 -1
- package/lib/commonjs/{MaskedViewNative.cjs → MaskedViewNative.js} +1 -1
- package/lib/commonjs/{MissingIcon.cjs → MissingIcon.js} +3 -2
- package/lib/commonjs/MissingIcon.js.map +1 -0
- package/lib/commonjs/{PlatformPressable.cjs → PlatformPressable.js} +16 -15
- package/lib/commonjs/PlatformPressable.js.map +1 -0
- package/lib/commonjs/{ResourceSavingView.cjs → ResourceSavingView.js} +1 -1
- package/lib/commonjs/{SafeAreaProviderCompat.cjs → SafeAreaProviderCompat.js} +3 -1
- package/lib/commonjs/{SafeAreaProviderCompat.cjs.map → SafeAreaProviderCompat.js.map} +1 -1
- package/lib/commonjs/{Screen.cjs → Screen.js} +22 -20
- package/lib/commonjs/Screen.js.map +1 -0
- package/lib/commonjs/{Text.cjs → Text.js} +3 -1
- package/lib/commonjs/Text.js.map +1 -0
- package/lib/commonjs/assets/back-icon-mask.png +0 -0
- package/lib/commonjs/assets/back-icon@4x.ios.png +0 -0
- package/lib/commonjs/assets/clear-icon.png +0 -0
- package/lib/commonjs/assets/clear-icon@1x.png +0 -0
- package/lib/commonjs/assets/clear-icon@2x.png +0 -0
- package/lib/commonjs/assets/clear-icon@3x.png +0 -0
- package/lib/commonjs/assets/clear-icon@4x.png +0 -0
- package/lib/commonjs/assets/close-icon.png +0 -0
- package/lib/commonjs/assets/close-icon@1x.png +0 -0
- package/lib/commonjs/assets/close-icon@2x.png +0 -0
- package/lib/commonjs/assets/close-icon@3x.png +0 -0
- package/lib/commonjs/assets/close-icon@4x.png +0 -0
- package/lib/commonjs/assets/search-icon.png +0 -0
- package/lib/commonjs/assets/search-icon@1x.android.png +0 -0
- package/lib/commonjs/assets/search-icon@1x.ios.png +0 -0
- package/lib/commonjs/assets/search-icon@2x.android.png +0 -0
- package/lib/commonjs/assets/search-icon@2x.ios.png +0 -0
- package/lib/commonjs/assets/search-icon@3x.android.png +0 -0
- package/lib/commonjs/assets/search-icon@3x.ios.png +0 -0
- package/lib/commonjs/assets/search-icon@4x.android.png +0 -0
- package/lib/commonjs/assets/search-icon@4x.ios.png +0 -0
- package/lib/commonjs/{getDefaultSidebarWidth.cjs → getDefaultSidebarWidth.js} +1 -1
- package/lib/commonjs/{getNamedContext.cjs → getNamedContext.js} +1 -1
- package/lib/commonjs/{index.cjs → index.js} +28 -25
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/{types.cjs → types.js} +1 -1
- package/lib/module/{Background.mjs → Background.js} +3 -1
- package/lib/module/Background.js.map +1 -0
- package/lib/module/{Button.mjs → Button.js} +5 -3
- package/lib/module/Button.js.map +1 -0
- package/lib/module/Header/{Header.mjs → Header.js} +116 -43
- package/lib/module/Header/Header.js.map +1 -0
- package/lib/module/Header/{HeaderBackButton.mjs → HeaderBackButton.js} +47 -58
- package/lib/module/Header/HeaderBackButton.js.map +1 -0
- package/lib/module/Header/HeaderBackContext.js +5 -0
- package/lib/module/Header/HeaderBackContext.js.map +1 -0
- package/lib/module/Header/{HeaderBackground.mjs → HeaderBackground.js} +3 -1
- package/lib/module/Header/HeaderBackground.js.map +1 -0
- package/lib/module/Header/{HeaderButton.mjs → HeaderButton.js} +4 -2
- package/lib/module/Header/HeaderButton.js.map +1 -0
- package/lib/module/Header/HeaderHeightContext.js +5 -0
- package/lib/module/Header/HeaderHeightContext.js.map +1 -0
- package/lib/module/Header/HeaderIcon.js +39 -0
- package/lib/module/Header/HeaderIcon.js.map +1 -0
- package/lib/module/Header/HeaderSearchBar.js +260 -0
- package/lib/module/Header/HeaderSearchBar.js.map +1 -0
- package/lib/module/Header/HeaderShownContext.js +5 -0
- package/lib/module/Header/{HeaderShownContext.mjs.map → HeaderShownContext.js.map} +1 -1
- package/lib/module/Header/{HeaderTitle.mjs → HeaderTitle.js} +3 -1
- package/lib/module/Header/HeaderTitle.js.map +1 -0
- package/lib/module/Header/{getDefaultHeaderHeight.mjs → getDefaultHeaderHeight.js} +3 -1
- package/lib/module/Header/getDefaultHeaderHeight.js.map +1 -0
- package/lib/module/Header/{getHeaderTitle.mjs → getHeaderTitle.js} +3 -1
- package/lib/module/Header/getHeaderTitle.js.map +1 -0
- package/lib/module/Header/{useHeaderHeight.mjs → useHeaderHeight.js} +4 -2
- package/lib/module/Header/useHeaderHeight.js.map +1 -0
- package/lib/module/Label/{Label.mjs → Label.js} +4 -2
- package/lib/module/Label/Label.js.map +1 -0
- package/lib/module/Label/{getLabel.mjs → getLabel.js} +3 -1
- package/lib/module/Label/getLabel.js.map +1 -0
- package/lib/module/MaskedView.android.js +4 -0
- package/lib/module/MaskedView.android.js.map +1 -0
- package/lib/module/MaskedView.ios.js +4 -0
- package/lib/module/MaskedView.ios.js.map +1 -0
- package/lib/module/{MaskedView.mjs → MaskedView.js} +3 -1
- package/lib/module/MaskedView.js.map +1 -0
- package/lib/module/{MaskedViewNative.mjs → MaskedViewNative.js} +3 -1
- package/lib/module/MaskedViewNative.js.map +1 -0
- package/lib/module/{MissingIcon.mjs → MissingIcon.js} +5 -2
- package/lib/module/MissingIcon.js.map +1 -0
- package/lib/module/{PlatformPressable.mjs → PlatformPressable.js} +18 -15
- package/lib/module/PlatformPressable.js.map +1 -0
- package/lib/module/{ResourceSavingView.mjs → ResourceSavingView.js} +3 -1
- package/lib/module/ResourceSavingView.js.map +1 -0
- package/lib/module/{SafeAreaProviderCompat.mjs → SafeAreaProviderCompat.js} +5 -1
- package/lib/module/SafeAreaProviderCompat.js.map +1 -0
- package/lib/module/{Screen.mjs → Screen.js} +24 -20
- package/lib/module/Screen.js.map +1 -0
- package/lib/module/{Text.mjs → Text.js} +4 -1
- package/lib/module/Text.js.map +1 -0
- package/lib/module/assets/back-icon-mask.png +0 -0
- package/lib/module/assets/back-icon@4x.ios.png +0 -0
- package/lib/module/assets/clear-icon.png +0 -0
- package/lib/module/assets/clear-icon@1x.png +0 -0
- package/lib/module/assets/clear-icon@2x.png +0 -0
- package/lib/module/assets/clear-icon@3x.png +0 -0
- package/lib/module/assets/clear-icon@4x.png +0 -0
- package/lib/module/assets/close-icon.png +0 -0
- package/lib/module/assets/close-icon@1x.png +0 -0
- package/lib/module/assets/close-icon@2x.png +0 -0
- package/lib/module/assets/close-icon@3x.png +0 -0
- package/lib/module/assets/close-icon@4x.png +0 -0
- package/lib/module/assets/search-icon.png +0 -0
- package/lib/module/assets/search-icon@1x.android.png +0 -0
- package/lib/module/assets/search-icon@1x.ios.png +0 -0
- package/lib/module/assets/search-icon@2x.android.png +0 -0
- package/lib/module/assets/search-icon@2x.ios.png +0 -0
- package/lib/module/assets/search-icon@3x.android.png +0 -0
- package/lib/module/assets/search-icon@3x.ios.png +0 -0
- package/lib/module/assets/search-icon@4x.android.png +0 -0
- package/lib/module/assets/search-icon@4x.ios.png +0 -0
- package/lib/module/{getDefaultSidebarWidth.mjs → getDefaultSidebarWidth.js} +3 -1
- package/lib/module/getDefaultSidebarWidth.js.map +1 -0
- package/lib/module/{getNamedContext.mjs → getNamedContext.js} +3 -1
- package/lib/module/getNamedContext.js.map +1 -0
- package/lib/module/index.js +32 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +4 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/Background.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/Button.d.ts.map +1 -0
- package/lib/typescript/{src → commonjs/src}/Header/Header.d.ts +13 -0
- package/lib/typescript/commonjs/src/Header/Header.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/Header/HeaderBackButton.d.ts +3 -0
- package/lib/typescript/commonjs/src/Header/HeaderBackButton.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/Header/HeaderBackContext.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/Header/HeaderBackground.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/Header/HeaderButton.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/Header/HeaderHeightContext.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/Header/HeaderIcon.d.ts +5 -0
- package/lib/typescript/commonjs/src/Header/HeaderIcon.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/Header/HeaderSearchBar.d.ts +10 -0
- package/lib/typescript/commonjs/src/Header/HeaderSearchBar.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/Header/HeaderShownContext.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/Header/HeaderTitle.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/Header/getDefaultHeaderHeight.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/Header/getHeaderTitle.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/Header/useHeaderHeight.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/Label/Label.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/Label/getLabel.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/MaskedView.android.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/MaskedView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/MaskedView.ios.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/MaskedViewNative.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/MissingIcon.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/PlatformPressable.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/ResourceSavingView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/SafeAreaProviderCompat.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/Screen.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/Text.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/getDefaultSidebarWidth.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/getNamedContext.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/{src → commonjs/src}/types.d.ts +73 -10
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/tsconfig.build.tsbuildinfo +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/Background.d.ts +9 -0
- package/lib/typescript/module/src/Background.d.ts.map +1 -0
- package/lib/typescript/module/src/Button.d.ts +13 -0
- package/lib/typescript/module/src/Button.d.ts.map +1 -0
- package/lib/typescript/module/src/Header/Header.d.ts +31 -0
- package/lib/typescript/module/src/Header/Header.d.ts.map +1 -0
- package/lib/typescript/module/src/Header/HeaderBackButton.d.ts +3 -0
- package/lib/typescript/module/src/Header/HeaderBackButton.d.ts.map +1 -0
- package/lib/typescript/module/src/Header/HeaderBackContext.d.ts +5 -0
- package/lib/typescript/module/src/Header/HeaderBackContext.d.ts.map +1 -0
- package/lib/typescript/module/src/Header/HeaderBackground.d.ts +9 -0
- package/lib/typescript/module/src/Header/HeaderBackground.d.ts.map +1 -0
- package/lib/typescript/module/src/Header/HeaderButton.d.ts +3 -0
- package/lib/typescript/module/src/Header/HeaderButton.d.ts.map +1 -0
- package/lib/typescript/module/src/Header/HeaderHeightContext.d.ts +2 -0
- package/lib/typescript/module/src/Header/HeaderHeightContext.d.ts.map +1 -0
- package/lib/typescript/module/src/Header/HeaderIcon.d.ts +5 -0
- package/lib/typescript/module/src/Header/HeaderIcon.d.ts.map +1 -0
- package/lib/typescript/module/src/Header/HeaderSearchBar.d.ts +10 -0
- package/lib/typescript/module/src/Header/HeaderSearchBar.d.ts.map +1 -0
- package/lib/typescript/module/src/Header/HeaderShownContext.d.ts +2 -0
- package/lib/typescript/module/src/Header/HeaderShownContext.d.ts.map +1 -0
- package/lib/typescript/module/src/Header/HeaderTitle.d.ts +9 -0
- package/lib/typescript/module/src/Header/HeaderTitle.d.ts.map +1 -0
- package/lib/typescript/module/src/Header/getDefaultHeaderHeight.d.ts +3 -0
- package/lib/typescript/module/src/Header/getDefaultHeaderHeight.d.ts.map +1 -0
- package/lib/typescript/module/src/Header/getHeaderTitle.d.ts +6 -0
- package/lib/typescript/module/src/Header/getHeaderTitle.d.ts.map +1 -0
- package/lib/typescript/module/src/Header/useHeaderHeight.d.ts +2 -0
- package/lib/typescript/module/src/Header/useHeaderHeight.d.ts.map +1 -0
- package/lib/typescript/module/src/Label/Label.d.ts +9 -0
- package/lib/typescript/module/src/Label/Label.d.ts.map +1 -0
- package/lib/typescript/module/src/Label/getLabel.d.ts +5 -0
- package/lib/typescript/module/src/Label/getLabel.d.ts.map +1 -0
- package/lib/typescript/module/src/MaskedView.android.d.ts +2 -0
- package/lib/typescript/module/src/MaskedView.android.d.ts.map +1 -0
- package/lib/typescript/module/src/MaskedView.d.ts +11 -0
- package/lib/typescript/module/src/MaskedView.d.ts.map +1 -0
- package/lib/typescript/module/src/MaskedView.ios.d.ts +2 -0
- package/lib/typescript/module/src/MaskedView.ios.d.ts.map +1 -0
- package/lib/typescript/module/src/MaskedViewNative.d.ts +11 -0
- package/lib/typescript/module/src/MaskedViewNative.d.ts.map +1 -0
- package/lib/typescript/module/src/MissingIcon.d.ts +9 -0
- package/lib/typescript/module/src/MissingIcon.d.ts.map +1 -0
- package/lib/typescript/module/src/PlatformPressable.d.ts +21 -0
- package/lib/typescript/module/src/PlatformPressable.d.ts.map +1 -0
- package/lib/typescript/module/src/ResourceSavingView.d.ts +10 -0
- package/lib/typescript/module/src/ResourceSavingView.d.ts.map +1 -0
- package/lib/typescript/module/src/SafeAreaProviderCompat.d.ts +13 -0
- package/lib/typescript/module/src/SafeAreaProviderCompat.d.ts.map +1 -0
- package/lib/typescript/module/src/Screen.d.ts +18 -0
- package/lib/typescript/module/src/Screen.d.ts.map +1 -0
- package/lib/typescript/module/src/Text.d.ts +3 -0
- package/lib/typescript/module/src/Text.d.ts.map +1 -0
- package/lib/typescript/module/src/getDefaultSidebarWidth.d.ts +4 -0
- package/lib/typescript/module/src/getDefaultSidebarWidth.d.ts.map +1 -0
- package/lib/typescript/module/src/getNamedContext.d.ts +6 -0
- package/lib/typescript/module/src/getNamedContext.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +25 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/types.d.ts +289 -0
- package/lib/typescript/module/src/types.d.ts.map +1 -0
- package/lib/typescript/module/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +27 -14
- package/src/Header/Header.tsx +157 -60
- package/src/Header/HeaderBackButton.tsx +83 -79
- package/src/Header/HeaderIcon.tsx +36 -0
- package/src/Header/HeaderSearchBar.tsx +283 -0
- package/src/MissingIcon.tsx +3 -1
- package/src/PlatformPressable.tsx +20 -13
- package/src/SafeAreaProviderCompat.tsx +2 -1
- package/src/Screen.tsx +19 -14
- package/src/Text.tsx +1 -0
- package/src/assets/back-icon-mask.png +0 -0
- package/src/assets/back-icon@4x.ios.png +0 -0
- package/src/assets/clear-icon.png +0 -0
- package/src/assets/clear-icon@1x.png +0 -0
- package/src/assets/clear-icon@2x.png +0 -0
- package/src/assets/clear-icon@3x.png +0 -0
- package/src/assets/clear-icon@4x.png +0 -0
- package/src/assets/close-icon.png +0 -0
- package/src/assets/close-icon@1x.png +0 -0
- package/src/assets/close-icon@2x.png +0 -0
- package/src/assets/close-icon@3x.png +0 -0
- package/src/assets/close-icon@4x.png +0 -0
- package/src/assets/search-icon.png +0 -0
- package/src/assets/search-icon@1x.android.png +0 -0
- package/src/assets/search-icon@1x.ios.png +0 -0
- package/src/assets/search-icon@2x.android.png +0 -0
- package/src/assets/search-icon@2x.ios.png +0 -0
- package/src/assets/search-icon@3x.android.png +0 -0
- package/src/assets/search-icon@3x.ios.png +0 -0
- package/src/assets/search-icon@4x.android.png +0 -0
- package/src/assets/search-icon@4x.ios.png +0 -0
- package/src/index.tsx +10 -1
- package/src/types.tsx +77 -10
- package/lib/commonjs/Header/Header.cjs.map +0 -1
- package/lib/commonjs/Header/HeaderBackButton.cjs.map +0 -1
- package/lib/commonjs/MissingIcon.cjs.map +0 -1
- package/lib/commonjs/PlatformPressable.cjs.map +0 -1
- package/lib/commonjs/Screen.cjs.map +0 -1
- package/lib/commonjs/Text.cjs.map +0 -1
- package/lib/commonjs/index.cjs.map +0 -1
- package/lib/module/Background.mjs.map +0 -1
- package/lib/module/Button.mjs.map +0 -1
- package/lib/module/Header/Header.mjs.map +0 -1
- package/lib/module/Header/HeaderBackButton.mjs.map +0 -1
- package/lib/module/Header/HeaderBackContext.mjs +0 -3
- package/lib/module/Header/HeaderBackContext.mjs.map +0 -1
- package/lib/module/Header/HeaderBackground.mjs.map +0 -1
- package/lib/module/Header/HeaderButton.mjs.map +0 -1
- package/lib/module/Header/HeaderHeightContext.mjs +0 -3
- package/lib/module/Header/HeaderHeightContext.mjs.map +0 -1
- package/lib/module/Header/HeaderShownContext.mjs +0 -3
- package/lib/module/Header/HeaderTitle.mjs.map +0 -1
- package/lib/module/Header/getDefaultHeaderHeight.mjs.map +0 -1
- package/lib/module/Header/getHeaderTitle.mjs.map +0 -1
- package/lib/module/Header/useHeaderHeight.mjs.map +0 -1
- package/lib/module/Label/Label.mjs.map +0 -1
- package/lib/module/Label/getLabel.mjs.map +0 -1
- package/lib/module/MaskedView.android.mjs +0 -2
- package/lib/module/MaskedView.android.mjs.map +0 -1
- package/lib/module/MaskedView.ios.mjs +0 -2
- package/lib/module/MaskedView.ios.mjs.map +0 -1
- package/lib/module/MaskedView.mjs.map +0 -1
- package/lib/module/MaskedViewNative.mjs.map +0 -1
- package/lib/module/MissingIcon.mjs.map +0 -1
- package/lib/module/PlatformPressable.mjs.map +0 -1
- package/lib/module/ResourceSavingView.mjs.map +0 -1
- package/lib/module/SafeAreaProviderCompat.mjs.map +0 -1
- package/lib/module/Screen.mjs.map +0 -1
- package/lib/module/Text.mjs.map +0 -1
- package/lib/module/getDefaultSidebarWidth.mjs.map +0 -1
- package/lib/module/getNamedContext.mjs.map +0 -1
- package/lib/module/index.mjs +0 -27
- package/lib/module/index.mjs.map +0 -1
- package/lib/module/types.mjs +0 -2
- package/lib/typescript/src/Background.d.ts.map +0 -1
- package/lib/typescript/src/Button.d.ts.map +0 -1
- package/lib/typescript/src/Header/Header.d.ts.map +0 -1
- package/lib/typescript/src/Header/HeaderBackButton.d.ts +0 -3
- package/lib/typescript/src/Header/HeaderBackButton.d.ts.map +0 -1
- package/lib/typescript/src/Header/HeaderBackContext.d.ts.map +0 -1
- package/lib/typescript/src/Header/HeaderBackground.d.ts.map +0 -1
- package/lib/typescript/src/Header/HeaderButton.d.ts.map +0 -1
- package/lib/typescript/src/Header/HeaderHeightContext.d.ts.map +0 -1
- package/lib/typescript/src/Header/HeaderShownContext.d.ts.map +0 -1
- package/lib/typescript/src/Header/HeaderTitle.d.ts.map +0 -1
- package/lib/typescript/src/Header/getDefaultHeaderHeight.d.ts.map +0 -1
- package/lib/typescript/src/Header/getHeaderTitle.d.ts.map +0 -1
- package/lib/typescript/src/Header/useHeaderHeight.d.ts.map +0 -1
- package/lib/typescript/src/Label/Label.d.ts.map +0 -1
- package/lib/typescript/src/Label/getLabel.d.ts.map +0 -1
- package/lib/typescript/src/MaskedView.android.d.ts.map +0 -1
- package/lib/typescript/src/MaskedView.d.ts.map +0 -1
- package/lib/typescript/src/MaskedView.ios.d.ts.map +0 -1
- package/lib/typescript/src/MaskedViewNative.d.ts.map +0 -1
- package/lib/typescript/src/MissingIcon.d.ts.map +0 -1
- package/lib/typescript/src/PlatformPressable.d.ts.map +0 -1
- package/lib/typescript/src/ResourceSavingView.d.ts.map +0 -1
- package/lib/typescript/src/SafeAreaProviderCompat.d.ts.map +0 -1
- package/lib/typescript/src/Screen.d.ts.map +0 -1
- package/lib/typescript/src/Text.d.ts.map +0 -1
- package/lib/typescript/src/getDefaultSidebarWidth.d.ts.map +0 -1
- package/lib/typescript/src/getNamedContext.d.ts.map +0 -1
- package/lib/typescript/src/index.d.ts.map +0 -1
- package/lib/typescript/src/types.d.ts.map +0 -1
- /package/lib/commonjs/{Background.cjs.map → Background.js.map} +0 -0
- /package/lib/commonjs/{Button.cjs.map → Button.js.map} +0 -0
- /package/lib/commonjs/Header/{HeaderBackContext.cjs.map → HeaderBackContext.js.map} +0 -0
- /package/lib/commonjs/Header/{HeaderBackground.cjs.map → HeaderBackground.js.map} +0 -0
- /package/lib/commonjs/Header/{HeaderButton.cjs.map → HeaderButton.js.map} +0 -0
- /package/lib/commonjs/Header/{HeaderHeightContext.cjs.map → HeaderHeightContext.js.map} +0 -0
- /package/lib/commonjs/Header/{HeaderShownContext.cjs.map → HeaderShownContext.js.map} +0 -0
- /package/lib/commonjs/Header/{HeaderTitle.cjs.map → HeaderTitle.js.map} +0 -0
- /package/lib/commonjs/Header/{getDefaultHeaderHeight.cjs.map → getDefaultHeaderHeight.js.map} +0 -0
- /package/lib/commonjs/Header/{getHeaderTitle.cjs.map → getHeaderTitle.js.map} +0 -0
- /package/lib/commonjs/Header/{useHeaderHeight.cjs.map → useHeaderHeight.js.map} +0 -0
- /package/lib/commonjs/Label/{Label.cjs.map → Label.js.map} +0 -0
- /package/lib/commonjs/Label/{getLabel.cjs.map → getLabel.js.map} +0 -0
- /package/lib/commonjs/{MaskedView.android.cjs.map → MaskedView.android.js.map} +0 -0
- /package/lib/commonjs/{MaskedView.ios.cjs.map → MaskedView.ios.js.map} +0 -0
- /package/lib/commonjs/{MaskedView.cjs.map → MaskedView.js.map} +0 -0
- /package/lib/commonjs/{MaskedViewNative.cjs.map → MaskedViewNative.js.map} +0 -0
- /package/lib/commonjs/{ResourceSavingView.cjs.map → ResourceSavingView.js.map} +0 -0
- /package/lib/commonjs/{getDefaultSidebarWidth.cjs.map → getDefaultSidebarWidth.js.map} +0 -0
- /package/lib/commonjs/{getNamedContext.cjs.map → getNamedContext.js.map} +0 -0
- /package/lib/commonjs/{types.cjs.map → types.js.map} +0 -0
- /package/lib/module/{types.mjs.map → types.js.map} +0 -0
- /package/lib/typescript/{src → commonjs/src}/Background.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/Button.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/Header/HeaderBackContext.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/Header/HeaderBackground.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/Header/HeaderButton.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/Header/HeaderHeightContext.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/Header/HeaderShownContext.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/Header/HeaderTitle.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/Header/getDefaultHeaderHeight.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/Header/getHeaderTitle.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/Header/useHeaderHeight.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/Label/Label.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/Label/getLabel.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/MaskedView.android.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/MaskedView.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/MaskedView.ios.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/MaskedViewNative.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/MissingIcon.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/PlatformPressable.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/ResourceSavingView.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/SafeAreaProviderCompat.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/Screen.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/Text.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/getDefaultSidebarWidth.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/getNamedContext.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/index.d.ts +0 -0
package/src/Header/Header.tsx
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { useNavigation, useTheme } from '@react-navigation/native';
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import {
|
|
3
4
|
Animated,
|
|
5
|
+
type LayoutChangeEvent,
|
|
4
6
|
Platform,
|
|
5
7
|
StyleSheet,
|
|
6
8
|
View,
|
|
@@ -11,9 +13,14 @@ import {
|
|
|
11
13
|
useSafeAreaInsets,
|
|
12
14
|
} from 'react-native-safe-area-context';
|
|
13
15
|
|
|
16
|
+
import searchIcon from '../assets/search-icon.png';
|
|
14
17
|
import type { HeaderOptions, Layout } from '../types';
|
|
15
18
|
import { getDefaultHeaderHeight } from './getDefaultHeaderHeight';
|
|
19
|
+
import { HeaderBackButton } from './HeaderBackButton';
|
|
16
20
|
import { HeaderBackground } from './HeaderBackground';
|
|
21
|
+
import { HeaderButton } from './HeaderButton';
|
|
22
|
+
import { HeaderIcon } from './HeaderIcon';
|
|
23
|
+
import { HeaderSearchBar } from './HeaderSearchBar';
|
|
17
24
|
import { HeaderShownContext } from './HeaderShownContext';
|
|
18
25
|
import { HeaderTitle } from './HeaderTitle';
|
|
19
26
|
|
|
@@ -21,6 +28,19 @@ import { HeaderTitle } from './HeaderTitle';
|
|
|
21
28
|
const IPAD_MINI_MEDIUM_WIDTH = 414;
|
|
22
29
|
|
|
23
30
|
type Props = HeaderOptions & {
|
|
31
|
+
/**
|
|
32
|
+
* Options for the back button.
|
|
33
|
+
*/
|
|
34
|
+
back?: {
|
|
35
|
+
/**
|
|
36
|
+
* Title of the previous screen.
|
|
37
|
+
*/
|
|
38
|
+
title: string | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* The `href` to use for the anchor tag on web
|
|
41
|
+
*/
|
|
42
|
+
href: string | undefined;
|
|
43
|
+
};
|
|
24
44
|
/**
|
|
25
45
|
* Whether the header is in a modal
|
|
26
46
|
*/
|
|
@@ -54,20 +74,42 @@ const warnIfHeaderStylesDefined = (styles: Record<string, any>) => {
|
|
|
54
74
|
export function Header(props: Props) {
|
|
55
75
|
const insets = useSafeAreaInsets();
|
|
56
76
|
const frame = useSafeAreaFrame();
|
|
77
|
+
const { colors } = useTheme();
|
|
57
78
|
|
|
79
|
+
const navigation = useNavigation();
|
|
58
80
|
const isParentHeaderShown = React.useContext(HeaderShownContext);
|
|
59
81
|
|
|
82
|
+
const [searchBarVisible, setSearchBarVisible] = React.useState(false);
|
|
83
|
+
const [titleLayout, setTitleLayout] = React.useState<Layout | undefined>(
|
|
84
|
+
undefined
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
const onTitleLayout = (e: LayoutChangeEvent) => {
|
|
88
|
+
const { height, width } = e.nativeEvent.layout;
|
|
89
|
+
|
|
90
|
+
setTitleLayout((titleLayout) => {
|
|
91
|
+
if (
|
|
92
|
+
titleLayout &&
|
|
93
|
+
height === titleLayout.height &&
|
|
94
|
+
width === titleLayout.width
|
|
95
|
+
) {
|
|
96
|
+
return titleLayout;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return { height, width };
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
|
|
60
103
|
const {
|
|
104
|
+
// eslint-disable-next-line @eslint-react/no-unstable-default-props
|
|
61
105
|
layout = frame,
|
|
62
106
|
modal = false,
|
|
107
|
+
back,
|
|
63
108
|
title,
|
|
64
109
|
headerTitle: customTitle,
|
|
65
|
-
headerTitleAlign = Platform.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}),
|
|
69
|
-
headerLeft,
|
|
70
|
-
headerLeftLabelVisible,
|
|
110
|
+
headerTitleAlign = Platform.OS === 'ios' ? 'center' : 'left',
|
|
111
|
+
headerLeft = back ? (props) => <HeaderBackButton {...props} /> : undefined,
|
|
112
|
+
headerSearchBarOptions,
|
|
71
113
|
headerTransparent,
|
|
72
114
|
headerTintColor,
|
|
73
115
|
headerBackground,
|
|
@@ -77,11 +119,14 @@ export function Header(props: Props) {
|
|
|
77
119
|
headerLeftContainerStyle: leftContainerStyle,
|
|
78
120
|
headerRightContainerStyle: rightContainerStyle,
|
|
79
121
|
headerTitleContainerStyle: titleContainerStyle,
|
|
122
|
+
headerBackButtonDisplayMode = Platform.OS === 'ios' ? 'default' : 'minimal',
|
|
123
|
+
headerBackTitleStyle,
|
|
80
124
|
headerBackgroundContainerStyle: backgroundContainerStyle,
|
|
81
125
|
headerStyle: customHeaderStyle,
|
|
82
126
|
headerShadowVisible,
|
|
83
127
|
headerPressColor,
|
|
84
128
|
headerPressOpacity,
|
|
129
|
+
// eslint-disable-next-line @eslint-react/no-unstable-default-props
|
|
85
130
|
headerStatusBarHeight = isParentHeaderShown ? 0 : insets.top,
|
|
86
131
|
} = props;
|
|
87
132
|
|
|
@@ -194,20 +239,35 @@ export function Header(props: Props) {
|
|
|
194
239
|
},
|
|
195
240
|
];
|
|
196
241
|
|
|
242
|
+
const iconTintColor =
|
|
243
|
+
headerTintColor ??
|
|
244
|
+
Platform.select({
|
|
245
|
+
ios: colors.primary,
|
|
246
|
+
default: colors.text,
|
|
247
|
+
});
|
|
248
|
+
|
|
197
249
|
const leftButton = headerLeft
|
|
198
250
|
? headerLeft({
|
|
199
|
-
tintColor:
|
|
251
|
+
tintColor: iconTintColor,
|
|
200
252
|
pressColor: headerPressColor,
|
|
201
253
|
pressOpacity: headerPressOpacity,
|
|
202
|
-
|
|
254
|
+
displayMode: headerBackButtonDisplayMode,
|
|
255
|
+
titleLayout,
|
|
256
|
+
screenLayout: layout,
|
|
257
|
+
canGoBack: Boolean(back),
|
|
258
|
+
onPress: back ? navigation.goBack : undefined,
|
|
259
|
+
label: back?.title,
|
|
260
|
+
labelStyle: headerBackTitleStyle,
|
|
261
|
+
href: back?.href,
|
|
203
262
|
})
|
|
204
263
|
: null;
|
|
205
264
|
|
|
206
265
|
const rightButton = headerRight
|
|
207
266
|
? headerRight({
|
|
208
|
-
tintColor:
|
|
267
|
+
tintColor: iconTintColor,
|
|
209
268
|
pressColor: headerPressColor,
|
|
210
269
|
pressOpacity: headerPressOpacity,
|
|
270
|
+
canGoBack: Boolean(back),
|
|
211
271
|
})
|
|
212
272
|
: null;
|
|
213
273
|
|
|
@@ -254,53 +314,88 @@ export function Header(props: Props) {
|
|
|
254
314
|
>
|
|
255
315
|
{leftButton}
|
|
256
316
|
</Animated.View>
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
?
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
317
|
+
{Platform.OS === 'ios' || !searchBarVisible ? (
|
|
318
|
+
<>
|
|
319
|
+
<Animated.View
|
|
320
|
+
pointerEvents="box-none"
|
|
321
|
+
style={[
|
|
322
|
+
styles.title,
|
|
323
|
+
{
|
|
324
|
+
// Avoid the title from going offscreen or overlapping buttons
|
|
325
|
+
maxWidth:
|
|
326
|
+
headerTitleAlign === 'center'
|
|
327
|
+
? layout.width -
|
|
328
|
+
((leftButton
|
|
329
|
+
? headerBackButtonDisplayMode !== 'minimal'
|
|
330
|
+
? 80
|
|
331
|
+
: 32
|
|
332
|
+
: 16) +
|
|
333
|
+
(rightButton || headerSearchBarOptions ? 16 : 0) +
|
|
334
|
+
Math.max(insets.left, insets.right)) *
|
|
335
|
+
2
|
|
336
|
+
: layout.width -
|
|
337
|
+
((leftButton ? 52 : 16) +
|
|
338
|
+
(rightButton || headerSearchBarOptions ? 52 : 16) +
|
|
339
|
+
insets.left -
|
|
340
|
+
insets.right),
|
|
341
|
+
},
|
|
342
|
+
headerTitleAlign === 'left' && leftButton
|
|
343
|
+
? { marginStart: 4 }
|
|
344
|
+
: { marginHorizontal: 16 },
|
|
345
|
+
titleContainerStyle,
|
|
346
|
+
]}
|
|
347
|
+
>
|
|
348
|
+
{headerTitle({
|
|
349
|
+
children: title,
|
|
350
|
+
allowFontScaling: titleAllowFontScaling,
|
|
351
|
+
tintColor: headerTintColor,
|
|
352
|
+
onLayout: onTitleLayout,
|
|
353
|
+
style: titleStyle,
|
|
354
|
+
})}
|
|
355
|
+
</Animated.View>
|
|
356
|
+
<Animated.View
|
|
357
|
+
pointerEvents="box-none"
|
|
358
|
+
style={[
|
|
359
|
+
styles.end,
|
|
360
|
+
styles.expand,
|
|
361
|
+
{ marginEnd: insets.right },
|
|
362
|
+
rightContainerStyle,
|
|
363
|
+
]}
|
|
364
|
+
>
|
|
365
|
+
{rightButton}
|
|
366
|
+
{headerSearchBarOptions ? (
|
|
367
|
+
<HeaderButton
|
|
368
|
+
tintColor={iconTintColor}
|
|
369
|
+
pressColor={headerPressColor}
|
|
370
|
+
pressOpacity={headerPressOpacity}
|
|
371
|
+
onPress={() => setSearchBarVisible(true)}
|
|
372
|
+
>
|
|
373
|
+
<HeaderIcon
|
|
374
|
+
style={
|
|
375
|
+
Boolean(iconTintColor) && { tintColor: iconTintColor }
|
|
376
|
+
}
|
|
377
|
+
source={searchIcon}
|
|
378
|
+
/>
|
|
379
|
+
</HeaderButton>
|
|
380
|
+
) : null}
|
|
381
|
+
</Animated.View>
|
|
382
|
+
</>
|
|
383
|
+
) : null}
|
|
384
|
+
{Platform.OS === 'ios' || searchBarVisible ? (
|
|
385
|
+
<HeaderSearchBar
|
|
386
|
+
{...headerSearchBarOptions}
|
|
387
|
+
visible={searchBarVisible}
|
|
388
|
+
onClose={() => {
|
|
389
|
+
setSearchBarVisible(false);
|
|
390
|
+
headerSearchBarOptions?.onClose?.();
|
|
391
|
+
}}
|
|
392
|
+
style={[
|
|
393
|
+
Platform.OS === 'ios'
|
|
394
|
+
? [StyleSheet.absoluteFill, { backgroundColor: colors.card }]
|
|
395
|
+
: !leftButton && { marginStart: 8 },
|
|
396
|
+
]}
|
|
397
|
+
/>
|
|
398
|
+
) : null}
|
|
304
399
|
</View>
|
|
305
400
|
</Animated.View>
|
|
306
401
|
);
|
|
@@ -319,12 +414,14 @@ const styles = StyleSheet.create({
|
|
|
319
414
|
justifyContent: 'center',
|
|
320
415
|
},
|
|
321
416
|
start: {
|
|
322
|
-
|
|
323
|
-
alignItems: '
|
|
417
|
+
flexDirection: 'row',
|
|
418
|
+
alignItems: 'center',
|
|
419
|
+
justifyContent: 'flex-start',
|
|
324
420
|
},
|
|
325
421
|
end: {
|
|
326
|
-
|
|
327
|
-
alignItems: '
|
|
422
|
+
flexDirection: 'row',
|
|
423
|
+
alignItems: 'center',
|
|
424
|
+
justifyContent: 'flex-end',
|
|
328
425
|
},
|
|
329
426
|
expand: {
|
|
330
427
|
flexGrow: 1,
|
|
@@ -3,9 +3,10 @@ import * as React from 'react';
|
|
|
3
3
|
import {
|
|
4
4
|
Animated,
|
|
5
5
|
Image,
|
|
6
|
-
type LayoutChangeEvent,
|
|
7
6
|
Platform,
|
|
7
|
+
type StyleProp,
|
|
8
8
|
StyleSheet,
|
|
9
|
+
type TextStyle,
|
|
9
10
|
View,
|
|
10
11
|
} from 'react-native';
|
|
11
12
|
|
|
@@ -14,6 +15,7 @@ import backIconMask from '../assets/back-icon-mask.png';
|
|
|
14
15
|
import { MaskedView } from '../MaskedView';
|
|
15
16
|
import type { HeaderBackButtonProps } from '../types';
|
|
16
17
|
import { HeaderButton } from './HeaderButton';
|
|
18
|
+
import { HeaderIcon, ICON_MARGIN } from './HeaderIcon';
|
|
17
19
|
|
|
18
20
|
export function HeaderBackButton({
|
|
19
21
|
disabled,
|
|
@@ -21,13 +23,13 @@ export function HeaderBackButton({
|
|
|
21
23
|
backImage,
|
|
22
24
|
label,
|
|
23
25
|
labelStyle,
|
|
24
|
-
|
|
26
|
+
displayMode = Platform.OS === 'ios' ? 'default' : 'minimal',
|
|
25
27
|
onLabelLayout,
|
|
26
28
|
onPress,
|
|
27
29
|
pressColor,
|
|
28
30
|
pressOpacity,
|
|
29
31
|
screenLayout,
|
|
30
|
-
tintColor
|
|
32
|
+
tintColor,
|
|
31
33
|
titleLayout,
|
|
32
34
|
truncatedLabel = 'Back',
|
|
33
35
|
accessibilityLabel = label && label !== 'Back' ? `${label}, back` : 'Go back',
|
|
@@ -38,85 +40,97 @@ export function HeaderBackButton({
|
|
|
38
40
|
const { colors, fonts } = useTheme();
|
|
39
41
|
const { direction } = useLocale();
|
|
40
42
|
|
|
41
|
-
const [
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const tintColor =
|
|
46
|
-
customTintColor !== undefined
|
|
47
|
-
? customTintColor
|
|
48
|
-
: Platform.select({
|
|
49
|
-
ios: colors.primary,
|
|
50
|
-
default: colors.text,
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
const handleLabelLayout = (e: LayoutChangeEvent) => {
|
|
54
|
-
onLabelLayout?.(e);
|
|
55
|
-
|
|
56
|
-
const { layout } = e.nativeEvent;
|
|
57
|
-
|
|
58
|
-
setInitialLabelWidth(
|
|
59
|
-
(direction === 'rtl' ? layout.y : layout.x) + layout.width
|
|
60
|
-
);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const shouldTruncateLabel = () => {
|
|
64
|
-
return (
|
|
65
|
-
!label ||
|
|
66
|
-
(initialLabelWidth &&
|
|
67
|
-
titleLayout &&
|
|
68
|
-
screenLayout &&
|
|
69
|
-
(screenLayout.width - titleLayout.width) / 2 < initialLabelWidth + 26)
|
|
70
|
-
);
|
|
71
|
-
};
|
|
43
|
+
const [labelWidth, setLabelWidth] = React.useState<number | null>(null);
|
|
44
|
+
const [truncatedLabelWidth, setTruncatedLabelWidth] = React.useState<
|
|
45
|
+
number | null
|
|
46
|
+
>(null);
|
|
72
47
|
|
|
73
48
|
const renderBackImage = () => {
|
|
74
49
|
if (backImage) {
|
|
75
|
-
return backImage({ tintColor });
|
|
50
|
+
return backImage({ tintColor: tintColor ?? colors.text });
|
|
76
51
|
} else {
|
|
77
52
|
return (
|
|
78
|
-
<
|
|
53
|
+
<HeaderIcon
|
|
79
54
|
style={[
|
|
80
55
|
styles.icon,
|
|
81
|
-
|
|
82
|
-
Boolean(labelVisible) && styles.iconWithLabel,
|
|
56
|
+
displayMode !== 'minimal' && styles.iconWithLabel,
|
|
83
57
|
Boolean(tintColor) && { tintColor },
|
|
84
58
|
]}
|
|
85
|
-
resizeMode="contain"
|
|
86
59
|
source={backIcon}
|
|
87
|
-
fadeDuration={0}
|
|
88
60
|
/>
|
|
89
61
|
);
|
|
90
62
|
}
|
|
91
63
|
};
|
|
92
64
|
|
|
93
65
|
const renderLabel = () => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if (!labelVisible || leftLabelText === undefined) {
|
|
66
|
+
if (displayMode === 'minimal') {
|
|
97
67
|
return null;
|
|
98
68
|
}
|
|
99
69
|
|
|
70
|
+
const availableSpace =
|
|
71
|
+
titleLayout && screenLayout
|
|
72
|
+
? (screenLayout.width - titleLayout.width) / 2 -
|
|
73
|
+
(ICON_WIDTH + ICON_MARGIN)
|
|
74
|
+
: null;
|
|
75
|
+
|
|
76
|
+
const potentialLabelText =
|
|
77
|
+
displayMode === 'default' ? label : truncatedLabel;
|
|
78
|
+
const finalLabelText =
|
|
79
|
+
availableSpace && labelWidth && truncatedLabelWidth
|
|
80
|
+
? availableSpace > labelWidth
|
|
81
|
+
? potentialLabelText
|
|
82
|
+
: availableSpace > truncatedLabelWidth
|
|
83
|
+
? truncatedLabel
|
|
84
|
+
: null
|
|
85
|
+
: potentialLabelText;
|
|
86
|
+
|
|
87
|
+
const commonStyle: Animated.WithAnimatedValue<StyleProp<TextStyle>> = [
|
|
88
|
+
fonts.regular,
|
|
89
|
+
styles.label,
|
|
90
|
+
labelStyle,
|
|
91
|
+
];
|
|
92
|
+
|
|
93
|
+
const hiddenStyle: Animated.WithAnimatedValue<StyleProp<TextStyle>> = [
|
|
94
|
+
commonStyle,
|
|
95
|
+
{
|
|
96
|
+
position: 'absolute',
|
|
97
|
+
top: 0,
|
|
98
|
+
left: 0,
|
|
99
|
+
opacity: 0,
|
|
100
|
+
},
|
|
101
|
+
];
|
|
102
|
+
|
|
100
103
|
const labelElement = (
|
|
101
104
|
<View style={styles.labelWrapper}>
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
105
|
+
{label && displayMode === 'default' ? (
|
|
106
|
+
<Animated.Text
|
|
107
|
+
style={hiddenStyle}
|
|
108
|
+
numberOfLines={1}
|
|
109
|
+
onLayout={(e) => setLabelWidth(e.nativeEvent.layout.width)}
|
|
110
|
+
>
|
|
111
|
+
{label}
|
|
112
|
+
</Animated.Text>
|
|
113
|
+
) : null}
|
|
114
|
+
{truncatedLabel ? (
|
|
115
|
+
<Animated.Text
|
|
116
|
+
style={hiddenStyle}
|
|
117
|
+
numberOfLines={1}
|
|
118
|
+
onLayout={(e) => setTruncatedLabelWidth(e.nativeEvent.layout.width)}
|
|
119
|
+
>
|
|
120
|
+
{truncatedLabel}
|
|
121
|
+
</Animated.Text>
|
|
122
|
+
) : null}
|
|
123
|
+
{finalLabelText ? (
|
|
124
|
+
<Animated.Text
|
|
125
|
+
accessible={false}
|
|
126
|
+
onLayout={onLabelLayout}
|
|
127
|
+
style={[tintColor ? { color: tintColor } : null, commonStyle]}
|
|
128
|
+
numberOfLines={1}
|
|
129
|
+
allowFontScaling={!!allowFontScaling}
|
|
130
|
+
>
|
|
131
|
+
{finalLabelText}
|
|
132
|
+
</Animated.Text>
|
|
133
|
+
) : null}
|
|
120
134
|
</View>
|
|
121
135
|
);
|
|
122
136
|
|
|
@@ -175,6 +189,9 @@ export function HeaderBackButton({
|
|
|
175
189
|
);
|
|
176
190
|
}
|
|
177
191
|
|
|
192
|
+
const ICON_WIDTH = Platform.OS === 'ios' ? 13 : 24;
|
|
193
|
+
const ICON_MARGIN_END = Platform.OS === 'ios' ? 22 : 3;
|
|
194
|
+
|
|
178
195
|
const styles = StyleSheet.create({
|
|
179
196
|
container: {
|
|
180
197
|
paddingHorizontal: 0,
|
|
@@ -198,25 +215,12 @@ const styles = StyleSheet.create({
|
|
|
198
215
|
// Otherwise it messes with the measurement of the label
|
|
199
216
|
flexDirection: 'row',
|
|
200
217
|
alignItems: 'flex-start',
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
218
|
+
marginEnd: ICON_MARGIN,
|
|
219
|
+
},
|
|
220
|
+
icon: {
|
|
221
|
+
width: ICON_WIDTH,
|
|
222
|
+
marginEnd: ICON_MARGIN_END,
|
|
205
223
|
},
|
|
206
|
-
icon: Platform.select({
|
|
207
|
-
ios: {
|
|
208
|
-
height: 21,
|
|
209
|
-
width: 13,
|
|
210
|
-
marginStart: 8,
|
|
211
|
-
marginEnd: 22,
|
|
212
|
-
marginVertical: 8,
|
|
213
|
-
},
|
|
214
|
-
default: {
|
|
215
|
-
height: 24,
|
|
216
|
-
width: 24,
|
|
217
|
-
margin: 3,
|
|
218
|
-
},
|
|
219
|
-
}),
|
|
220
224
|
iconWithLabel:
|
|
221
225
|
Platform.OS === 'ios'
|
|
222
226
|
? {
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useLocale, useTheme } from '@react-navigation/native';
|
|
2
|
+
import { Image, type ImageProps, Platform, StyleSheet } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export function HeaderIcon({ source, style, ...rest }: ImageProps) {
|
|
5
|
+
const { colors } = useTheme();
|
|
6
|
+
const { direction } = useLocale();
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<Image
|
|
10
|
+
source={source}
|
|
11
|
+
resizeMode="contain"
|
|
12
|
+
fadeDuration={0}
|
|
13
|
+
style={[
|
|
14
|
+
styles.icon,
|
|
15
|
+
direction === 'rtl' && styles.flip,
|
|
16
|
+
{ tintColor: colors.text },
|
|
17
|
+
style,
|
|
18
|
+
]}
|
|
19
|
+
{...rest}
|
|
20
|
+
/>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const ICON_SIZE = Platform.OS === 'ios' ? 21 : 24;
|
|
25
|
+
export const ICON_MARGIN = Platform.OS === 'ios' ? 8 : 3;
|
|
26
|
+
|
|
27
|
+
const styles = StyleSheet.create({
|
|
28
|
+
icon: {
|
|
29
|
+
width: ICON_SIZE,
|
|
30
|
+
height: ICON_SIZE,
|
|
31
|
+
margin: ICON_MARGIN,
|
|
32
|
+
},
|
|
33
|
+
flip: {
|
|
34
|
+
transform: 'scaleX(-1)',
|
|
35
|
+
},
|
|
36
|
+
});
|