Skip to content

Commit

Permalink
Refactoring HomeTour Step
Browse files Browse the repository at this point in the history
Signed-off-by: ClaudeArs <[email protected]>
  • Loading branch information
ClaudeArs committed Feb 7, 2025
1 parent 10b51ab commit 87ef78a
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useTheme } from '../../contexts/theme'
import { RenderProps, TourStep } from '../../contexts/tour/tour-context'

import { TourBox } from './TourBox'
import useHandleStop from '../../hooks/close-modal-tour'
import useCloseModalTour from '../../hooks/close-modal-tour'
import { DispatchAction } from '../../contexts/reducers/store'

export const credentialOfferTourSteps: TourStep[] = [
Expand All @@ -15,18 +15,18 @@ export const credentialOfferTourSteps: TourStep[] = [
const { currentTour, currentStep, next, stop, previous } = props
const { t } = useTranslation()
const { ColorPallet, TextTheme } = useTheme()
const handleStop = useHandleStop()
const closeModalTour = useCloseModalTour()

return (
<TourBox
title={t('Tour.CredentialOffers')}
hideLeft
rightText={t('Tour.Done')}
onRight={() => handleStop(stop, DispatchAction.UPDATE_SEEN_CREDENTIAL_OFFER_TOUR)}
onRight={() => closeModalTour(stop, DispatchAction.UPDATE_SEEN_CREDENTIAL_OFFER_TOUR)}
currentTour={currentTour}
currentStep={currentStep}
previous={previous}
stop={() => handleStop(stop, DispatchAction.UPDATE_SEEN_CREDENTIAL_OFFER_TOUR)}
stop={() => closeModalTour(stop, DispatchAction.UPDATE_SEEN_CREDENTIAL_OFFER_TOUR)}
next={next}
>
<Text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useTheme } from '../../contexts/theme'
import { RenderProps, TourStep } from '../../contexts/tour/tour-context'

import { TourBox } from './TourBox'
import useHandleStop from '../../hooks/close-modal-tour'
import useCloseModalTour from '../../hooks/close-modal-tour'
import { DispatchAction } from '../../contexts/reducers/store'

export const credentialsTourSteps: TourStep[] = [
Expand All @@ -15,18 +15,18 @@ export const credentialsTourSteps: TourStep[] = [
const { currentTour, currentStep, next, stop, previous } = props
const { t } = useTranslation()
const { ColorPallet, TextTheme } = useTheme()
const handleStop = useHandleStop()
const closeModalTour = useCloseModalTour()

return (
<TourBox
title={t('Tour.AddCredentials')}
hideLeft
rightText={t('Tour.Done')}
onRight={() => handleStop(stop, DispatchAction.UPDATE_SEEN_CREDENTIALS_TOUR)}
onRight={() => closeModalTour(stop, DispatchAction.UPDATE_SEEN_CREDENTIALS_TOUR)}
currentTour={currentTour}
currentStep={currentStep}
previous={previous}
stop={() => handleStop(stop, DispatchAction.UPDATE_SEEN_CREDENTIALS_TOUR)}
stop={() => closeModalTour(stop, DispatchAction.UPDATE_SEEN_CREDENTIALS_TOUR)}
next={next}
>
<Text
Expand Down
61 changes: 27 additions & 34 deletions packages/legacy/core/App/components/tour/HomeTourSteps.tsx
Original file line number Diff line number Diff line change
@@ -1,42 +1,47 @@
import * as React from 'react'
import { useTranslation } from 'react-i18next'
import { Text } from 'react-native'
import { Text, TextStyle } from 'react-native'

import { useTheme } from '../../contexts/theme'
import { RenderProps, TourStep } from '../../contexts/tour/tour-context'

import { TourBox } from './TourBox'
import useHandleStop from '../../hooks/close-modal-tour'
import useCloseModalTour from '../../hooks/close-modal-tour'
import { DispatchAction } from '../../contexts/reducers/store'

const useCommonStyles = () => {
const { ColorPallet, TextTheme } = useTheme()

const textStyle: TextStyle = {
...TextTheme.normal,
color: ColorPallet.notification.infoText,
}

return { textStyle }
}

export const homeTourSteps: TourStep[] = [
{
Render: (props: RenderProps) => {
const { currentTour, currentStep, next, stop, previous } = props
const { t } = useTranslation()
const { ColorPallet, TextTheme } = useTheme()
const handleStop = useHandleStop()
const { textStyle } = useCommonStyles()
const closeModalTour = useCloseModalTour()

return (
<TourBox
title={t('Tour.AddAndShare')}
leftText={t('Tour.Skip')}
rightText={t('Tour.Next')}
onLeft={() => handleStop(stop, DispatchAction.UPDATE_SEEN_HOME_TOUR)}
onLeft={() => closeModalTour(stop, DispatchAction.UPDATE_SEEN_HOME_TOUR)}
onRight={next}
currentTour={currentTour}
currentStep={currentStep}
previous={previous}
stop={() => handleStop(stop, DispatchAction.UPDATE_SEEN_HOME_TOUR)}
stop={() => closeModalTour(stop, DispatchAction.UPDATE_SEEN_HOME_TOUR)}
next={next}
>
<Text
style={{
...TextTheme.normal,
color: ColorPallet.notification.infoText,
}}
allowFontScaling={false}
>
<Text style={textStyle} allowFontScaling={false}>
{t('Tour.AddAndShareDescription')}
</Text>
</TourBox>
Expand All @@ -47,8 +52,8 @@ export const homeTourSteps: TourStep[] = [
Render: (props: RenderProps) => {
const { currentTour, currentStep, next, stop, previous } = props
const { t } = useTranslation()
const { ColorPallet, TextTheme } = useTheme()
const handleStop = useHandleStop()
const { textStyle } = useCommonStyles()
const closeModalTour = useCloseModalTour()

return (
<TourBox
Expand All @@ -60,16 +65,10 @@ export const homeTourSteps: TourStep[] = [
currentTour={currentTour}
currentStep={currentStep}
next={next}
stop={() => handleStop(stop, DispatchAction.UPDATE_SEEN_HOME_TOUR)}
stop={() => closeModalTour(stop, DispatchAction.UPDATE_SEEN_HOME_TOUR)}
previous={previous}
>
<Text
style={{
...TextTheme.normal,
color: ColorPallet.notification.infoText,
}}
allowFontScaling={false}
>
<Text style={textStyle} allowFontScaling={false}>
{t('Tour.NotificationsDescription')}
</Text>
</TourBox>
Expand All @@ -80,29 +79,23 @@ export const homeTourSteps: TourStep[] = [
Render: (props: RenderProps) => {
const { currentTour, currentStep, next, stop, previous } = props
const { t } = useTranslation()
const { ColorPallet, TextTheme } = useTheme()
const handleStop = useHandleStop()
const { textStyle } = useCommonStyles()
const closeModalTour = useCloseModalTour()

return (
<TourBox
title={t('Tour.YourCredentials')}
leftText={t('Tour.Back')}
rightText={t('Tour.Done')}
onLeft={previous}
onRight={() => handleStop(stop, DispatchAction.UPDATE_SEEN_HOME_TOUR)}
onRight={() => closeModalTour(stop, DispatchAction.UPDATE_SEEN_HOME_TOUR)}
currentTour={currentTour}
currentStep={currentStep}
next={next}
stop={() => handleStop(stop, DispatchAction.UPDATE_SEEN_HOME_TOUR)}
stop={() => closeModalTour(stop, DispatchAction.UPDATE_SEEN_HOME_TOUR)}
previous={previous}
>
<Text
style={{
...TextTheme.normal,
color: ColorPallet.notification.infoText,
}}
allowFontScaling={false}
>
<Text style={textStyle} allowFontScaling={false}>
{t('Tour.YourCredentialsDescription')}
</Text>
</TourBox>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useTheme } from '../../contexts/theme'
import { RenderProps, TourStep } from '../../contexts/tour/tour-context'

import { TourBox } from './TourBox'
import useHandleStop from '../../hooks/close-modal-tour'
import useCloseModalTour from '../../hooks/close-modal-tour'
import { DispatchAction } from '../../contexts/reducers/store'

export const proofRequestTourSteps: TourStep[] = [
Expand All @@ -15,18 +15,18 @@ export const proofRequestTourSteps: TourStep[] = [
const { currentTour, currentStep, next, stop, previous } = props
const { t } = useTranslation()
const { ColorPallet, TextTheme } = useTheme()
const handleStop = useHandleStop()
const closeModalTour = useCloseModalTour()

return (
<TourBox
title={t('Tour.ProofRequests')}
hideLeft
rightText={t('Tour.Done')}
onRight={() => handleStop(stop, DispatchAction.UPDATE_SEEN_PROOF_REQUEST_TOUR)}
onRight={() => closeModalTour(stop, DispatchAction.UPDATE_SEEN_PROOF_REQUEST_TOUR)}
currentTour={currentTour}
currentStep={currentStep}
previous={previous}
stop={() => handleStop(stop, DispatchAction.UPDATE_SEEN_PROOF_REQUEST_TOUR)}
stop={() => closeModalTour(stop, DispatchAction.UPDATE_SEEN_PROOF_REQUEST_TOUR)}
next={next}
>
<Text
Expand Down
4 changes: 2 additions & 2 deletions packages/legacy/core/App/hooks/close-modal-tour.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useCallback } from 'react'
import { DispatchAction } from '../contexts/reducers/store'
import { useStore } from '../contexts/store'
const useHandleStop = () => {
const useCloseModalTour = () => {
const [, dispatch] = useStore()

const handleStop = useCallback(
Expand All @@ -18,4 +18,4 @@ const useHandleStop = () => {
return handleStop
}

export default useHandleStop
export default useCloseModalTour
10 changes: 9 additions & 1 deletion packages/legacy/core/App/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import { CredentialListFooterProps } from './types/credential-list-footer'
import { OpenIDCredentialRecordProvider } from './modules/openid/context/OpenIDCredentialRecordProvider'
import { defaultConfig, defaultHistoryEventsLogger } from './container-impl'
import useInitializeAgent from './hooks/initialize-agent'
import useCloseModalTour from './hooks/close-modal-tour'
import { DefaultScreenLayoutOptions } from './navigators/defaultLayoutOptions'

export * from './navigators'
Expand Down Expand Up @@ -83,7 +84,13 @@ export { BifoldError } from './types/error'
export { EventTypes } from './constants'
export { migrateToAskar } from './utils/migration'
export { createLinkSecretIfRequired, getAgentModules } from './utils/agent'
export { removeExistingInvitationIfRequired, connectFromScanOrDeepLink, formatTime, useCredentialConnectionLabel, getConnectionName } from './utils/helpers'
export {
removeExistingInvitationIfRequired,
connectFromScanOrDeepLink,
formatTime,
useCredentialConnectionLabel,
getConnectionName,
} from './utils/helpers'
export { isValidAnonCredsCredential, getCredentialIdentifiers } from './utils/credential'
export { buildFieldsFromAnonCredsCredential } from './utils/oca'

Expand Down Expand Up @@ -173,6 +180,7 @@ export {
NotificationListItem,
useDefaultStackOptions,
useInitializeAgent,
useCloseModalTour,
Splash,
Developer,
Terms,
Expand Down

0 comments on commit 87ef78a

Please sign in to comment.