-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32968 from pasyukevich/feature/migrate-PinButton
[TS migration] Migrate 'PinButton.js' component to TypeScript
- Loading branch information
Showing
2 changed files
with
43 additions
and
49 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,43 @@ | ||
import React from 'react'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useTheme from '@hooks/useTheme'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import * as ReportActions from '@userActions/Report'; | ||
import * as Session from '@userActions/Session'; | ||
import CONST from '@src/CONST'; | ||
import type {Report} from '@src/types/onyx'; | ||
import Icon from './Icon'; | ||
import * as Expensicons from './Icon/Expensicons'; | ||
import PressableWithFeedback from './Pressable/PressableWithFeedback'; | ||
import Tooltip from './Tooltip'; | ||
|
||
type PinButtonProps = { | ||
/** Report to pin */ | ||
report: Report; | ||
}; | ||
|
||
function PinButton({report}: PinButtonProps) { | ||
const theme = useTheme(); | ||
const styles = useThemeStyles(); | ||
const {translate} = useLocalize(); | ||
|
||
return ( | ||
<Tooltip text={report.isPinned ? translate('common.unPin') : translate('common.pin')}> | ||
<PressableWithFeedback | ||
onPress={Session.checkIfActionIsAllowed(() => ReportActions.togglePinnedState(report.reportID, report.isPinned ?? false))} | ||
style={styles.touchableButtonImage} | ||
accessibilityLabel={report.isPinned ? translate('common.unPin') : translate('common.pin')} | ||
role={CONST.ROLE.BUTTON} | ||
> | ||
<Icon | ||
src={Expensicons.Pin} | ||
fill={report.isPinned ? theme.heading : theme.icon} | ||
/> | ||
</PressableWithFeedback> | ||
</Tooltip> | ||
); | ||
} | ||
|
||
PinButton.displayName = 'PinButton'; | ||
|
||
export default PinButton; |