diff --git a/src/components/HeaderWithBackButton/index.tsx b/src/components/HeaderWithBackButton/index.tsx index 97e915d47b22..fe214ae5b293 100755 --- a/src/components/HeaderWithBackButton/index.tsx +++ b/src/components/HeaderWithBackButton/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useMemo } from 'react'; import {Keyboard, StyleSheet, View} from 'react-native'; import AvatarWithDisplayName from '@components/AvatarWithDisplayName'; import Header from '@components/Header'; @@ -58,6 +58,7 @@ function HeaderWithBackButton({ shouldOverlay = false, singleExecution = (func) => func, shouldNavigateToTopMostReport = false, + progressBarPercentage, }: HeaderWithBackButtonProps) { const theme = useTheme(); const styles = useThemeStyles(); @@ -70,6 +71,36 @@ function HeaderWithBackButton({ // If the icon is present, the header bar should be taller and use different font. const isCentralPaneSettings = !!icon; + const middleContent = useMemo(() => { + if (progressBarPercentage) { + return ( + + + + + + ); + } + + if (shouldShowAvatarWithDisplay) { + return ( + + ); + } + + return ( +
+ ); + }, [StyleUtils, policy, progressBarPercentage, report, shouldEnableDetailPageNavigation, shouldShowAvatarWithDisplay, stepCounter, styles.progressBar, styles.progressBarWrapper, subtitle, title, titleColor, translate]); + return ( )} - {shouldShowAvatarWithDisplay ? ( - - ) : ( -
- )} + {middleContent} {children} {shouldShowDownloadButton && ( diff --git a/src/components/HeaderWithBackButton/types.ts b/src/components/HeaderWithBackButton/types.ts index 83afbad8636b..e31f6f83c552 100644 --- a/src/components/HeaderWithBackButton/types.ts +++ b/src/components/HeaderWithBackButton/types.ts @@ -121,6 +121,9 @@ type HeaderWithBackButtonProps = Partial & { /** Whether we should overlay the 3 dots menu */ shouldOverlayDots?: boolean; + + /** 0 - 100 number indicating current progress of the progress bar */ + progressBarPercentage?: number; }; export type {ThreeDotsMenuItem}; diff --git a/src/stories/HeaderWithBackButton.stories.js b/src/stories/HeaderWithBackButton.stories.js index eb31413de1d5..c0efd292a3e5 100644 --- a/src/stories/HeaderWithBackButton.stories.js +++ b/src/stories/HeaderWithBackButton.stories.js @@ -24,6 +24,8 @@ function Template(args) { const Default = Template.bind({}); const Attachment = Template.bind({}); const Profile = Template.bind({}); +const ProgressBar = Template.bind({}); + Default.args = { title: 'Settings', }; @@ -35,6 +37,11 @@ Profile.args = { title: 'Profile', shouldShowBackButton: true, }; +ProgressBar.args = { + title: 'ProgressBar', + shouldShowBackButton: true, + progressBarPercentage: 33, +}; export default story; -export {Default, Attachment, Profile}; +export {Default, Attachment, Profile, ProgressBar}; diff --git a/src/styles/index.ts b/src/styles/index.ts index 19f5b791a9af..fb05c237c47b 100644 --- a/src/styles/index.ts +++ b/src/styles/index.ts @@ -4343,6 +4343,21 @@ const styles = (theme: ThemeColors) => borderColor: theme.icon, }, + progressBarWrapper: { + position: 'absolute', + width: variables.componentSizeMedium, + height: 4, + borderRadius: variables.componentBorderRadiusRounded, + backgroundColor: theme.progressBarBackground, + alignSelf: 'center', + }, + + progressBar: { + borderRadius: variables.componentBorderRadiusRounded, + height: '100%', + backgroundColor: theme.progressBarFill, + }, + interactiveStepHeaderContainer: { flex: 1, alignSelf: 'center', diff --git a/src/styles/theme/themes/dark.ts b/src/styles/theme/themes/dark.ts index bce0145099b9..5077a01eab87 100644 --- a/src/styles/theme/themes/dark.ts +++ b/src/styles/theme/themes/dark.ts @@ -86,6 +86,8 @@ const darkTheme = { loungeAccessOverlay: colors.blue800, mapAttributionText: colors.black, white: colors.white, + progressBarBackground: colors.green800, + progressBarFill: colors.green400, // Adding a color here will animate the status bar to the right color when the screen is opened. // Note that it needs to be a screen name, not a route url. diff --git a/src/styles/theme/themes/light.ts b/src/styles/theme/themes/light.ts index ebd9c07aa60a..c7788151382b 100644 --- a/src/styles/theme/themes/light.ts +++ b/src/styles/theme/themes/light.ts @@ -86,6 +86,8 @@ const lightTheme = { loungeAccessOverlay: colors.blue800, mapAttributionText: colors.black, white: colors.white, + progressBarBackground: colors.green800, + progressBarFill: colors.green400, // Adding a color here will animate the status bar to the right color when the screen is opened. // Note that it needs to be a screen name, not a route url. diff --git a/src/styles/theme/types.ts b/src/styles/theme/types.ts index 6d7c0183c142..cdbac1ccf44a 100644 --- a/src/styles/theme/types.ts +++ b/src/styles/theme/types.ts @@ -89,6 +89,8 @@ type ThemeColors = { loungeAccessOverlay: Color; mapAttributionText: Color; white: Color; + progressBarBackground: Color; + progressBarFill: Color; PAGE_THEMES: Record;