Use appropriate icons for toasts (#4803)

* use appropriate icons for toasts

* use info for session expiry

* tweak size

* message -> safeMessage

---------

Co-authored-by: Samuel Newman <10959775+mozzius@users.noreply.github.com>
This commit is contained in:
Samuel Newman 2024-07-23 15:01:04 +01:00 committed by GitHub
parent 59bafb426f
commit 27d712290a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
48 changed files with 134 additions and 95 deletions

View file

@ -77,7 +77,7 @@ export function Component({}: {}) {
const onCopy = React.useCallback(() => {
if (appPassword) {
setStringAsync(appPassword)
Toast.show(_(msg`Copied to clipboard`))
Toast.show(_(msg`Copied to clipboard`), 'clipboard-check')
setWasCopied(true)
}
}, [appPassword, _])
@ -93,7 +93,7 @@ export function Component({}: {}) {
_(
msg`Please enter a name for your app password. All spaces is not allowed.`,
),
'times',
'xmark',
)
return
}
@ -101,13 +101,13 @@ export function Component({}: {}) {
if (name.length < 4) {
Toast.show(
_(msg`App Password names must be at least 4 characters long.`),
'times',
'xmark',
)
return
}
if (passwords?.find(p => p.name === name)) {
Toast.show(_(msg`This name is already in use`), 'times')
Toast.show(_(msg`This name is already in use`), 'xmark')
return
}
@ -116,11 +116,11 @@ export function Component({}: {}) {
if (newPassword) {
setAppPassword(newPassword.password)
} else {
Toast.show(_(msg`Failed to create app password.`), 'times')
Toast.show(_(msg`Failed to create app password.`), 'xmark')
// TODO: better error handling (?)
}
} catch (e) {
Toast.show(_(msg`Failed to create app password.`), 'times')
Toast.show(_(msg`Failed to create app password.`), 'xmark')
logger.error('Failed to create app password', {message: e})
}
}
@ -137,6 +137,7 @@ export function Component({}: {}) {
_(
msg`App Password names can only contain letters, numbers, spaces, dashes, and underscores.`,
),
'xmark',
)
}
}

View file

@ -317,7 +317,7 @@ function CustomHandleForm({
// =
const onPressCopy = React.useCallback(() => {
setStringAsync(isDNSForm ? `did=${currentAccount.did}` : currentAccount.did)
Toast.show(_(msg`Copied to clipboard`))
Toast.show(_(msg`Copied to clipboard`), 'clipboard-check')
}, [currentAccount, isDNSForm, _])
const onChangeHandle = React.useCallback(
(v: string) => {

View file

@ -150,7 +150,7 @@ function InviteCode({
const onPress = React.useCallback(() => {
setStringAsync(invite.code)
Toast.show(_(msg`Copied to clipboard`))
Toast.show(_(msg`Copied to clipboard`), 'clipboard-check')
setInviteCopied(invite.code)
}, [setInviteCopied, invite, _])

View file

@ -7,32 +7,33 @@ import {
View,
} from 'react-native'
import {AppBskyActorDefs, AppBskyGraphDefs} from '@atproto/api'
import {ScrollView, TextInput} from './util'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import {Text} from '../util/text/Text'
import {Button} from '../util/forms/Button'
import {UserAvatar} from '../util/UserAvatar'
import * as Toast from '../util/Toast'
import {s, colors} from 'lib/styles'
import {usePalette} from 'lib/hooks/usePalette'
import {isWeb} from 'platform/detection'
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
import {useIsKeyboardVisible} from 'lib/hooks/useIsKeyboardVisible'
import {cleanError} from 'lib/strings/errors'
import {sanitizeDisplayName} from 'lib/strings/display-names'
import {sanitizeHandle} from 'lib/strings/handles'
import {HITSLOP_20} from '#/lib/constants'
import {Trans, msg} from '@lingui/macro'
import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {HITSLOP_20} from '#/lib/constants'
import {useModalControls} from '#/state/modals'
import {useActorAutocompleteQuery} from '#/state/queries/actor-autocomplete'
import {
useDangerousListMembershipsQuery,
getMembership,
ListMembersip,
useDangerousListMembershipsQuery,
useListMembershipAddMutation,
useListMembershipRemoveMutation,
} from '#/state/queries/list-memberships'
import {useActorAutocompleteQuery} from '#/state/queries/actor-autocomplete'
import {useIsKeyboardVisible} from 'lib/hooks/useIsKeyboardVisible'
import {usePalette} from 'lib/hooks/usePalette'
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
import {sanitizeDisplayName} from 'lib/strings/display-names'
import {cleanError} from 'lib/strings/errors'
import {sanitizeHandle} from 'lib/strings/handles'
import {colors, s} from 'lib/styles'
import {isWeb} from 'platform/detection'
import {Button} from '../util/forms/Button'
import {Text} from '../util/text/Text'
import * as Toast from '../util/Toast'
import {UserAvatar} from '../util/UserAvatar'
import {ScrollView, TextInput} from './util'
export const snapPoints = ['90%']
@ -200,7 +201,7 @@ function UserResult({
onChange?.('remove', profile)
}
} catch (e) {
Toast.show(cleanError(e))
Toast.show(cleanError(e), 'xmark')
} finally {
setIsProcessing(false)
}

View file

@ -166,7 +166,7 @@ function ListItem({
onRemove?.(list.uri)
}
} catch (e) {
Toast.show(cleanError(e))
Toast.show(cleanError(e), 'xmark')
} finally {
setIsProcessing(false)
}