Files
inji-wallet/screens/MainLayout.tsx
balachandarg-tw 6aa6f8ad0a [INJIMOB-2242]: Vc Verifier integration with Inji (#1661)
* [INJIMOB-2242]: Integrating VcVerifier with Vc Validation and support for mutliple format into Inji for Android.

Signed-off-by: BalachandarG <balachandar.g@thoughtworks.com>

* [INJIMOM-2242]: Handling Error codes for Verification failures.

Signed-off-by: BalachandarG <balachandar.g@thoughtworks.com>

* [INJIMOB-2242]: Passing credential format to VcVerifier.

Signed-off-by: BalachandarG <balachandar.g@thoughtworks.com>

* [INJIMOB-2242]: Refactoring the code and updating the locales

Signed-off-by: BalachandarG <balachandar.g@thoughtworks.com>

* [INJIMOB-2242]: Updating the locales for verification error codes

Signed-off-by: BalachandarG <balachandar.g@thoughtworks.com>

* [INJIMOB-2242]: Updating talisman file.

Signed-off-by: BalachandarG <balachandar.g@thoughtworks.com>

* [INJIMOB-2242]:Updating package-lock.json and adding comment in verifyCredential.

Signed-off-by: BalachandarG <balachandar.g@thoughtworks.com>

* [INJIMOB-2242]: Reverting package-lock.json to align with develop

Signed-off-by: BalachandarG <balachandar.g@thoughtworks.com>

* [INJIMOB-2242]: Revert package-lock.json

Signed-off-by: BalachandarG <balachandar.g@thoughtworks.com>

* [INJIMOB-2242]: Update talismanrc

Signed-off-by: BalachandarG <balachandar.g@thoughtworks.com>

---------

Signed-off-by: BalachandarG <balachandar.g@thoughtworks.com>
2024-11-06 12:37:58 +05:30

142 lines
5.2 KiB
TypeScript

import React, {useContext, useEffect} from 'react';
import {
BottomTabNavigationOptions,
createBottomTabNavigator,
} from '@react-navigation/bottom-tabs';
import {mainRoutes, share} from '../routes/main';
import {Theme} from '../components/ui/styleUtils';
import {useTranslation} from 'react-i18next';
import {Column} from '../components/ui';
import {GlobalContext} from '../shared/GlobalContext';
import {ScanEvents} from '../machines/bleShare/scan/scanMachine';
import testIDProps from '../shared/commonUtil';
import {SvgImage} from '../components/ui/svg';
import {isIOS} from '../shared/constants';
import {CopilotProvider} from 'react-native-copilot';
import {View} from 'react-native';
import {CopilotTooltip} from '../components/CopilotTooltip';
import {Copilot} from '../components/ui/Copilot';
import LinearGradient from 'react-native-linear-gradient';
import {useNavigation} from '@react-navigation/native';
import {useSelector} from '@xstate/react';
import {selectIsLinkCode} from '../machines/app';
import {BOTTOM_TAB_ROUTES} from '../routes/routesConstants';
const {Navigator, Screen} = createBottomTabNavigator();
export const MainLayout: React.FC = () => {
const {t} = useTranslation('MainLayout');
const {appService} = useContext(GlobalContext);
const scanService = appService.children.get('scan');
const options: BottomTabNavigationOptions = {
tabBarShowLabel: true,
tabBarActiveTintColor: Theme.Colors.IconBg,
...Theme.BottomTabBarStyle,
};
const navigation = useNavigation<ScanLayoutNavigation>();
const linkCode = useSelector(appService, selectIsLinkCode);
useEffect(() => {
if (linkCode != '') {
navigation.navigate(BOTTOM_TAB_ROUTES.share);
}
}, [linkCode]);
return (
<CopilotProvider
stopOnOutsideClick
androidStatusBarVisible
tooltipComponent={CopilotTooltip}
tooltipStyle={Theme.Styles.copilotStyle}
stepNumberComponent={() => null}
animated>
<Navigator
initialRouteName={mainRoutes[0].name}
screenOptions={({route}) => ({
tabBarAccessibilityLabel: route.name,
...options,
})}>
{mainRoutes.map((route, index) => (
<Screen
key={route.name}
name={route.name}
component={route.component}
listeners={{
tabPress: e => {
if (route.name == share.name) {
scanService?.send(ScanEvents.RESET());
}
},
}}
options={{
...route.options,
title: t(route.name),
tabBarIcon: ({focused}) => (
<Column
{...testIDProps(route.name + 'Icon')}
align="center"
crossAlign="center"
style={focused ? Theme.Styles.bottomTabIconStyle : null}>
{route.name === 'home' ? (
focused ? (
<LinearGradient
colors={Theme.Colors.GradientColorsLight}
start={Theme.LinearGradientDirection.start}
end={Theme.LinearGradientDirection.end}
style={{
width: 36,
height: 36,
borderRadius: 10,
justifyContent: 'center',
alignItems: 'center',
}}>
<View>{SvgImage[`${route.name}`](focused)}</View>
</LinearGradient>
) : (
<View>{SvgImage[`${route.name}`](focused)}</View>
)
) : (
<Copilot
title={t(`copilot:${route.name}Title`)}
description={t(`copilot:${route.name}Message`)}
order={2 + index}
targetStyle={Theme.Styles.tabBarIconCopilot}
children={
<>
{focused ? (
<LinearGradient
style={{
width: 36,
height: 36,
borderRadius: 10,
justifyContent: 'center',
alignItems: 'center',
}}
colors={Theme.Colors.GradientColorsLight}
start={Theme.LinearGradientDirection.start}
end={Theme.LinearGradientDirection.end}>
{SvgImage[`${route.name}`](focused)}
</LinearGradient>
) : (
<View>{SvgImage[`${route.name}`](focused)}</View>
)}
</>
}
/>
)}
</Column>
),
tabBarAccessibilityLabel: isIOS() ? t(route.name) : route.name,
tabBarTestID: route.name,
}}
/>
))}
</Navigator>
</CopilotProvider>
);
};