Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mobile/1649 - feat:use context menu for information about unregistered username instead screen #1985

Merged
merged 4 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

* Fixed mobile bugs - joining by QR code and not showing username taken screen for user who has unique name

* Use context menu for information about unregistered username instead screen

* Shorter dots-placeholder for invite link

* Removed registration attempts selector and corresponding usage.
Expand Down
5 changes: 3 additions & 2 deletions packages/mobile/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ import StoreProvider from './Provider'
import { RootStackParamList } from './route.params'
import ConnectionProcessScreen from './screens/ConnectionProcess/ConnectionProcess.screen'
import { DuplicatedUsernameScreen } from './screens/DuplicatedUsername/DuplicatedUsername.screen'
import { UnregisteredUsernameScreen } from './screens/UnregisteredUsername/UnregisteredUsername.screen'

import UsernameTakenScreen from './screens/UsernameTaken/UsernameTaken.screen'
import NewUsernameRequestedScreen from './screens/NewUsernameRequested/NewUsernameRequested.screen'
import { PossibleImpersonationAttackScreen } from './screens/PossibleImpersonationAttack/PossibleImpersonationAttack.screen'
import { UnregisteredUsernameContextMenu } from './components/ContextMenu/menus/UnregisteredUsernameContextMenu.container'

LogBox.ignoreAllLogs()

Expand Down Expand Up @@ -105,7 +106,6 @@ function App(): JSX.Element {
<Screen component={SuccessScreen} name={ScreenNames.SuccessScreen} />
<Screen component={ErrorScreen} name={ScreenNames.ErrorScreen} />
<Screen component={DuplicatedUsernameScreen} name={ScreenNames.DuplicatedUsernameScreen} />
<Screen component={UnregisteredUsernameScreen} name={ScreenNames.UnregisteredUsernameScreen} />
<Screen component={UsernameTakenScreen} name={ScreenNames.UsernameTakenScreen} />
<Screen component={NewUsernameRequestedScreen} name={ScreenNames.NewUsernameRequestedScreen} />
<Screen
Expand All @@ -116,6 +116,7 @@ function App(): JSX.Element {
<CommunityContextMenu />
<ChannelContextMenu />
<InvitationContextMenu />
<UnregisteredUsernameContextMenu />
<ConfirmationBox {...confirmationBox} />
</ThemeProvider>
</MenuProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React, { FC } from 'react'
import { View, Image, FlatList, TouchableWithoutFeedback, TouchableOpacity, Animated } from 'react-native'
import { Typography } from '../Typography/Typography.component'
import { ContextMenuItemProps, ContextMenuProps } from './ContextMenu.types'

import { defaultPalette } from '../../styles/palettes/default.palette'
import { appImages } from '../../assets'
import { Button } from '../Button/Button.component'

export const ContextMenu: FC<ContextMenuProps> = ({
visible,
Expand All @@ -16,6 +16,8 @@ export const ContextMenu: FC<ContextMenuProps> = ({
linkAction = () => {
console.log('No action attached for link tap gesture.')
},
unregisteredUsername,
username,
}) => {
const [show, setShow] = React.useState<boolean>(false)
const slidingAnimation = React.useRef(new Animated.Value(0)).current
Expand Down Expand Up @@ -140,24 +142,45 @@ export const ContextMenu: FC<ContextMenuProps> = ({
</Typography>
</View>
)}
<View style={{ width: '100%', paddingBottom: 10 }}>
<FlatList
data={items}
keyExtractor={item => item.title}
renderItem={({ item, index }) => (
<View
style={[
{ borderTopWidth: 1, borderColor: defaultPalette.background.gray06 },
index === items.length - 1 ? { borderBottomWidth: 1 } : { borderBottomWidth: 0 },
]}
>
<ContextMenuItem {...item} />
</View>
)}
style={{ backgroundColor: defaultPalette.background.white }}
showsVerticalScrollIndicator={false}
/>
</View>

{items.length !== 0 && (
<View style={{ width: '100%', paddingBottom: 10 }}>
<FlatList
data={items}
keyExtractor={item => item.title}
renderItem={({ item, index }) => (
<View
style={[
{ borderTopWidth: 1, borderColor: defaultPalette.background.gray06 },
index === items.length - 1 ? { borderBottomWidth: 1 } : { borderBottomWidth: 0 },
]}
>
<ContextMenuItem {...item} />
</View>
)}
style={{ backgroundColor: defaultPalette.background.white }}
showsVerticalScrollIndicator={false}
/>
</View>
)}

{unregisteredUsername && username && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong. ContextMenu component was meant to be universal and here you introduced the explicit conditional. Use an existing hint prop or add another one if you really have to but make it "label", "description" or something like that. Also try to never render the contents of the component conditionally otherwise it'll soon get messy and overcomplicated

<View style={{ padding: 20, alignItems: 'center' }}>
<Typography fontSize={14} style={{ textAlign: 'center' }}>
The username{' '}
<Typography fontSize={14} fontWeight={'bold'}>
@{username}
</Typography>{' '}
has not been registered yet with the community owner, so it’s still possible for someone else to
register the same username. When the community owner is online,{' '}
<Typography fontSize={14} fontWeight={'bold'}>
@{username}
</Typography>{' '}
will be registered automatically and this alert will go away.
</Typography>
<Button width={60} title={'OK'} onPress={handleClose} />
</View>
)}
</View>
</TouchableWithoutFeedback>
</Animated.View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ export interface ContextMenuProps {
link?: string
linkAction?: () => void
style?: TextStyle
unregisteredUsername?: boolean
username?: string
}

export interface ContextMenuItemProps {
title: string
action: () => void
}

export type UnregisteredUsernameArgs = {
username: string
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React, { FC } from 'react'
import { useContextMenu } from '../../../hooks/useContextMenu'
import { MenuName } from '../../../const/MenuNames.enum'
import { ContextMenu } from '../ContextMenu.component'
import { UnregisteredUsernameArgs } from '../ContextMenu.types'

export const UnregisteredUsernameContextMenu: FC = () => {
const title = 'Unregistered username'
const usernameTakenContextMenu = useContextMenu<UnregisteredUsernameArgs>(MenuName.UnregisteredUsername)

return (
<ContextMenu
title={title}
items={[]}
{...usernameTakenContextMenu}
unregisteredUsername
username={usernameTakenContextMenu.username}
/>
)
}

This file was deleted.

Loading
Loading