forked from openwallet-foundation/bifold-wallet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: IoC/Service Discovery (openwallet-foundation#1075)
Signed-off-by: Clécio Varjão <[email protected]> Signed-off-by: Mostafa Gamal <[email protected]> Co-authored-by: Mostafa Gamal <[email protected]>
- Loading branch information
Showing
28 changed files
with
544 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Container, TokenMapping } from '@hyperledger/aries-bifold-core' | ||
import { DependencyContainer } from 'tsyringe' | ||
|
||
export class AppContainer implements Container { | ||
private container: DependencyContainer | ||
public constructor(bifoldContainer: Container) { | ||
this.container = bifoldContainer.getContainer().createChildContainer() | ||
} | ||
public init(): Container { | ||
// eslint-disable-next-line no-console | ||
console.log(`Initializing App container`) | ||
// Here you can register any component to override components in core package | ||
// Example: Replacing button in core with custom button | ||
// this.container.registerInstance(TOKENS.COMP_BUTTON, Button) | ||
return this | ||
} | ||
|
||
public resolve<K extends keyof TokenMapping>(token: K): TokenMapping[K] { | ||
return this.container.resolve(token) as TokenMapping[K] | ||
} | ||
|
||
public getContainer(): DependencyContainer { | ||
return this.container | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import AgentProvider from '@aries-framework/react-hooks' | ||
import * as React from 'react' | ||
import { useEffect, useMemo } from 'react' | ||
import { StatusBar } from 'react-native' | ||
import SplashScreen from 'react-native-splash-screen' | ||
import Toast from 'react-native-toast-message' | ||
|
||
import { animatedComponents } from './animated-components' | ||
import ErrorModal from './components/modals/ErrorModal' | ||
import NetInfo from './components/network/NetInfo' | ||
import toastConfig from './components/toast/ToastConfig' | ||
import { credentialOfferTourSteps } from './components/tour/CredentialOfferTourSteps' | ||
import { credentialsTourSteps } from './components/tour/CredentialsTourSteps' | ||
import { homeTourSteps } from './components/tour/HomeTourSteps' | ||
import { proofRequestTourSteps } from './components/tour/ProofRequestTourSteps' | ||
import { Container, ContainerProvider } from './container-api' | ||
import { AnimatedComponentsProvider } from './contexts/animated-components' | ||
import { AuthProvider } from './contexts/auth' | ||
import { CommonUtilProvider } from './contexts/commons' | ||
import { ConfigurationProvider } from './contexts/configuration' | ||
import { NetworkProvider } from './contexts/network' | ||
import { StoreProvider } from './contexts/store' | ||
import { ThemeProvider } from './contexts/theme' | ||
import { TourProvider } from './contexts/tour/tour-provider' | ||
import { defaultConfiguration } from './defaultConfiguration' | ||
import { initLanguages, initStoredLanguage, translationResources } from './localization' | ||
import RootStack from './navigators/RootStack' | ||
import { theme } from './theme' | ||
//import { credentialOfferTourSteps, credentialsTourSteps, proofRequestTourSteps } from './index' | ||
|
||
initLanguages(translationResources) | ||
|
||
function App(sytem: Container) { | ||
return () => { | ||
useMemo(() => { | ||
initStoredLanguage().then() | ||
}, []) | ||
|
||
useEffect(() => { | ||
// Hide the native splash / loading screen so that our | ||
// RN version can be displayed. | ||
SplashScreen.hide() | ||
}, []) | ||
|
||
return ( | ||
<ContainerProvider value={sytem}> | ||
<StoreProvider> | ||
<AgentProvider> | ||
<ThemeProvider value={theme}> | ||
<AnimatedComponentsProvider value={animatedComponents}> | ||
<ConfigurationProvider value={defaultConfiguration}> | ||
<CommonUtilProvider> | ||
<AuthProvider> | ||
<NetworkProvider> | ||
<StatusBar | ||
hidden={false} | ||
barStyle="light-content" | ||
backgroundColor={theme.ColorPallet.brand.primary} | ||
translucent={false} | ||
/> | ||
<NetInfo /> | ||
<ErrorModal /> | ||
<TourProvider | ||
homeTourSteps={homeTourSteps} | ||
credentialsTourSteps={credentialsTourSteps} | ||
credentialOfferTourSteps={credentialOfferTourSteps} | ||
proofRequestTourSteps={proofRequestTourSteps} | ||
overlayColor={'gray'} | ||
overlayOpacity={0.7} | ||
> | ||
<RootStack /> | ||
</TourProvider> | ||
<Toast topOffset={15} config={toastConfig} /> | ||
</NetworkProvider> | ||
</AuthProvider> | ||
</CommonUtilProvider> | ||
</ConfigurationProvider> | ||
</AnimatedComponentsProvider> | ||
</ThemeProvider> | ||
</AgentProvider> | ||
</StoreProvider> | ||
</ContainerProvider> | ||
) | ||
} | ||
} | ||
export default App |
42 changes: 42 additions & 0 deletions
42
packages/legacy/core/App/components/buttons/Button-api.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { TouchableOpacity } from 'react-native' | ||
|
||
export enum ButtonType { | ||
Critical, | ||
Primary, | ||
Secondary, | ||
ModalCritical, | ||
ModalPrimary, | ||
ModalSecondary, | ||
} | ||
|
||
export interface ButtonProps extends React.PropsWithChildren { | ||
title: string | ||
buttonType: ButtonType | ||
accessibilityLabel?: string | ||
testID?: string | ||
onPress?: () => void | ||
disabled?: boolean | ||
} | ||
|
||
export enum ButtonState { | ||
Default = 'default', | ||
Disabled = 'disabled', | ||
Active = 'active', | ||
} | ||
|
||
export enum ButtonStyleNames { | ||
Critical_Default = 'Critical' + '_' + ButtonState.Default, | ||
Critical_Disabled = 'Critical' + '_' + ButtonState.Disabled, | ||
Critical_Active = 'Critical' + '_' + ButtonState.Active, | ||
} | ||
/* | ||
type stylesType = { readonly [key in ButtonStyleNames]?: ViewStyle | TextStyle | ImageStyle} | ||
const styles: stylesType = StyleSheet.create({ | ||
[ButtonStyleNames.Critical_Default]: {}, | ||
[ButtonType.Secondary]: {}, | ||
[ButtonType.ModalCritical]: {}, | ||
[ButtonType.ModalPrimary]: {}, | ||
[ButtonType.ModalSecondary]: {}, | ||
}) | ||
*/ | ||
export type Button = React.FC<ButtonProps & React.RefAttributes<TouchableOpacity>> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.