about summary refs log tree commit diff
path: root/src/view/screens/content/PostThread.tsx
blob: fde74e7788279a31efc25c6a6f4acb017f94a01e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import React, {useLayoutEffect} from 'react'
import {TouchableOpacity} from 'react-native'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import {AdxUri} from '@adxp/mock-api'
import {Shell} from '../../shell'
import type {RootTabsScreenProps} from '../../routes/types'
import {PostThread as PostThreadComponent} from '../../com/post-thread/PostThread'

export const PostThread = ({
  navigation,
  route,
}: RootTabsScreenProps<'PostThread'>) => {
  const {name, recordKey} = route.params

  const urip = new AdxUri(`adx://todo/`)
  urip.host = name
  urip.collection = 'blueskyweb.xyz:Posts'
  urip.recordKey = recordKey
  const uri = urip.toString()

  useLayoutEffect(() => {
    navigation.setOptions({
      headerShown: true,
      headerTitle: 'Thread',
      headerLeft: () => (
        <TouchableOpacity onPress={() => navigation.goBack()}>
          <FontAwesomeIcon icon="arrow-left" />
        </TouchableOpacity>
      ),
    })
  }, [navigation])

  const onNavigateContent = (screen: string, props: Record<string, string>) => {
    // @ts-ignore it's up to the callers to supply correct params -prf
    navigation.push(screen, props)
  }

  return (
    <Shell>
      <PostThreadComponent uri={uri} onNavigateContent={onNavigateContent} />
    </Shell>
  )
}