Skip to content
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

Update Fallback Avatar to Support Themes #38674

Merged
merged 20 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
prettier and type fix
  • Loading branch information
grgia committed Mar 20, 2024
commit 6c85462631e56436b6350cb36b603b872b493567
10 changes: 3 additions & 7 deletions src/components/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import type {AvatarSource} from '@libs/UserUtils';
import type {AvatarSizeName} from '@styles/utils';
import CONST from '@src/CONST';
import type {SVGAvatarColorStyle} from '@src/styles/utils/types';

Check failure on line 12 in src/components/Avatar.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Module '"@src/styles/utils/types"' has no exported member 'SVGAvatarColorStyle'.
import type {AvatarType} from '@src/types/onyx/OnyxCommon';
import type {SVGAvatarColorStyle} from '@src/types';
import Icon from './Icon';
import * as Expensicons from './Icon/Expensicons';
import Image from './Image';
Expand Down Expand Up @@ -93,7 +93,7 @@
iconColors = null;
}

const fallbackAvatar = isWorkspace ? ReportUtils.getDefaultWorkspaceAvatar(name) : (fallbackIcon || Expensicons.FallbackAvatar);
const fallbackAvatar = isWorkspace ? ReportUtils.getDefaultWorkspaceAvatar(name) : fallbackIcon || Expensicons.FallbackAvatar;
const fallbackAvatarTestID = isWorkspace ? ReportUtils.getDefaultWorkspaceAvatarTestID(name) : fallbackIconTestID || 'SvgFallbackAvatar Icon';

const avatarSource = imageError ? fallbackAvatar : source;
Expand All @@ -112,15 +112,11 @@
<View style={iconStyle}>
<Icon
testID={fallbackAvatarTestID}
src={avatarSource}

Check failure on line 115 in src/components/Avatar.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Type 'number | FC<SvgProps> | ImageURISource | ImageURISource[] | undefined' is not assignable to type 'IconAsset'.
height={iconSize}
width={iconSize}
fill={imageError ? theme.offline : fill}
additionalStyles={[
StyleUtils.getAvatarBorderStyle(size, type),
iconColors,
iconAdditionalStyles,
]}
additionalStyles={[StyleUtils.getAvatarBorderStyle(size, type), iconColors, iconAdditionalStyles]}
/>
</View>
)}
Expand Down
2 changes: 1 addition & 1 deletion src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import lodashSet from 'lodash/set';
import lodashSortBy from 'lodash/sortBy';
import Onyx from 'react-native-onyx';
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
import {FallbackAvatar} from '@components/Icon/Expensicons';
import CONST from '@src/CONST';
import type {TranslationPaths} from '@src/languages/types';
import ONYXKEYS from '@src/ONYXKEYS';
Expand Down Expand Up @@ -34,7 +35,6 @@ import type DeepValueOf from '@src/types/utils/DeepValueOf';
import type {EmptyObject} from '@src/types/utils/EmptyObject';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import times from '@src/utils/times';
import {FallbackAvatar} from '@components/Icon/Expensicons';
import Timing from './actions/Timing';
import * as CollectionUtils from './CollectionUtils';
import * as ErrorUtils from './ErrorUtils';
Expand Down
3 changes: 1 addition & 2 deletions src/styles/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
EReceiptColorName,
EreceiptColorStyle,
ParsableStyle,
TextColorStyle,
SVGAvatarColorStyle,

Check failure on line 41 in src/styles/utils/index.ts

View workflow job for this annotation

GitHub Actions / typecheck

Module '"./types"' has no exported member 'SVGAvatarColorStyle'.
TextColorStyle,
} from './types';

const workspaceColorOptions: SVGAvatarColorStyle[] = [
Expand Down Expand Up @@ -273,10 +273,9 @@
function getDefaultWorkspaceAvatarColor(workspaceName: string): ViewStyle {
const colorHash = UserUtils.hashText(workspaceName.trim(), workspaceColorOptions.length);

return workspaceColorOptions[colorHash];

Check failure on line 276 in src/styles/utils/index.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unsafe return of an `any` typed value
}


/**
* Helper method to return formatted backgroundColor and fill styles
*/
Expand Down
Loading