2021-02-20 19:12:44 +01:00
|
|
|
import { getInstanceActive, getInstances } from '@utils/slices/instancesSlice'
|
2021-01-17 22:37:05 +01:00
|
|
|
import { StyleConstants } from '@utils/styles/constants'
|
2020-12-11 00:29:22 +01:00
|
|
|
import React, { useContext } from 'react'
|
2021-01-19 01:13:45 +01:00
|
|
|
import { StyleSheet, View } from 'react-native'
|
2021-01-17 22:37:05 +01:00
|
|
|
import { useSelector } from 'react-redux'
|
|
|
|
import ComposeContext from '../utils/createContext'
|
2021-01-24 02:25:43 +01:00
|
|
|
import ComposePostingAs from './Header/PostingAs'
|
2021-01-19 01:13:45 +01:00
|
|
|
import ComposeSpoilerInput from './Header/SpoilerInput'
|
|
|
|
import ComposeTextInput from './Header/TextInput'
|
2020-12-11 00:29:22 +01:00
|
|
|
|
|
|
|
const ComposeRootHeader: React.FC = () => {
|
|
|
|
const { composeState } = useContext(ComposeContext)
|
2021-02-20 19:12:44 +01:00
|
|
|
const instanceActive = useSelector(getInstanceActive)
|
2021-02-10 00:40:44 +01:00
|
|
|
const localInstances = useSelector(
|
2021-02-20 19:12:44 +01:00
|
|
|
getInstances,
|
2021-02-10 00:40:44 +01:00
|
|
|
(prev, next) => prev.length === next.length
|
|
|
|
)
|
2020-12-11 00:29:22 +01:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2021-02-20 19:12:44 +01:00
|
|
|
{instanceActive !== -1 &&
|
2021-01-17 22:37:05 +01:00
|
|
|
localInstances.length &&
|
|
|
|
localInstances.length > 1 && (
|
|
|
|
<View style={styles.postingAs}>
|
2021-01-24 02:25:43 +01:00
|
|
|
<ComposePostingAs />
|
2021-01-17 22:37:05 +01:00
|
|
|
</View>
|
|
|
|
)}
|
2020-12-11 00:29:22 +01:00
|
|
|
{composeState.spoiler.active ? <ComposeSpoilerInput /> : null}
|
|
|
|
<ComposeTextInput />
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-01-17 22:37:05 +01:00
|
|
|
const styles = StyleSheet.create({
|
|
|
|
postingAs: {
|
|
|
|
marginHorizontal: StyleConstants.Spacing.Global.PagePadding,
|
|
|
|
marginTop: StyleConstants.Spacing.S
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-12-11 00:29:22 +01:00
|
|
|
export default ComposeRootHeader
|