forked from Expensify/App
-
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.
Merge pull request Expensify#27767 from thiagobrez/thiagobrez/selecti…
…on-list-phase-3-base Selection List refactor phase 3: base
- Loading branch information
Showing
17 changed files
with
529 additions
and
410 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import React from 'react'; | ||
import {View} from 'react-native'; | ||
import lodashGet from 'lodash/get'; | ||
import PressableWithFeedback from '../Pressable/PressableWithFeedback'; | ||
import styles from '../../styles/styles'; | ||
import Icon from '../Icon'; | ||
import * as Expensicons from '../Icon/Expensicons'; | ||
import themeColors from '../../styles/themes/default'; | ||
import {baseListItemPropTypes} from './selectionListPropTypes'; | ||
import * as StyleUtils from '../../styles/StyleUtils'; | ||
import UserListItem from './UserListItem'; | ||
import RadioListItem from './RadioListItem'; | ||
import OfflineWithFeedback from '../OfflineWithFeedback'; | ||
import CONST from '../../CONST'; | ||
|
||
function BaseListItem({item, isFocused = false, isDisabled = false, showTooltip, canSelectMultiple = false, onSelectRow, onDismissError = () => {}}) { | ||
const isUserItem = lodashGet(item, 'icons.length', 0) > 0; | ||
const ListItem = isUserItem ? UserListItem : RadioListItem; | ||
|
||
return ( | ||
<OfflineWithFeedback | ||
onClose={() => onDismissError(item)} | ||
pendingAction={item.pendingAction} | ||
errors={item.errors} | ||
errorRowStyles={styles.ph5} | ||
> | ||
<PressableWithFeedback | ||
onPress={() => onSelectRow(item)} | ||
disabled={isDisabled} | ||
accessibilityLabel={item.text} | ||
accessibilityRole={CONST.ACCESSIBILITY_ROLE.BUTTON} | ||
hoverDimmingValue={1} | ||
hoverStyle={styles.hoveredComponentBG} | ||
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}} | ||
> | ||
<View | ||
style={[ | ||
styles.flex1, | ||
styles.justifyContentBetween, | ||
styles.sidebarLinkInner, | ||
styles.userSelectNone, | ||
isUserItem ? styles.peopleRow : styles.optionRow, | ||
isFocused && styles.sidebarLinkActive, | ||
]} | ||
> | ||
{canSelectMultiple && ( | ||
<View style={styles.checkboxPressable}> | ||
<View | ||
style={[ | ||
StyleUtils.getCheckboxContainerStyle(20, 4), | ||
styles.mr3, | ||
item.isSelected && styles.checkedContainer, | ||
item.isSelected && styles.borderColorFocus, | ||
item.isDisabled && styles.cursorDisabled, | ||
item.isDisabled && styles.buttonOpacityDisabled, | ||
]} | ||
> | ||
{item.isSelected && ( | ||
<Icon | ||
src={Expensicons.Checkmark} | ||
fill={themeColors.textLight} | ||
height={14} | ||
width={14} | ||
/> | ||
)} | ||
</View> | ||
</View> | ||
)} | ||
|
||
<ListItem | ||
item={item} | ||
isFocused={isFocused} | ||
isDisabled={isDisabled} | ||
onSelectRow={onSelectRow} | ||
showTooltip={showTooltip} | ||
/> | ||
|
||
{!canSelectMultiple && item.isSelected && ( | ||
<View | ||
style={[styles.flexRow, styles.alignItemsCenter, styles.ml3]} | ||
accessible={false} | ||
> | ||
<View> | ||
<Icon | ||
src={Expensicons.Checkmark} | ||
fill={themeColors.success} | ||
/> | ||
</View> | ||
</View> | ||
)} | ||
</View> | ||
</PressableWithFeedback> | ||
</OfflineWithFeedback> | ||
); | ||
} | ||
|
||
BaseListItem.displayName = 'BaseListItem'; | ||
BaseListItem.propTypes = baseListItemPropTypes; | ||
|
||
export default BaseListItem; |
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
Oops, something went wrong.