-
Notifications
You must be signed in to change notification settings - Fork 51
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
24 changed files
with
561 additions
and
34 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,35 @@ | ||
import {useId} from 'react'; | ||
import {ImageSourcePropType} from 'react-native'; | ||
import {Defs, Image, ImageProps, Path, Pattern, Svg} from 'react-native-svg'; | ||
|
||
export type AvatarProps = ImageProps & { | ||
size?: number; | ||
source?: ImageSourcePropType; | ||
}; | ||
|
||
export const Avatar: React.FC<AvatarProps> = ({size, source}) => { | ||
const id = useId(); | ||
|
||
return ( | ||
<Svg width={size} height={size} viewBox="0 0 96 96" fill="none"> | ||
<Path | ||
d="M40.75 4.91784C45.2363 2.32766 50.7637 2.32766 55.25 4.91784L81.6852 20.1802C86.1716 22.7704 88.9352 27.5573 88.9352 32.7376V63.2624C88.9352 68.4427 86.1716 73.2296 81.6852 75.8198L55.25 91.0822C50.7637 93.6723 45.2363 93.6723 40.75 91.0822L14.3148 75.8198C9.82844 73.2296 7.06475 68.4427 7.06475 63.2624V32.7376C7.06475 27.5573 9.82844 22.7704 14.3148 20.1802L40.75 4.91784Z" | ||
fill={`url(#pattern_${id})`} | ||
stroke="#F4F9FF" | ||
strokeWidth="3" | ||
/> | ||
|
||
<Defs> | ||
<Pattern id={`pattern_${id}`} patternUnits="userSpaceOnUse" width="96" height="96"> | ||
<Image | ||
id={`image_${id}`} | ||
width="96" | ||
height="96" | ||
preserveAspectRatio="xMinYMin slice" | ||
xlinkHref={source} | ||
/> | ||
</Pattern> | ||
</Defs> | ||
</Svg> | ||
); | ||
}; |
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,33 @@ | ||
import {useStyles} from '../../hooks'; | ||
import {Input, InputProps} from '../Input'; | ||
import stylesheet from './styles'; | ||
|
||
export type SquareInputProps = InputProps; | ||
|
||
export const SquareInput: React.FC<SquareInputProps> = (props) => { | ||
const { | ||
error, | ||
left, | ||
right, | ||
style: styleProp, | ||
containerStyle: containerStyleProp, | ||
inputStyle: inputStyleProp, | ||
multiline, | ||
...inputProps | ||
} = props; | ||
|
||
const styles = useStyles(stylesheet, !!left, !!right, !!multiline); | ||
|
||
return ( | ||
<Input | ||
style={[styles.content, styleProp]} | ||
containerStyle={[styles.container, containerStyleProp]} | ||
inputStyle={[styles.input, inputStyleProp]} | ||
error={error} | ||
left={left} | ||
right={right} | ||
multiline={multiline} | ||
{...inputProps} | ||
/> | ||
); | ||
}; |
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,40 @@ | ||
import {Spacing, ThemedStyleSheet} from '../../styles'; | ||
|
||
export default ThemedStyleSheet((theme, left: boolean, right: boolean, multiline: boolean) => ({ | ||
container: { | ||
width: '100%', | ||
}, | ||
content: { | ||
borderRadius: 8, | ||
height: 48, | ||
|
||
...(multiline && { | ||
height: 110, | ||
}), | ||
|
||
...(left && { | ||
paddingLeft: Spacing.small, | ||
}), | ||
|
||
...(right && { | ||
paddingRight: Spacing.small, | ||
}), | ||
}, | ||
|
||
input: { | ||
paddingHorizontal: Spacing.small, | ||
|
||
...(multiline && { | ||
paddingVertical: Spacing.small, | ||
textAlignVertical: 'top', | ||
}), | ||
|
||
...(left && { | ||
paddingLeft: Spacing.none, | ||
}), | ||
|
||
...(right && { | ||
paddingRight: Spacing.none, | ||
}), | ||
}, | ||
})); |
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,35 @@ | ||
import {NDKUserProfile} from '@nostr-dev-kit/ndk'; | ||
import {useMutation} from '@tanstack/react-query'; | ||
|
||
import {useNostrContext} from '../context/NostrContext'; | ||
import {useAuth} from '../store/auth'; | ||
|
||
export const useEditProfile = () => { | ||
const {ndk} = useNostrContext(); | ||
const {publicKey, privateKey} = useAuth(); | ||
|
||
return useMutation({ | ||
mutationKey: ['editProfile'], | ||
mutationFn: async (data: NDKUserProfile) => { | ||
try { | ||
if (!privateKey) { | ||
throw new Error('Private key is required'); | ||
} | ||
|
||
const user = ndk.getUser({pubkey: publicKey}); | ||
await user.fetchProfile(); | ||
|
||
if (!user.profile) { | ||
throw new Error('Profile not found'); | ||
} | ||
|
||
user.profile = {...user.profile, ...data}; | ||
|
||
return user.publish(); | ||
} catch (error) { | ||
console.error('Error editing profile', error); | ||
throw error; | ||
} | ||
}, | ||
}); | ||
}; |
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
Oops, something went wrong.