Skip to content

Commit

Permalink
chore: rename HeaderButton into ButtonWithIcon
Browse files Browse the repository at this point in the history
Signed-off-by: Nguyen, Tom CITZ:EX <[email protected]>
  • Loading branch information
Nguyen, Tom CITZ:EX authored and Nguyen, Tom CITZ:EX committed Oct 3, 2024
1 parent a657da4 commit 4c7f4ee
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export enum ButtonLocation {
Right,
}

interface HeaderButtonProps {
interface ButtonWithIconProps {
buttonLocation: ButtonLocation
accessibilityLabel: string
testID: string
Expand All @@ -22,7 +22,7 @@ interface HeaderButtonProps {
iconTintColor?: string
}

const HeaderButton: React.FC<HeaderButtonProps> = ({
const ButtonWithIcon: React.FC<ButtonWithIconProps> = ({
buttonLocation,
icon,
text,
Expand Down Expand Up @@ -83,4 +83,4 @@ const HeaderButton: React.FC<HeaderButtonProps> = ({
)
}

export default HeaderButton
export default ButtonWithIcon
4 changes: 2 additions & 2 deletions packages/legacy/core/App/components/buttons/HeaderHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { useTranslation } from 'react-i18next'
import { Screens, TabStacks } from '../../types/navigators'
import { testIdWithKey } from '../../utils/testable'

import HeaderButton, { ButtonLocation } from './HeaderButton'
import ButtonWithIcon, { ButtonLocation } from './ButtonWithIcon'

const HeaderRightHome: React.FC = () => {
const { t } = useTranslation()
const navigation = useNavigation()

return (
<HeaderButton
<ButtonWithIcon
buttonLocation={ButtonLocation.Right}
accessibilityLabel={t('Global.Home')}
testID={testIdWithKey('HomeButton')}
Expand Down
4 changes: 2 additions & 2 deletions packages/legacy/core/App/components/buttons/InfoIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useTranslation } from 'react-i18next'
import { RootStackParams, Screens, Stacks } from '../../types/navigators'
import { testIdWithKey } from '../../utils/testable'

import HeaderButton, { ButtonLocation } from './HeaderButton'
import ButtonWithIcon, { ButtonLocation } from './ButtonWithIcon'

interface InfoIconProps {
connectionId: string
Expand All @@ -17,7 +17,7 @@ const InfoIcon: React.FC<InfoIconProps> = ({ connectionId }) => {
const { t } = useTranslation()

return (
<HeaderButton
<ButtonWithIcon
buttonLocation={ButtonLocation.Right}
accessibilityLabel={t('Screens.Settings')}
testID={testIdWithKey('Settings')}
Expand Down
4 changes: 2 additions & 2 deletions packages/legacy/core/App/components/buttons/SettingsMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import { useTranslation } from 'react-i18next'
import { RootStackParams, Screens, Stacks } from '../../types/navigators'
import { testIdWithKey } from '../../utils/testable'

import HeaderButton, { ButtonLocation } from './HeaderButton'
import ButtonWithIcon, { ButtonLocation } from './ButtonWithIcon'

const SettingsMenu: React.FC = () => {
const navigation = useNavigation<StackNavigationProp<RootStackParams>>()
const { t } = useTranslation()

return (
<HeaderButton
<ButtonWithIcon
buttonLocation={ButtonLocation.Left}
accessibilityLabel={t('Screens.Settings')}
testID={testIdWithKey('Settings')}
Expand Down
8 changes: 4 additions & 4 deletions packages/legacy/core/App/components/misc/NewQRView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { ConnectStackParams, Screens, Stacks } from '../../types/navigators'
import { createConnectionInvitation } from '../../utils/helpers'
import { testIdWithKey } from '../../utils/testable'
import LoadingIndicator from '../animated/LoadingIndicator'
import HeaderButton, { ButtonLocation } from '../buttons/HeaderButton'
import ButtonWithIcon, { ButtonLocation } from '../buttons/ButtonWithIcon'
import InfoBox, { InfoBoxType } from '../misc/InfoBox'
import DismissiblePopupModal from '../modals/DismissiblePopupModal'

Expand Down Expand Up @@ -138,7 +138,7 @@ const NewQRView: React.FC<Props> = ({ defaultToConnect, handleCodeScan, error, e

useEffect(() => {
let headerRight = invitation ? (
<HeaderButton
<ButtonWithIcon
buttonLocation={ButtonLocation.Right}
accessibilityLabel={t('Global.Share')}
testID={testIdWithKey('ShareButton')}
Expand All @@ -152,7 +152,7 @@ const NewQRView: React.FC<Props> = ({ defaultToConnect, handleCodeScan, error, e

if (firstTabActive) {
headerRight = (
<HeaderButton
<ButtonWithIcon
buttonLocation={ButtonLocation.Right}
accessibilityLabel={t('Global.Share')}
testID={testIdWithKey('ShareButton')}
Expand Down Expand Up @@ -312,7 +312,7 @@ const NewQRView: React.FC<Props> = ({ defaultToConnect, handleCodeScan, error, e
<Text testID={testIdWithKey('WalletName')} style={[styles.walletName, { paddingHorizontal: 20 }]}>
{store.preferences.walletName}
</Text>
<HeaderButton
<ButtonWithIcon
buttonLocation={ButtonLocation.Right}
accessibilityLabel={t('NameWallet.EditWalletName')}
testID={testIdWithKey('EditWalletName')}
Expand Down
4 changes: 2 additions & 2 deletions packages/legacy/core/App/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import AgentProvider from '@credo-ts/react-hooks'
import App from './App'
import * as components from './components'
import { Button as IButton, ButtonImpl as Button, ButtonType } from './components/buttons/Button'
import HeaderButton, { ButtonLocation } from './components/buttons/HeaderButton'
import ButtonWithIcon, { ButtonLocation } from './components/buttons/ButtonWithIcon'
import BulletPoint from './components/inputs/BulletPoint'
import CheckBoxRow from './components/inputs/CheckBoxRow'
import ContentGradient from './components/misc/ContentGradient'
Expand Down Expand Up @@ -121,7 +121,7 @@ export {
credentialOfferTourSteps,
proofRequestTourSteps,
ButtonType,
HeaderButton,
ButtonWithIcon,
ButtonLocation,
CheckBoxRow,
CredentialCard,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { StackNavigationProp } from '@react-navigation/stack'
import React from 'react'
import { useTranslation } from 'react-i18next'

import HeaderButton, { ButtonLocation } from '../../../../components/buttons/HeaderButton'
import ButtonWithIcon, { ButtonLocation } from '../../../../components/buttons/ButtonWithIcon'
import { RootStackParams, Screens, Stacks } from '../../../../types/navigators'
import { testIdWithKey } from '../../../../utils/testable'

Expand All @@ -12,7 +12,7 @@ const HistoryMenu: React.FC = () => {
const { t } = useTranslation()

return (
<HeaderButton
<ButtonWithIcon
buttonLocation={ButtonLocation.Right}
accessibilityLabel={t('Screens.Settings')}
testID={testIdWithKey('Settings')}
Expand Down
6 changes: 3 additions & 3 deletions packages/legacy/core/App/navigators/ProofRequestStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createStackNavigator } from '@react-navigation/stack'
import React from 'react'
import { useTranslation } from 'react-i18next'

import HeaderButton, { ButtonLocation } from '../components/buttons/HeaderButton'
import ButtonWithIcon, { ButtonLocation } from '../components/buttons/ButtonWithIcon'
import HeaderRightHome from '../components/buttons/HeaderHome'
import { useTheme } from '../contexts/theme'
import ListProofRequests from '../screens/ListProofRequests'
Expand Down Expand Up @@ -53,7 +53,7 @@ const ProofRequestStack: React.FC = () => {
options={({ navigation }) => ({
title: t('ProofRequest.RequestForProof'),
headerLeft: () => (
<HeaderButton
<ButtonWithIcon
buttonLocation={ButtonLocation.Left}
accessibilityLabel={t('Global.Back')}
testID={testIdWithKey('BackButton')}
Expand All @@ -69,7 +69,7 @@ const ProofRequestStack: React.FC = () => {
options={({ navigation, route }) => ({
title: '',
headerLeft: () => (
<HeaderButton
<ButtonWithIcon
buttonLocation={ButtonLocation.Left}
accessibilityLabel={t('Global.Back')}
testID={testIdWithKey('BackButton')}
Expand Down
4 changes: 2 additions & 2 deletions packages/legacy/core/App/navigators/RootStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import React, { useCallback, useEffect, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { AppState, DeviceEventEmitter } from 'react-native'

import HeaderButton, { ButtonLocation } from '../components/buttons/HeaderButton'
import ButtonWithIcon, { ButtonLocation } from '../components/buttons/ButtonWithIcon'
import { EventTypes, walletTimeout } from '../constants'
import { TOKENS, useServices } from '../container-api'
import { useAuth } from '../contexts/auth'
Expand Down Expand Up @@ -271,7 +271,7 @@ const RootStack: React.FC = () => {
headerShown: true,
title: t('Screens.CredentialOffer'),
headerLeft: () => (
<HeaderButton
<ButtonWithIcon
buttonLocation={ButtonLocation.Left}
accessibilityLabel={t('Global.Back')}
testID={testIdWithKey('BackButton')}
Expand Down
4 changes: 2 additions & 2 deletions packages/legacy/core/App/screens/ListContacts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React, { useCallback, useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { DeviceEventEmitter, FlatList, StyleSheet, View } from 'react-native'

import HeaderButton, { ButtonLocation } from '../components/buttons/HeaderButton'
import ButtonWithIcon, { ButtonLocation } from '../components/buttons/ButtonWithIcon'
import ContactListItem from '../components/listItems/ContactListItem'
import EmptyListContacts from '../components/misc/EmptyListContacts'
import { EventTypes } from '../constants'
Expand Down Expand Up @@ -74,7 +74,7 @@ const ListContacts: React.FC<ListContactsProps> = ({ navigation }) => {
if (store.preferences.useConnectionInviterCapability) {
navigation.setOptions({
headerRight: () => (
<HeaderButton
<ButtonWithIcon
buttonLocation={ButtonLocation.Right}
accessibilityLabel={t('Contacts.AddContact')}
testID={testIdWithKey('AddContact')}
Expand Down
4 changes: 2 additions & 2 deletions packages/legacy/core/App/screens/Onboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next'
import { Animated, BackHandler, FlatList, View, useWindowDimensions } from 'react-native'
import { SafeAreaView } from 'react-native-safe-area-context'

import HeaderButton, { ButtonLocation } from '../components/buttons/HeaderButton'
import ButtonWithIcon, { ButtonLocation } from '../components/buttons/ButtonWithIcon'
import { Pagination } from '../components/misc/Pagination'
import { DispatchAction } from '../contexts/reducers/store'
import { useStore } from '../contexts/store'
Expand Down Expand Up @@ -101,7 +101,7 @@ const Onboarding: React.FC<OnboardingProps> = ({
!disableSkip &&
navigation.setOptions({
headerRight: () => (
<HeaderButton
<ButtonWithIcon
buttonLocation={ButtonLocation.Right}
accessibilityLabel={t('Onboarding.SkipA11y')}
testID={testIdWithKey('Skip')}
Expand Down
4 changes: 2 additions & 2 deletions packages/legacy/core/App/screens/ProofRequesting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { SafeAreaView } from 'react-native-safe-area-context'

import LoadingIndicator from '../components/animated/LoadingIndicator'
import Button, { ButtonType } from '../components/buttons/Button'
import HeaderButton, { ButtonLocation } from '../components/buttons/HeaderButton'
import ButtonWithIcon, { ButtonLocation } from '../components/buttons/ButtonWithIcon'
import QRRenderer from '../components/misc/QRRenderer'
import { EventTypes } from '../constants'
import { useStore } from '../contexts/store'
Expand Down Expand Up @@ -154,7 +154,7 @@ const ProofRequesting: React.FC<ProofRequestingProps> = ({ route, navigation })
useEffect(() => {
if (message && store.preferences.enableShareableLink) {
const scanShareUrl = () => (
<HeaderButton
<ButtonWithIcon
buttonLocation={ButtonLocation.Right}
accessibilityLabel={t('Global.Share')}
testID={testIdWithKey('ShareButton')}
Expand Down
4 changes: 2 additions & 2 deletions packages/legacy/core/App/screens/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { getVersion, getBuildNumber } from 'react-native-device-info'
import { SafeAreaView } from 'react-native-safe-area-context'
import Icon from 'react-native-vector-icons/MaterialIcons'

import HeaderButton, { ButtonLocation } from '../components/buttons/HeaderButton'
import ButtonWithIcon, { ButtonLocation } from '../components/buttons/ButtonWithIcon'
import { DispatchAction } from '../contexts/reducers/store'
import { useStore } from '../contexts/store'
import { useTheme } from '../contexts/theme'
Expand Down Expand Up @@ -291,7 +291,7 @@ const Settings: React.FC<SettingsProps> = ({ navigation }) => {
</Text>
</View>
{iconRight && (
<HeaderButton
<ButtonWithIcon
buttonLocation={ButtonLocation.Right}
accessibilityLabel={iconRight.accessibilityLabel!}
testID={iconRight.testID!}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { render, fireEvent } from '@testing-library/react-native'
import React from 'react'

import HeaderButton, { ButtonLocation } from '../../App/components/buttons/HeaderButton'
import ButtonWithIcon, { ButtonLocation } from '../../App/components/buttons/ButtonWithIcon'
import { testIdWithKey } from '../../App/utils/testable'

describe('HeaderButton Component', () => {
describe('ButtonWithIcon Component', () => {
test('Left alignment renders correctly', () => {
const tree = render(
<HeaderButton
<ButtonWithIcon
buttonLocation={ButtonLocation.Left}
accessibilityLabel={'LeftButton'}
testID={testIdWithKey('LeftButton')}
Expand All @@ -21,7 +21,7 @@ describe('HeaderButton Component', () => {

test('Right alignment renders correctly', () => {
const tree = render(
<HeaderButton
<ButtonWithIcon
buttonLocation={ButtonLocation.Right}
accessibilityLabel={'RightButton'}
testID={testIdWithKey('RightButton')}
Expand All @@ -35,7 +35,7 @@ describe('HeaderButton Component', () => {

test('Right alignment with text renders correctly', () => {
const tree = render(
<HeaderButton
<ButtonWithIcon
buttonLocation={ButtonLocation.Right}
accessibilityLabel={'RightButton'}
testID={testIdWithKey('RightButton')}
Expand All @@ -51,7 +51,7 @@ describe('HeaderButton Component', () => {
test('Button onPress triggers on press', () => {
const callback = jest.fn()
const { getByTestId } = render(
<HeaderButton
<ButtonWithIcon
buttonLocation={ButtonLocation.Left}
accessibilityLabel={'LeftButton'}
testID={testIdWithKey('LeftButton')}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`HeaderButton Component Left alignment renders correctly 1`] = `
exports[`ButtonWithIcon Component Left alignment renders correctly 1`] = `
<View
accessibilityLabel="LeftButton"
accessibilityRole="button"
Expand Down Expand Up @@ -80,7 +80,7 @@ exports[`HeaderButton Component Left alignment renders correctly 1`] = `
</View>
`;

exports[`HeaderButton Component Right alignment renders correctly 1`] = `
exports[`ButtonWithIcon Component Right alignment renders correctly 1`] = `
<View
accessibilityLabel="RightButton"
accessibilityRole="button"
Expand Down Expand Up @@ -160,7 +160,7 @@ exports[`HeaderButton Component Right alignment renders correctly 1`] = `
</View>
`;

exports[`HeaderButton Component Right alignment with text renders correctly 1`] = `
exports[`ButtonWithIcon Component Right alignment with text renders correctly 1`] = `
<View
accessibilityLabel="RightButton"
accessibilityRole="button"
Expand Down

0 comments on commit 4c7f4ee

Please sign in to comment.