Update compose prompt for isual balance and to include image button
parent
9d6c4698a1
commit
bf03167ca6
|
@ -82,6 +82,7 @@ export interface ComposerOptsPostRef {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export interface ComposerOpts {
|
export interface ComposerOpts {
|
||||||
|
imagesOpen?: boolean
|
||||||
replyTo?: ComposerOptsPostRef
|
replyTo?: ComposerOptsPostRef
|
||||||
onPost?: () => void
|
onPost?: () => void
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,10 +40,12 @@ const HITSLOP = {left: 10, top: 10, right: 10, bottom: 10}
|
||||||
|
|
||||||
export const ComposePost = observer(function ComposePost({
|
export const ComposePost = observer(function ComposePost({
|
||||||
replyTo,
|
replyTo,
|
||||||
|
imagesOpen,
|
||||||
onPost,
|
onPost,
|
||||||
onClose,
|
onClose,
|
||||||
}: {
|
}: {
|
||||||
replyTo?: ComposerOpts['replyTo']
|
replyTo?: ComposerOpts['replyTo']
|
||||||
|
imagesOpen?: ComposerOpts['imagesOpen']
|
||||||
onPost?: ComposerOpts['onPost']
|
onPost?: ComposerOpts['onPost']
|
||||||
onClose: () => void
|
onClose: () => void
|
||||||
}) {
|
}) {
|
||||||
|
@ -54,7 +56,9 @@ export const ComposePost = observer(function ComposePost({
|
||||||
const [processingState, setProcessingState] = useState('')
|
const [processingState, setProcessingState] = useState('')
|
||||||
const [error, setError] = useState('')
|
const [error, setError] = useState('')
|
||||||
const [text, setText] = useState('')
|
const [text, setText] = useState('')
|
||||||
const [isSelectingPhotos, setIsSelectingPhotos] = useState(false)
|
const [isSelectingPhotos, setIsSelectingPhotos] = useState(
|
||||||
|
imagesOpen || false,
|
||||||
|
)
|
||||||
const [selectedPhotos, setSelectedPhotos] = useState<string[]>([])
|
const [selectedPhotos, setSelectedPhotos] = useState<string[]>([])
|
||||||
|
|
||||||
// Using default import (React.use...) instead of named import (use...) to be able to mock store's data in jest environment
|
// Using default import (React.use...) instead of named import (use...) to be able to mock store's data in jest environment
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {StyleSheet, TouchableOpacity, View} from 'react-native'
|
import {StyleSheet, TouchableOpacity, View} from 'react-native'
|
||||||
|
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
||||||
import {Text} from '../util/text/Text'
|
import {Text} from '../util/text/Text'
|
||||||
import {usePalette} from '../../lib/hooks/usePalette'
|
import {usePalette} from '../../lib/hooks/usePalette'
|
||||||
|
|
||||||
|
@ -12,7 +13,7 @@ export function ComposePrompt({
|
||||||
text?: string
|
text?: string
|
||||||
btn?: string
|
btn?: string
|
||||||
isReply?: boolean
|
isReply?: boolean
|
||||||
onPressCompose: () => void
|
onPressCompose: (imagesOpen?: boolean) => void
|
||||||
}) {
|
}) {
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
return (
|
return (
|
||||||
|
@ -24,25 +25,50 @@ export function ComposePrompt({
|
||||||
styles.container,
|
styles.container,
|
||||||
isReply ? styles.containerReply : undefined,
|
isReply ? styles.containerReply : undefined,
|
||||||
]}
|
]}
|
||||||
onPress={onPressCompose}>
|
onPress={() => onPressCompose()}>
|
||||||
|
{!isReply && (
|
||||||
|
<FontAwesomeIcon
|
||||||
|
icon={['fas', 'pen-nib']}
|
||||||
|
size={18}
|
||||||
|
style={[pal.textLight, styles.iconLeft]}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<View style={styles.textContainer}>
|
<View style={styles.textContainer}>
|
||||||
<Text type="lg" style={[pal.textLight]}>
|
<Text type={isReply ? 'lg' : 'lg-medium'} style={pal.textLight}>
|
||||||
{text}
|
{text}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
<View style={[styles.btn, {backgroundColor: pal.colors.backgroundLight}]}>
|
{isReply ? (
|
||||||
|
<View
|
||||||
|
style={[styles.btn, {backgroundColor: pal.colors.backgroundLight}]}>
|
||||||
<Text type="button" style={pal.textLight}>
|
<Text type="button" style={pal.textLight}>
|
||||||
{btn}
|
{btn}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
) : (
|
||||||
|
<TouchableOpacity onPress={() => onPressCompose(true)}>
|
||||||
|
<FontAwesomeIcon
|
||||||
|
icon={['far', 'image']}
|
||||||
|
size={18}
|
||||||
|
style={[pal.textLight, styles.iconRight]}
|
||||||
|
/>
|
||||||
|
</TouchableOpacity>
|
||||||
|
)}
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
|
iconLeft: {
|
||||||
|
marginLeft: 22,
|
||||||
|
marginRight: 2,
|
||||||
|
// marginLeft: 28,
|
||||||
|
// marginRight: 14,
|
||||||
|
},
|
||||||
|
iconRight: {
|
||||||
|
marginRight: 20,
|
||||||
|
},
|
||||||
container: {
|
container: {
|
||||||
paddingLeft: 4,
|
|
||||||
paddingRight: 10,
|
|
||||||
paddingVertical: 14,
|
paddingVertical: 14,
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
|
|
|
@ -30,7 +30,7 @@ export const Feed = observer(function Feed({
|
||||||
feed: FeedModel
|
feed: FeedModel
|
||||||
style?: StyleProp<ViewStyle>
|
style?: StyleProp<ViewStyle>
|
||||||
scrollElRef?: MutableRefObject<FlatList<any> | null>
|
scrollElRef?: MutableRefObject<FlatList<any> | null>
|
||||||
onPressCompose: () => void
|
onPressCompose: (imagesOpen?: boolean) => void
|
||||||
onPressTryAgain?: () => void
|
onPressTryAgain?: () => void
|
||||||
onScroll?: OnScrollCb
|
onScroll?: OnScrollCb
|
||||||
testID?: string
|
testID?: string
|
||||||
|
@ -41,9 +41,7 @@ export const Feed = observer(function Feed({
|
||||||
// like PureComponent, shouldComponentUpdate, etc
|
// like PureComponent, shouldComponentUpdate, etc
|
||||||
const renderItem = ({item}: {item: any}) => {
|
const renderItem = ({item}: {item: any}) => {
|
||||||
if (item === COMPOSE_PROMPT_ITEM) {
|
if (item === COMPOSE_PROMPT_ITEM) {
|
||||||
return (
|
return <ComposePrompt onPressCompose={onPressCompose} />
|
||||||
<ComposePrompt onPressCompose={onPressCompose} text="New message" />
|
|
||||||
)
|
|
||||||
} else if (item === EMPTY_FEED_ITEM) {
|
} else if (item === EMPTY_FEED_ITEM) {
|
||||||
return (
|
return (
|
||||||
<EmptyState
|
<EmptyState
|
||||||
|
|
|
@ -69,8 +69,8 @@ export const Home = observer(function Home({
|
||||||
return cleanup
|
return cleanup
|
||||||
}, [visible, store, navIdx, doPoll, wasVisible])
|
}, [visible, store, navIdx, doPoll, wasVisible])
|
||||||
|
|
||||||
const onPressCompose = () => {
|
const onPressCompose = (imagesOpen?: boolean) => {
|
||||||
store.shell.openComposer({})
|
store.shell.openComposer({imagesOpen})
|
||||||
}
|
}
|
||||||
const onPressTryAgain = () => {
|
const onPressTryAgain = () => {
|
||||||
store.me.mainFeed.refresh()
|
store.me.mainFeed.refresh()
|
||||||
|
@ -107,7 +107,7 @@ export const Home = observer(function Home({
|
||||||
<Text style={styles.loadLatestText}>Load new posts</Text>
|
<Text style={styles.loadLatestText}>Load new posts</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
) : undefined}
|
) : undefined}
|
||||||
<FAB icon="pen-nib" onPress={onPressCompose} />
|
<FAB icon="pen-nib" onPress={() => onPressCompose(false)} />
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
|
@ -10,12 +10,14 @@ export const Composer = observer(
|
||||||
active,
|
active,
|
||||||
winHeight,
|
winHeight,
|
||||||
replyTo,
|
replyTo,
|
||||||
|
imagesOpen,
|
||||||
onPost,
|
onPost,
|
||||||
onClose,
|
onClose,
|
||||||
}: {
|
}: {
|
||||||
active: boolean
|
active: boolean
|
||||||
winHeight: number
|
winHeight: number
|
||||||
replyTo?: ComposerOpts['replyTo']
|
replyTo?: ComposerOpts['replyTo']
|
||||||
|
imagesOpen?: ComposerOpts['imagesOpen']
|
||||||
onPost?: ComposerOpts['onPost']
|
onPost?: ComposerOpts['onPost']
|
||||||
onClose: () => void
|
onClose: () => void
|
||||||
}) => {
|
}) => {
|
||||||
|
@ -56,7 +58,12 @@ export const Composer = observer(
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Animated.View style={[styles.wrapper, wrapperAnimStyle]}>
|
<Animated.View style={[styles.wrapper, wrapperAnimStyle]}>
|
||||||
<ComposePost replyTo={replyTo} onPost={onPost} onClose={onClose} />
|
<ComposePost
|
||||||
|
replyTo={replyTo}
|
||||||
|
imagesOpen={imagesOpen}
|
||||||
|
onPost={onPost}
|
||||||
|
onClose={onClose}
|
||||||
|
/>
|
||||||
</Animated.View>
|
</Animated.View>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
|
@ -484,6 +484,7 @@ export const MobileShell: React.FC = observer(() => {
|
||||||
onClose={() => store.shell.closeComposer()}
|
onClose={() => store.shell.closeComposer()}
|
||||||
winHeight={winDim.height}
|
winHeight={winDim.height}
|
||||||
replyTo={store.shell.composerOpts?.replyTo}
|
replyTo={store.shell.composerOpts?.replyTo}
|
||||||
|
imagesOpen={store.shell.composerOpts?.imagesOpen}
|
||||||
onPost={store.shell.composerOpts?.onPost}
|
onPost={store.shell.composerOpts?.onPost}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|
Loading…
Reference in New Issue