bottom sheet and other fixes

This commit is contained in:
KoalaSat 2023-01-18 22:54:28 +01:00
parent e89c4ba380
commit 4c6fdec00c
No known key found for this signature in database
GPG Key ID: 2F7F61C6146AB157
30 changed files with 277 additions and 229 deletions

Binary file not shown.

View File

@ -42,18 +42,6 @@ public class Websocket {
}
}
webSocket.sendText(message);
try {
JSONArray jsonArray = null;
jsonArray = new JSONArray(message);
String messageType = jsonArray.get(0).toString();
if (messageType.equals("EVENT")) {
JSONObject data = jsonArray.getJSONObject(2);
data.put("created_at", String.valueOf(System.currentTimeMillis() / 1000L));
database.saveEvent(data, pubKey);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
public void disconnect() {

View File

@ -70,10 +70,11 @@ export const LnPayment: React.FC<TextContentProps> = ({ open, setOpen, event, us
const rbSheetCustomStyles = React.useMemo(() => {
return {
container: {
...styles.rbsheetContainer,
backgroundColor: theme.colors.background,
padding: 16,
borderTopRightRadius: 28,
borderTopLeftRadius: 28,
},
draggableIcon: styles.rbsheetDraggableIcon,
}
}, [])
@ -159,14 +160,12 @@ export const LnPayment: React.FC<TextContentProps> = ({ open, setOpen, event, us
<View style={styles.cardActions}>
<View style={styles.actionButton}>
<IconButton icon='content-copy' size={28} onPress={copyInvoice} />
<Text>{t('profileConfigPage.copyNPub')}</Text>
<Text>{t('lnPayment.copy')}</Text>
</View>
<View style={styles.actionButton}>
<IconButton icon='wallet' size={28} onPress={openApp} />
<Text>{t('profileConfigPage.invoice')}</Text>
<Text>{t('lnPayment.open')}</Text>
</View>
<View style={styles.actionButton}></View>
<View style={styles.actionButton}></View>
</View>
</RBSheet>
</>
@ -186,9 +185,6 @@ const styles = StyleSheet.create({
flexDirection: 'row',
justifyContent: 'center',
},
rbsheetDraggableIcon: {
backgroundColor: '#000',
},
rbsheetContainer: {
padding: 16,
borderTopRightRadius: 28,

View File

@ -18,7 +18,7 @@ export const Logo: React.FC<LogoProps> = ({ onlyIcon = false, size = 'small' })
}
return (
<View style={styles.container}>
<SvgXml xml={nostrosLogoSvg} style={[styles.logo, { height: logoHeight[size] }]} />
<SvgXml height={logoHeight[size]} xml={nostrosLogoSvg} style={styles.logo} />
{!onlyIcon && (
<Text style={styles.text} variant={size === 'small' ? 'headlineSmall' : 'displayMedium'}>
NOSTROS
@ -38,7 +38,7 @@ const styles = StyleSheet.create({
alignItems: 'center',
},
text: {
fontFamily: 'SpaceGrotesk-Bold',
fontFamily: 'Iceland-Regular',
flex: 2,
height: 60,
textAlignVertical: 'center',

View File

@ -66,7 +66,7 @@ export const MenuItems: React.FC = () => {
<View style={styles.cardAvatar}>
<NostrosAvatar
name={user?.name}
pubKey={publicKey ?? ''}
pubKey={nPub ?? ''}
src={user?.picture}
lud06={user?.lnurl}
/>

View File

@ -27,6 +27,7 @@ import {
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'
import { REGEX_SOCKET_LINK } from '../../Constants/Relay'
import { push } from '../../lib/Navigation'
import { npubEncode } from 'nostr-tools/nip19'
interface NoteCardProps {
note: Note
@ -51,6 +52,7 @@ export const NoteCard: React.FC<NoteCardProps> = ({
const [repliesCount, setRepliesCount] = React.useState<number>(0)
const [hide, setHide] = useState<boolean>(isContentWarning(note))
const timestamp = useMemo(() => moment.unix(note.created_at).format('HH:mm DD-MM-YY'), [note])
const nPub = useMemo(() => npubEncode(note.pubkey), [note])
useEffect(() => {
if (database && publicKey && note.id) {
@ -187,14 +189,14 @@ export const NoteCard: React.FC<NoteCardProps> = ({
<View>
<NostrosAvatar
name={note.name}
pubKey={note.pubkey}
pubKey={nPub}
src={note.picture}
lud06={note.lnurl}
size={54}
/>
</View>
<View>
<Text>{usernamePubKey(note.name, note.pubkey)}</Text>
<Text>{usernamePubKey(note.name, nPub)}</Text>
<Text>{timestamp}</Text>
</View>
</View>
@ -221,6 +223,7 @@ export const NoteCard: React.FC<NoteCardProps> = ({
size={25}
/>
)}
disabled={userDownvoted}
>
{negaiveReactions === undefined || negaiveReactions === 0 ? '-' : negaiveReactions}
</Button>
@ -238,6 +241,7 @@ export const NoteCard: React.FC<NoteCardProps> = ({
size={25}
/>
)}
disabled={userUpvoted}
>
{positiveReactions === undefined || positiveReactions === 0 ? '-' : positiveReactions}
</Button>

View File

@ -27,6 +27,7 @@ export const ProfileCard: React.FC<ProfileCardProps> = ({ userPubKey, bottomShee
const [openLn, setOpenLn] = React.useState<boolean>(false)
const [isContact, setIsContact] = React.useState<boolean>()
const [showNotification, setShowNotification] = React.useState<undefined | string>()
const nPub = React.useMemo(() => npubEncode(userPubKey), [userPubKey])
React.useEffect(() => {
loadUser()
@ -77,7 +78,7 @@ export const ProfileCard: React.FC<ProfileCardProps> = ({ userPubKey, bottomShee
<View>
<NostrosAvatar
name={user?.name}
pubKey={userPubKey}
pubKey={nPub}
src={user?.picture}
lud06={user?.lnurl}
size={54}
@ -134,8 +135,7 @@ export const ProfileCard: React.FC<ProfileCardProps> = ({ userPubKey, bottomShee
size={28}
onPress={() => {
setShowNotification('npubCopied')
const profileNPud = npubEncode(userPubKey)
Clipboard.setString(profileNPud ?? '')
Clipboard.setString(nPub ?? '')
}}
/>
<Text>{t('profileCard.copyNPub')}</Text>

View File

@ -14,6 +14,8 @@ import { navigate } from '../lib/Navigation'
import { npubEncode, nsecEncode } from 'nostr-tools/nip19'
export interface UserContextProps {
userState: 'loading' | 'access' | 'ready'
setUserState: (userState: 'loading' | 'access' | 'ready') => void
nPub?: string
nSec?: string
publicKey?: string
@ -35,6 +37,8 @@ export interface UserContextProviderProps {
}
export const initialUserContext: UserContextProps = {
userState: 'loading',
setUserState: () => {},
setPublicKey: () => {},
setPrivateKey: () => {},
setUser: () => {},
@ -49,6 +53,7 @@ export const initialUserContext: UserContextProps = {
export const UserContextProvider = ({ children }: UserContextProviderProps): JSX.Element => {
const { database, loadingDb, init } = useContext(AppContext)
const { relayPool } = useContext(RelayPoolContext)
const [userState, setUserState] = useState<'loading' | 'access' | 'ready'>('loading')
const [publicKey, setPublicKey] = useState<string>()
const [nPub, setNpub] = useState<string>()
const [nSec, setNsec] = useState<string>()
@ -85,6 +90,7 @@ export const UserContextProvider = ({ children }: UserContextProviderProps): JSX
SInfo.deleteItem('privateKey', {}).then(() => {
SInfo.deleteItem('publicKey', {}).then(() => {
init()
setUserState('access')
navigate('Home', { screen: 'ProfileConnect' })
})
})
@ -109,22 +115,25 @@ export const UserContextProvider = ({ children }: UserContextProviderProps): JSX
}
}, [publicKey])
useEffect(() => {
if (userState === 'ready' && publicKey) {
navigate('Feed')
}
}, [userState, publicKey])
useEffect(() => {
if (!loadingDb) {
SInfo.getItem('privateKey', {}).then((privateResult) => {
if (privateResult && privateResult !== '') {
setPrivateKey(privateResult)
setPublicKey(getPublickey(privateResult))
navigate('Feed')
}
})
SInfo.getItem('publicKey', {}).then((publicResult) => {
if (publicResult && publicResult !== '') {
setPublicKey(publicResult)
setUserState('ready')
} else {
SInfo.getItem('publicKey', {}).then((publicResult) => {
if (publicResult && publicResult !== '') {
setPublicKey(publicResult)
navigate('Feed')
} else {
navigate('Home')
}
})
setUserState('access')
}
})
}
@ -133,6 +142,8 @@ export const UserContextProvider = ({ children }: UserContextProviderProps): JSX
return (
<UserContext.Provider
value={{
userState,
setUserState,
nSec,
nPub,
setUser,

View File

@ -3,6 +3,7 @@ import { QuickSQLiteConnection } from 'react-native-quick-sqlite'
import RelayPool from '../../../lib/nostr/RelayPool/intex'
import { getUser, getUsers, User } from '../../DatabaseFunctions/Users'
import { Event } from '../../../lib/nostr/Events'
import { npubEncode } from 'nostr-tools/nip19'
export const usersToTags: (users: User[]) => string[][] = (users) => {
return users.map((user): string[] => {
@ -19,7 +20,7 @@ export const tagToUser: (tag: string[]) => User = (tag) => {
}
export const username: (user: User) => string = (user) => {
return user.name && user.name !== '' ? user.name : formatPubKey(user.id)
return user.name && user.name !== '' ? user.name : formatPubKey(npubEncode(user.id))
}
export const usernamePubKey: (name: string, pubKey: string) => string = (name, pubKey) => {

View File

@ -9,7 +9,8 @@
"publicKeysDescription": "Piensa en la clave pública como tu nombre de usuario (como tu @handle en Twitter). Compártela con otras personas para que te añadan a su red.",
"privateKey": "Clave privada",
"privateKeyDescription": "Piensa en tu clave privada como tu contraseña.",
"privateKeysSnackbar": "Muy importante. Guarda tu clave privada en un lugar seguro, si la pierdes no podrás volver a acceder con ella ni recuperar tu cuenta."
"privateKeysSnackbarTitle": "Muy importante.",
"privateKeysSnackbarDescription": "Guarda tu clave privada en un lugar seguro, si la pierdes no podrás volver a acceder con ella ni recuperar tu cuenta."
},
"homeNavigator": {
"ProfileCreate": "",
@ -34,7 +35,7 @@
"profileLoadPage": {
"relaysDescripion": "Connect with other relays if you have problems finding your data.",
"relays": "See relays",
"home": "Access",
"home": "Go Home",
"searchingProfile": "Searching for your profile",
"foundProfile": "Found profile",
"foundContacts": "{{contactsCount}} contacts found"
@ -64,7 +65,10 @@
"monto": "Cantity (sats.)",
"comment": "Comment (optional)",
"generateInvoice": "Generate invoice",
"cancel": "Cancel"
"cancel": "Cancel",
"npub": "Public key",
"copy": "Copy",
"open": "Open wallet"
},
"notificationsFeed": {
"emptyTitle": "You don't have notifications",
@ -75,10 +79,9 @@
"notifications": {
"copied": "Private key copied.\n\nSave this key on a safe place."
},
"snackbarDescription": "Important. Save your key on a safe place, if loose it, you won't be able to access or recover your profile.",
"snackbarAction": "Copy private key",
"warningTitle": "Importante",
"warningDescription": "Guarda tu clave privada en un lugar seguro, si la pierdes, no podrás acceder a tu perfil ni recuperarlo.",
"warningTitle": "Important",
"warningDescription": "Save your key on a safe place, if loose it, you won't be able to access or recover your profile.",
"warningAction": "Copy private key",
"accessButton": "Access",
"label": "Private key",
"copied": "Key copied",

View File

@ -31,7 +31,6 @@ import {
TouchableRipple,
useTheme,
} from 'react-native-paper'
import { Tabs, TabScreen } from 'react-native-paper-tabs'
import NostrosAvatar from '../../Components/NostrosAvatar'
import { navigate } from '../../lib/Navigation'
import RBSheet from 'react-native-raw-bottom-sheet'
@ -41,6 +40,7 @@ import {
Route,
SceneRendererProps,
} from 'react-native-tab-view/lib/typescript/src/types'
import { npubEncode } from 'nostr-tools/nip19'
export const ContactsFeed: React.FC = () => {
const { t } = useTranslation('common')
@ -55,7 +55,7 @@ export const ContactsFeed: React.FC = () => {
const [contactInput, setContactInput] = useState<string>()
const [isAddingContact, setIsAddingContact] = useState<boolean>(false)
const [showNotification, setShowNotification] = useState<undefined | string>()
const [index, setIndex] = React.useState(0)
const [index] = React.useState(0)
const [routes] = React.useState([
{ key: 'following', title: t('contactsFeed.following', { count: following.length }) },
{ key: 'followers', title: t('contactsFeed.followers', { count: followers.length }) },
@ -153,30 +153,33 @@ export const ContactsFeed: React.FC = () => {
}
}
const renderContactItem: ListRenderItem<User> = ({ index, item }) => (
<TouchableRipple onPress={() => navigate('Profile', { pubKey: item.id })}>
<View key={item.id} style={styles.contactRow}>
<View style={styles.contactInfo}>
<NostrosAvatar
name={item.name}
pubKey={item.id}
src={item.picture}
lud06={item.lnurl}
size={40}
/>
<View style={styles.contactName}>
<Text>{formatPubKey(item.id)}</Text>
{item.name && <Text variant='titleSmall'>{username(item)}</Text>}
const renderContactItem: ListRenderItem<User> = ({ index, item }) => {
const nPub = npubEncode(item.id)
return (
<TouchableRipple onPress={() => navigate('Profile', { pubKey: item.id })}>
<View key={item.id} style={styles.contactRow}>
<View style={styles.contactInfo}>
<NostrosAvatar
name={item.name}
pubKey={nPub}
src={item.picture}
lud06={item.lnurl}
size={40}
/>
<View style={styles.contactName}>
<Text>{formatPubKey(nPub)}</Text>
{item.name && <Text variant='titleSmall'>{username(item)}</Text>}
</View>
</View>
<View style={styles.contactFollow}>
<Button onPress={() => (item.contact ? removeContact(item) : addContact(item))}>
{item.contact ? t('contactsFeed.stopFollowing') : t('contactsFeed.follow')}
</Button>
</View>
</View>
<View style={styles.contactFollow}>
<Button onPress={() => (item.contact ? removeContact(item) : addContact(item))}>
{item.contact ? t('contactsFeed.stopFollowing') : t('contactsFeed.follow')}
</Button>
</View>
</View>
</TouchableRipple>
)
</TouchableRipple>
)
}
const bottomSheetStyles = React.useMemo(() => {
return {
@ -186,9 +189,6 @@ export const ContactsFeed: React.FC = () => {
borderTopRightRadius: 28,
borderTopLeftRadius: 28,
},
draggableIcon: {
backgroundColor: '#000',
},
}
}, [])

View File

@ -36,6 +36,7 @@ import moment from 'moment'
import RBSheet from 'react-native-raw-bottom-sheet'
import { useTranslation } from 'react-i18next'
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'
import { npubEncode } from 'nostr-tools/nip19'
export const ConversationsFeed: React.FC = () => {
const theme = useTheme()
@ -107,7 +108,7 @@ export const ConversationsFeed: React.FC = () => {
<View style={styles.contactUser}>
<NostrosAvatar
name={user.name}
pubKey={user.id}
pubKey={npubEncode(user.id)}
src={user.picture}
lud06={user.lnurl}
size={40}
@ -141,9 +142,6 @@ export const ConversationsFeed: React.FC = () => {
borderTopRightRadius: 28,
borderTopLeftRadius: 28,
},
draggableIcon: {
backgroundColor: '#000',
},
}
}, [])
@ -186,7 +184,7 @@ export const ConversationsFeed: React.FC = () => {
<View style={styles.contactUser}>
<NostrosAvatar
name={item.name}
pubKey={item.id}
pubKey={npubEncode(item.id)}
src={item.picture}
lud06={item.lnurl}
size={40}

View File

@ -38,9 +38,6 @@ export const HomeNavigator: React.FC = () => {
borderTopRightRadius: 28,
borderTopLeftRadius: 28,
},
draggableIcon: {
backgroundColor: '#000',
},
}
}, [])

View File

@ -138,9 +138,6 @@ export const HomeFeed: React.FC<HomeFeedProps> = ({ jumpTo }) => {
borderTopRightRadius: 28,
borderTopLeftRadius: 28,
},
draggableIcon: {
backgroundColor: '#000',
},
}
}, [])

View File

@ -1,7 +1,7 @@
import * as React from 'react'
import { Platform, View } from 'react-native'
import { Platform, StyleSheet, View } from 'react-native'
import { CardStyleInterpolators, createStackNavigator } from '@react-navigation/stack'
import { Appbar, Snackbar, Text, useTheme } from 'react-native-paper'
import { Appbar, Text, useTheme } from 'react-native-paper'
import ProfileConnectPage from '../../Pages/ProfileConnectPage'
import ProfileLoadPage from '../../Pages/ProfileLoadPage'
import RBSheet from 'react-native-raw-bottom-sheet'
@ -32,16 +32,19 @@ export const HomeNavigator: React.FC = () => {
const BottomSheetKeys = React.useMemo(
() => (
<View>
<View style={styles.bottomSheetKeysContainer}>
<Text variant='headlineSmall'>{t('drawers.keysTitle')}</Text>
<Text variant='bodyMedium'>{t('drawers.keysDescription')}</Text>
<Text variant='titleMedium'>{t('drawers.publicKeys')}</Text>
<Text variant='bodyMedium'>{t('drawers.publicKeysDescription')}</Text>
<Text variant='titleMedium'>{t('drawers.privateKey')}</Text>
<Text variant='bodyMedium'>{t('drawers.privateKeyDescription')}</Text>
<Snackbar visible onDismiss={() => {}}>
{t('drawers.privateKeysSnackbar')}
</Snackbar>
<View style={[styles.warning, { backgroundColor: '#683D00' }]}>
<Text style={[styles.bold, { color: '#FFDCBB' }]}>
{t('drawers.privateKeysSnackbarTitle')}
</Text>
<Text style={{ color: '#FFDCBB' }}>{t('drawers.privateKeysSnackbarDescription')}</Text>
</View>
</View>
),
[],
@ -60,11 +63,11 @@ export const HomeNavigator: React.FC = () => {
const BottomSheets = {
keys: {
component: BottomSheetKeys,
height: 380,
height: 430,
},
relays: {
component: BottomSheetRelays,
height: 600,
height: 680,
},
}
@ -128,9 +131,6 @@ export const HomeNavigator: React.FC = () => {
borderTopRightRadius: 28,
borderTopLeftRadius: 28,
},
draggableIcon: {
backgroundColor: '#000',
},
}}
>
{BottomSheets[bottomSheetPage].component}
@ -139,4 +139,30 @@ export const HomeNavigator: React.FC = () => {
)
}
const styles = StyleSheet.create({
warning: {
borderRadius: 4,
padding: 16,
marginTop: 16,
marginBottom: 16,
},
warningTitle: {
marginBottom: 8,
},
warningAction: {
marginTop: 16,
},
warningActionOuterLayout: {
flexDirection: 'row',
justifyContent: 'flex-end',
},
bottomSheetKeysContainer: {
flex: 1,
justifyContent: 'space-between',
},
bold: {
fontWeight: 'bold',
},
})
export default HomeNavigator

View File

@ -0,0 +1,61 @@
import { createDrawerNavigator } from '@react-navigation/drawer'
import React, { useContext } from 'react'
import { StyleSheet, View } from 'react-native'
import { useTheme } from 'react-native-paper'
import Logo from '../../Components/Logo'
import MenuItems from '../../Components/MenuItems'
import { UserContext } from '../../Contexts/UserContext'
import FeedNavigator from '../FeedNavigator'
import HomeNavigator from '../HomeNavigator'
export const NostrosDrawerNavigator: React.FC = () => {
const theme = useTheme()
const { userState } = useContext(UserContext)
const DrawerNavigator = createDrawerNavigator()
const LoginDrawerNavigator = (
<DrawerNavigator.Screen
name='Home'
component={HomeNavigator}
options={{ headerShown: false }}
/>
)
const HomeDrawerNavigator = (
<DrawerNavigator.Screen
name='Feed'
component={FeedNavigator}
options={{ headerShown: false }}
/>
)
return userState !== 'loading' ? (
<DrawerNavigator.Navigator
drawerContent={({ navigation }) => <MenuItems navigation={navigation} />}
screenOptions={{
drawerStyle: {
borderRadius: 28,
width: 296,
},
}}
>
{userState === 'ready' ? HomeDrawerNavigator : LoginDrawerNavigator}
</DrawerNavigator.Navigator>
) : (
<View style={[styles.logo, { backgroundColor: theme.colors.background }]}>
<Logo size='big' />
</View>
)
}
const styles = StyleSheet.create({
logo: {
justifyContent: 'center',
alignContent: 'center',
flex: 1,
paddingLeft: 50,
},
})
export default NostrosDrawerNavigator

View File

@ -26,6 +26,7 @@ import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityI
import RBSheet from 'react-native-raw-bottom-sheet'
import ProfileCard from '../../Components/ProfileCard'
import { navigate } from '../../lib/Navigation'
import { useFocusEffect } from '@react-navigation/native'
interface NotePageProps {
route: { params: { noteId: string } }
@ -48,13 +49,18 @@ export const NotePage: React.FC<NotePageProps> = ({ route }) => {
const theme = useTheme()
const bottomSheetProfileRef = React.useRef<RBSheet>(null)
useEffect(() => {
relayPool?.unsubscribeAll()
subscribeNotes()
loadNote()
}, [])
useFocusEffect(
React.useCallback(() => {
relayPool?.unsubscribeAll()
subscribeNotes()
loadNote()
return () => relayPool?.unsubscribeAll()
}, []),
)
useEffect(() => {
console.log('loadNote', route.params.noteId)
loadNote()
}, [lastEventId])
@ -150,9 +156,6 @@ export const NotePage: React.FC<NotePageProps> = ({ route }) => {
borderTopRightRadius: 28,
borderTopLeftRadius: 28,
},
draggableIcon: {
backgroundColor: '#000',
},
}
}, [])
@ -211,6 +214,7 @@ export const NotePage: React.FC<NotePageProps> = ({ route }) => {
size={25}
/>
)}
disabled={userDownvoted}
>
{negaiveReactions === undefined || negaiveReactions === 0 ? '-' : negaiveReactions}
</Button>
@ -228,6 +232,7 @@ export const NotePage: React.FC<NotePageProps> = ({ route }) => {
size={25}
/>
)}
disabled={userUpvoted}
>
{positiveReactions === undefined || positiveReactions === 0
? '-'
@ -244,7 +249,7 @@ export const NotePage: React.FC<NotePageProps> = ({ route }) => {
)}
</ScrollView>
<AnimatedFAB
style={[styles.fab, { top: Dimensions.get('window').height - 140 }]}
style={[styles.fabSend, { top: Dimensions.get('window').height - 140 }]}
icon='message-plus-outline'
label='Label'
onPress={() => navigate('Reply', { note })}
@ -252,6 +257,15 @@ export const NotePage: React.FC<NotePageProps> = ({ route }) => {
iconMode='static'
extended={false}
/>
<AnimatedFAB
style={[styles.fabHome, { top: Dimensions.get('window').height - 220 }]}
icon='home-outline'
label='Label'
onPress={() => navigate('Feed')}
animateFrom='right'
iconMode='static'
extended={false}
/>
<RBSheet
ref={bottomSheetProfileRef}
closeOnDragDown={true}
@ -297,7 +311,11 @@ const styles = StyleSheet.create({
loading: {
paddingBottom: 60,
},
fab: {
fabSend: {
right: 16,
position: 'absolute',
},
fabHome: {
right: 16,
position: 'absolute',
},

View File

@ -130,9 +130,6 @@ export const NotificationsFeed: React.FC = () => {
borderTopRightRadius: 28,
borderTopLeftRadius: 28,
},
draggableIcon: {
backgroundColor: '#000',
},
}
}, [])

View File

@ -209,10 +209,11 @@ export const ProfileConfigPage: React.FC = () => {
const rbSheetCustomStyles = React.useMemo(() => {
return {
container: {
...styles.rbsheetContainer,
backgroundColor: theme.colors.background,
padding: 16,
borderTopRightRadius: 28,
borderTopLeftRadius: 28,
},
draggableIcon: styles.rbsheetDraggableIcon,
}
}, [])
@ -246,7 +247,7 @@ export const ProfileConfigPage: React.FC = () => {
) : (
<NostrosAvatar
name={user?.name}
pubKey={nPub ?? publicKey ?? ''}
pubKey={nPub ?? ''}
src={user?.picture}
lud06={user?.lnurl}
size={100}
@ -516,14 +517,6 @@ const styles = StyleSheet.create({
justifyContent: 'center',
alignItems: 'center',
},
rbsheetDraggableIcon: {
backgroundColor: '#000',
},
rbsheetContainer: {
padding: 16,
borderTopRightRadius: 28,
borderTopLeftRadius: 28,
},
snackbar: {
margin: 16,
bottom: 70,

View File

@ -28,13 +28,11 @@ export const ProfileConnectPage: React.FC = () => {
const onPress: () => void = () => {
if (inputValue && inputValue !== '') {
const key = isNip19 ? getNip19Key(inputValue) : inputValue
if (isPublic) {
setPublicKey(key)
} else {
setPrivateKey(key)
}
navigate('ProfileLoad')
}
}

View File

@ -13,7 +13,7 @@ interface ProfileCreatePageProps {
export const ProfileCreatePage: React.FC<ProfileCreatePageProps> = ({ navigation }) => {
const { t } = useTranslation('common')
const { setPrivateKey } = useContext(UserContext)
const { setPrivateKey, setUserState } = useContext(UserContext)
const [key, setKey] = useState<string>()
const [inputValue, setInputValue] = useState<string>()
const [copied, setCopied] = useState<boolean>(false)
@ -37,7 +37,7 @@ export const ProfileCreatePage: React.FC<ProfileCreatePageProps> = ({ navigation
const onPress: () => void = () => {
setPrivateKey(key)
navigation.jumpTo('Feed')
setUserState('ready')
}
return (
@ -126,6 +126,9 @@ const styles = StyleSheet.create({
justifyContent: 'center',
alignContent: 'center',
},
bold: {
fontWeight: 'bold',
},
})
export default ProfileCreatePage

View File

@ -8,18 +8,19 @@ import { useTranslation } from 'react-i18next'
import moment from 'moment'
import { StyleSheet, View } from 'react-native'
import Logo from '../../Components/Logo'
import { Button, Snackbar, Text } from 'react-native-paper'
import { Button, Text, useTheme } from 'react-native-paper'
import { navigate } from '../../lib/Navigation'
import { useFocusEffect } from '@react-navigation/native'
export const ProfileLoadPage: React.FC = () => {
const theme = useTheme()
const { database } = useContext(AppContext)
const { relayPool, lastEventId } = useContext(RelayPoolContext)
const { publicKey, reloadUser, user } = useContext(UserContext)
const { publicKey, reloadUser, user, setUserState } = useContext(UserContext)
const { t } = useTranslation('common')
const [profileFound, setProfileFound] = useState<boolean>(false)
const [contactsCount, setContactsCount] = useState<number>(0)
useFocusEffect(
React.useCallback(() => {
console.log('FOCUS ProfileLoadPage')
@ -32,10 +33,8 @@ export const ProfileLoadPage: React.FC = () => {
])
}
return () => {
console.log('UNFOCUS ProfileLoadPage')
};
}, [])
return () => relayPool?.unsubscribeAll()
}, []),
)
useEffect(() => {
@ -58,7 +57,7 @@ export const ProfileLoadPage: React.FC = () => {
{
kinds: [EventKind.meta, EventKind.textNote],
authors,
since: moment().unix() - 43200,
since: moment().unix() - 86400,
},
])
}
@ -66,45 +65,62 @@ export const ProfileLoadPage: React.FC = () => {
}
}
const goHome: () => void = () => {
navigate('Feed')
}
return (
<View style={styles.container}>
<Logo onlyIcon size='medium' />
<Text variant='titleMedium'>
{profileFound ? t('profileLoadPage.foundProfile') : t('profileLoadPage.searchingProfile')}
</Text>
<Text variant='titleMedium'>{t('profileLoadPage.foundContacts', { contactsCount })}</Text>
<Button mode='contained' onPress={goHome}>
{t('profileLoadPage.home')}
</Button>
<Snackbar
style={styles.snackbar}
visible
onDismiss={() => {}}
action={{
label: t('profileLoadPage.relays') ?? '',
onPress: () => {
relayPool?.unsubscribeAll()
navigate('Relays')
},
}}
>
{t('profileLoadPage.relaysDescripion')}
</Snackbar>
<View style={styles.info}>
<Logo onlyIcon size='medium' />
<Text variant='titleMedium' style={styles.center}>
{profileFound ? t('profileLoadPage.foundProfile') : t('profileLoadPage.searchingProfile')}
</Text>
<Text variant='titleMedium' style={styles.center}>
{t('profileLoadPage.foundContacts', { contactsCount })}
</Text>
<Button mode='contained' onPress={() => setUserState('ready')}>
{t('profileLoadPage.home')}
</Button>
</View>
<View style={[styles.warning, { backgroundColor: theme.colors.primaryContainer }]}>
<Text>{t('profileLoadPage.relaysDescripion')}</Text>
<View style={styles.warningActionOuterLayout}>
<Button style={styles.warningAction} mode='text' onPress={() => navigate('Relays')}>
{t('profileLoadPage.relays')}
</Button>
</View>
</View>
</View>
)
}
const styles = StyleSheet.create({
info: {
top: 150,
height: 220,
justifyContent: 'space-between',
},
container: {
padding: 16,
justifyContent: 'space-between',
flex: 1,
},
snackbar: {
top: 150,
flexDirection: 'column',
center: {
alignContent: 'center',
textAlign: 'center',
},
warning: {
borderRadius: 4,
padding: 16,
marginTop: 16,
marginBottom: 16,
},
warningTitle: {
marginBottom: 8,
},
warningAction: {
marginTop: 16,
},
warningActionOuterLayout: {
flexDirection: 'row',
justifyContent: 'flex-end',
},
})

View File

@ -180,9 +180,6 @@ export const ProfilePage: React.FC<ProfilePageProps> = ({ route }) => {
borderTopRightRadius: 28,
borderTopLeftRadius: 28,
},
draggableIcon: {
backgroundColor: '#000',
},
}
}, [])
@ -193,7 +190,7 @@ export const ProfilePage: React.FC<ProfilePageProps> = ({ route }) => {
<View>
<NostrosAvatar
name={user?.name}
pubKey={route.params.pubKey}
pubKey={npubEncode(route.params.pubKey)}
src={user?.picture}
lud06={user?.lnurl}
size={54}

View File

@ -17,7 +17,6 @@ import {
Snackbar,
} from 'react-native-paper'
import RBSheet from 'react-native-raw-bottom-sheet'
import { useFocusEffect } from '@react-navigation/native'
export const RelaysPage: React.FC = () => {
const defaultRelayInput = React.useMemo(() => 'wss://', [])
@ -92,10 +91,11 @@ export const RelaysPage: React.FC = () => {
const rbSheetCustomStyles = React.useMemo(() => {
return {
container: {
...styles.rbsheetContainer,
backgroundColor: theme.colors.background,
padding: 16,
borderTopRightRadius: 28,
borderTopLeftRadius: 28,
},
draggableIcon: styles.rbsheetDraggableIcon,
}
}, [])
@ -203,14 +203,6 @@ const styles = StyleSheet.create({
right: 16,
position: 'absolute',
},
rbsheetDraggableIcon: {
backgroundColor: '#000',
},
rbsheetContainer: {
padding: 16,
borderTopRightRadius: 28,
borderTopLeftRadius: 28,
},
relayActions: {
flexDirection: 'row',
},

View File

@ -14,6 +14,7 @@ import RBSheet from 'react-native-raw-bottom-sheet'
import { UserContext } from '../../Contexts/UserContext'
import NostrosAvatar from '../../Components/NostrosAvatar'
import { goBack } from '../../lib/Navigation'
import { npubEncode } from 'nostr-tools/nip19'
interface SendPageProps {
route: { params: { note: Note } | undefined }
@ -124,7 +125,7 @@ export const SendPage: React.FC<SendPageProps> = ({ route }) => {
<View style={styles.contactInfo}>
<NostrosAvatar
name={item.name}
pubKey={item.id}
pubKey={npubEncode(item.id)}
src={item.picture}
lud06={item.lnurl}
size={34}

View File

@ -5,7 +5,6 @@ import {
DefaultTheme as NavigationDefaultTheme,
DarkTheme as NavigationDarkTheme,
} from '@react-navigation/native'
import { createDrawerNavigator } from '@react-navigation/drawer'
import { RelayPoolContextProvider } from './Contexts/RelayPoolContext'
import { I18nextProvider } from 'react-i18next'
import { adaptNavigationTheme, Provider as PaperProvider } from 'react-native-paper'
@ -13,17 +12,12 @@ import { SafeAreaProvider, SafeAreaInsetsContext } from 'react-native-safe-area-
import i18n from './i18n.config'
import nostrosDarkTheme from './Constants/Theme/theme-dark.json'
import { navigationRef } from './lib/Navigation'
import HomeNavigator from './Pages/HomeNavigator'
import MenuItems from './Components/MenuItems'
import FeedNavigator from './Pages/FeedNavigator'
import { UserContextProvider } from './Contexts/UserContext'
import { LogBox, StyleSheet, View } from 'react-native'
import Logo from './Components/Logo'
import { LogBox } from 'react-native'
import NostrosDrawerNavigator from './Pages/NostrosDrawerNavigator'
LogBox.ignoreAllLogs()
const DrawerNavigator = createDrawerNavigator()
export const Frontend: React.FC = () => {
const { DarkTheme } = adaptNavigationTheme({
reactNavigationLight: NavigationDefaultTheme,
@ -40,12 +34,6 @@ export const Frontend: React.FC = () => {
}
}, [])
const Loading: React.FC = () => (
<View style={styles.logo}>
<Logo onlyIcon size='big' />
</View>
)
return (
<PaperProvider theme={nostrosDarkTheme}>
<SafeAreaProvider>
@ -56,37 +44,7 @@ export const Frontend: React.FC = () => {
<RelayPoolContextProvider>
<React.Fragment>
<SafeAreaInsetsContext.Consumer>
{() => {
return (
<DrawerNavigator.Navigator
drawerContent={({ navigation }) => (
<MenuItems navigation={navigation} />
)}
screenOptions={{
drawerStyle: {
borderRadius: 28,
width: 296,
},
}}
>
<DrawerNavigator.Screen
name='Loading'
component={Loading}
options={{ headerShown: false }}
/>
<DrawerNavigator.Screen
name='Home'
component={HomeNavigator}
options={{ headerShown: false }}
/>
<DrawerNavigator.Screen
name='Feed'
component={FeedNavigator}
options={{ headerShown: false }}
/>
</DrawerNavigator.Navigator>
)
}}
{() => <NostrosDrawerNavigator />}
</SafeAreaInsetsContext.Consumer>
</React.Fragment>
</RelayPoolContextProvider>
@ -98,12 +56,5 @@ export const Frontend: React.FC = () => {
</PaperProvider>
)
}
const styles = StyleSheet.create({
logo: {
justifyContent: 'center',
alignContent: 'center',
flex: 1,
},
})
export default Frontend