-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add BannerImage and AvatarImage components
- Loading branch information
1 parent
e5f773d
commit 6e65c61
Showing
4 changed files
with
62 additions
and
0 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,28 @@ | ||
import { type Image as ExpoImage } from 'expo-image'; | ||
import React from 'react'; | ||
|
||
import DEFAULT_AVATAR from '@/assets/img/default_avatar.png'; | ||
import Image, { type ImageProps } from '@/components/content/Image'; | ||
|
||
export { ImageFragment as AvatarImageFragment } from '@/components/content/Image'; | ||
|
||
export type AvatarImageProps = ImageProps & { | ||
size: number; | ||
}; | ||
|
||
export default React.forwardRef<ExpoImage, AvatarImageProps>( | ||
function AvatarImage({ size, style, source, ...props }, ref) { | ||
source = source ?? { | ||
views: [{ url: DEFAULT_AVATAR, height: 190, width: 190 }], | ||
blurhash: 'UNGSJtogKQWB~qof9Zay4:of?GogIpof-okC', | ||
}; | ||
return ( | ||
<Image | ||
ref={ref} | ||
source={source} | ||
style={[{ width: size, height: size, borderRadius: size / 2 }, style]} | ||
{...props} | ||
/> | ||
); | ||
} | ||
); |
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,2 @@ | ||
export { default } from './AvatarImage'; | ||
export * from './AvatarImage'; |
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,30 @@ | ||
import { type Image as ExpoImage } from 'expo-image'; | ||
import React from 'react'; | ||
import Animated from 'react-native-reanimated'; | ||
|
||
import DEFAULT_BANNER from '@/assets/img/default_cover.png'; | ||
import Image, { type ImageProps } from '@/components/content/Image'; | ||
|
||
export { ImageFragment as BannerImageFragment } from '@/components/content/Image'; | ||
|
||
export type BannerImageProps = ImageProps; | ||
|
||
export default Animated.createAnimatedComponent( | ||
React.forwardRef<ExpoImage, BannerImageProps>(function BannerImage( | ||
{ style, source, ...props }, | ||
ref | ||
) { | ||
source = source ?? { | ||
views: [{ url: DEFAULT_BANNER, height: 400, width: 1440 }], | ||
blurhash: 'c16b#q_M00nD4WQwyaTCio%w%NRQS#nSVu', | ||
}; | ||
return ( | ||
<Image | ||
ref={ref} | ||
source={source} | ||
style={[{ width: '100%' }, style]} | ||
{...props} | ||
/> | ||
); | ||
}) | ||
); |
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,2 @@ | ||
export { default } from './BannerImage'; | ||
export * from './BannerImage'; |