From 53267d755b583765d68062bd5879230d10a5dfa1 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Fri, 30 Dec 2022 15:42:09 -0600 Subject: [PATCH] Integrate composer into design system --- src/view/com/composer/Autocomplete.tsx | 19 +++++---- src/view/com/composer/ComposePost.tsx | 41 ++++++++----------- src/view/com/composer/PhotoCarouselPicker.tsx | 21 ++++------ 3 files changed, 36 insertions(+), 45 deletions(-) diff --git a/src/view/com/composer/Autocomplete.tsx b/src/view/com/composer/Autocomplete.tsx index b151e0d9..4ee527ee 100644 --- a/src/view/com/composer/Autocomplete.tsx +++ b/src/view/com/composer/Autocomplete.tsx @@ -8,6 +8,7 @@ import { import {useAnimatedValue} from '../../lib/hooks/useAnimatedValue' import {Text} from '../util/text/Text' import {colors} from '../../lib/styles' +import {usePalette} from '../../lib/hooks/usePalette' interface AutocompleteItem { handle: string @@ -23,6 +24,7 @@ export function Autocomplete({ items: AutocompleteItem[] onSelect: (item: string) => void }) { + const pal = usePalette('default') const winDim = useWindowDimensions() const positionInterp = useAnimatedValue(0) @@ -41,13 +43,18 @@ export function Autocomplete({ }), } return ( - + {items.map((item, i) => ( onSelect(item.handle)}> - @{item.handle} + + {item.displayName || item.handle} + +  @{item.handle} + + ))} @@ -60,17 +67,11 @@ const styles = StyleSheet.create({ left: 0, right: 0, bottom: 0, - backgroundColor: colors.white, borderTopWidth: 1, - borderTopColor: colors.gray2, }, item: { borderBottomWidth: 1, - borderBottomColor: colors.gray1, paddingVertical: 16, paddingHorizontal: 16, }, - itemText: { - fontSize: 16, - }, }) diff --git a/src/view/com/composer/ComposePost.tsx b/src/view/com/composer/ComposePost.tsx index fe310f19..dc0bec13 100644 --- a/src/view/com/composer/ComposePost.tsx +++ b/src/view/com/composer/ComposePost.tsx @@ -31,6 +31,7 @@ import {detectLinkables} from '../../../lib/strings' import {UserLocalPhotosModel} from '../../../state/models/user-local-photos' import {PhotoCarouselPicker} from './PhotoCarouselPicker' import {SelectedPhoto} from './SelectedPhoto' +import {usePalette} from '../../lib/hooks/usePalette' const MAX_TEXT_LENGTH = 256 const DANGER_TEXT_LENGTH = MAX_TEXT_LENGTH @@ -45,6 +46,7 @@ export const ComposePost = observer(function ComposePost({ onPost?: ComposerOpts['onPost'] onClose: () => void }) { + const pal = usePalette('default') const store = useStores() const textInput = useRef(null) const [isProcessing, setIsProcessing] = useState(false) @@ -167,7 +169,7 @@ export const ComposePost = observer(function ComposePost({ return v } else { return ( - + {v.link} ) @@ -178,11 +180,11 @@ export const ComposePost = observer(function ComposePost({ return ( + style={[pal.view, styles.outer]}> - Cancel + Cancel {isProcessing ? ( @@ -202,13 +204,13 @@ export const ComposePost = observer(function ComposePost({ ) : ( - - Post + + Post )} {isProcessing ? ( - + {processingState} ) : undefined} @@ -226,7 +228,7 @@ export const ComposePost = observer(function ComposePost({ )} {replyTo ? ( - + - + {replyTo.text} ) : undefined} - + onChangeText(text)} placeholder={selectTextInputPlaceholder} - placeholderTextColor={colors.gray4} - style={styles.textInput}> + placeholderTextColor={pal.colors.textLight} + style={[pal.text, styles.textInput]}> {textDecorated} @@ -277,16 +281,14 @@ export const ComposePost = observer(function ComposePost({ localPhotos={localPhotos} /> )} - + @@ -343,7 +345,6 @@ const styles = StyleSheet.create({ outer: { flexDirection: 'column', flex: 1, - backgroundColor: '#fff', padding: 15, paddingBottom: Platform.OS === 'ios' ? 0 : 50, height: '100%', @@ -361,7 +362,6 @@ const styles = StyleSheet.create({ paddingVertical: 6, }, processingLine: { - backgroundColor: colors.gray1, borderRadius: 6, paddingHorizontal: 8, paddingVertical: 6, @@ -395,7 +395,6 @@ const styles = StyleSheet.create({ textInputLayout: { flexDirection: 'row', borderTopWidth: 1, - borderTopColor: colors.gray2, paddingTop: 16, }, textInput: { @@ -404,12 +403,10 @@ const styles = StyleSheet.create({ fontSize: 18, marginLeft: 8, alignSelf: 'flex-start', - color: colors.black, }, replyToLayout: { flexDirection: 'row', borderTopWidth: 1, - borderTopColor: colors.gray2, paddingTop: 16, paddingBottom: 16, }, @@ -424,7 +421,5 @@ const styles = StyleSheet.create({ paddingRight: 5, alignItems: 'center', borderTopWidth: 1, - borderTopColor: colors.gray2, - backgroundColor: colors.white, }, }) diff --git a/src/view/com/composer/PhotoCarouselPicker.tsx b/src/view/com/composer/PhotoCarouselPicker.tsx index 7f2c4e52..47c4c374 100644 --- a/src/view/com/composer/PhotoCarouselPicker.tsx +++ b/src/view/com/composer/PhotoCarouselPicker.tsx @@ -8,6 +8,7 @@ import { openCropper, } from 'react-native-image-crop-picker' import {compressIfNeeded} from '../../../lib/images' +import {usePalette} from '../../lib/hooks/usePalette' const IMAGE_PARAMS = { width: 1000, @@ -26,6 +27,7 @@ export const PhotoCarouselPicker = ({ onSelectPhotos: (v: string[]) => void localPhotos: any }) => { + const pal = usePalette('default') const handleOpenCamera = useCallback(async () => { try { const cameraRes = await openCamera({ @@ -83,26 +85,22 @@ export const PhotoCarouselPicker = ({ return ( - + - + {localPhotos.photos.map((item: any, index: number) => ( handleSelectPhoto(item.node.image.uri)}> @@ -117,11 +115,9 @@ const styles = StyleSheet.create({ maxHeight: 96, padding: 8, overflow: 'hidden', - backgroundColor: colors.white, }, galleryButton: { borderWidth: 1, - borderColor: colors.gray3, alignItems: 'center', justifyContent: 'center', }, @@ -131,7 +127,6 @@ const styles = StyleSheet.create({ marginRight: 8, borderWidth: 1, borderRadius: 16, - borderColor: colors.gray3, }, photo: { width: 75,