import React, { useState } from 'react';
import {View, Text, TextInput, StyleSheet} from 'react-native';

export default function ModuleEditor(props) {
	let [module, setModule] = useState(props.value || {});
	return (
			<View style={styles.container}>
				<View style={styles.row}>
					<Text style={[styles.title, styles.capFirst]}>Module</Text>
					<TextInput style={styles.defaultInput} 
						onChangeText={(text) => {
							module.value = text;
							props.onChange && props.onChange(module);
							setModule(module);
						}}
	    				value={module.value}/>
    			</View>
    			<View style={styles.row}>
					<Text style={[styles.title, styles.capFirst]}>Namespace</Text>
					<TextInput style={styles.defaultInput} 
						onChangeText={(text) => {
							module.namespace = text;
							props.onChange && props.onChange(module);
							setModule(module);
						}}
	    				value={module.namespace}/>
				</View>
			</View>
		);
}

const styles = StyleSheet.create({
	container:{
		flexDirection: 'column'
	},
	row: {
		flexDirection: 'row',
		alignItems: 'baseline',
		justifyContent: 'space-between',
	},
	capFirst: {
		fontSize: 14, 
		fontFamily: 'roboto-light',
		textTransform: 'capitalize'
	},
	defaultInput: {
		marginTop:6,
		borderWidth:1,
		backgroundColor: 'white',
		boxShadow: '0px 3px 6px #00000029',
		borderColor: '#FFFFFF66',
		borderRadius: 14
	},
	title: {

	}
})
