Skip to content

Commit

Permalink
feat: inject global screen configuration into core config (#1054)
Browse files Browse the repository at this point in the history
Signed-off-by: OPS <[email protected]>
  • Loading branch information
MosCD3 authored Jan 13, 2024
1 parent e677e16 commit 1cc24b9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 23 deletions.
3 changes: 2 additions & 1 deletion packages/legacy/core/App/contexts/configuration.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IndyVdrPoolConfig } from '@aries-framework/indy-vdr'
import { ProofRequestTemplate } from '@hyperledger/aries-bifold-verifier'
import { OCABundleResolverType } from '@hyperledger/aries-oca/build/legacy'
import { StackScreenProps } from '@react-navigation/stack'
import { StackNavigationOptions, StackScreenProps } from '@react-navigation/stack'
import { createContext, ReducerAction, useContext } from 'react'

import { EmptyListProps } from '../components/misc/EmptyList'
Expand Down Expand Up @@ -54,6 +54,7 @@ export interface ConfigurationContext {
whereToUseWalletUrl: string
showScanHelp?: boolean
showScanButton?: boolean
globalScreenOptions?: StackNavigationOptions
}

export const ConfigurationContext = createContext<ConfigurationContext>(null as unknown as ConfigurationContext)
Expand Down
50 changes: 28 additions & 22 deletions packages/legacy/core/App/navigators/defaultStackOptions.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
import { StackNavigationOptions } from '@react-navigation/stack'
import React from 'react'
import { useTranslation } from 'react-i18next'

import HeaderTitle from '../components/texts/HeaderTitle'
import { useConfiguration } from '../contexts/configuration'
import { ITheme } from '../theme'

export function createDefaultStackOptions({ ColorPallet }: ITheme): any {
export function createDefaultStackOptions({ ColorPallet }: ITheme): StackNavigationOptions {
const { t } = useTranslation()
return {
headerTintColor: ColorPallet.brand.headerIcon,
headerShown: true,
headerBackTitleVisible: false,
headerTitleContainerStyle: {
flexShrink: 1,
maxWidth: '68%',
width: '100%',
},
headerStyle: {
elevation: 0,
shadowOffset: { width: 0, height: 6 },
shadowRadius: 6,
shadowColor: ColorPallet.grayscale.black,
shadowOpacity: 0.15,
borderBottomWidth: 0,
},
headerTitleAlign: 'center' as 'center' | 'left',
headerTitle: (props: { children: React.ReactNode }) => <HeaderTitle {...props} />,
headerBackAccessibilityLabel: t('Global.Back'),
}
const { globalScreenOptions } = useConfiguration()

return (
globalScreenOptions ?? {
headerTintColor: ColorPallet.brand.headerIcon,
headerShown: true,
headerBackTitleVisible: false,
headerTitleContainerStyle: {
flexShrink: 1,
maxWidth: '68%',
width: '100%',
},
headerStyle: {
elevation: 0,
shadowOffset: { width: 0, height: 6 },
shadowRadius: 6,
shadowColor: ColorPallet.grayscale.black,
shadowOpacity: 0.15,
borderBottomWidth: 0,
},
headerTitleAlign: 'center' as 'center' | 'left',
headerTitle: (props: { children: React.ReactNode }) => <HeaderTitle {...props} />,
headerBackAccessibilityLabel: t('Global.Back'),
}
)
}

0 comments on commit 1cc24b9

Please sign in to comment.