-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
77 changed files
with
1,257 additions
and
364 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ViewStyle } from "react-native" | ||
|
||
export interface AvatarProps { | ||
/** | ||
* The URL of the avatar | ||
*/ | ||
src: string | ||
|
||
/** | ||
* The size of the avatar. Default is `64` pt. | ||
*/ | ||
size?: number | ||
|
||
/** | ||
* Set to `true` to display the Civic Liker halo. Default is `false` | ||
*/ | ||
isCivicLiker?: boolean | ||
|
||
/** | ||
* An optional style override useful for padding & margin. | ||
*/ | ||
style?: ViewStyle | ||
} |
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,27 @@ | ||
import { | ||
ImageStyle, | ||
StyleSheet, | ||
ViewStyle, | ||
} from "react-native" | ||
import { color, spacing } from "../../theme" | ||
|
||
export const AvatarStyle = StyleSheet.create({ | ||
Gradient: { | ||
borderWidth: spacing[1], | ||
borderColor: color.transparent, | ||
margin: spacing[1], | ||
} as ViewStyle, | ||
Halo: { | ||
position: "absolute", | ||
top: 0, | ||
left: 0, | ||
right: 0, | ||
bottom: 0, | ||
} as ViewStyle, | ||
Image: { | ||
overflow: "hidden", | ||
} as ImageStyle, | ||
Root: { | ||
position: "relative", | ||
} as ViewStyle, | ||
}) |
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,68 @@ | ||
import * as React from "react" | ||
import { View, ViewStyle, Image, ImageStyle, StyleSheet } from "react-native" | ||
import LinearGradient from "react-native-linear-gradient" | ||
|
||
import { AvatarProps as Props } from "./avatar.props" | ||
import { AvatarStyle as Style } from "./avatar.style" | ||
import CivicLikerHalo from "./civic-liker-halo.svg" | ||
|
||
import { gradient } from "../../theme" | ||
|
||
/** | ||
* Avatar for Liker | ||
*/ | ||
function AvatarComponent(props: Props) { | ||
const { src, size, isCivicLiker, style, ...rest } = props | ||
|
||
const rootStyle = React.useMemo( | ||
() => [Style.Root, style], | ||
[style] | ||
) | ||
|
||
const imageStyle = React.useMemo( | ||
() => StyleSheet.flatten([ | ||
Style.Image, | ||
{ | ||
width: size, | ||
height: size, | ||
borderRadius: size / 2, | ||
} as ImageStyle | ||
]), | ||
[size] | ||
) | ||
|
||
const gradientStyle = React.useMemo( | ||
() => [ | ||
Style.Gradient, | ||
{ | ||
borderRadius: imageStyle.borderRadius + Style.Gradient.borderWidth, | ||
} as ViewStyle, | ||
], | ||
[size] | ||
) | ||
|
||
return ( | ||
<View style={rootStyle} {...rest}> | ||
<LinearGradient | ||
colors={gradient.LikeCoin} | ||
start={{ x: 0.0, y: 1.0 }} | ||
end={{ x: 1.0, y: 0.0 }} | ||
style={gradientStyle} | ||
> | ||
<Image | ||
style={imageStyle} | ||
source={{ uri: src }} | ||
/> | ||
</LinearGradient> | ||
{isCivicLiker && <CivicLikerHalo style={Style.Halo} />} | ||
</View> | ||
) | ||
} | ||
|
||
AvatarComponent.displayName = "Avatar" | ||
|
||
AvatarComponent.defaultProps = { | ||
size: 64, | ||
} as Partial<Props> | ||
|
||
export const Avatar = React.memo(AvatarComponent) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ | ||
export * from "./avatar" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.