Skip to content

Commit

Permalink
Merge pull request #38218 from shubham1206agra/redesign-ws-invite-page
Browse files Browse the repository at this point in the history
Move the position of checkmark in WS Invite Page
  • Loading branch information
luacmartins authored Mar 13, 2024
2 parents 34930fe + d01452a commit 13f8bc0
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/components/SelectionList/BaseListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Icon from '@components/Icon';
import * as Expensicons from '@components/Icon/Expensicons';
import OfflineWithFeedback from '@components/OfflineWithFeedback';
import PressableWithFeedback from '@components/Pressable/PressableWithFeedback';
import SelectCircle from '@components/SelectCircle';
import useHover from '@hooks/useHover';
import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
Expand All @@ -23,6 +24,7 @@ function BaseListItem<TItem extends ListItem>({
onCheckboxPress,
onDismissError = () => {},
rightHandSideComponent,
checkmarkPosition = CONST.DIRECTION.LEFT,
keyForList,
errors,
pendingAction,
Expand Down Expand Up @@ -76,7 +78,7 @@ function BaseListItem<TItem extends ListItem>({
style={pressableStyle}
>
<View style={wrapperStyle}>
{canSelectMultiple && (
{canSelectMultiple && checkmarkPosition === CONST.DIRECTION.LEFT && (
<PressableWithFeedback
accessibilityLabel={item.text ?? ''}
role={CONST.ROLE.BUTTON}
Expand All @@ -100,6 +102,21 @@ function BaseListItem<TItem extends ListItem>({

{typeof children === 'function' ? children(hovered) : children}

{canSelectMultiple && checkmarkPosition === CONST.DIRECTION.RIGHT && (
<PressableWithFeedback
onPress={handleCheckboxPress}
disabled={isDisabled}
role={CONST.ROLE.BUTTON}
accessibilityLabel={item.text ?? ''}
style={[styles.ml2, styles.optionSelectCircle]}
>
<SelectCircle
isChecked={item.isSelected ?? false}
selectCircleStyles={styles.ml0}
/>
</PressableWithFeedback>
)}

{!canSelectMultiple && item.isSelected && !rightHandSideComponent && (
<View
style={[styles.flexRow, styles.alignItemsCenter, styles.ml3]}
Expand Down
2 changes: 2 additions & 0 deletions src/components/SelectionList/BaseSelectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ function BaseSelectionList<TItem extends ListItem>(
shouldShowTooltips = true,
shouldUseDynamicMaxToRenderPerBatch = false,
rightHandSideComponent,
checkmarkPosition,
isLoadingNewOptions = false,
onLayout,
customListHeader,
Expand Down Expand Up @@ -330,6 +331,7 @@ function BaseSelectionList<TItem extends ListItem>(
onDismissError={() => onDismissError?.(item)}
shouldPreventDefaultFocusOnSelectRow={shouldPreventDefaultFocusOnSelectRow}
rightHandSideComponent={rightHandSideComponent}
checkmarkPosition={checkmarkPosition}
keyForList={item.keyForList ?? ''}
isMultilineSupported={isRowMultilineSupported}
/>
Expand Down
2 changes: 2 additions & 0 deletions src/components/SelectionList/RadioListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function RadioListItem({
onDismissError,
shouldPreventDefaultFocusOnSelectRow,
rightHandSideComponent,
checkmarkPosition,
isMultilineSupported = false,
}: RadioListItemProps) {
const styles = useThemeStyles();
Expand All @@ -36,6 +37,7 @@ function RadioListItem({
onDismissError={onDismissError}
shouldPreventDefaultFocusOnSelectRow={shouldPreventDefaultFocusOnSelectRow}
rightHandSideComponent={rightHandSideComponent}
checkmarkPosition={checkmarkPosition}
keyForList={item.keyForList}
>
<>
Expand Down
2 changes: 2 additions & 0 deletions src/components/SelectionList/TableListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function TableListItem({
onDismissError,
shouldPreventDefaultFocusOnSelectRow,
rightHandSideComponent,
checkmarkPosition,
}: TableListItemProps) {
const styles = useThemeStyles();
const theme = useTheme();
Expand All @@ -42,6 +43,7 @@ function TableListItem({
onDismissError={onDismissError}
shouldPreventDefaultFocusOnSelectRow={shouldPreventDefaultFocusOnSelectRow}
rightHandSideComponent={rightHandSideComponent}
checkmarkPosition={checkmarkPosition}
errors={item.errors}
pendingAction={item.pendingAction}
keyForList={item.keyForList}
Expand Down
2 changes: 2 additions & 0 deletions src/components/SelectionList/UserListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function UserListItem({
onDismissError,
shouldPreventDefaultFocusOnSelectRow,
rightHandSideComponent,
checkmarkPosition,
}: UserListItemProps) {
const styles = useThemeStyles();
const theme = useTheme();
Expand All @@ -47,6 +48,7 @@ function UserListItem({
onDismissError={onDismissError}
shouldPreventDefaultFocusOnSelectRow={shouldPreventDefaultFocusOnSelectRow}
rightHandSideComponent={rightHandSideComponent}
checkmarkPosition={checkmarkPosition}
errors={item.errors}
pendingAction={item.pendingAction}
FooterComponent={
Expand Down
7 changes: 7 additions & 0 deletions src/components/SelectionList/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type {MutableRefObject, ReactElement, ReactNode} from 'react';
import type {GestureResponderEvent, InputModeOptions, LayoutChangeEvent, SectionListData, StyleProp, TextInput, TextStyle, ViewStyle} from 'react-native';
import type {ValueOf} from 'type-fest';
import type {MaybePhraseKey} from '@libs/Localize';
import type CONST from '@src/CONST';
import type {Errors, Icon, PendingAction} from '@src/types/onyx/OnyxCommon';
Expand Down Expand Up @@ -34,6 +35,9 @@ type CommonListItemProps<TItem> = {
/** Component to display on the right side */
rightHandSideComponent?: ((item: TItem) => ReactElement<TItem>) | ReactElement | null;

/** Direction of checkmark to show */
checkmarkPosition?: ValueOf<typeof CONST.DIRECTION>;

/** Styles for the pressable component */
pressableStyle?: StyleProp<ViewStyle>;

Expand Down Expand Up @@ -270,6 +274,9 @@ type BaseSelectionListProps<TItem extends ListItem> = Partial<ChildrenProps> & {
/** Component to display on the right side of each child */
rightHandSideComponent?: ((item: ListItem) => ReactElement<ListItem>) | ReactElement | null;

/** Direction of checkmark to show */
checkmarkPosition?: ValueOf<typeof CONST.DIRECTION>;

/** Whether to show the loading indicator for new options */
isLoadingNewOptions?: boolean;

Expand Down
1 change: 1 addition & 0 deletions src/pages/workspace/WorkspaceInvitePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ function WorkspaceInvitePage({
showScrollIndicator
showLoadingPlaceholder={!didScreenTransitionEnd || !OptionsListUtils.isPersonalDetailsReady(personalDetailsProp)}
shouldPreventDefaultFocusOnSelectRow={!DeviceCapabilities.canUseTouchScreen()}
checkmarkPosition={CONST.DIRECTION.RIGHT}
/>
<View style={[styles.flexShrink0]}>
<FormAlertWithSubmitButton
Expand Down

0 comments on commit 13f8bc0

Please sign in to comment.