import React, { useState } from 'react'; import { ScrollView, View } from 'react-native'; import { Appbar, Button, useTheme } from 'react-native-paper'; import { useNavigation } from '@react-navigation/native'; import { useRealm } from '@realm/react'; import styles from '../styles'; import { generateRandomColor, validateColor, validateTagName, } from '../utilities'; import { ORIENTATION, useDimensions } from '../contexts'; import { Tag } from '../database'; import { TagEditor } from '../components'; const AddTag = () => { const { goBack } = useNavigation(); const { colors } = useTheme(); const { orientation } = useDimensions(); const realm = useRealm(); const [tagName, setTagName] = useState(validateTagName('newTag')); const [tagColor, setTagColor] = useState( validateColor(generateRandomColor()), ); const handleSave = () => { realm.write(() => { realm.create(Tag.schema.name, { name: tagName.parsed, color: tagColor.parsed, }); }); goBack(); }; return ( <> goBack()} /> ); }; export default AddTag;