diff --git a/app/components/ChatMenu/SettingsDrawer.tsx b/app/components/ChatMenu/SettingsDrawer.tsx index b81421f..9e604f5 100644 --- a/app/components/ChatMenu/SettingsDrawer.tsx +++ b/app/components/ChatMenu/SettingsDrawer.tsx @@ -188,7 +188,7 @@ const SettingsDrawer: React.FC = ({ booleans: [showModal, s handlePush('/UserInfo')}> + onPress={() => handlePush('components/UserEditor')}> { + const router = useRouter() + + const { data } = useLiveQuery(Characters.db.query.cardListQuery('user')) + + const { userCard, imageID, id, setCard } = Characters.useUserCard( + useShallow((state) => ({ + userCard: state.card, + imageID: state.card?.data.image_id ?? 0, + id: state.id, + setCard: state.setCard, + })) + ) + + const [currentCard, setCurrentCard] = useState(userCard) + const userName = userCard?.data.name + + useEffect(() => { + setCurrentCard(userCard) + }, []) + + const saveCard = async () => { + if (currentCard && id) { + await Characters.db.mutate.updateCard(currentCard, id) + setCard(id) + } + } + + const handleUploadImage = () => { + DocumentPicker.getDocumentAsync({ + copyToCacheDirectory: true, + type: 'image/*', + }).then((result) => { + if (result.canceled) return + if (id) Characters.useUserCard.getState().updateImage(result.assets[0].uri) + }) + } + + return ( + + + + + + + + + Name + { + if (currentCard) + setCurrentCard({ + ...currentCard, + data: { ...currentCard.data, name: text }, + }) + }} + placeholder="Empty names are discouraged!" + placeholderTextColor={Style.getColor('destructive-brand')} + /> + + + + + + Description + + { + if (currentCard) + setCurrentCard({ + ...currentCard, + data: { ...currentCard.data, description: text }, + }) + }} + placeholder="Describe this user..." + placeholderTextColor={Style.getColor('primary-text2')} + /> + + + + + Change Image + + + + + Save + + + + + item.id.toString()} + renderItem={({ item, index }) => ( + + {item.name} + + )} + /> + + ) +} + +export default UserEditor + +const styles = StyleSheet.create({ + mainContainer: { + paddingTop: 16, + paddingHorizontal: 16, + paddingBottom: 24, + flex: 1, + }, + + userContainer: { + minHeight: Dimensions.get('screen').height / 3, + }, + + optionsBar: { + flexDirection: 'row', + alignItems: 'center', + columnGap: 24, + }, + + buttonContainer: { + marginTop: 12, + flexDirection: 'row', + columnGap: 8, + }, + + buttonIcon: {}, + + button: { + flexDirection: 'row', + flex: 1, + paddingVertical: 8, + paddingHorizontal: 12, + columnGap: 8, + borderRadius: 8, + backgroundColor: Style.getColor('primary-surface4'), + }, + + buttonDestructive: { + flexDirection: 'row', + columnGap: 8, + flex: 1, + paddingVertical: 8, + paddingHorizontal: 12, + borderRadius: 8, + backgroundColor: Style.getColor('destructive-brand'), + }, + + buttonApprove: { + flexDirection: 'row', + columnGap: 8, + flex: 1, + paddingVertical: 8, + paddingHorizontal: 12, + borderRadius: 8, + backgroundColor: Style.getColor('confirm-brand'), + }, + + userName: { + color: Style.getColor('primary-text1'), + fontSize: 20, + }, + + userImage: { + width: 84, + height: 84, + borderRadius: 20, + borderColor: Style.getColor('primary-brand'), + borderWidth: 2, + }, + + inputName: { + textAlign: 'center', + color: Style.getColor('primary-text1'), + textAlignVertical: 'top', + borderColor: Style.getColor('primary-brand'), + borderWidth: 1, + padding: 8, + borderRadius: 8, + }, + + inputArea: { + flex: 1, + }, + + input: { + flex: 1, + color: Style.getColor('primary-text1'), + textAlignVertical: 'top', + borderColor: Style.getColor('primary-brand'), + borderWidth: 1, + padding: 8, + borderRadius: 8, + }, + + userListContainer: {}, +})