From cb310ab1c1e4d2beb6f39b39e4972b9ae21f9849 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Mon, 5 Sep 2022 14:16:48 -0500 Subject: Rewrite the post composer as a modal --- src/view/com/composer/Composer.tsx | 90 -------------------------------------- 1 file changed, 90 deletions(-) delete mode 100644 src/view/com/composer/Composer.tsx (limited to 'src/view/com/composer/Composer.tsx') diff --git a/src/view/com/composer/Composer.tsx b/src/view/com/composer/Composer.tsx deleted file mode 100644 index 6a15599d8..000000000 --- a/src/view/com/composer/Composer.tsx +++ /dev/null @@ -1,90 +0,0 @@ -import React, {useState, forwardRef, useImperativeHandle} from 'react' -import {KeyboardAvoidingView, StyleSheet, TextInput, View} from 'react-native' -import Toast from '../util/Toast' -import ProgressCircle from '../util/ProgressCircle' -import {useStores} from '../../../state' -import {s} from '../../lib/styles' -import * as apilib from '../../../state/lib/api' - -const MAX_TEXT_LENGTH = 256 -const WARNING_TEXT_LENGTH = 200 -const DANGER_TEXT_LENGTH = 255 - -export const Composer = forwardRef(function Composer( - { - replyTo, - }: { - replyTo: string | undefined - }, - ref, -) { - const store = useStores() - const [text, setText] = useState('') - - const onChangeText = (newText: string) => { - if (newText.length > MAX_TEXT_LENGTH) { - setText(newText.slice(0, MAX_TEXT_LENGTH)) - } else { - setText(newText) - } - } - - useImperativeHandle(ref, () => ({ - async publish() { - if (text.trim().length === 0) { - return false - } - await apilib.post(store.api, 'alice.com', text, replyTo) - Toast.show(`Your ${replyTo ? 'reply' : 'post'} has been created`, { - duration: Toast.durations.LONG, - position: Toast.positions.TOP, - shadow: true, - animation: true, - hideOnPress: true, - }) - return true - }, - })) - - const progressColor = - text.length > DANGER_TEXT_LENGTH - ? '#e60000' - : text.length > WARNING_TEXT_LENGTH - ? '#f7c600' - : undefined - - return ( - - onChangeText(text)} - value={text} - placeholder={replyTo ? 'Write your reply' : "What's new in the scene?"} - style={styles.textInput} - /> - - - - - - - - ) -}) - -const styles = StyleSheet.create({ - outer: { - flexDirection: 'column', - backgroundColor: '#fff', - padding: 10, - height: '100%', - }, - textInput: { - flex: 1, - padding: 10, - }, -}) -- cgit 1.4.1