Skip to content

Commit

Permalink
Use plain RN image for startup-blocking UI
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Nov 3, 2023
1 parent 5e2025e commit 250a701
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 11 deletions.
29 changes: 21 additions & 8 deletions src/view/com/util/UserAvatar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, {useMemo} from 'react'
import {StyleSheet, View} from 'react-native'
import {Image, StyleSheet, View} from 'react-native'
import Svg, {Circle, Rect, Path} from 'react-native-svg'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import {HighPriorityImage} from 'view/com/util/images/Image'
Expand Down Expand Up @@ -27,6 +27,7 @@ interface BaseUserAvatarProps {

interface UserAvatarProps extends BaseUserAvatarProps {
moderation?: ModerationUI
usePlainRNImage?: boolean
}

interface EditableUserAvatarProps extends BaseUserAvatarProps {
Expand Down Expand Up @@ -110,6 +111,7 @@ export function UserAvatar({
size,
avatar,
moderation,
usePlainRNImage = false,
}: UserAvatarProps) {
const pal = usePalette('default')

Expand Down Expand Up @@ -146,13 +148,24 @@ export function UserAvatar({
return avatar &&
!((moderation?.blur && isAndroid) /* android crashes with blur */) ? (
<View style={{width: size, height: size}}>
<HighPriorityImage
testID="userAvatarImage"
style={aviStyle}
contentFit="cover"
source={{uri: avatar}}
blurRadius={moderation?.blur ? BLUR_AMOUNT : 0}
/>
{usePlainRNImage ? (
<Image
accessibilityIgnoresInvertColors
testID="userAvatarImage"
style={aviStyle}
resizeMode="cover"
source={{uri: avatar}}
blurRadius={moderation?.blur ? BLUR_AMOUNT : 0}
/>
) : (
<HighPriorityImage
testID="userAvatarImage"
style={aviStyle}
contentFit="cover"
source={{uri: avatar}}
blurRadius={moderation?.blur ? BLUR_AMOUNT : 0}
/>
)}
{alert}
</View>
) : (
Expand Down
6 changes: 5 additions & 1 deletion src/view/shell/Drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,11 @@ export const DrawerContent = observer(function DrawerContentImpl() {
accessibilityLabel="Profile"
accessibilityHint="Navigates to your profile"
onPress={onPressProfile}>
<UserAvatar size={80} avatar={store.me.avatar} />
<UserAvatar
size={80}
avatar={store.me.avatar}
usePlainRNImage={true}
/>
<Text
type="title-lg"
style={[pal.text, s.bold, styles.profileCardDisplayName]}
Expand Down
12 changes: 10 additions & 2 deletions src/view/shell/bottom-bar/BottomBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,19 @@ export const BottomBar = observer(function BottomBarImpl({
styles.onProfile,
{borderColor: pal.text.color},
]}>
<UserAvatar avatar={store.me.avatar} size={27} />
<UserAvatar
avatar={store.me.avatar}
size={27}
usePlainRNImage={true}
/>
</View>
) : (
<View style={[styles.ctrlIcon, pal.text, styles.profileIcon]}>
<UserAvatar avatar={store.me.avatar} size={28} />
<UserAvatar
avatar={store.me.avatar}
size={28}
usePlainRNImage={true}
/>
</View>
)}
</View>
Expand Down

0 comments on commit 250a701

Please sign in to comment.