[🐴] Skeleton header (#3921)
parent
3bac0182b5
commit
55ac287d5e
|
@ -19,8 +19,8 @@ import {PreviewableUserAvatar} from 'view/com/util/UserAvatar'
|
||||||
import {CenteredView} from 'view/com/util/Views'
|
import {CenteredView} from 'view/com/util/Views'
|
||||||
import {MessagesList} from '#/screens/Messages/Conversation/MessagesList'
|
import {MessagesList} from '#/screens/Messages/Conversation/MessagesList'
|
||||||
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
||||||
import {Button, ButtonText} from '#/components/Button'
|
|
||||||
import {ConvoMenu} from '#/components/dms/ConvoMenu'
|
import {ConvoMenu} from '#/components/dms/ConvoMenu'
|
||||||
|
import {Error} from '#/components/Error'
|
||||||
import {ListMaybePlaceholder} from '#/components/Lists'
|
import {ListMaybePlaceholder} from '#/components/Lists'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import {ClipClopGate} from '../gate'
|
import {ClipClopGate} from '../gate'
|
||||||
|
@ -54,29 +54,30 @@ export function MessagesConversationScreen({route}: Props) {
|
||||||
|
|
||||||
function Inner() {
|
function Inner() {
|
||||||
const convo = useConvo()
|
const convo = useConvo()
|
||||||
|
const {_} = useLingui()
|
||||||
|
|
||||||
if (
|
if (
|
||||||
convo.status === ConvoStatus.Uninitialized ||
|
convo.status === ConvoStatus.Uninitialized ||
|
||||||
convo.status === ConvoStatus.Initializing
|
convo.status === ConvoStatus.Initializing
|
||||||
) {
|
) {
|
||||||
return <ListMaybePlaceholder isLoading />
|
return (
|
||||||
|
<CenteredView style={a.flex_1} sideBorders>
|
||||||
|
<Header />
|
||||||
|
<ListMaybePlaceholder isLoading />
|
||||||
|
</CenteredView>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (convo.status === ConvoStatus.Error) {
|
if (convo.status === ConvoStatus.Error) {
|
||||||
// TODO
|
|
||||||
return (
|
return (
|
||||||
<View>
|
<CenteredView style={a.flex_1} sideBorders>
|
||||||
<CenteredView style={{flex: 1}} sideBorders>
|
<Header />
|
||||||
<Text>Something went wrong</Text>
|
<Error
|
||||||
<Button
|
title={_(msg`Something went wrong`)}
|
||||||
label="Retry"
|
message={_(msg`We couldn't load this conversation`)}
|
||||||
onPress={() => {
|
onRetry={() => convo.error.retry()}
|
||||||
convo.error.retry()
|
/>
|
||||||
}}>
|
</CenteredView>
|
||||||
<ButtonText>Retry</ButtonText>
|
|
||||||
</Button>
|
|
||||||
</CenteredView>
|
|
||||||
</View>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +87,7 @@ function Inner() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<KeyboardProvider>
|
<KeyboardProvider>
|
||||||
<CenteredView style={{flex: 1}} sideBorders>
|
<CenteredView style={a.flex_1} sideBorders>
|
||||||
<Header profile={convo.recipients[0]} />
|
<Header profile={convo.recipients[0]} />
|
||||||
<MessagesList />
|
<MessagesList />
|
||||||
</CenteredView>
|
</CenteredView>
|
||||||
|
@ -97,7 +98,7 @@ function Inner() {
|
||||||
let Header = ({
|
let Header = ({
|
||||||
profile,
|
profile,
|
||||||
}: {
|
}: {
|
||||||
profile: AppBskyActorDefs.ProfileViewBasic
|
profile?: AppBskyActorDefs.ProfileViewBasic
|
||||||
}): React.ReactNode => {
|
}): React.ReactNode => {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
|
@ -152,12 +153,34 @@ let Header = ({
|
||||||
<View style={{width: 30}} />
|
<View style={{width: 30}} />
|
||||||
)}
|
)}
|
||||||
<View style={[a.align_center, a.gap_sm, a.flex_1]}>
|
<View style={[a.align_center, a.gap_sm, a.flex_1]}>
|
||||||
<PreviewableUserAvatar size={32} profile={profile} />
|
{profile ? (
|
||||||
<Text style={[a.text_lg, a.font_bold, a.text_center]}>
|
<>
|
||||||
{profile.displayName}
|
<PreviewableUserAvatar size={32} profile={profile} />
|
||||||
</Text>
|
<Text style={[a.text_lg, a.font_bold, a.text_center]}>
|
||||||
|
{profile.displayName}
|
||||||
|
</Text>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
{width: 32, height: 32},
|
||||||
|
a.rounded_full,
|
||||||
|
t.atoms.bg_contrast_25,
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
{width: 120, height: 18},
|
||||||
|
a.rounded_xs,
|
||||||
|
t.atoms.bg_contrast_25,
|
||||||
|
a.mb_2xs,
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
{convo.status === ConvoStatus.Ready ? (
|
{convo.status === ConvoStatus.Ready && profile ? (
|
||||||
<ConvoMenu
|
<ConvoMenu
|
||||||
convo={convo.convo}
|
convo={convo.convo}
|
||||||
profile={profile}
|
profile={profile}
|
||||||
|
|
Loading…
Reference in New Issue