-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[No QA][Search v1] TransactionListItem and SearchTableHeader #41102
Merged
luacmartins
merged 22 commits into
Expensify:main
from
software-mansion-labs:search-v1/search-list
Apr 30, 2024
Merged
Changes from 10 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
d25bcdf
Add template of SearchTableHeader
WojtekBoman c423cb8
Add template of ExpenseListItem
WojtekBoman 6235eb1
Merge branch 'main' into search-v1/search-table-header
WojtekBoman a948542
Merge branch 'search-v1/search-table-header' into search-v1/search-list
WojtekBoman ff30cb5
Add test data to SearchPage
WojtekBoman 13273b6
Rename ExpenseListItem to TransactionListItem
WojtekBoman 0ec7b8a
Modify TransactionListItem
WojtekBoman c598002
Merge branch 'main' into search-v1/search-list
WojtekBoman dcad06e
Refactor SearchUtils
WojtekBoman c2c2203
add styles for narrow screens for TransactionListItem
Kicu 26a354f
Add SearchTransactionType
WojtekBoman 1969563
handle clicking on TransactionListItem
Kicu 19c976e
Add flex1 to views with text
WojtekBoman cda5777
improve TransactionListItem on narrow screens
Kicu 6ff87da
add small fixes to TransactionListItem after review
Kicu c7925fb
Merge branch 'main' into search-v1/search-list
Kicu 71d1b58
add using actual api results
Kicu 29d2fa5
Handle opening search page with invalid queries
WojtekBoman 596c997
improve TransactionListItem layout on narrow screens
Kicu aa625fa
add more small fixes to TransactionListItem
Kicu 7995911
Add fixes to Search
WojtekBoman 241b602
Fix lint
WojtekBoman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,203 @@ | ||||||
import {format} from 'date-fns'; | ||||||
import React, {useCallback} from 'react'; | ||||||
import {View} from 'react-native'; | ||||||
import Avatar from '@components/Avatar'; | ||||||
import Button from '@components/Button'; | ||||||
import Icon from '@components/Icon'; | ||||||
import * as Expensicons from '@components/Icon/Expensicons'; | ||||||
import MultipleAvatars from '@components/MultipleAvatars'; | ||||||
import {usePersonalDetails} from '@components/OnyxProvider'; | ||||||
import PressableWithFeedback from '@components/Pressable/PressableWithFeedback'; | ||||||
import Text from '@components/Text'; | ||||||
import TextWithTooltip from '@components/TextWithTooltip'; | ||||||
import useStyleUtils from '@hooks/useStyleUtils'; | ||||||
import useTheme from '@hooks/useTheme'; | ||||||
import useThemeStyles from '@hooks/useThemeStyles'; | ||||||
import * as CurrencyUtils from '@libs/CurrencyUtils'; | ||||||
import CONST from '@src/CONST'; | ||||||
import BaseListItem from './BaseListItem'; | ||||||
import type {ListItem, TransactionListItemProps} from './types'; | ||||||
|
||||||
function TransactionListItem<TItem extends ListItem>({ | ||||||
item, | ||||||
isFocused, | ||||||
showTooltip, | ||||||
isDisabled, | ||||||
canSelectMultiple, | ||||||
onSelectRow, | ||||||
onCheckboxPress, | ||||||
onDismissError, | ||||||
shouldPreventDefaultFocusOnSelectRow, | ||||||
rightHandSideComponent, | ||||||
onFocus, | ||||||
shouldSyncFocus, | ||||||
}: TransactionListItemProps<TItem>) { | ||||||
const styles = useThemeStyles(); | ||||||
const theme = useTheme(); | ||||||
const StyleUtils = useStyleUtils(); | ||||||
const personalDetails = usePersonalDetails() ?? CONST.EMPTY_OBJECT; | ||||||
const focusedBackgroundColor = styles.sidebarLinkActive.backgroundColor; | ||||||
const hoveredBackgroundColor = styles.sidebarLinkHover?.backgroundColor ? styles.sidebarLinkHover.backgroundColor : theme.sidebar; | ||||||
|
||||||
const handleCheckboxPress = useCallback(() => { | ||||||
if (onCheckboxPress) { | ||||||
onCheckboxPress(item); | ||||||
} else { | ||||||
onSelectRow(item); | ||||||
} | ||||||
}, [item, onCheckboxPress, onSelectRow]); | ||||||
|
||||||
console.log('personalDetails', personalDetails); | ||||||
|
||||||
return ( | ||||||
<BaseListItem | ||||||
item={item} | ||||||
pressableStyle={[[styles.selectionListPressableItemWrapper, item.isSelected && styles.activeComponentBG, isFocused && styles.sidebarLinkActive]]} | ||||||
wrapperStyle={[styles.flexRow, styles.flex1, styles.justifyContentBetween, styles.userSelectNone, styles.alignItemsCenter]} | ||||||
containerStyle={[styles.mb3]} | ||||||
isFocused={isFocused} | ||||||
isDisabled={isDisabled} | ||||||
showTooltip={showTooltip} | ||||||
canSelectMultiple={canSelectMultiple} | ||||||
onSelectRow={onSelectRow} | ||||||
onDismissError={onDismissError} | ||||||
shouldPreventDefaultFocusOnSelectRow={shouldPreventDefaultFocusOnSelectRow} | ||||||
rightHandSideComponent={rightHandSideComponent} | ||||||
errors={item.errors} | ||||||
pendingAction={item.pendingAction} | ||||||
keyForList={item.keyForList} | ||||||
onFocus={onFocus} | ||||||
shouldSyncFocus={shouldSyncFocus} | ||||||
hoverStyle={item.isSelected && styles.activeComponentBG} | ||||||
> | ||||||
{(hovered) => ( | ||||||
<> | ||||||
{canSelectMultiple && ( | ||||||
<PressableWithFeedback | ||||||
accessibilityLabel={item.text ?? ''} | ||||||
role={CONST.ROLE.BUTTON} | ||||||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing | ||||||
disabled={isDisabled || item.isDisabledCheckbox} | ||||||
onPress={handleCheckboxPress} | ||||||
style={[styles.cursorUnset, StyleUtils.getCheckboxPressableStyle(), item.isDisabledCheckbox && styles.cursorDisabled, styles.mr3]} | ||||||
> | ||||||
<View style={[StyleUtils.getCheckboxContainerStyle(20), StyleUtils.getMultiselectListStyles(!!item.isSelected, !!item.isDisabled)]}> | ||||||
{item.isSelected && ( | ||||||
<Icon | ||||||
src={Expensicons.Checkmark} | ||||||
fill={theme.textLight} | ||||||
height={14} | ||||||
width={14} | ||||||
/> | ||||||
)} | ||||||
</View> | ||||||
</PressableWithFeedback> | ||||||
)} | ||||||
{!!item.icons && ( | ||||||
<MultipleAvatars | ||||||
icons={item.icons ?? []} | ||||||
shouldShowTooltip={showTooltip} | ||||||
secondAvatarStyle={[ | ||||||
StyleUtils.getBackgroundAndBorderStyle(theme.sidebar), | ||||||
isFocused ? StyleUtils.getBackgroundAndBorderStyle(focusedBackgroundColor) : undefined, | ||||||
hovered && !isFocused ? StyleUtils.getBackgroundAndBorderStyle(hoveredBackgroundColor) : undefined, | ||||||
]} | ||||||
/> | ||||||
)} | ||||||
<View style={[styles.flexRow, styles.flex1, styles.gap3]}> | ||||||
<View style={[styles.flex1, styles.flexColumn, styles.justifyContentCenter, styles.alignItemsStretch]}> | ||||||
<TextWithTooltip | ||||||
shouldShowTooltip={showTooltip} | ||||||
text={format(new Date(item.created), 'MMM dd')} | ||||||
style={[styles.optionDisplayName, styles.textNormalThemeText, styles.pre, styles.justifyContentCenter]} | ||||||
/> | ||||||
</View> | ||||||
<View style={[styles.flex1, styles.flexColumn, styles.justifyContentCenter, styles.alignItemsStretch]}> | ||||||
<TextWithTooltip | ||||||
shouldShowTooltip={showTooltip} | ||||||
text={item.description} | ||||||
style={[styles.optionDisplayName, styles.textNormalThemeText, styles.pre, styles.justifyContentCenter]} | ||||||
/> | ||||||
</View> | ||||||
<View style={[styles.flex1, styles.flexColumn, styles.justifyContentCenter, styles.alignItemsStretch]}> | ||||||
<View style={[styles.flexRow, styles.gap3, styles.flex1, styles.alignItemsCenter]}> | ||||||
<Avatar | ||||||
imageStyles={[styles.alignSelfCenter]} | ||||||
size={CONST.AVATAR_SIZE.SMALL} | ||||||
source={personalDetails[item.managerID]?.avatar} | ||||||
name={personalDetails[item.managerID]?.displayName} | ||||||
type={CONST.ICON_TYPE_WORKSPACE} | ||||||
/> | ||||||
<Text | ||||||
numberOfLines={1} | ||||||
style={[styles.flex1, styles.flexGrow1, styles.textStrong]} | ||||||
> | ||||||
{personalDetails[item.managerID]?.displayName} | ||||||
</Text> | ||||||
</View> | ||||||
</View> | ||||||
<View style={[styles.flex1, styles.flexColumn, styles.justifyContentCenter, styles.alignItemsStretch]}> | ||||||
<View style={[styles.flexRow, styles.gap3, styles.flex1, styles.alignItemsCenter]}> | ||||||
<Avatar | ||||||
imageStyles={[styles.alignSelfCenter]} | ||||||
size={CONST.AVATAR_SIZE.SMALL} | ||||||
source={personalDetails[item.accountID]?.avatar} | ||||||
name={personalDetails[item.accountID]?.displayName} | ||||||
type={CONST.ICON_TYPE_WORKSPACE} | ||||||
/> | ||||||
<Text | ||||||
numberOfLines={1} | ||||||
style={[styles.flex1, styles.flexGrow1, styles.textStrong]} | ||||||
> | ||||||
{personalDetails[item.accountID]?.displayName} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
</Text> | ||||||
</View> | ||||||
</View> | ||||||
<View style={[styles.flex1, styles.flexColumn, styles.justifyContentCenter, styles.alignItemsStretch]}> | ||||||
<TextWithTooltip | ||||||
shouldShowTooltip={showTooltip} | ||||||
text={item.category} | ||||||
style={[styles.optionDisplayName, styles.textNormalThemeText, styles.pre, styles.justifyContentCenter]} | ||||||
/> | ||||||
</View> | ||||||
<View style={[styles.flex1, styles.flexColumn, styles.justifyContentCenter, styles.alignItemsStretch]}> | ||||||
<TextWithTooltip | ||||||
shouldShowTooltip={showTooltip} | ||||||
text={item.tag} | ||||||
style={[styles.optionDisplayName, styles.textNormalThemeText, styles.pre, styles.justifyContentCenter]} | ||||||
/> | ||||||
</View> | ||||||
<View style={[styles.flex1, styles.flexColumn, styles.justifyContentCenter, styles.alignItemsEnd]}> | ||||||
<TextWithTooltip | ||||||
shouldShowTooltip={showTooltip} | ||||||
text={`${CurrencyUtils.getLocalizedCurrencySymbol(item.currency)}${item.amount}`} | ||||||
style={[styles.optionDisplayName, styles.textNewKansasNormal, styles.pre, styles.justifyContentCenter]} | ||||||
/> | ||||||
</View> | ||||||
<View style={[styles.flex1, styles.flexColumn, styles.justifyContentCenter, styles.alignItemsStretch]}> | ||||||
<Icon | ||||||
src={Expensicons.CreditCard} | ||||||
fill={theme.icon} | ||||||
/> | ||||||
</View> | ||||||
|
||||||
<View style={[styles.flex1, styles.flexColumn, styles.justifyContentCenter, styles.alignItemsStretch]}> | ||||||
<Button | ||||||
success | ||||||
onPress={() => {}} | ||||||
small | ||||||
pressOnEnter | ||||||
text="View" | ||||||
/> | ||||||
</View> | ||||||
</View> | ||||||
{!!item.rightElement && item.rightElement} | ||||||
</> | ||||||
)} | ||||||
</BaseListItem> | ||||||
); | ||||||
} | ||||||
|
||||||
TransactionListItem.displayName = 'TransactionListItem'; | ||||||
|
||||||
export default TransactionListItem; |
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From
should beitem.accountID